/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* --- UNIFIED THEME VARIABLES: BLUE/DARK THEME (as confirmed by you) --- */
:root {
    --primary-bg: #0a0a1a;
    --secondary-bg: #101025;
    --card-bg: #1a1a3a;
    --accent-bg: #2a2a4a;
    --text-primary: #ffffff;
    --text-secondary: #e0e0e0;
    --text-muted: #9a9acc;
    --text-dim: #aaaaaa;
    --accent-color: #8a8aff; /* The distinct blue accent */
    --hover-color: #4a4a6a; /* Darker blue/purple for hover states */
    --border-color: #3a3a5a; /* Blue/purple border color */
    --gradient-primary: linear-gradient(145deg, #1a1a3a, #0a0a1a); /* Main dark blue gradient */
    --gradient-card: linear-gradient(135deg, #1a1a3a, #2a2a4a); /* Card background gradient */
    --shadow-light: 0 2px 10px rgba(138, 138, 255, 0.1); /* Blue-tinted shadows */
    --shadow-medium: 0 4px 15px rgba(138, 138, 255, 0.2);
    --shadow-heavy: 0 8px 25px rgba(138, 138, 255, 0.3);
    --transition-fast: 0.2s ease;
    --transition-medium: 0.3s ease;
    --border-radius: 12px;
    --border-radius-small: 8px;

    /* Spacing variables (kept from your original CSS for consistency) */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-xxl: 3rem;
    
    /* Typography variables (kept from your original CSS) */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;
    
    /* Border radius variables (kept from your original CSS) */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    
    /* Shadow variables (kept from your original CSS for consistency with various elements) */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.2);

    /* Navbar Height Variable - Corrected and made responsive (from previous fixes) */
    --navbar-height-desktop: 80px;
    --navbar-height-mobile: 70px;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--primary-bg); /* Uses primary-bg from :root */
    color: var(--text-secondary); /* Uses text-secondary from :root */
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
    padding-top: var(--navbar-height-desktop); /* Pushes content down to clear the fixed navbar */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

/* --- NAVIGATION STYLES (ADAPTED TO BOOTSTRAP CLASSES AND MATCHING BLUE/DARK THEME) --- */
.navbar { /* Targets <nav class="navbar"> */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--gradient-primary) !important; /* FORCES NAVIGATION BACKGROUND to blue gradient */
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1rem;
    transition: transform 0.2s ease-out;
    will-change: transform;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
}

.navbar-brand { /* Targets <a class="navbar-brand"> */
    display: flex;
    align-items: center;
    padding: 0;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--accent-color) !important; /* Uses accent-color for the brand text (blue) */
    text-decoration: none;
    gap: 0.5rem;
}


.brand-logo { /* Targets <img class="brand-logo"> */
    height: 60px;
    width: auto;
}

.navbar-toggler { /* Targets <button class="navbar-toggler"> */
    border: none;
    padding: 0.5rem;
    background: none;
    color: var(--text-primary); /* Ensures toggler icon is visible (white) */
    font-size: 1.5rem;
    cursor: pointer;
}

.navbar-toggler-icon { /* Targets <span class="navbar-toggler-icon"> */
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.8%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

.navbar-nav { /* Targets <ul class="navbar-nav"> */
    display: flex;
    list-style: none;
    gap: 2rem;
    align-items: center;
    margin-left: auto;
}

.navbar-nav .nav-item { /* Standard Bootstrap nav-item spacing */
    /* Kept for potential overrides, but gap on .navbar-nav usually handles spacing */
}

.navbar-nav .nav-link { /* Targets <a class="nav-link"> inside .navbar-nav */
    color: var(--text-secondary) !important; /* Uses secondary text color for links */
    text-decoration: none;
    transition: color var(--transition-fast);
    font-weight: 500;
    padding: 0; /* Reset Bootstrap padding to use gap for spacing */
    white-space: nowrap;
}

.navbar-nav .nav-link:hover,
.navbar-nav .nav-link.active { /* FIX FOR GREY ACTIVE/HOVER BACKGROUND IN NAVIGATION */
    color: var(--accent-color) !important; /* Uses accent color for text on hover/active */
    background-color: var(--hover-color) !important; /* Uses hover-color from :root for background */
    border-radius: var(--border-radius-small); /* Applies a subtle border-radius */
}

/* Dropdown menu styling */
.dropdown-menu {
    background-color: var(--secondary-bg); /* Uses secondary background for dropdown */
    border: 1px solid var(--border-color); /* Uses border color for dropdown */
    border-radius: var(--border-radius-small);
    box-shadow: var(--shadow-medium);
    padding: 0.5rem 0;
}

.dropdown-item {
    color: var(--text-secondary);
    padding: 0.75rem 1.5rem;
    transition: background-color var(--transition-fast), color var(--transition-fast);
    border-radius: 0;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: var(--hover-color); /* Uses hover-color for dropdown item hover */
    color: var(--text-primary);
}

.dropdown-divider {
    border-top: 1px solid var(--border-color); /* Uses border color for divider */
    margin: 0.25rem 0;
}

/* Class to hide the navbar (used by JS) */
.navbar.hidden {
    transform: translateY(-100%);
}

/* Custom CSS for nested Bootstrap dropdowns */
.dropdown-menu .dropdown-submenu .dropdown-menu {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    margin-top: -1px;
}

.dropdown-menu .dropdown-submenu:hover > .dropdown-menu {
    display: block;
}

@media (min-width: 992px) { /* Applies hover effect for dropdowns on desktop */
    .navbar-nav .dropdown:hover > .dropdown-menu {
        display: block;
    }
}

/* Main content */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0rem 1rem 0;
    min-height: calc(100vh - 200px);
}

