:root {
    --pac-red: #A51C30;
    --pac-grey-dark: #333333;
    --pac-grey-text: #4A4A4A;
    --pac-grey-light: #F8F9FA;
    --sidebar-bg: #FFFFFF;
    --chat-bg: #FFFFFF;
    --glass-bg: rgba(255, 255, 255, 0.8);
    --bubble-user: var(--pac-red);
    --bubble-assistant: #F0F2F5;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--pac-grey-text);
    background-color: #F0F2F5;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar Styling */
.sidebar {
    width: 300px;
    background: var(--sidebar-bg);
    border-right: 1px solid #E0E0E0;
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    z-index: 10;
}

.logo-container {
    margin-bottom: 3rem;
    text-align: center;
}

.logo {
    max-width: 100%;
    height: auto;
}

.pillars-nav {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 2rem;
    padding-right: 0.5rem;
}

.pillars-nav::-webkit-scrollbar {
    width: 4px;
}

.pillars-nav::-webkit-scrollbar-thumb {
    background: #EEE;
    border-radius: 2px;
}

.pillars-nav h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
    color: #999;
    margin-bottom: 1.5rem;
}

.pillars-nav ul {
    list-style: none;
}

.pillars-nav li {
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    color: var(--pac-grey-dark);
}

.pillars-nav li:hover {
    background: #F5F5F5;
    color: var(--pac-red);
}

.sidebar-footer {
    margin-top: auto;
    font-size: 0.8rem;
    color: #AAA;
    text-align: center;
}

/* Main Chat Area */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    position: relative;
}

.chat-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #EEE;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #FFF;
}

.chat-header h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    color: var(--pac-grey-dark);
}

.status-badge {
    font-size: 0.7rem;
    background: #E8F5E9;
    color: #2E7D32;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-weight: 600;
}

/* Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.message {
    max-width: 80%;
    padding: 1rem 1.25rem;
    border-radius: 18px;
    font-size: 1rem;
    line-height: 1.5;
    animation: fadeIn 0.3s ease forwards;
}

.assistant-message {
    align-self: flex-start;
    background: var(--bubble-assistant);
    color: var(--pac-grey-dark);
    border-bottom-left-radius: 4px;
}

.user-message {
    align-self: flex-end;
    background: var(--pac-red);
    color: #FFF;
    border-bottom-right-radius: 4px;
}

/* Input Area */
.chat-input-container {
    padding: 1.5rem 2rem;
    background: #FFF;
    border-top: 1px solid #EEE;
}

.input-wrapper {
    display: flex;
    background: #F8F9FA;
    border: 1px solid #DDD;
    border-radius: 12px;
    padding: 0.5rem 0.75rem;
    align-items: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.02);
}

#user-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.75rem;
    font-size: 1rem;
    outline: none;
    color: var(--pac-grey-dark);
}

#send-btn {
    background: var(--pac-red);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

#send-btn:hover {
    opacity: 0.9;
}

/* Modal Styling */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    padding: 2.5rem;
    border-radius: 20px;
    width: 450px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.15);
    text-align: center;
}

.modal-content h2 {
    font-family: 'Outfit', sans-serif;
    color: var(--pac-red);
    margin-bottom: 1rem;
}

.modal-content p {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 2rem;
    line-height: 1.6;
}

#api-key-input {
    width: 100%;
    padding: 1rem;
    border: 1px solid #DDD;
    border-radius: 10px;
    margin-bottom: 2rem;
    font-family: monospace;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Buttons */
.primary-btn {
    background: var(--pac-red);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.secondary-btn {
    background: #F0F2F5;
    color: var(--pac-grey-text);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.secondary-btn:hover {
    background: #E4E6E9;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: #DDD;
    border-radius: 3px;
}

/* Citation Links */
.citation-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.65rem;
    margin: 0.25rem 0.15rem;
    background: rgba(165, 28, 48, 0.06);
    border: 1px solid rgba(165, 28, 48, 0.18);
    border-radius: 20px;
    color: var(--pac-red);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.01rem;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.citation-link::after {
    content: '↗';
    font-size: 0.7rem;
    opacity: 0.6;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.citation-link:hover {
    background: var(--pac-red);
    color: #FFF;
    border-color: var(--pac-red);
    box-shadow: 0 2px 10px rgba(165, 28, 48, 0.25);
    transform: translateY(-1px);
}

.citation-link:hover::after {
    opacity: 1;
    transform: translate(1px, -1px);
}

/* Ensure citation links inside assistant bubbles inherit readable colours */
.assistant-message .citation-link {
    color: var(--pac-red);
}

.assistant-message .citation-link:hover {
    color: #FFF;
}

/* Headings inside chat messages */
.message-content .msg-heading {
    font-size: 1rem;
    font-weight: 700;
    color: var(--pac-red);
    margin: 0.75rem 0 0.4rem 0;
    line-height: 1.3;
}
.message-content .msg-heading:first-child {
    margin-top: 0;
}

/* --- Academic Evidence UI --- */

.evidence-nav li {
    font-size: 0.85rem;
    color: #555;
    border-left: 3px solid transparent;
    border-radius: 0 8px 8px 0;
}

.evidence-nav li:hover {
    border-left: 3px solid var(--pac-red);
    background: rgba(165, 28, 48, 0.05);
}

/* Evidence Block in Chat */
.evidence-block {
    margin-top: 1.25rem;
    padding: 1.25rem;
    background: rgba(0, 0, 0, 0.03);
    border-left: 4px solid #777;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #444;
}

.evidence-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05rem;
    color: #666;
    margin-bottom: 0.75rem;
}

.evidence-block ul {
    list-style: none;
    padding-left: 0;
}

.evidence-block li {
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    line-height: 1.4;
}

.evidence-block li:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Academic Modal Customisations */
.academic-modal {
    width: 700px;
    max-width: 90vw;
    text-align: left;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #EEE;
    padding-bottom: 1rem;
}

.close-modal {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #999;
}

.evidence-list {
    overflow-y: auto;
    padding-right: 1rem;
    flex: 1;
}

.evidence-list .ref-item {
    padding: 1rem;
    border-bottom: 1px solid #F0F0F0;
    font-size: 0.95rem;
    line-height: 1.5;
}

.evidence-list .ref-item:last-child {
    border-bottom: none;
}

.modal-footer {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #EEE;
    font-size: 0.75rem;
    color: #AAA;
    text-align: center;
}
