/* =============================================
   CSS Custom Properties
   ============================================= */
:root {
    --color-green:      #006600;
    --color-green-dark: #004d00;
    --color-red:        #c8102e;
    --color-red-dark:   #9e0022;
    --color-bg:         #f5f5f5;
    --color-surface:    #ffffff;
    --color-border:     #e0e0e0;
    --color-text:       #1a1a1a;
    --color-text-muted: #666666;
    --color-live:       #22c55e;
    --color-offline:    #ef4444;

    --radius:     8px;
    --radius-lg:  12px;
    --shadow:     0 2px 8px rgba(0,0,0,.1);
    --shadow-lg:  0 4px 20px rgba(0,0,0,.15);
    --transition: 150ms ease;

    --container:  1400px;
    --gap:        1.5rem;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--color-green);
    text-decoration: none;
}
a:hover { color: var(--color-green-dark); text-decoration: underline; }

img { max-width: 100%; height: auto; display: block; }

ul { list-style: none; }

/* =============================================
   Layout
   ============================================= */
.container {
    width: 100%;
    max-width: var(--container);
    margin-inline: auto;
    padding-inline: 1rem;
}

.site-main {
    flex: 1;
    padding-block: 2rem;
}

/* =============================================
   Header & Navigation
   ============================================= */
.site-header {
    background: var(--color-surface);
    border-bottom: 3px solid var(--color-green);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.site-header .container {
    display: flex;
    align-items: center;
    gap: 2rem;
    height: 64px;
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: .4rem;
    flex-shrink: 0;
}
.logo:hover { color: var(--color-text); text-decoration: none; }

.logo-pt {
    background: var(--color-green);
    color: #fff;
    padding: .1rem .4rem;
    border-radius: 4px;
    font-size: .85em;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-left: auto;
}

.nav-link {
    padding: .5rem .75rem;
    border-radius: var(--radius);
    font-size: .95rem;
    color: var(--color-text);
    font-weight: 500;
    border: none;
    background: none;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.nav-link:hover,
.nav-link.active {
    background: var(--color-bg);
    color: var(--color-green);
    text-decoration: none;
}

/* Dropdown */
.nav-dropdown { position: relative; }

.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + .5rem);
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    padding: .5rem 0;
    z-index: 200;
    max-height: 60vh;
    overflow-y: auto;
}

.nav-dropdown.open .dropdown-menu { display: block; }

.dropdown-menu a {
    display: block;
    padding: .5rem 1rem;
    color: var(--color-text);
    font-size: .9rem;
}
.dropdown-menu a:hover {
    background: var(--color-bg);
    color: var(--color-green);
    text-decoration: none;
}

/* Mobile burger */
.nav-burger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: .5rem;
    margin-left: auto;
}
.nav-burger span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--color-text);
    border-radius: 2px;
    transition: var(--transition);
}

/* =============================================
   Breadcrumb
   ============================================= */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem .5rem;
    font-size: .85rem;
    color: var(--color-text-muted);
    margin-bottom: 1.5rem;
}
.breadcrumb a { color: var(--color-text-muted); }
.breadcrumb a:hover { color: var(--color-green); }
.breadcrumb-sep { color: var(--color-border); }

/* =============================================
   Page Header
   ============================================= */
.page-header {
    margin-bottom: 2rem;
}
.page-header h1 {
    font-size: clamp(1.5rem, 3vw, 2.5rem);
    font-weight: 700;
    line-height: 1.2;
}
.page-header .subtitle {
    color: var(--color-text-muted);
    margin-top: .5rem;
    font-size: 1.05rem;
}

/* =============================================
   Webcam Grid & Cards
   ============================================= */
.webcams-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--gap);
}

.webcam-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform var(--transition), box-shadow var(--transition);
}
.webcam-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.card-embed-wrapper {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #000;
    overflow: hidden;
}

.card-embed-wrapper iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* Placeholder shown before iframe loads */
.card-embed-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #111;
    color: #888;
    font-size: .8rem;
    cursor: pointer;
}
.card-embed-placeholder svg {
    width: 48px;
    height: 48px;
    fill: #555;
}
.card-embed-placeholder:hover svg { fill: var(--color-red); }

/* Live / offline badge */
.live-badge {
    position: absolute;
    top: .6rem;
    left: .6rem;
    z-index: 3;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    line-height: 1.4;
}
.live-badge.live {
    background: var(--color-live);
    color: #fff;
}
.live-badge.offline {
    background: rgba(0,0,0,.5);
    color: #ccc;
}
.live-badge.badge-external {
    background: #374151;
    color: #fff;
}
.live-badge.badge-static {
    background: #0284c7;
    color: #fff;
}

