/* CSS styles for History Today App */

:root {
    /* Color Palette */
    --color-primary: #3b82f6; /* Blue-500 */
    --color-primary-hover: #2563eb; /* Blue-600 */
    --color-secondary: #8b5cf6; /* Purple-500 */
    --color-accent: #f97316; /* Orange-500 */

    /* Backgrounds & Surfaces */
    --color-bg: #f8fafc; /* Slate-50 */
    --color-surface: #ffffff; /* White */

    /* Text Colors */
    --color-text: #1e293b; /* Slate-900 */
    --color-text-muted: #64748b; /* Slate-500 */

    /* Borders & Dividers */
    --color-border: #e2e8f0; /* Slate-200 */

    /* Status Colors */
    --color-success: #22c55e; /* Green-500 */
    --color-error: #ef4444; /* Red-500 */

    /* Category Specific Colors */
    --color-ancient: #b45309; /* Amber-700 */
    --color-modern: #1e40af; /* Blue-800 */
    --color-contemporary: #065f46; /* Emerald-800 */

    /* Fonts & Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; 

    /* Shadow Gradients */
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);

    /* Sizings & Transitions */
    --radius: 0.75rem; /* Rounded corners */
    --transition: all 0.2s ease-in-out; /* Smooth transitions */
}

/* Base Styles */
html {
    box-sizing: border-box; /* Use border-box for consistent sizing */
}
*, *::before, *::after {
    box-sizing: inherit; /* Inherit box-sizing for all elements */
}

body {
    margin: 0;
    font-family: var(--font-sans);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Utility Classes */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

main {
    padding: 2rem 0;
}

.hidden {
    display: none !important;
}

/* Fade-in Animation for Sections */
.section-fade {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.section-fade.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Header */
.main-header {
    background-color: rgba(255,255,255,0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--color-border);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
    text-decoration: none;
    flex-shrink: 0; /* Prevent shrinking on small screens */
}

.nav-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap; /* Allow buttons to wrap */
    justify-content: flex-end; /* Align to end if wrapped */
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: 999px; /* Pill shape */
    border: 1px solid transparent;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap; /* Prevent text wrapping inside button */
    font-size: 0.95rem; /* Adjust font size for better fit */
}

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

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

.btn-outline {
    border-color: var(--color-border);
    background-color: var(--color-surface);
    color: var(--color-text-muted);
}

.btn-outline:hover {
    background-color: var(--color-bg);
    border-color: #cbd5e1; /* Lighter border on hover */
}

/* Page Header & Controls */
.page-header {
    text-align: center;
    margin-bottom: 3rem;
    padding-top: 1rem; /* Spacing from header */
}

.page-title {
    font-size: 2.5rem;
    margin: 0 0 1rem;
    background: linear-gradient(to right, var(--color-primary), var(--color-secondary));
    -webkit-background-clip: text;
    color: transparent;
    font-weight: 800;
}

.page-subtitle {
    font-size: 1.1rem;
    color: var(--color-text-muted);
    max-width: 600px;
    margin: 0 auto;
}

/* Controls Section (Wrapper for controls-group) */
.controls-section {
    display: flex;
    flex-wrap: wrap; 
    justify-content: center;
    align-items: center;
    background: var(--color-surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    margin-bottom: 3rem;
}

/* NEW: controls-group to hold both day navigation and category filters */
.controls-group {
    display: flex;
    flex-direction: column; /* Default stack on top of each other */
    align-items: center; /* Center items inside the group horizontally */
    gap: 1rem; /* Gap between date navigation and category filters */
    width: 100%; /* Take full width of controls-section */
}

/* Day Navigation (Previous/Next day buttons) */
.day-navigation {
    display: flex;
    align-items: center;
    gap: 0.25rem; /* Reduced gap between buttons and date picker */
    justify-content: center;
    flex-wrap: wrap; /* Allow wrapping */
}

.date-picker {
    padding: 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    font-size: 1rem;
    flex-grow: 0; 
    width: 140px; /* Specific width */
    text-align: center; 
    box-sizing: border-box; 
    min-width: 100px; 
}

.day-navigation .btn {
    padding: 0.6rem 0.8rem; /* Adjust padding to be more compact */
}


.category-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    flex-grow: 1; /* Allow to grow */
    width: 100%; /* Take full width of controls-group if needed */
}

.filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: transparent;
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
    font-size: 0.9rem;
}

