/* ================================================
   Magistrate's Courts of Sri Lanka – Main Stylesheet
   Theme: Dark Charcoal & Gold
   (Matching Magistrate's Court Theme Colors & Typography)
   ================================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Poppins:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Magistrate's Court Theme: Dark Charcoal & Gold */
    --primary-color: #1F1E1F;
    /* Dark Charcoal - Professional & Authoritative */
    --secondary-color: #2a2829;
    /* Slightly lighter charcoal for hover states */

    /* Elegant Gold accent to maintain visual interest */
    --gold-accent: #C5A059;
    --gold-light: #e4c580;
    --gold-dark: #a68a42;

    --text-light: #ffffff;
    --text-muted: rgba(255, 255, 255, 0.75);
    --text-dark: #1F1E1F;
    --bg-light: #f9f9f9;
    --bg-dark: #121213;

    --primary-deep: #171617;
    --primary-darker: #0d0d0e;
    --primary-light: #383638;

    /* Shadows */
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.35);
    --shadow-medium: 0 8px 30px rgba(0, 0, 0, 0.45);
    --shadow-heavy: 0 16px 48px rgba(0, 0, 0, 0.6);
    --shadow-gold: 0 4px 20px rgba(197, 160, 89, 0.35);

    /* Transitions */
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ================================================
   Reset & Base
   ================================================ */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
    height: 100%;
}

body {
    font-family: 'Poppins', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-light);
    background: url('../images/h2.webp') center center / cover no-repeat fixed;
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: linear-gradient(160deg, rgba(18, 17, 18, 0.88) 0%, rgba(31, 30, 31, 0.55) 50%, rgba(14, 13, 14, 0.94) 100%);
    z-index: -1;
    pointer-events: none;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(18, 17, 18, 0.9);
}

::-webkit-scrollbar-thumb {
    background: rgba(197, 160, 89, 0.4);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gold-accent);
}

.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 24px;
}

.grid-container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 clamp(16px, 2.5vw, 36px);
}

a {
    text-decoration: none;
    color: inherit;
}

/* ================================================
   Main Centered Wrapper
   ================================================ */
.page-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: clamp(16px, 3vh, 40px) 0;
    position: relative;
    z-index: 2;
    min-height: 0;
}

/* ================================================
   Hero Section
   ================================================ */
.hero {
    position: relative;
    padding-top: 0;
    padding-bottom: clamp(8px, 1.2vh, 14px);
    background: none;
    overflow: visible;
    z-index: 2;
}

.hero-overlay {
    display: none;
}

.hero-particles {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.hero-particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: var(--gold-accent);
    border-radius: 50%;
    opacity: 0;
    animation: particleFloat 8s infinite ease-in-out;
}

@keyframes particleFloat {
    0%, 100% { opacity: 0; transform: translateY(0) scale(0.5); }
    20% { opacity: 0.6; }
    50% { opacity: 0.3; transform: translateY(-120px) scale(1); }
    80% { opacity: 0.6; }
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 100%;
    text-align: left;
    padding: 0;
    font-family: 'Poppins', sans-serif;
}

.hero-title {
    font-family: 'Poppins', serif;
    font-size: clamp(2.2rem, 3.8vw, 3.6rem);
    font-weight: 700;
    color: var(--text-light);
    line-height: 1.15;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
    text-shadow: 0 4px 16px rgba(0, 0, 0, 0.7);
}

