/* ===== CLUP Page Styles - QC-Inspired Dark Blue Theme ===== */

/* CSS Variables */
:root {
    /* QC-Style Dark Blue Theme */
    --hero-bg: #1e3a5f;
    --hero-bg-dark: #0f2744;
    --hero-gradient: linear-gradient(135deg, #1e3a5f 0%, #2c5282 100%);
    --header-gradient: linear-gradient(135deg, #1e3a5f 0%, #2c5282 50%, #3182ce 100%);

    /* Pagadian Accent */
    --accent-gold: #d4a017;
    --accent-gold-light: #f6e05e;

    /* UI Colors */
    --primary: 221 83% 53%;
    --primary-foreground: 210 40% 98%;
    --secondary: 210 40% 96%;
    --secondary-foreground: 222 47% 11%;
    --muted: 210 40% 96%;
    --muted-foreground: 215 16% 47%;
    --background: 0 0% 100%;
    --foreground: 222 84% 5%;
    --card: 0 0% 100%;
    --card-foreground: 222 84% 5%;
    --border: 214 32% 91%;
    --ring: 221 83% 53%;
    --success: 142 76% 36%;
    --warning: 38 92% 50%;

    /* Layout */
    --radius: 0.5rem;
    --header-height: 4rem;
    --sidebar-width: 280px;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Consolas', 'Monaco', monospace;
}

[data-theme="dark"] {
    --background: 222 84% 5%;
    --foreground: 210 40% 98%;
    --card: 222 47% 11%;
    --card-foreground: 210 40% 98%;
    --secondary: 217 33% 17%;
    --secondary-foreground: 210 40% 98%;
    --muted: 217 33% 17%;
    --muted-foreground: 215 20% 65%;
    --border: 217 33% 25%;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    line-height: 1.6;
    min-height: 100vh;
}

/* Layout */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== Header ===== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-height);
    background: var(--header-gradient);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(8px);
}

.header-inner {
    max-width: 1800px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 0 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: white;
    flex-shrink: 0;
}

.logo-icon {
    width: 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius);
}

.logo-text {
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.2px;
}

.logo-accent {
    color: var(--accent-gold);
    font-weight: 800;
    font-size: 1.2em;
}

.logo-subtitle {
    font-size: 0.7rem;
    opacity: 0.85;
    display: block;
    letter-spacing: 0.5px;
}