.filter-btn-all { color: var(--color-text-muted); }
.filter-btn-ancient { color: var(--color-ancient); }
.filter-btn-modern { color: var(--color-modern); }
.filter-btn-contemporary { color: var(--color-contemporary); }

.filter-btn.active,
.filter-btn:hover {
    background-color: var(--color-primary);
    color: white !important; /* !important to override specific colors */
    border-color: var(--color-primary);
}

/* Event Grid */
.event-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.event-card {
    background-color: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.event-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap; /* Allow category and year to wrap */
    gap: 0.5rem; /* Gap between wrapped items */
}

.event-year {
    background-color: var(--color-bg);
    color: var(--color-text-muted);
    font-weight: 700;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    flex-shrink: 0; /* Prevent shrinking */
}

.event-category {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    flex-shrink: 0; /* Prevent shrinking */
}

.category-ancient { background-color: #fef3c7; color: var(--color-ancient); }
.category-modern { background-color: #dbeafe; color: var(--color-modern); }
.category-contemporary { background-color: #dcfce7; color: var(--color-contemporary); }

.event-description {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    flex-grow: 1; /* Allow description to take available height */
}

.event-actions {
    display: flex;
    gap: 0.75rem;
    border-top: 1px solid var(--color-border);
    padding-top: 1rem;
    margin-top: auto; /* Push actions to the bottom */
    flex-wrap: wrap; /* Allow buttons to wrap */
}

.action-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap; /* Prevent text wrapping */
    flex-shrink: 0; /* Prevent shrinking */
}

.action-btn:hover {
    color: var(--color-primary);
}

.action-btn.bookmarked {
    color: var(--color-accent);
}

/* Quote Section */
.quote-section {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: white;
    padding: 3rem 1.5rem;
    border-radius: var(--radius);
    text-align: center;
    margin: 4rem 0;
    box-shadow: var(--shadow-lg); /* Add shadow for better appearance */
}

.quote-text {
    font-size: 1.5rem;
    font-style: italic;
    max-width: 800px;
    margin: 0 auto 1rem;
    line-height: 1.5;
}

.quote-author {
    font-weight: 600;
    opacity: 0.9;
    font-size: 1.1rem;
}

/* Monthly Stats Grid - MODIFIED FOR SINGLE COLUMN LAYOUT */
.month-grid {
    display: flex; /* Use flexbox for vertical stacking */
    flex-direction: column; /* Stack children vertically */
    gap: 2rem; /* Gap between month cards */
}

.month-card {
    background-color: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column; /* Stack month title and day grid */
    break-inside: avoid; /* Avoid breaking cards across columns if they were to wrap, ensures entire card stays together */
}

.month-title {
    font-size: 1.8rem;
    margin: 0 0 1.5rem;
    color: var(--color-primary);
    font-weight: 700;
    text-align: center; /* Center month titles */
}

.day-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); /* Adjusted minmax for day links */
    gap: 0.75rem;
    flex-grow: 1; /* Allow day grid to fill space in month card */
}

.day-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--color-border);
    text-decoration: none;
    color: var(--color-text);
    transition: var(--transition);
    height: 70px; /* Fixed height for squares */
}

.day-link.has-events {
    background-color: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.day-link.no-events { /* New style for days without events */
    background-color: var(--color-bg);
    color: var(--color-text-muted);
    border-color: var(--color-border);
    opacity: 0.7; /* Slightly dim days without events */
}

.day-link:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-sm);
}

