/**
 * Custom Premium Stylesheet - Indian Festivals & Holidays Calendar
 * Modern typography, perfect contrast color systems, glassmorphism overlays.
 */

:root {
    /* Dynamic Theme Defaults - Overridden dynamically in header.php */
    --primary-color: #E65100;
    --primary-gradient: linear-gradient(135deg, #E65100 0%, #FF8F00 100%);
    --secondary-color: #FF8F00;
    --accent-color: #FFD54F;

    /* Light Theme Color System (Excellent Contrast) */
    --bg-color: #fbf7f4;
    --card-bg: #ffffff;
    --card-border: rgba(230, 81, 0, 0.08);
    --text-primary: #261103;
    --text-secondary: #4a2811;
    --text-muted: #734e35;
    --border-color: rgba(230, 81, 0, 0.12);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(230, 81, 0, 0.1);
}

body.dark-mode {
    /* Dark Theme Color System (Vibrant & Ultra Readable) */
    --bg-color: #120700;
    --card-bg: rgba(28, 12, 2, 0.85);
    --card-border: rgba(255, 143, 0, 0.15);
    --text-primary: #fff2ea;
    --text-secondary: #e6d3c7;
    --text-muted: #baa394;
    --border-color: rgba(255, 143, 0, 0.2);
    --glass-bg: rgba(28, 12, 2, 0.65);
    --glass-border: rgba(255, 143, 0, 0.12);
}

html, body {
    font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color) !important;
    color: var(--text-secondary) !important;
    transition: background-color 0.3s, color 0.3s;
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
    position: relative !important;
    touch-action: pan-y pinch-zoom !important; /* Blocks native horizontal touch swipe-dragging completely! */
}

main {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* Typography Overrides (Highly Readable) */
h1, h2, h3, h4, h5, h6, .card-title, .navbar-brand, .form-label, .filter-title {
    color: var(--text-primary) !important;
    font-weight: 700;
}

p, .card-text, .lead, .fs-7, .fs-8, .breadcrumb-item {
    color: var(--text-secondary) !important;
}

.text-muted, .text-secondary, .text-secondary-emphasis, .form-text {
    color: var(--text-muted) !important;
}

.text-gradient {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}
::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}

/* Navbar Theme Adaptation */
.navbar-premium {
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    background-color: var(--glass-bg) !important;
    transition: all 0.3s ease;
}

.navbar-premium .nav-link {
    color: var(--text-secondary) !important;
    transition: color 0.2s;
}

.navbar-premium .nav-link:hover, .navbar-premium .nav-link.active {
    color: var(--primary-color) !important;
}

/* Hero Banner */
.hero-banner {
    background: linear-gradient(rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.85)), url('../images/hero-bg.jpg') no-repeat center center/cover;
    min-height: 380px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-bottom: 40px;
    position: relative;
    overflow: hidden;
}

/* Glassmorphism Cards */
.card-glass {
    border-radius: 16px;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    background-color: var(--card-bg) !important;
    border: 1px solid var(--card-border) !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.card-glass:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(230, 81, 0, 0.15);
    border-color: var(--secondary-color) !important;
}

.card-glass .card-img-container {
    position: relative;
    overflow: hidden;
    height: 190px;
}

.card-glass .card-img-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
}

.card-glass:hover .card-img-container img {
    transform: scale(1.08);
}

/* Category Badge Styling */
.badge-category {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 30px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Inputs & Form Controls */
.form-control, .form-select {
    background-color: var(--card-bg) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    transition: all 0.3s;
}

.form-control::placeholder {
    color: var(--text-muted) !important;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 10px rgba(230, 81, 0, 0.25) !important;
}

/* Live Search Wrapper */
.search-wrapper {
    position: relative;
}
.search-wrapper .search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-color);
    z-index: 10;
}
.search-wrapper .form-control {
    padding-left: 50px !important;
    border-radius: 30px !important;
    height: 54px;
    font-size: 1.05rem;
}

/* Interactive Filter Sidebar */
.filter-sidebar {
    background-color: var(--card-bg) !important;
    border: 1px solid var(--card-border) !important;
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.02);
}

.filter-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
    display: inline-block;
}

/* Detail Page Custom Design */
.detail-hero {
    min-height: 400px;
    position: relative;
    background-size: cover;
    background-position: center;
    border-radius: 24px;
    overflow: hidden;
    margin-bottom: 40px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}

.detail-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 15%, rgba(0, 0, 0, 0.35) 100%);
}

.detail-hero-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 40px;
    color: #fff;
    z-index: 2;
}

/* Floating Actions & Buttons */
.btn-floating-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 1000;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: #fff !important;
    border: none;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-floating-top.show {
    opacity: 1;
    visibility: visible;
}

.btn-floating-top:hover {
    transform: translateY(-5px);
}

.btn-festive {
    background: var(--primary-gradient) !important;
    border: none !important;
    color: white !important;
    padding: 10px 24px;
    font-weight: 600;
    border-radius: 30px;
    transition: all 0.3s;
}

.btn-festive:hover {
    box-shadow: 0 5px 15px rgba(230, 81, 0, 0.35) !important;
    transform: translateY(-2px);
}

/* Footer Section */
.footer-premium {
    background-color: #0c0500 !important;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.footer-premium h5, .footer-premium strong {
    color: #fff2ea !important;
}

.footer-premium p, .footer-premium span {
    color: #baa394 !important;
}

