/**
 * Rajasthan Government Calendar - Main Stylesheet
 * Modern, Premium Government Portal Design
 */

/* ==================== ROOT VARIABLES ==================== */
:root {
    /* Government Color Scheme */
    --raj-primary: #1e3a8a;
    --raj-secondary: #f97316;
    --raj-accent: #0ea5e9;
    --raj-gold: #f59e0b;

    /* Holiday Colors */
    --holiday-gazetted: #dc2626;
    --holiday-restricted: #f97316;
    --holiday-observance: #3b82f6;
    --holiday-festival: #fef3c7;
    --today-highlight: #10b981;

    /* Background Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: #ffffff;
    --bg-footer: #1e293b;

    /* Text Colors */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;

    /* Border Colors */
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;

    /* Fonts */
    --font-hindi: 'Noto Sans Devanagari', sans-serif;
    --font-english: 'Roboto', sans-serif;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/* Dark Mode Variables */
body.dark-mode {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-footer: #020617;

    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-light: #94a3b8;

    --border-color: #334155;
    --border-hover: #475569;
}

/* ==================== GLOBAL STYLES ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-english);
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Hindi Font Support */
body[lang="hi"],
.hindi-text {
    font-family: var(--font-hindi);
}

/* Main Content */
.main-content {
    flex: 1;
}

/* ==================== GOVERNMENT HEADER ==================== */
.gov-header {
    background: linear-gradient(135deg, var(--raj-primary) 0%, #1e40af 100%);
    color: white;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.gov-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    border-radius: 50%;
}

.emblem-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    transition: transform 0.3s ease;
}

.emblem-logo:hover {
    transform: scale(1.05);
}

.gov-title {
    font-size: 2rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    letter-spacing: 0.5px;
}

.gov-subtitle {
    font-size: 1rem;
    opacity: 0.9;
    font-weight: 300;
    letter-spacing: 0.3px;
}

.header-controls .btn {
    border-radius: 50px;
    padding: 0.4rem 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.header-controls .btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ==================== NAVIGATION ==================== */
.navbar {
    box-shadow: var(--shadow-sm);
    background: linear-gradient(135deg, var(--raj-primary) 0%, #2563eb 100%) !important;
}

.navbar-nav .nav-link {
    color: rgba(255, 255, 255, 0.9) !important;
    font-weight: 500;
    padding: 0.5rem 1.5rem !important;
    transition: all 0.3s ease;
    position: relative;
    border-radius: 8px;
    margin: 0 0.25rem;
}

.navbar-nav .nav-link::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--raj-secondary);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.navbar-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white !important;
}

.navbar-nav .nav-link:hover::before {
    width: 80%;
}

.navbar-nav .nav-link.active {
    background: rgba(255, 255, 255, 0.15);
    color: white !important;
}

/* ==================== CARDS ==================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    border-radius: 12px 12px 0 0 !important;
    font-weight: 600;
}

/* ==================== CALENDAR GRID ==================== */
.calendar-month-title {
    color: var(--raj-primary);
    font-weight: 700;
    font-size: 2rem;
}

.dark-mode .calendar-month-title {
    color: var(--raj-accent);
}

.calendar-grid {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: linear-gradient(135deg, var(--raj-primary) 0%, #2563eb 100%);
    color: white;
    font-weight: 600;
    text-align: center;
    border-radius: 12px 12px 0 0;
}

.calendar-day-header {
    padding: 1rem 0.5rem;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.5px;
}

.calendar-day-header:last-child {
    border-right: none;
}

.calendar-day-header.weekend {
    color: #fef3c7;
    font-weight: 700;
}

/* Backward compatibility */
.calendar-day-header.sunday {
    color: #fef3c7;
    font-weight: 700;
}

.calendar-body {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0;
    background: var(--bg-card);
}

.calendar-day {
    min-height: 120px;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
}

.calendar-day:hover {
    background: var(--bg-secondary);
    box-shadow: inset var(--shadow-md);
    transform: scale(1.02);
    z-index: 10;
}

.calendar-day.empty {
    background: var(--bg-secondary);
    cursor: default;
}

.calendar-day.empty:hover {
    transform: none;
    box-shadow: none;
}

.day-header-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.25rem;
}

.day-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.tithi-number {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.05);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    line-height: 1.2;
}

.dark-mode .tithi-number {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
}

.hindu-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    margin: 0.25rem 0;
}

.hindu-info small {
    font-size: 0.7rem;
    color: var(--text-secondary);
    line-height: 1.2;
}

.hindu-info .tithi {
    font-weight: 500;
    color: var(--raj-accent);
}

.hindu-info .special {
    font-weight: 600;
    color: var(--raj-gold);
    background: rgba(245, 158, 11, 0.1);
    padding: 0.125rem 0.25rem;
    border-radius: 4px;
}

.holiday-name,
.festival-name {
    margin-top: auto;
    font-weight: 600;
    line-height: 1.2;
}

.holiday-name small {
    color: white;
    display: block;
}