/* Ensure hover state for no-events is distinct */
.day-link.no-events:hover {
    background-color: var(--color-surface); /* Lighter hover for no-events */
    color: var(--color-text-muted);
    opacity: 1;
}


.day-number {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.day-count {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-top: 0.2rem;
}

/* Modal Styling (Bookmarks) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none; /* Allows clicks to pass through when hidden */
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto; /* Enables clicks when active */
}

.modal-content {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 600px;
    width: 90%; /* Responsive width */
    box-shadow: var(--shadow-lg);
    transform: scale(0.95); /* Initial scale for animation */
    transition: transform 0.2s ease;
    max-height: 90vh; /* Limit modal height */
    overflow: hidden; /* Hide overflow to make bookmarks-list scrollable */
    display: flex;
    flex-direction: column;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-shrink: 0; /* Prevent shrinking */
}

.modal-title {
    font-size: 1.5rem;
    margin: 0;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: color 0.2s ease;
}

.modal-close-btn:hover {
    color: var(--color-text);
}

.bookmarks-list {
    flex-grow: 1; /* Allow list to take available space */
    overflow-y: auto; /* Enable scrolling for the list content */
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-right: 0.5rem; /* Space for scrollbar */
}

.bookmark-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    background: var(--color-bg);
    padding: 1rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap; /* Allow items to wrap */
}

.bookmark-info {
    flex-grow: 1;
    min-width: 150px; /* Ensure info doesn't shrink too much */
}

.bookmark-desc {
    font-weight: 600;
    margin-bottom: 0.2rem;
}

.bookmark-year {
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.bookmark-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
    margin-top: 0.5rem; /* Space when wrapping */
}

.remove-bookmark-btn {
    color: var(--color-error);
}

/* Footer */
.main-footer {
    text-align: center;
    padding: 2rem 0;
    margin-top: 2rem;
    border-top: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* Scroll-to-top button */
#scroll-to-top-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--color-primary);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 0; /* Initial hidden */
    transform: translateY(20px); /* Initial offset for animation */
    z-index: 999;
}

#scroll-to-top-btn.show {
    opacity: 1;
    transform: translateY(0);
}

#scroll-to-top-btn:hover {
    background-color: var(--color-primary-hover);
    box-shadow: var(--shadow-lg);
}

/* Media Queries for Responsiveness */
@media (max-width: 1024px) {
    .container {
        padding: 0 1rem; /* Reduce padding on slightly smaller screens */
    }
}