.header-nav {
    display: flex;
    gap: 1rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: white;
    text-decoration: none;
    font-size: 0.875rem;
    border-radius: var(--radius);
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.1);
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.2);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.btn-icon {
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

/* ===== Hero Section - QC Dark Blue Style ===== */
.hero {
    background: var(--hero-gradient);
    color: white;
    padding: 4rem 1.5rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}

.hero-content {
    max-width: 900px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.hero-icon {
    width: 6rem;
    height: 6rem;
    margin: 0 auto 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.hero-subtitle {
    font-size: 1.5rem;
    color: var(--accent-gold);
    font-weight: 600;
    margin-bottom: 1rem;
}

.hero-description {
    font-size: 1.125rem;
    opacity: 0.9;
    max-width: 700px;
    margin: 0 auto 2rem;
    line-height: 1.7;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    flex-wrap: wrap;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    display: block;
    color: var(--accent-gold);
}

.stat-label {
    font-size: 0.875rem;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ===== Main Content Grid ===== */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr 1fr;
    gap: 1.25rem;
    padding: 1.25rem;
    max-width: 1800px;
    margin: 0 auto;
    width: 100%;
}

/* ===== Sidebar ===== */
.sidebar {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - var(--header-height) - 2.5rem);
    position: sticky;
    top: calc(var(--header-height) + 1.25rem);
    overflow: hidden;
}

.sidebar-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid hsl(var(--border));
    background: hsl(var(--muted));
}

.sidebar-header h2 {
    font-size: 0.9375rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: hsl(var(--foreground));
}

.category-tree {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
}

.category-item {
    margin-bottom: 0.25rem;
}

.category-link {
    display: flex;
    align-items: center;
    padding: 0.625rem 0.875rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.875rem;
    color: hsl(var(--foreground));
    text-decoration: none;
    gap: 0.625rem;
}

.category-link:hover {
    background: hsl(var(--muted));
}

.category-link.active {
    background: var(--hero-bg);
    color: white;
}

.category-link svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.category-link.active svg {
    opacity: 1;
}

.category-count {
    margin-left: auto;
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    background: hsl(var(--muted));
    border-radius: 9999px;
    color: hsl(var(--muted-foreground));
}

.category-link.active .category-count {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* ===== Documents Panel ===== */
.documents-panel {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid hsl(var(--border));
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: hsl(var(--muted));
}

.panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.panel-search input {
    padding: 0.5rem 1rem;
    border: 1px solid hsl(var(--border));
    border-radius: 9999px;
    font-size: 0.875rem;
    width: 200px;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
}

.panel-search input:focus {
    outline: none;
    border-color: var(--hero-bg);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.document-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

/* ===== Document Cards - QC Inspired ===== */
.document-card {
    background: hsl(var(--background));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: all 0.2s;
    position: relative;
}

.document-card:hover {
    border-color: var(--hero-bg);
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.1);
    transform: translateY(-2px);
}

.document-card:last-child {
    margin-bottom: 0;
}

.doc-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.25rem 0.75rem;
    background: #dc2626;
    color: white;
    font-size: 0.6875rem;
    font-weight: 700;
    border-radius: var(--radius);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.doc-badge.ordinance {
    background: var(--hero-bg);
}

.doc-badge.info {
    background: #0891b2;
}

.doc-content {
    padding-right: 4rem;
}

.doc-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: hsl(var(--foreground));
    line-height: 1.4;
}

.doc-description {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

.doc-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.75rem;
    margin-bottom: 1rem;
}

.doc-meta span {
    padding: 0.25rem 0.625rem;
    background: hsl(var(--muted));
    border-radius: var(--radius);
    color: hsl(var(--muted-foreground));
}

.doc-category {
    background: rgba(30, 58, 95, 0.1) !important;
    color: var(--hero-bg) !important;
}

.doc-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Action Buttons - QC Style */
.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-preview {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-preview:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-download {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.btn-download:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.btn-request {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
}

.btn-request:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

/* ===== Viewer Panel ===== */
.viewer-panel {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: calc(100vh - var(--header-height) - 2.5rem);
    position: sticky;
    top: calc(var(--header-height) + 1.25rem);
}

.viewer-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid hsl(var(--border));
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: hsl(var(--muted));
}

.viewer-header h3 {
    font-size: 0.9375rem;
    font-weight: 600;
}

.viewer-actions {
    display: flex;
    gap: 0.5rem;
}

.viewer-actions .btn-icon {
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    border: 1px solid hsl(var(--border));
}

.viewer-actions .btn-icon:hover {
    background: var(--hero-bg);
    color: white;
    border-color: var(--hero-bg);
}

.viewer-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.viewer-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 400px;
    text-align: center;
    color: hsl(var(--muted-foreground));
}

.viewer-placeholder svg {
    margin-bottom: 1.5rem;
    opacity: 0.3;
}

.viewer-placeholder p {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.viewer-placeholder span {
    font-size: 0.875rem;
    opacity: 0.7;
}

/* PDF Embed */
.pdf-embed {
    width: 100%;
    height: 100%;
    min-height: 600px;
    border: none;
    border-radius: var(--radius);
}

/* ===== Related/Legal Section ===== */
.related-section {
    padding: 3rem 1.5rem;
    background: hsl(var(--muted));
    border-top: 1px solid hsl(var(--border));
}

.section-header {
    max-width: 1800px;
    margin: 0 auto 2rem;
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: hsl(var(--foreground));
}

.legal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
    max-width: 1800px;
    margin: 0 auto;
}

.legal-card {
    display: flex;
    gap: 1rem;
    padding: 1.25rem;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    transition: all 0.2s;
}

.legal-card:hover {
    border-color: var(--hero-bg);
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.1);
}

.legal-icon {
    width: 3rem;
    height: 3rem;
    background: var(--hero-bg);
    color: white;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.legal-content h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
    color: hsl(var(--foreground));
}

.legal-content p {
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
    line-height: 1.5;
}

