/* Global Reset & Typography */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #F4F3EE;
    color: #1B2A4A;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* App Layout */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at top right, rgba(212, 168, 67, 0.05) 0%, rgba(27, 42, 74, 0.02) 100%);
}

/* Sidebar Navigation */
.sidebar {
    width: 280px;
    background-color: #1B2A4A;
    color: #FFFFFF;
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    flex-shrink: 0;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.05);
    z-index: 10;
}

.sidebar-header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.school-logo {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 50%;
    border: 3px solid #D4A843;
    padding: 3px;
    background-color: #FFFFFF;
    margin-bottom: 1rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.sidebar-header h2 {
    font-size: 1.3rem;
    font-weight: 600;
    color: #D4A843;
    letter-spacing: 0.5px;
}

.sidebar-header p {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 0.2rem;
}

.sidebar-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    padding: 0.85rem 1rem;
    border-radius: 8px;
    text-align: left;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s ease-in-out;
}

.nav-btn svg {
    opacity: 0.7;
}

.nav-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #FFFFFF;
}

.nav-btn.active {
    background-color: #D4A843;
    color: #1B2A4A;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(212, 168, 67, 0.2);
}

.nav-btn.active svg {
    opacity: 1;
}

.status-card {
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    margin-top: auto;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 3px;
    flex-shrink: 0;
}

.status-indicator.online {
    background-color: #4CAF50;
    box-shadow: 0 0 8px #4CAF50;
}

.status-details h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #FFFFFF;
}

.status-details p {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 0.1rem;
    margin-bottom: 0.5rem;
}

.badge {
    background-color: rgba(212, 168, 67, 0.15);
    color: #D4A843;
    padding: 0.2rem 0.5rem;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 600;
    border: 1px solid rgba(212, 168, 67, 0.3);
}

.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1.5rem;
    text-align: center;
    margin-top: 2rem;
}

.sidebar-footer p {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

.sidebar-footer span {
    font-size: 0.65rem;
    color: rgba(212, 168, 67, 0.6);
    display: block;
    margin-top: 0.2rem;
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.view-section {
    display: none;
    flex-direction: column;
    width: 100%;
    height: 100%;
    padding: 2rem;
}

.view-section.active {
    display: flex;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(27, 42, 74, 0.05);
    padding-bottom: 1.5rem;
    flex-shrink: 0;
}

.header-title h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1B2A4A;
}

.header-title p {
    font-size: 0.9rem;
    color: rgba(27, 42, 74, 0.6);
    margin-top: 0.25rem;
}

.clear-btn {
    background-color: #FFFFFF;
    border: 1px solid rgba(27, 42, 74, 0.1);
    color: rgba(27, 42, 74, 0.6);
    padding: 0.6rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clear-btn:hover {
    background-color: #FFEBEE;
    border-color: #FFCDD2;
    color: #D32F2F;
}

/* Chat Area Wrapper with Watermark Background */
.chat-area-wrapper {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin-bottom: 1.5rem;
}

.chat-area-wrapper::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('logo_La_GRACE.jpg');
    background-repeat: no-repeat;
    background-position: center;
    background-size: 320px;
    opacity: 0.12;
    pointer-events: none;
    z-index: 0;
    mix-blend-mode: multiply;
}

/* Chat Messages Box */
.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding-right: 0.5rem;
    position: relative;
    z-index: 1;
    background: transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background-color: rgba(27, 42, 74, 0.1);
    border-radius: 100px;
}

/* Chat Bubble Styles */
.message {
    display: flex;
    gap: 1rem;
    max-width: 85%;
    align-self: flex-start;
    animation: fadeInUp 0.3s ease-out forwards;
    position: relative;
    z-index: 1;
}

.message.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: rgba(27, 42, 74, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    flex-shrink: 0;
}

.message.user-message .avatar {
    background-color: rgba(212, 168, 67, 0.1);
}

.message-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.message.user-message .message-wrapper {
    align-items: flex-end;
}

.message-content {
    background-color: #FFFFFF;
    border: 1px solid rgba(27, 42, 74, 0.06);
    border-radius: 0 16px 16px 16px;
    padding: 1rem;
    box-shadow: 0 2px 12px rgba(27, 42, 74, 0.02);
    font-size: 0.95rem;
    line-height: 1.5;
}

.message-content p {
    margin-bottom: 0.5rem;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message.user-message .message-content {
    background-color: #1B2A4A;
    color: #FFFFFF;
    border-radius: 16px 0 16px 16px;
    border: none;
    box-shadow: 0 4px 15px rgba(27, 42, 74, 0.1);
}

.message-time {
    font-size: 0.75rem;
    color: rgba(27, 42, 74, 0.4);
}

/* System/Status Messages */
.message.system-message {
    max-width: 90%;
}

.message.system-message .message-content {
    background-color: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(212, 168, 67, 0.15);
    backdrop-filter: blur(8px);
}

/* Citation source reference badges */
.citations {
    margin-top: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.citation-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background-color: #F0E6CD;
    color: #8C6A1E;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    border: 1px solid rgba(212, 168, 67, 0.2);
    text-decoration: none;
    transition: all 0.2s ease;
}

.citation-badge:hover {
    background-color: #E2D3AD;
    color: #6C5113;
}

/* Stream loading dot indicator */
.typing-indicator {
    display: flex;
    gap: 0.3rem;
    padding: 0.4rem 0.2rem;
    align-items: center;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: rgba(27, 42, 74, 0.4);
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* Input bar area */
.chat-input-area {
    background-color: #FFFFFF;
    border: 1px solid rgba(27, 42, 74, 0.08);
    border-radius: 12px;
    padding: 0.75rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
    flex-shrink: 0;
}

.chat-form {
    display: flex;
    gap: 0.75rem;
}

#chat-input {
    flex-grow: 1;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 0.95rem;
    color: #1B2A4A;
    padding: 0.5rem;
}

#chat-input::placeholder {
    color: rgba(27, 42, 74, 0.4);
}