.card-info {
    padding: .85rem 1rem;
}
.card-info h3 {
    font-size: .95rem;
    font-weight: 600;
    margin-bottom: .3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.card-info h3 a {
    color: var(--color-text);
}
.card-info h3 a:hover { color: var(--color-green); text-decoration: none; }

.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem .5rem;
    font-size: .8rem;
    color: var(--color-text-muted);
}
.card-meta a {
    color: var(--color-text-muted);
    font-size: .8rem;
}
.card-meta a:hover { color: var(--color-green); }
.card-meta .sep { color: var(--color-border); }

/* =============================================
   Hero Section (Home)
   ============================================= */
.hero {
    background: linear-gradient(135deg, var(--color-green-dark) 0%, var(--color-green) 50%, #008000 100%);
    color: #fff;
    padding: 3rem 0;
    margin-bottom: 3rem;
    margin-top: -2rem;
}
.hero h1 {
    font-size: clamp(1.8rem, 4vw, 3rem);
    font-weight: 800;
    margin-bottom: .75rem;
}
.hero p {
    font-size: 1.1rem;
    opacity: .9;
}
.hero .hero-stats {
    display: flex;
    gap: 2rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}
.hero-stat strong {
    display: block;
    font-size: 1.8rem;
    font-weight: 800;
}
.hero-stat span {
    font-size: .85rem;
    opacity: .8;
}

/* =============================================
   Section
   ============================================= */
.section {
    margin-bottom: 3rem;
}
.section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: .5rem;
}
.section-title {
    font-size: 1.4rem;
    font-weight: 700;
}
.section-link {
    font-size: .9rem;
}

/* =============================================
   Districts Grid (Home)
   ============================================= */
.districts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}

.district-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    border: 1px solid var(--color-border);
    transition: border-color var(--transition), box-shadow var(--transition);
    display: block;
    color: var(--color-text);
}
.district-card:hover {
    border-color: var(--color-green);
    box-shadow: var(--shadow);
    color: var(--color-text);
    text-decoration: none;
}
.district-card-name {
    font-weight: 600;
    font-size: .95rem;
}
.district-card-count {
    font-size: .8rem;
    color: var(--color-text-muted);
    margin-top: .2rem;
}

/* =============================================
   Regions Grid (Home)
   ============================================= */
.regions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.region-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.25rem 1rem;
    text-align: center;
    border: 1px solid var(--color-border);
    transition: border-color var(--transition), box-shadow var(--transition);
    display: block;
    color: var(--color-text);
}
.region-card:hover {
    border-color: var(--color-green);
    box-shadow: var(--shadow);
    color: var(--color-text);
    text-decoration: none;
}
.region-card-name {
    font-weight: 600;
    font-size: 1rem;
}
.region-card-count {
    font-size: .8rem;
    color: var(--color-text-muted);
    margin-top: .2rem;
}

/* =============================================
   Categories Grid (Home)
   ============================================= */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
}

.category-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.25rem 1rem;
    text-align: center;
    border: 1px solid var(--color-border);
    display: block;
    color: var(--color-text);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.category-card:hover {
    border-color: var(--color-red);
    box-shadow: var(--shadow);
    color: var(--color-text);
    text-decoration: none;
}
.category-icon {
    font-size: 2rem;
    margin-bottom: .5rem;
    display: block;
}
.category-card-name {
    font-weight: 600;
    font-size: .9rem;
}
.category-card-count {
    font-size: .78rem;
    color: var(--color-text-muted);
    margin-top: .2rem;
}

/* =============================================
   Cities Grid (District page)
   ============================================= */
.cities-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.city-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: .9rem 1rem;
    border: 1px solid var(--color-border);
    display: block;
    color: var(--color-text);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.city-card:hover {
    border-color: var(--color-green);
    box-shadow: var(--shadow);
    color: var(--color-text);
    text-decoration: none;
}
.city-card-name {
    font-weight: 600;
}
.city-card-count {
    font-size: .8rem;
    color: var(--color-text-muted);
}

/* =============================================
   Webcam Detail Page
   ============================================= */
