/* --- VARIABLES & BASE STYLES (Updated for Dark Mode) --- */
:root {
    --sidebar-width: 280px;
    --header-height-mobile: 70px;
    --font-family: 'Montserrat', sans-serif;

    /* Inverted Color Palette */
    --color-background: #121212; /* Very dark grey for the main background */
    --color-surface: #1e1e1e; /* Slightly lighter grey for cards, sidebar, etc. */
    --color-primary: #ffffff; /* White for primary text and active elements */
    --color-on-primary: #000000; /* Black for text on top of white active elements */
    --color-text: #e0e0e0; /* Light grey for standard text */
    --color-text-muted: #a0a0a0; /* Dimmer grey for less important text */
    --color-border: #333333; /* Dark grey for borders */
    
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.5);
    --border-radius: 8px;
    --transition-speed: 0.3s;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--color-background);
    color: var(--color-text);
    line-height: 1.6;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

hr {
    border: none;
    height: 1px;
    background: var(--color-border);
    margin: 24px 0;
}


/* --- APP LAYOUT --- */
.app-wrapper {
    display: flex;
}

.main-content {
    flex-grow: 1;
    padding: 32px;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}


/* --- SIDEBAR --- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    padding: 24px;
    display: flex;
    flex-direction: column;
    z-index: 1100;
    transition: transform var(--transition-speed) ease;
}

.sidebar-header {
    text-align: left;
    margin-bottom: 14px;
    padding: 14px;
}

.sidebar-logo {
    font-size: 24px;
    letter-spacing: 4px;
    line-height: 1.4;
    color: var(--color-primary);
}

.sidebar-links {
    margin-top: 0; 
}

.sidebar-link {
    display: block;
    padding: 12px 16px;
    font-weight: 500;
    border-radius: var(--border-radius);
    margin-bottom: 8px;
    color: var(--color-text);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.sidebar-link:hover {
    background-color: var(--color-background);
}

.sidebar-link.active {
    background-color: var(--color-primary);
    color: var(--color-on-primary);
}


/* --- HEADER (MOBILE ONLY) --- */
.header {
    display: none;
}


/* --- RESPONSIVE STYLES (Mobile View) --- */
@media (max-width: 1000px) {
    .header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: var(--header-height-mobile);
        background: var(--color-surface);
        display: flex;
        align-items: center;
        padding: 0 24px;
        box-shadow: var(--shadow-sm);
        z-index: 1000;
        border-bottom: 1px solid var(--color-border);
    }

    .header-logo {
        margin-left: auto;
        margin-right: auto;
        font-size: 16px;
        font-weight: 700;
        letter-spacing: 2px;
        line-height: 1.2;
        text-align: center;
        color: var(--color-primary);
    }
    
    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-sm);
    }

    .sidebar.is-open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        margin-top: var(--header-height-mobile);
        padding: 24px;
    }
    
    .overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.7); /* Darker overlay for dark mode */
        z-index: 1099;
        opacity: 0;
        visibility: hidden;
        transition: opacity var(--transition-speed) ease, visibility var(--transition-speed) ease;
    }

    .overlay.is-visible {
        opacity: 1;
        visibility: visible;
    }
}


/* --- HAMBURGER BUTTON --- */
.hamburger {
    position: relative;
    display: inline-block;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 1101;
}
.hamburger-box {
    position: absolute;
    top: 50%;
    left: 0;
    width: 24px;
    height: 2px;
    margin-top: -1px;
}
.hamburger-inner, .hamburger-inner::before, .hamburger-inner::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 2px;
    background-color: var(--color-primary); /* Will now be white */
    border-radius: 4px;
    transition: transform 0.2s ease-in-out;
}
.hamburger-inner::before { top: -8px; }
.hamburger-inner::after { top: 8px; }


/* --- MODAL DIALOG --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
}

.modal-overlay.is-visible {
    opacity: 1;
}

.modal-content {
    background: var(--color-surface);
    border-radius: var(--border-radius);
    padding: 32px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    transform: scale(0.95);
    transition: transform var(--transition-speed) ease;
    border: 1px solid var(--color-border);
}

.modal-overlay.is-visible .modal-content {
    transform: scale(1);
}

#modal_title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--color-primary);
}

#modal_info {
    color: var(--color-text-muted);
    margin-bottom: 24px;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}


/* --- UTILITY & BUTTONS --- */
.btn {
    display: inline-block;
    padding: 10px 24px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-family: var(--font-family);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--color-primary);
    color: var(--color-on-primary);
}

.btn-primary:hover {
    background: #e0e0e0; /* Slightly off-white on hover */
}

.btn-secondary {
    background: transparent;
    color: var(--color-text);
    border-color: var(--color-border);
}

.btn-secondary:hover {
    background: var(--color-border);
    color: var(--color-primary);
}


.book-source {
    font-size: 1.18rem;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.book-source a {
    color: var(--text-link-color);
    text-decoration: none;
}
.book-source a:hover {
    text-decoration: underline;
}
.book-footer-info {
        margin-top: auto;
        padding-top: 16px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
    }
    .book-chips-container {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        gap: 8px;
    }
    .freshness-chip {
        display: inline-block;
        border: 1px solid var(--color-primary);
        color: var(--color-primary);
        padding: 3px 10px;
        border-radius: 15px;
        font-size: 12px;
        font-weight: 600;
    }
    .status-chip {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        border: 1px solid;
        padding: 3px 10px;
        border-radius: 15px;
        font-size: 12px;
        font-weight: 600;
    }
    .status-chip svg { width: 14px; height: 14px; }
    .status-chip.status-new { color: #3498db; border-color: #3498db; } /* Blue */
    .status-chip.status-verified { color: #2ecc71; border-color: #2ecc71; } /* Green */
    .status-chip.status-data_error { color: #e74c3c; border-color: #e74c3c; } /* Red */
    .status-chip.status-stale { color: #f39c12; border-color: #f39c12; } /* Orange */