.gold-text {
    background: linear-gradient(135deg, var(--gold-light), var(--gold-accent), var(--gold-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.hero-description {
    font-size: clamp(0.82rem, 1vw, 0.94rem);
    color: rgba(255, 255, 255, 0.88);
    max-width: 860px;
    margin: 0 0 12px;
    line-height: 1.45;
    font-weight: 400;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
}

/* Hero Stats */
.hero-stats {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: clamp(16px, 2.5vw, 32px);
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.stat-item {
    text-align: left;
}

.stat-number {
    font-family: 'Poppins', sans-serif !important;
    font-size: clamp(1.2rem, 1.8vw, 1.45rem);
    font-weight: 700;
    color: var(--gold-accent);
    line-height: 1;
    margin-bottom: 2px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.stat-label {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.85);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 500;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.stat-divider {
    width: 1px;
    height: 32px;
    background: rgba(197, 160, 89, 0.3);
}

/* ================================================
   Search & Filter Bar
   ================================================ */
.search-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 16px;
    padding: 6px 12px;
    background: rgba(31, 30, 31, 0.90);
    border-radius: 12px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(197, 160, 89, 0.35);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
    max-width: 950px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-filter-bar:focus-within {
    border-color: var(--gold-accent);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 15px rgba(197, 160, 89, 0.25);
}

.search-box {
    position: relative;
    flex: 1 1 200px;
    min-width: 170px;
}

.search-box i.fa-search {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gold-accent);
    font-size: 0.85rem;
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 8px 32px 8px 34px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    font-size: 0.84rem;
    font-family: 'Poppins', sans-serif;
    color: var(--text-light);
    background: rgba(0, 0, 0, 0.35);
    transition: all var(--transition-fast);
}

.search-box input::placeholder {
    color: rgba(255, 255, 255, 0.55);
}

.search-box input:focus {
    outline: none;
    border-color: var(--gold-accent);
    background: rgba(0, 0, 0, 0.55);
    box-shadow: 0 0 0 2px rgba(197, 160, 89, 0.25);
}

.search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    display: none;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color var(--transition-fast);
}

.search-clear.visible {
    display: block;
}

.search-clear:hover {
    color: var(--gold-accent);
}

/* District Dropdown Filter */
.district-filter-box {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    min-width: 175px;
}

.district-icon {
    position: absolute;
    left: 10px;
    color: var(--gold-accent);
    font-size: 0.78rem;
    pointer-events: none;
    z-index: 1;
}

.district-select {
    width: 100%;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding: 7px 28px 7px 28px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.35);
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.78rem;
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    outline: none;
}

.district-select:hover {
    border-color: var(--gold-accent);
    background: rgba(197, 160, 89, 0.12);
    color: #ffffff;
}

.district-select:focus {
    border-color: var(--gold-accent);
    background: rgba(0, 0, 0, 0.55);
    box-shadow: 0 0 0 2px rgba(197, 160, 89, 0.25);
    color: #ffffff;
}

.district-select option {
    background-color: #1F1E1F;
    color: #ffffff;
    padding: 8px 12px;
}

.select-arrow {
    position: absolute;
    right: 10px;
    color: var(--gold-accent);
    font-size: 0.65rem;
    pointer-events: none;
    transition: transform var(--transition-fast);
}

.district-filter-box:focus-within .select-arrow {
    transform: rotate(180deg);
}

.filter-group {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.75rem;
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.filter-btn:hover {
    border-color: var(--gold-accent);
    color: var(--gold-accent);
    background: rgba(197, 160, 89, 0.15);
}

.filter-btn.active {
    background: var(--gold-accent);
    color: var(--primary-color);
    border-color: var(--gold-accent);
    font-weight: 600;
}

.filter-count {
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.18);
    color: inherit;
}

.filter-btn.active .filter-count {
    background: rgba(0, 0, 0, 0.22);
    color: var(--primary-color);
    font-weight: 700;
}

.filter-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.active-dot {
    background: #22c55e;
}

.coming-dot {
    background: var(--gold-accent);
}

.filter-btn.active .coming-dot {
    background: var(--primary-color);
}

.filter-btn.active .active-dot {
    background: #15803d;
}

/* ================================================
   Courts Section
   ================================================ */
.courts-section {
    background: none;
    padding-top: clamp(6px, 1vh, 12px);
    padding-bottom: clamp(10px, 1.8vh, 22px);
    position: relative;
    z-index: 2;
}

/* Courts Grid - 11 columns on desktop */
.courts-grid {
    display: grid;
    grid-template-columns: repeat(11, 1fr);
    gap: 7px;
    margin-bottom: 0;
    position: relative;
}

/* Court Card */
.court-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 7px 4px;
    min-height: 42px;
    background: rgba(31, 30, 31, 0.78);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.35);
    text-align: center;
    transition: transform var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
    overflow: hidden;
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    text-decoration: none;
}

.court-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--gold-light), var(--gold-accent));
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.court-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 15px rgba(197, 160, 89, 0.2);
    border-color: var(--gold-accent);
    background: rgba(42, 40, 41, 0.96);
}

.court-card:hover::before {
    opacity: 1;
}

/* Featured (Active) Card - Colombo Fort */
.court-card.featured {
    border: 1.5px solid var(--gold-accent);
    background: rgba(42, 40, 41, 0.92);
    box-shadow: 0 4px 18px rgba(197, 160, 89, 0.35);
}

.court-card.featured::before {
    opacity: 1;
    height: 3px;
    background: linear-gradient(90deg, var(--gold-accent), var(--gold-light), var(--gold-accent));
}

.court-card.featured:hover {
    box-shadow: 0 8px 28px rgba(197, 160, 89, 0.5);
    border-color: #ffd885;
}

/* Card Shine Effect */
.card-shine {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        135deg,
        transparent 40%,
        rgba(255, 255, 255, 0.12) 50%,
        transparent 60%
    );
    transform: translateX(-100%);
    transition: transform 0.6s ease;
    pointer-events: none;
}

.court-card:hover .card-shine {
    transform: translateX(100%);
}

/* Card Active Badge */
.card-active-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.pulse-dot {
    width: 7px;
    height: 7px;
    background: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 8px #22c55e;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    50% { transform: scale(1.15); opacity: 0.9; box-shadow: 0 0 0 5px rgba(34, 197, 94, 0); }
}

/* Card Title */
.court-card .card-title {
    font-family: 'Poppins', 'Inter', sans-serif;
    font-size: clamp(0.64rem, 0.69vw, 0.75rem);
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 0;
    line-height: 1.2;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
    transition: color var(--transition-fast);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    padding: 0 3px;
}