.festival-name small {
    color: var(--raj-primary);
    display: block;
}

/* Holiday Type Colors (moved before weekend for proper cascading) */
.calendar-day.holiday-gazetted {
    background: linear-gradient(135deg, var(--holiday-gazetted) 0%, #b91c1c 100%);
    color: white;
    border-color: var(--holiday-gazetted);
}

.calendar-day.holiday-gazetted .day-number,
.calendar-day.holiday-gazetted .hindu-info small {
    color: white;
}

.calendar-day.holiday-restricted {
    background: linear-gradient(135deg, var(--holiday-restricted) 0%, #ea580c 100%);
    color: white;
    border-color: var(--holiday-restricted);
}

.calendar-day.holiday-restricted .day-number,
.calendar-day.holiday-restricted .hindu-info small {
    color: white;
}

.calendar-day.holiday-observance {
    background: linear-gradient(135deg, var(--holiday-observance) 0%, #2563eb 100%);
    color: white;
    border-color: var(--holiday-observance);
}

.calendar-day.holiday-observance .day-number,
.calendar-day.holiday-observance .hindu-info small {
    color: white;
}

/* Optional Holiday - Dark Red Text Only */
.calendar-day.holiday-optional {
    /* Do not set background so it defaults to white (weekday) or weekend color */
    color: #991b1b;
    border-color: #b91c1c;
}

.calendar-day.holiday-optional .holiday-name small {
    color: #991b1b !important;
    font-weight: 700;
}

.calendar-day.holiday-optional .day-number {
    color: #991b1b !important;
}

/* Ensure Tithi Number matches */
.calendar-day.holiday-optional .tithi-number {
    color: #991b1b !important;
    border-color: #fca5a5;
}

/* Ensure Border is visible on Weekends */
.calendar-day.weekend.holiday-optional {
    border: 2px solid #b91c1c !important;
}

/* Weekday Accent */
.calendar-day:not(.weekend).holiday-optional {
    border-left: 3px solid #b91c1c;
}

.calendar-day.holiday-festival {
    background: var(--holiday-festival);
    border-color: var(--raj-gold);
}

/* Weekend Holiday Styling - Must come AFTER holiday styles for specificity */
/* For weekends WITHOUT specific holidays */
.calendar-day.saturday:not(.holiday-gazetted):not(.holiday-restricted):not(.holiday-observance):not(.holiday-optional) {
    background: linear-gradient(135deg, #e9d5ff 0%, #f3e8ff 100%) !important;
    border-left: 3px solid #a855f7 !important;
}

.calendar-day.sunday:not(.holiday-gazetted):not(.holiday-restricted):not(.holiday-observance):not(.holiday-optional) {
    background: linear-gradient(135deg, #fef3c7 0%, #fff4d4 100%) !important;
    border-left: 3px solid #f59e0b !important;
}

.dark-mode .calendar-day.saturday:not(.holiday-gazetted):not(.holiday-restricted):not(.holiday-observance):not(.holiday-optional) {
    background: linear-gradient(135deg, #581c87 0%, #6b21a8 100%) !important;
    border-left: 3px solid #c084fc !important;
}

.dark-mode .calendar-day.sunday:not(.holiday-gazetted):not(.holiday-restricted):not(.holiday-observance):not(.holiday-optional) {
    background: linear-gradient(135deg, #422006 0%, #713f12 100%) !important;
    border-left: 3px solid #f59e0b !important;
}

/* Weekend indicator badge/stripe for ALL weekends (even with holidays) */
.calendar-day.weekend-holiday::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 30px 30px 0;
    border-color: transparent #a855f7 transparent transparent;
    opacity: 0.3;
}

/* Today Highlight */
.calendar-day.today {
    border: 3px solid var(--today-highlight);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.calendar-day.today .day-number {
    color: var(--today-highlight);
}

/* ==================== LEGEND ==================== */
.legend-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.legend-color {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.legend-color.holiday-gazetted {
    background: var(--holiday-gazetted);
}

.legend-color.holiday-restricted {
    background: var(--holiday-restricted);
}

.legend-color.holiday-observance {
    background: var(--holiday-observance);
}

.legend-color.holiday-festival {
    background: var(--holiday-festival);
    border: 2px solid var(--raj-gold);
}

.legend-color.weekend-holiday {
    background: linear-gradient(135deg, #e9d5ff 0%, #f3e8ff 100%);
    border: 2px solid #a855f7;
}

.legend-color.today-highlight {
    background: var(--today-highlight);
}

/* Legend Modal */
.legend-item {
    padding: 1rem;
    margin-bottom: 1rem;
    border-left: 4px solid var(--raj-primary);
    background: var(--bg-secondary);
    border-radius: 8px;
}

.legend-item:last-child {
    margin-bottom: 0;
}

/* ==================== FOOTER ==================== */
.gov-footer {
    background: var(--bg-footer);
    color: #cbd5e1;
    padding: 3rem 0 1rem;
    margin-top: auto;
}

.gov-footer h5 {
    color: white;
    font-weight: 600;
    margin-bottom: 1rem;
}

.gov-footer a {
    color: #cbd5e1;
    text-decoration: none;
    transition: color 0.3s ease;
}

.gov-footer a:hover {
    color: var(--raj-secondary);
}

.gov-footer hr {
    opacity: 0.2;
}

/* ==================== RESPONSIVE DESIGN ==================== */
@media (max-width: 768px) {
    .gov-title {
        font-size: 1.5rem;
    }

    .gov-subtitle {
        font-size: 0.875rem;
    }

    .calendar-day {
        min-height: 90px;
        padding: 0.5rem;
    }

    .day-number {
        font-size: 1.2rem;
    }

    .hindu-info small,
    .holiday-name small,
    .festival-name small {
        font-size: 0.6rem;
    }

    .calendar-day-header {
        padding: 0.75rem 0.25rem;
        font-size: 0.75rem;
    }

    .calendar-month-title {
        font-size: 1.5rem;
    }
}

@media (max-width: 576px) {
    .emblem-logo {
        width: 60px;
        height: 60px;
    }

    .calendar-day {
        min-height: 70px;
        padding: 0.25rem;
    }

    .day-number {
        font-size: 1rem;
    }

    .hindu-info,
    .holiday-name,
    .festival-name {
        display: none;
    }
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeIn 0.5s ease-out;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.calendar-day.today {
    animation: pulse 2s ease-in-out infinite;
}

/* ==================== UTILITIES ==================== */
.text-primary-custom {
    color: var(--raj-primary) !important;
}

.bg-primary-custom {
    background: var(--raj-primary) !important;
}

.text-secondary-custom {
    color: var(--raj-secondary) !important;
}

.bg-secondary-custom {
    background: var(--raj-secondary) !important;
}

/* Smooth Transitions */
* {
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Tithi Visibility Optimization for Colored Backgrounds */
.calendar-day.weekend .tithi-number,
.calendar-day.saturday .tithi-number,
.calendar-day.sunday .tithi-number,
.calendar-day.holiday-gazetted .tithi-number,
.calendar-day.holiday-restricted .tithi-number,
.calendar-day.holiday-optional .tithi-number {
    background: rgba(255, 255, 255, 0.85) !important;
    color: #000 !important;
    font-weight: 700;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.dark-mode .calendar-day.weekend .tithi-number,
.dark-mode .calendar-day.holiday-gazetted .tithi-number {
    color: #fff !important;
}

/* ==================== MOBILE OPTIMIZATION ==================== */
@media (max-width: 768px) {

    /* 1. FORCE EDGE-TO-EDGE by resetting Bootstrap paddings */
    .container,
    .container-fluid,
    .row,
    .col-12,
    .col-md-12,
    .card,
    .card-body {
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 0 !important;
        border: none !important;
    }

    /* 2. STRICT GRID LAYOUT */
    .calendar-header,
    .calendar-body {
        display: grid !important;
        grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
        /* CRITICAL: minmax(0, 1fr) allows shrinking */
        width: 100vw !important;
        /* Force exact viewport width */
        gap: 1px !important;
        /* Clean grid lines */
        background: #e2e8f0;
        /* Gray background allows gaps to look like borders */
        border: none !important;
    }

    .calendar-day-header {
        font-size: 0.65rem;
        padding: 4px 0;
        white-space: nowrap;
        overflow: hidden;
    }

    /* 3. CELL COMPACT LAYOUT */
    .calendar-day {
        min-height: 14vw !important;
        /* Aspect ratio control */
        height: auto !important;
        padding: 2px !important;
        position: relative !important;
        background: white;
        /* Ensure cells have background vs grid gap */
        overflow: hidden !important;
    }

    /* 4. ABSOLUTE POSITIONING to free up width */
    .day-header-row {
        display: block !important;
        margin: 0 !important;
    }

    .day-number {
        position: absolute !important;
        top: 2px !important;
        left: 2px !important;
        font-size: 0.8rem !important;
        line-height: 1;
        z-index: 2;
    }

    .tithi-number {
        position: absolute !important;
        top: 2px !important;
        right: 2px !important;
        font-size: 0.55rem !important;
        padding: 1px 2px !important;
        z-index: 2;
        max-width: 50%;
        background: rgba(255, 255, 255, 0.8);
        /* Readability over backgrounds */
    }

    /* 5. CONTENT MANAGEMENT */
    .holiday-name,
    .festival-name,
    .hindu-info {
        margin-top: 1rem !important;
        /* Clear the top numbers */
        width: 100%;
        text-align: center;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-end;
    }

    .holiday-name small,
    .festival-name small,
    .hindu-info small {
        font-size: 0.55rem !important;
        line-height: 1;
        white-space: normal !important;
        text-align: center;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* Hide Maas on mobile grid to save space, show only distinct events */
    .maas-name {
        display: none !important;
    }
}