/* ===== Footer ===== */
.footer {
    background: var(--hero-bg);
    color: white;
    padding: 2rem 1.5rem;
}

.footer-content {
    max-width: 1800px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.footer-info p {
    margin: 0.25rem 0;
    font-size: 0.875rem;
}

.footer-tagline {
    color: var(--accent-gold);
    font-style: italic;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
}

.footer-links a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--accent-gold);
}

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: hsl(var(--card));
    border-radius: var(--radius);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
}

.modal-content.modal-large {
    max-width: 900px;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid hsl(var(--border));
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--hero-bg);
    color: white;
}

.modal-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: calc(80vh - 70px);
    color: hsl(var(--foreground));
}

/* Vision Content */
.vision-content h3 {
    color: var(--hero-bg);
    font-size: 1.125rem;
    margin: 1.5rem 0 0.75rem;
}

.vision-content h3:first-child {
    margin-top: 0;
}

.vision-content p {
    line-height: 1.7;
    margin-bottom: 1rem;
}

.vision-content ul {
    padding-left: 1.5rem;
}

.vision-content li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

/* Ordinance Content */
.ordinance-text {
    font-size: 0.9375rem;
    line-height: 1.8;
}

.ordinance-text h3 {
    color: var(--hero-bg);
    margin: 1.5rem 0 0.75rem;
    font-size: 1rem;
}

.ordinance-text p {
    margin-bottom: 1rem;
    text-align: justify;
}

/* ===== Zoning Map Modal ===== */
.map-modal-body {
    display: flex;
    gap: 1rem;
    padding: 0;
    height: 70vh;
    max-height: none;
}

.zoning-map-container {
    flex: 1;
    min-height: 400px;
    border-radius: 0 0 0 var(--radius);
}

.map-legend {
    width: 200px;
    padding: 1rem;
    background: hsl(var(--muted));
    border-left: 1px solid hsl(var(--border));
}

.map-legend h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: hsl(var(--foreground));
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.8125rem;
}

.legend-marker {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.legend-marker.urban {
    background: #2a5298;
}

.legend-marker.rural {
    background: #28a745;
}

.legend-stats {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid hsl(var(--border));
    font-size: 0.8125rem;
}

.legend-stats p {
    margin: 0.5rem 0;
}

.map-controls {
    display: flex;
    gap: 0.5rem;
    margin-right: auto;
    margin-left: 1rem;
}

.map-filter-btn {
    padding: 0.375rem 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: var(--radius);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.map-filter-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.map-filter-btn.active {
    background: var(--accent-gold);
    border-color: var(--accent-gold);
    color: #1e3a5f;
    font-weight: 600;
}

/* Leaflet Popup Styles */
.leaflet-popup-content-wrapper {
    border-radius: var(--radius);
}

.leaflet-popup-content {
    margin: 0.75rem;
    font-size: 0.8125rem;
}

.barangay-popup h4 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--hero-bg);
}

.barangay-popup p {
    margin: 0.25rem 0;
}

/* ===== Responsive Design ===== */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: var(--sidebar-width) 1fr;
    }

    .viewer-panel {
        display: none;
    }
}

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        max-height: none;
    }

    .header-nav {
        display: none;
    }

    .hero-stats {
        gap: 2rem;
    }

    .stat-value {
        font-size: 2rem;
    }
}

@media (max-width: 600px) {
    .header-inner {
        padding: 0 1rem;
    }

    .hero {
        padding: 2.5rem 1rem;
    }

    .hero h1 {
        font-size: 1.75rem;
    }

    .hero-subtitle {
        font-size: 1.25rem;
    }

    .hero-description {
        font-size: 1rem;
    }

    .hero-stats {
        gap: 1.5rem;
    }

    .stat-value {
        font-size: 1.75rem;
    }

    .doc-actions {
        flex-direction: column;
    }

    .action-btn {
        justify-content: center;
    }

    .legal-grid {
        grid-template-columns: 1fr;
    }

    .footer-content {
        flex-direction: column;
        text-align: center;
    }

    .footer-links {
        flex-direction: column;
        gap: 0.75rem;
    }
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.document-card {
    animation: fadeIn 0.3s ease-out;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