.webcam-detail-embed {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-lg);
}
.webcam-detail-embed iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Static image webcam */
.static-image-block {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.static-webcam-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.refresh-note {
    position: absolute;
    bottom: .5rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: .7rem;
    color: #ccc;
    background: rgba(0,0,0,.6);
    padding: .2rem .6rem;
    border-radius: 999px;
    white-space: nowrap;
}
.refresh-note a { color: #93c5fd; }

/* External link webcam */
.external-link-block {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    color: #ccc;
    font-size: .95rem;
}
.btn-external {
    display: inline-block;
    padding: .65rem 1.5rem;
    background: #2563eb;
    color: #fff;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 1rem;
    text-decoration: none;
    transition: background .15s;
}
.btn-external:hover { background: #1d4ed8; color: #fff; }

/* Card placeholders for new types */
.card-external-placeholder,
.card-static-placeholder {
    cursor: default;
}
.card-external-placeholder svg {
    width: 40px;
    height: 40px;
    fill: #2563eb;
}
.card-external-placeholder:hover svg { fill: #1d4ed8; }

/* External card with thumbnail image */
.card-has-thumbnail {
    overflow: hidden;
}
.card-thumbnail-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    z-index: 1;
}
.card-external-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.25);
    transition: background var(--transition);
}
.card-external-overlay svg {
    width: 40px;
    height: 40px;
    fill: rgba(255, 255, 255, 0.85) !important;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,.5));
    transition: fill var(--transition), transform var(--transition);
}
.card-has-thumbnail:hover .card-external-overlay {
    background: rgba(0, 0, 0, 0.45);
}
.card-has-thumbnail:hover .card-external-overlay svg {
    fill: #fff !important;
    transform: scale(1.1);
}
.external-link-thumbnail {
    width: 100%;
    max-height: 320px;
    object-fit: cover;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.webcam-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 2rem;
}
.webcam-meta-item label {
    display: block;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--color-text-muted);
    margin-bottom: .25rem;
}
.webcam-meta-item span {
    font-weight: 600;
    font-size: .95rem;
}

/* =============================================
   Filter Bar
   ============================================= */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    margin-bottom: 1.5rem;
    align-items: center;
}
.filter-bar select,
.filter-bar input {
    padding: .5rem .75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    font-size: .9rem;
    color: var(--color-text);
}
.filter-bar select:focus,
.filter-bar input:focus {
    outline: none;
    border-color: var(--color-green);
}
.filter-bar .filter-sep {
    width: 1px;
    height: 1.5rem;
    background: var(--color-border);
}
.tipo-pills {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    align-items: center;
}
.tipo-pill {
    display: inline-flex;
    align-items: center;
    padding: .3rem .8rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    border: 2px solid transparent;
    text-decoration: none;
    transition: background .15s, color .15s;
    line-height: 1;
}
.tipo-pill:hover { text-decoration: none; opacity: .85; }
.tipo-pill--all        { border-color: var(--color-border); color: var(--color-text-muted); background: var(--color-surface); }
.tipo-pill--all.active { background: var(--color-text); border-color: var(--color-text); color: #fff; }
.tipo-pill--live        { border-color: var(--color-live); color: var(--color-live); background: transparent; }
.tipo-pill--live.active { background: var(--color-live); color: #fff; }
.tipo-pill--ext        { border-color: #374151; color: #374151; background: transparent; }
.tipo-pill--ext.active { background: #374151; color: #fff; }
.tipo-pill--static        { border-color: #0284c7; color: #0284c7; background: transparent; }
.tipo-pill--static.active { background: #0284c7; color: #fff; }

/* =============================================
   Pagination
   ============================================= */
.pagination {
    display: flex;
    justify-content: center;
    gap: .4rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}
.pagination a,
.pagination span {
    padding: .45rem .8rem;
    border-radius: var(--radius);
    font-size: .9rem;
    border: 1px solid var(--color-border);
    color: var(--color-text);
    background: var(--color-surface);
}
.pagination a:hover { border-color: var(--color-green); color: var(--color-green); text-decoration: none; }
.pagination .current { background: var(--color-green); color: #fff; border-color: var(--color-green); }
.pagination .disabled { opacity: .4; pointer-events: none; }

/* =============================================
   Empty State
   ============================================= */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--color-text-muted);
}
.empty-state h2 { margin-bottom: .5rem; }

/* =============================================
   Footer
   ============================================= */
.site-footer {
    background: #111;
    color: #aaa;
    padding: 3rem 0 1.5rem;
    margin-top: auto;
}
.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}
.footer-heading {
    color: #fff;
    font-size: 1rem;
    margin-bottom: .75rem;
}
.footer-links li { margin-bottom: .35rem; }
.footer-links a { color: #888; font-size: .9rem; }
.footer-links a:hover { color: #fff; }
.footer-copy {
    border-top: 1px solid #222;
    padding-top: 1rem;
    font-size: .8rem;
    text-align: center;
}

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 768px) {
    .main-nav { display: none; }
    .nav-burger { display: flex; }

    .main-nav.open {
        display: flex;
        flex-direction: column;
        position: fixed;
        inset: 64px 0 0 0;
        background: var(--color-surface);
        padding: 1rem;
        z-index: 99;
        overflow-y: auto;
        gap: .25rem;
    }
    .main-nav.open .nav-dropdown { width: 100%; }
    .main-nav.open .dropdown-menu {
        position: static;
        box-shadow: none;
        border: none;
        background: var(--color-bg);
        display: none;
        max-height: none;
    }
    .main-nav.open .nav-dropdown.open .dropdown-menu { display: block; }

    .footer-grid { grid-template-columns: 1fr; }

    .webcams-grid { grid-template-columns: 1fr; }

    .hero { padding: 2rem 0; margin-bottom: 2rem; }
}