/* Hero section */
.hero-section {
    text-align: center;
    padding: 3rem 1rem;
    background: var(--gradient-primary); /* Uses primary gradient for hero */
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
    box-shadow: var(--shadow-light);
}

.hero-section h1 {
    color: var(--text-primary);
    font-weight: 700;
    font-size: clamp(2rem, 5vw, 3rem);
    margin-bottom: 1rem;
    background: linear-gradient(45deg, #fff, var(--accent-color)); /* Text gradient with accent color */
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-section p {
    font-size: clamp(1rem, 3vw, 1.2rem);
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
}

/* Calendar navigation */
.calendar-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
    background: var(--secondary-bg); /* Uses secondary background for navigation */
    padding: 1rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#current-month {
    margin: 0;
    min-width: 200px;
    text-align: center;
    color: var(--text-primary);
    font-size: clamp(1.2rem, 4vw, 1.5rem);
    font-weight: 600;
}

.nav-btn, .today-btn {
    background: var(--gradient-card); /* Uses card gradient for buttons */
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius-small);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-weight: 500;
    white-space: nowrap;
}

.nav-btn:hover, .today-btn:hover {
    background: var(--hover-color); /* Uses hover-color for button hover */
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.nav-btn:active, .today-btn:active {
    transform: translateY(0);
}

/* Calendar container */
.calendar-container {
    background: var(--secondary-bg); /* Uses secondary background for calendar */
    padding: 1.5rem;
    border-radius: var(--border-radius);
    margin-bottom: 2rem;
    box-shadow: var(--shadow-light);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
    position: relative;
}

.calendar-grid.loading::before {
    content: 'Loading Moon Data...';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(16, 16, 37, 0.95);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(1rem, 4vw, 1.5rem);
    z-index: 10;
    border-radius: var(--border-radius);
    backdrop-filter: blur(5px);
}

.calendar-header {
    text-align: center;
    font-weight: bold;
    padding: 1rem 0.5rem;
    color: var(--text-muted); /* Uses muted text color */
    font-size: clamp(0.8rem, 3vw, 1rem);
}

.calendar-day {
    background: var(--gradient-card); /* Uses card gradient for day cells */
    border-radius: var(--border-radius-small);
    padding: 0.75rem;
    text-align: center;
    min-height: clamp(100px, 15vw, 120px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.calendar-day::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gradient-card);
    opacity: 0;
    transition: opacity var(--transition-fast);
    z-index: -1;
}

.calendar-day:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-medium);
    border-color: var(--accent-color); /* Highlights with accent color on hover */
}

.calendar-day:hover::before {
    opacity: 1;
}

.calendar-day.other-month {
    opacity: 0.4;
}

.calendar-day.today {
    border-color: var(--accent-color); /* Highlights today with accent color */
    box-shadow: var(--shadow-light);
}

.calendar-day.selected {
    background: var(--hover-color); /* Uses hover-color for selected day */
    border-color: var(--text-primary);
    transform: translateY(-5px);
    box-shadow: var(--shadow-heavy);
}

.day-number {
    font-weight: bold;
    align-self: flex-end;
    font-size: clamp(0.9rem, 3vw, 1.1rem);
    color: var(--text-primary);
}

.moon-icon {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    margin: 0.25rem 0;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.illumination-percent {
    font-size: clamp(0.7rem, 2.5vw, 0.8rem);
    color: var(--text-dim);
    font-weight: 500;
}

/* Details section */
.moon-details {
    background: var(--secondary-bg); /* Uses secondary background */
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    margin-bottom: 2rem; /* Added margin-bottom to separate from the new zodiac section */
}

.moon-details h3 {
    color: var(--text-primary);
    font-size: clamp(1.3rem, 4vw, 1.75rem);
    margin-bottom: 1.5rem;
    text-align: center;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.detail-item {
    background: var(--gradient-card); /* Uses card gradient */
    padding: 1rem;
    border-radius: var(--border-radius-small);
    border: 1px solid var(--border-color);
    transition: all var(--transition-fast);
}

.detail-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-light);
}

.detail-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-muted); /* Uses muted text color */
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.detail-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-word;
}