@media (max-width: 768px) { /* Adjust breakpoint as needed */
    .header-content {
        flex-direction: column;
        align-items: flex-start;
        height: auto;
        padding: 0.8rem 0;
        gap: 0.8rem;
    }
    .nav-actions {
        width: 100%;
        justify-content: space-around; /* Distribute buttons evenly */
        gap: 0.5rem;
    }

    /* Small screen navigation: hide icons, show text */
    .nav-actions .btn i { /* Target Font Awesome icon directly, assuming it's the `<i>` tag */
        display: none; 
    }
    .nav-actions .btn .btn-text {
        display: inline; /* Ensure text is always visible */
    }
    .nav-actions .btn {
        padding: 0.5rem 0.8rem; /* Adjust padding for text-only buttons */
        font-size: 0.85rem;
        gap: 0; /* No gap when icon is hidden */
    }

    .page-title {
        font-size: 2rem;
    }
    .page-subtitle {
        font-size: 1rem;
        padding: 0 0.5rem;
    }
    .controls-section {
        flex-direction: column; /* Remain column-stacked on small screens */
        padding: 1rem;
        gap: 0.8rem; /* Gap between controls-group and other potential elements in controls-section */
    }
    /* NEW: controls-group for small screens */
    .controls-group {
        flex-direction: column; /* Stack date and filters vertically */
        gap: 0.8rem; /* Gap between date navigation and category filters on small screens */
        width: 100%;
    }

    .day-navigation {
        width: 100%;
        justify-content: space-between; /* Distribute prev/date/next more evenly */
        gap: 0.5rem; /* Gap internal to day nav */
    }
    .date-picker {
        flex-grow: 1; /* Allow it to take more space on mobile */
        max-width: none; /* Remove max width constraint */
    }
    .day-navigation .btn {
        flex-shrink: 0; /* Prevent buttons from shrinking too much */
        width: auto; /* Let content dictate width */
    }
    .category-filters {
        width: 100%;
        justify-content: space-around;
    }
    .filter-btn {
        flex-grow: 1; /* Allow filter buttons to grow */
        font-size: 0.85rem;
        padding: 0.4rem 0.6rem;
    }
    .event-grid {
        grid-template-columns: 1fr; /* Single column on mobile */
        /* Ensure gap is still applied */
        gap: 1rem; /* Slightly reduced gap for mobile to save space */
    }
    .event-card {
        /* No specific width/height here; it should adapt to 1fr grid column */
        /* Ensure it's not hidden by mistake */
        display: flex; /* Explicitly keep it flex */
        min-width: unset; /* Ensure no fixed min-width is breaking layout */
    }
    .quote-section {
        padding: 2rem 1rem;
        margin: 3rem 0;
    }
    .quote-text {
        font-size: 1.2rem;
    }
    .quote-author {
        font-size: 1rem;
    }
    /* Monthly Grid layout should already be single column flex-direction */
    .day-link {
        height: 60px; /* Smaller day boxes */
    }
    .day-number {
        font-size: 1.3rem;
    }
    .day-count {
        font-size: 0.7rem;
    }
    .modal-content {
        padding: 1.5rem;
        width: 95%; /* Adjust modal width for smaller screens */
    }
    .modal-title {
        font-size: 1.2rem;
    }
    .bookmark-item {
        flex-direction: column;
        align-items: flex-start;
        padding: 0.8rem;
    }
    .bookmark-actions {
        width: 100%;
        justify-content: flex-end;
        margin-top: 0.8rem;
    }
    #scroll-to-top-btn {
        bottom: 1rem;
        right: 1rem;
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
    }
}

@media (max-width: 480px) { /* Even smaller screens if needed */
    body {
        font-size: 0.9rem; /* Slightly smaller base font for tiny screens */
    }
    .container {
        padding: 0 0.5rem;
    }
    .logo {
        font-size: 1.2rem;
    }
    .nav-actions .btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.75rem;
    }

    /* Re-confirming for very small screens header nav */
    .nav-actions .btn i {
        display: none;
    }
    .nav-actions .btn .btn-text {
        display: inline;
    }

    .page-title {
        font-size: 1.5rem;
    }
    .page-subtitle {
        font-size: 0.9rem;
    }
    .day-navigation {
        gap: 0.2rem; /* Even tighter gap for very small screens */
    }
    .date-picker {
        font-size: 0.9rem;
         width: 100px; /* Slightly narrower date picker for smallest screens */
    }
    .day-navigation .btn {
        padding: 0.5rem 0.6rem; /* Adjust padding for very small prev/next buttons */
    }
    .category-filters {
        /* Ensure filter buttons wrap if needed */
        justify-content: center;
    }
    .category-filters .filter-btn {
        flex-grow: unset; /* Allow filter buttons to shrink to content, prevent excessive stretching */
        font-size: 0.75rem;
        padding: 0.3rem 0.4rem;
        white-space: nowrap; /* Keep text on one line */
    }
    .event-card {
        padding: 0.8rem;
    }
    .event-description {
        font-size: 0.95rem;
    }
    .quote-text {
        font-size: 1rem;
    }
    .quote-author {
        font-size: 0.9rem;
    }
    /* ... other minor adjustments for very small screens */
} 