.send-btn {
    background-color: #1B2A4A;
    color: #FFFFFF;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.send-btn:hover {
    background-color: #263C69;
    box-shadow: 0 4px 12px rgba(27, 42, 74, 0.25);
}

.send-btn svg {
    transition: transform 0.2s ease;
}

.send-btn:hover svg {
    transform: translate(2px, -2px);
}

/* Admin Portal Grid */
.admin-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    flex-grow: 1;
    overflow: hidden;
}

.admin-card {
    background-color: #FFFFFF;
    border: 1px solid rgba(27, 42, 74, 0.08);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.02);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.admin-card h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #1B2A4A;
    margin-bottom: 0.5rem;
}

.admin-card p {
    font-size: 0.9rem;
    color: rgba(27, 42, 74, 0.6);
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.card-icon {
    background-color: rgba(212, 168, 67, 0.1);
    color: #D4A843;
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.25rem;
    border: 1px solid rgba(212, 168, 67, 0.2);
}

/* Upload Zone Box */
.upload-zone {
    flex-grow: 1;
    border: 2px dashed rgba(27, 42, 74, 0.15);
    border-radius: 12px;
    background-color: #FBFBFA;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 1.5rem;
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: #D4A843;
    background-color: rgba(212, 168, 67, 0.02);
}

.upload-label {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    cursor: pointer;
    width: 100%;
}

.upload-label span {
    font-size: 0.95rem;
    color: rgba(27, 42, 74, 0.7);
}

.upload-label strong {
    color: #D4A843;
    font-weight: 600;
}

.file-name-display {
    font-size: 0.85rem !important;
    font-weight: 600;
    color: #1B2A4A !important;
    background-color: rgba(27, 42, 74, 0.05);
    padding: 0.4rem 1rem;
    border-radius: 6px;
    display: inline-block;
    align-self: center;
    max-width: 80%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.action-btn {
    background-color: #1B2A4A;
    color: #FFFFFF;
    border: none;
    padding: 0.85rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    box-shadow: 0 4px 10px rgba(27, 42, 74, 0.15);
}

.action-btn:hover:not(:disabled) {
    background-color: #263C69;
    box-shadow: 0 4px 15px rgba(27, 42, 74, 0.25);
}

.action-btn:disabled {
    background-color: rgba(27, 42, 74, 0.1);
    color: rgba(27, 42, 74, 0.4);
    cursor: not-allowed;
    box-shadow: none;
}

/* Console logs styling */
.console-box {
    flex-grow: 1;
    background-color: #1E1E1E;
    border-radius: 12px;
    padding: 1rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.8rem;
    color: #A9B7C6;
    overflow-y: auto;
    border: 1px solid #2B2B2B;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.console-line {
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-all;
}

.console-line.system { color: #5597d4; }
.console-line.success { color: #6A8759; }
.console-line.error { color: #BC3F3C; }
.console-line.info { color: #BBB; }

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

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Responsive Design (Mobile / Tablet) */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        padding: 0.75rem 1rem;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    }

    .sidebar-header {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        margin-bottom: 0;
        text-align: left;
    }

    .school-logo {
        width: 40px;
        height: 40px;
        margin-bottom: 0;
        border-width: 2px;
        padding: 1px;
    }

    .sidebar-header h2 {
        font-size: 1.05rem;
    }

    .sidebar-header p {
        font-size: 0.7rem;
        margin-top: 0;
    }

    .sidebar-content {
        flex-direction: row;
        align-items: center;
        gap: 1rem;
        flex-grow: 0;
    }

    /* Hide redundant elements on mobile to save space */
    .status-card {
        margin-top: 0;
        padding: 0.35rem 0.65rem;
        border-radius: 6px;
        align-items: center;
    }
    
    .status-card .status-indicator {
        margin-top: 0;
    }
    
    .status-details h4, .status-details p {
        display: none;
    }
    .sidebar-footer {
        display: none;
    }

    .main-content {
        height: auto;
        flex: 1;
        min-height: 0;
    }

    .view-section {
        height: auto;
        flex: 1;
        min-height: 0;
        padding: 1rem;
    }

    .view-header {
        margin-bottom: 1rem;
        padding-bottom: 1rem;
    }

    .header-title h1 {
        font-size: 1.3rem;
    }

    .header-title p {
        font-size: 0.8rem;
    }

    .message {
        max-width: 95%;
    }

    .message-content {
        padding: 0.85rem;
        font-size: 0.9rem;
    }

    .chat-area-wrapper::before {
        background-size: 200px;
    }
}