/* --- FIX: ZODIAC HISTORY LAYOUT & STYLING --- */
/* This rule targets the specific detail-item that contains the zodiac history */
.detail-item.zodiac-history {
    grid-column: 1 / -1; /* Make it span the full width within the details-grid */
    /* Override standard detail-item styling to make it look like a section header */
    background: none; /* Remove card background */
    border: none; /* Remove card border */
    box-shadow: none; /* Remove card shadow */
    padding: 0; /* Remove padding */
    display: block; /* Ensure it behaves like a block element */
    margin-bottom: 0; /* Remove internal margin if any */
}

/* Style for the "Recent Zodiac History" heading inside the detail-item */
.detail-item.zodiac-history .detail-label {
    font-size: var(--font-size-xl); /* Larger font size for the heading */
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-lg); /* Space below heading */
    display: block; /* Ensure it takes full width */
}

/* Wrapper for the individual zodiac cards */
.zodiac-history-list { /* This targets the ID in your HTML */
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); 
    gap: var(--spacing-md); /* Space between the cards */
    width: 100%; /* Ensure it takes full available width */
    margin-top: var(--spacing-lg); /* Space between "Recent Zodiac History" label and the cards */
}

/* Style for each individual zodiac card (these are the items *inside* .zodiac-history-list) */
/* Assuming your JS creates divs with class 'zodiac-card' inside 'zodiac-history-list' */
.zodiac-history-list .zodiac-card { 
    background: var(--gradient-card); /* Uses card gradient for card background */
    padding: var(--spacing-lg);
    border-radius: var(--border-radius-small);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex; /* Ensures content inside card stacks */
    flex-direction: column;
    justify-content: center;
    align-items: flex-start; /* Align text to the left within the card */
}

/* Hover effect for the cards */
.zodiac-history-list .zodiac-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-medium);
    border-color: var(--accent-color); /* Highlights with accent color on hover */
}

/* Style for the zodiac sign title (e.g., Gemini, Taurus) inside the card */
.zodiac-history-list .zodiac-card .zodiac-card-title { 
    font-size: var(--font-size-lg);
    font-weight: bold;
    color: var(--accent-color); /* Uses accent color for card titles */
    margin-bottom: var(--spacing-sm);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

/* Style for the date range text inside the card */
.zodiac-history-list .zodiac-card .zodiac-card-dates {
    font-size: var(--font-size-sm);
    color: var(--text-secondary); /* Uses secondary text color */
    line-height: 1.4;
}

/* Moon Legend */
.moon-legend {
    background-color: var(--secondary-bg);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-top: 2rem;
    margin-bottom: var(--spacing-xl);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-light);
}

.moon-legend h3 {
    color: var(--text-primary);
    font-size: clamp(1.3rem, 4vw, 1.75rem);
    margin-bottom: 1.5rem;
    text-align: center;
}

.legend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: 1rem;
    background: var(--gradient-card);
    border-radius: var(--border-radius-small);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.legend-icon {
    font-size: 1.5rem;
    filter: drop-shadow(0 0 5px rgba(138, 138, 255, 0.3)); /* Adjust glow to accent color */
}

.legend-text {
    color: var(--text-primary);
}

/* Educational Content */
.educational-content {
    background-color: var(--secondary-bg);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-top: 2rem;
    margin-bottom: var(--spacing-xl);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-light);
}

.educational-content h3 {
    color: var(--text-primary);
    font-size: clamp(1.3rem, 4vw, 1.75rem);
    margin-bottom: 1.5rem;
    text-align: center;
}

.content-section {
    margin-bottom: 2rem;
}

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

.content-section h4 {
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-size: clamp(1rem, 3vw, 1.25rem);
}

.content-section p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.content-section ul {
    list-style: none;
    padding-left: 0;
}

.content-section li {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    padding-left: 1.5rem;
    position: relative;
}

.content-section li::before {
    content: "🌙";
    position: absolute;
    left: 0;
    top: 0;
}

/* FAQ Section */
.faq-section {
    background-color: var(--secondary-bg);
    border-radius: var(--border-radius);
    padding: 2rem;
    margin-top: 2rem;
    margin-bottom: var(--spacing-xl);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-light);
}

.faq-section h3 {
    color: var(--text-primary);
    font-size: clamp(1.3rem, 4vw, 1.75rem);
    margin-bottom: 1.5rem;
    text-align: center;
}



@media (max-width: 480px) {
    .main-content {
        padding: 0rem 0rem 0;
    }

    .calendar-container, .moon-details {
        padding: 1rem;
    }

    .calendar-day {
        min-height: 80px;
        padding: 0.4rem;
    }

    .moon-icon {
        font-size: 1.5rem;
    }

    .day-number {
        font-size: 0.9rem;
    }

    .illumination-percent {
        font-size: 0.7rem;
    }

}

/* Focus styles for accessibility */
.nav-btn:focus, .today-btn:focus, .calendar-day:focus, #closeModalBtn:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .navbar, #moonInfoModal { /* Changed .nav-header to .navbar for consistency */
        display: none !important;
    }
    
    .main-content {
        max-width: none;
        margin: 0;
        padding: 0;
    }
    
    .calendar-day {
        break-inside: avoid;
    }
}