.footer-premium a {
    color: #baa394 !important;
    text-decoration: none;
    transition: color 0.3s;
}

.footer-premium a:hover {
    color: var(--accent-color) !important;
}

/* CSS transition overrides for bootstrap list groups */
.list-group-item {
    color: var(--text-secondary) !important;
}
.list-group-item.active {
    color: #fff !important;
    background: var(--primary-gradient) !important;
}
.breadcrumb-item a {
    color: var(--text-muted) !important;
}
.breadcrumb-item.active {
    color: var(--text-primary) !important;
}
.btn-outline-warning {
    color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}
.btn-outline-warning:hover {
    background: var(--primary-gradient) !important;
    color: white !important;
    border-color: transparent !important;
}

/* Mobile responsive refinements */
@media (max-width: 575.98px) {
    /* Festival cards: clean, compact layout with perfect 100px 1:1 square thumbnail */
    .homepage-festival-card {
        cursor: pointer;
        height: 100px !important;
        min-height: 100px !important;
        max-height: 100px !important;
        overflow: hidden !important;
        border-radius: 12px !important;
    }

    .homepage-festival-card .col-5 {
        width: 100px !important;
        flex: 0 0 100px !important;
        max-width: 100px !important;
        height: 100px !important;
        min-height: 100px !important;
        aspect-ratio: 1 / 1 !important;
        align-self: stretch !important;
    }

    .homepage-festival-card .col-7 {
        width: calc(100% - 100px) !important;
        flex: 0 0 calc(100% - 100px) !important;
        max-width: calc(100% - 100px) !important;
        padding: 6px 10px !important;
        height: 100px !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
    }

    /* Font size and line-height compression */
    .homepage-festival-card h5 {
        font-size: 0.85rem !important;
        margin: 0 !important;
        line-height: 1.2 !important;
    }

    .homepage-festival-card .fs-8.5 {
        font-size: 0.7rem !important;
        margin-top: 1px !important;
        margin-bottom: 1px !important;
    }

    .homepage-festival-card .card-text {
        font-size: 0.66rem !important;
        line-height: 1.2 !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 1 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        margin: 0 !important;
    }

    /* Compact footer action and badge */
    .homepage-festival-card .d-flex.align-items-center.justify-content-between.pt-2.mt-2.border-top {
        margin-top: 1px !important;
        padding-top: 2px !important;
        border-top: 1px solid rgba(255, 143, 0, 0.08) !important;
    }

    .homepage-festival-card .font-weight-bold {
        font-size: 0.62rem !important;
    }

    .homepage-festival-card .btn-outline-warning {
        padding: 1px 6px !important;
        font-size: 0.64rem !important;
    }


    /* Year Navigation Buttons Tuning */
    #prevYearBtn, #currentYearBtn, #nextYearBtn {
        font-size: 0.76rem !important;
        padding: 6px 8px !important;
        white-space: nowrap !important;
        flex: 1 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    #calendar-section .d-flex.gap-2 {
        width: 100% !important;
        justify-content: space-between !important;
        gap: 5px !important;
    }
    #calendar-section .card {
        padding: 12px 10px !important;
    }
    
    /* Navbar Brand text wrapping to prevent right overflow */
    .navbar-brand {
        white-space: normal !important;
        font-size: 1.1rem !important;
        max-width: calc(100% - 65px) !important;
        display: flex !important;
        align-items: center !important;
        line-height: 1.2 !important;
    }
    .navbar-brand span {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* Mobile detail page content improvements to prevent top/bottom cropping */
    .detail-hero {
        min-height: auto !important;
        height: auto !important;
        padding: 20px 10px !important;
        margin-bottom: 20px !important;
        border-radius: 16px !important;
    }
    .detail-hero-content {
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        padding: 15px 10px !important;
        margin: 0 !important;
        width: 100% !important;
    }
    .detail-hero-content .row {
        flex-direction: column !important;
        align-items: center !important;
    }
    .detail-hero-content img, .detail-hero-content .rounded-4 {
        max-height: 160px !important;
        width: 160px !important;
        height: 160px !important;
        margin-bottom: 5px !important;
        object-fit: cover !important;
    }
    .detail-hero-content h1 {
        font-size: 1.8rem !important;
        margin-top: 8px !important;
        line-height: 1.25 !important;
        text-align: center !important;
    }
    .detail-hero-content .badge-category {
        font-size: 0.72rem !important;
        padding: 4px 10px !important;
    }
    .detail-hero-content .d-flex.flex-wrap {
        gap: 10px !important;
        margin-top: 12px !important;
        font-size: 0.78rem !important;
        justify-content: center !important;
    }

    /* Compress padding of cards on mobile for neat spacing (excluding homepage festival cards which have internal row layout) */
    .card-glass:not(.homepage-festival-card), .col-lg-8 .card, .col-lg-4 .card {
        padding: 16px !important;
        margin-bottom: 16px !important;
        border-radius: 12px !important;
    }
    
    .festival-content {
        font-size: 0.92rem !important;
        line-height: 1.6 !important;
    }
    
    /* Related festivals mobile grid tuning */
    .col-lg-4 .d-flex.flex-column.gap-3 {
        gap: 12px !important;
    }

    /* Handle rich text content element overflows (like large tables/images) inside festival-content */
    .festival-content table {
        width: 100% !important;
        display: block !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    .festival-content img {
        max-width: 100% !important;
        height: auto !important;
    }
}