.court-card.featured .card-title {
    color: var(--gold-light);
    font-weight: 700;
}

.court-card:hover .card-title {
    color: var(--gold-light);
}

/* No Results */
.no-results {
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.7);
}

.no-results i {
    font-size: 2.2rem;
    margin-bottom: 12px;
    color: var(--gold-accent);
    opacity: 0.85;
}

.no-results h3 {
    font-size: 1.15rem;
    color: #ffffff;
    margin-bottom: 6px;
}

.no-results p {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.65);
}

/* Card hidden by filter */
.court-card.hidden {
    display: none !important;
}

/* ================================================
   Bottom Bar
   ================================================ */
.bottom-bar {
    background: rgba(18, 17, 18, 0.95);
    padding: 10px 0;
    text-align: center;
    border-top: 1px solid rgba(197, 160, 89, 0.2);
    margin-top: auto;
    position: relative;
    z-index: 10;
}

.bottom-bar p {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.75);
    letter-spacing: 0.3px;
}

/* ================================================
   Back to Top
   ================================================ */
.back-to-top {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--gold-accent);
    color: var(--primary-color);
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(15px);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease, background 0.2s ease;
    z-index: 99990;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.35);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background: #ffffff;
    color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(197, 160, 89, 0.45);
}

/* ================================================
   Animations
   ================================================ */
[data-animate] {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: opacity, transform;
}

[data-animate].animated {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

/* ================================================
   Responsive Breakpoints
   ================================================ */

/* Wide Screens (1440px+) */
@media (min-width: 1440px) {
    .courts-grid {
        grid-template-columns: repeat(11, 1fr);
        gap: 7px;
    }
}

/* Standard Desktops (1200px - 1439px) */
@media (max-width: 1439px) and (min-width: 1200px) {
    .courts-grid {
        grid-template-columns: repeat(10, 1fr);
        gap: 6px;
    }
}

/* Laptops / Small Desktops (992px - 1199px) */
@media (max-width: 1199px) and (min-width: 992px) {
    .courts-grid {
        grid-template-columns: repeat(8, 1fr);
        gap: 6px;
    }
}

/* Tablets (768px - 991px) */
@media (max-width: 991px) and (min-width: 768px) {
    .courts-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 6px;
    }

    .hero-stats {
        gap: 20px;
    }
}

/* Small Tablets & Large Phones (576px - 767px) */
@media (max-width: 767px) and (min-width: 576px) {
    .page-main {
        justify-content: flex-start;
        padding-top: 20px;
        padding-bottom: 24px;
    }

    .hero {
        padding-top: 10px;
    }

    .hero-title,
    .hero-description {
        text-align: center;
    }

    .hero-stats {
        justify-content: center;
        gap: 16px;
    }

    .stat-item {
        text-align: center;
    }

    .search-filter-bar {
        justify-content: center;
        padding: 8px 10px;
    }

    .search-box {
        width: 100%;
        min-width: 100%;
    }

    .district-filter-box {
        width: 100%;
        min-width: 100%;
    }

    .filter-group {
        width: 100%;
        justify-content: center;
    }

    .courts-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }
}

/* Mobile Portrait (420px - 575px) */
@media (max-width: 575px) and (min-width: 420px) {
    .hero-title {
        font-size: 1.8rem;
        text-align: center;
    }

    .hero-description {
        font-size: 0.85rem;
        text-align: center;
    }

    .hero-stats {
        gap: 14px;
        justify-content: center;
    }

    .stat-number {
        font-size: 1.25rem;
    }

    .search-box,
    .district-filter-box {
        width: 100%;
        min-width: 100%;
    }

    .filter-group {
        width: 100%;
        justify-content: center;
    }

    .courts-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 5px;
    }

    .court-card {
        min-height: 40px;
        padding: 5px 3px;
    }

    .court-card .card-title {
        font-size: 0.7rem;
    }
}

/* Extra Small Mobile (< 420px) */
@media (max-width: 419px) {
    .hero-title {
        font-size: 1.55rem;
        text-align: center;
    }

    .hero-description {
        font-size: 0.8rem;
        text-align: center;
    }

    .hero-stats {
        gap: 10px;
        justify-content: center;
    }

    .stat-number {
        font-size: 1.15rem;
    }

    .stat-divider {
        height: 22px;
    }

    .search-box,
    .district-filter-box {
        width: 100%;
        min-width: 100%;
    }

    .filter-group {
        width: 100%;
        justify-content: center;
    }

    .courts-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 5px;
    }

    .court-card {
        min-height: 38px;
        padding: 4px 6px;
    }

    .court-card .card-title {
        font-size: 0.68rem;
    }

    .district-select {
        font-size: 0.74rem;
        padding: 6px 24px 6px 26px;
    }

    .filter-btn {
        padding: 5px 8px;
        font-size: 0.7rem;
    }
}