/* ========================================
   DigiPIN Web App - Design System
   Full-Page Map with Sidebar Layout
   Dark/Light Theme with Glassmorphism
   ======================================== */

/* CSS Variables for Theming */
:root {
    /* Light Mode (default) */
    --bg-primary: #f0f4f8;
    --bg-secondary: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.92);
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --accent-primary: #3182ce;
    --accent-secondary: #2b6cb0;
    --accent-glow: rgba(49, 130, 206, 0.3);
    --border-color: rgba(0, 0, 0, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.1);
    --success-color: #38a169;
    --error-color: #e53e3e;

    /* Sidebar */
    --sidebar-width: 380px;
}

[data-theme="dark"] {
    /* Dark Mode */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-glass: rgba(22, 27, 34, 0.95);
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent-primary: #58a6ff;
    --accent-secondary: #1f6feb;
    --accent-glow: rgba(88, 166, 255, 0.3);
    --border-color: rgba(240, 246, 252, 0.1);
    --shadow-color: rgba(0, 0, 0, 0.5);
    --success-color: #3fb950;
    --error-color: #f85149;
}

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

html,
body {
    height: 100%;
    overflow: hidden;
}

/* Allow scrolling on specific pages */
/* Allow scrolling on specific pages */
html.scrollable-page,
body.scrollable-page {
    overflow: auto !important;
    height: auto !important;
    min-height: 100%;
}

html {
    font-size: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ========================================
   Layout - Sidebar + Full Map
   ======================================== */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* ========================================
   Sidebar
   ======================================== */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-brand svg {
    width: 28px;
    height: 28px;
    color: var(--accent-primary);
}

.header-brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: var(--bg-secondary);
    border-radius: 10px;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.theme-toggle:hover {
    background: var(--accent-primary);
    color: white;
    transform: scale(1.05);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
}

/* Sidebar Sections */
.sidebar-section {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.sidebar-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* Search Container */
.search-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.search-input-wrapper {
    position: relative;
}

.search-input-wrapper svg {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.search-input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 2.75rem;
    font-size: 0.95rem;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

.search-input::placeholder {
    color: var(--text-muted);
}

/* Clear Button */
.clear-btn {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s ease;
    padding: 0;
}

.clear-btn:hover {
    background: var(--accent-primary);
    color: white;
}

.clear-btn svg {
    width: 14px;
    height: 14px;
    position: static;
    transform: none;
}

.search-input-wrapper .search-icon {
    pointer-events: none;
}

.search-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    flex: 1;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.btn svg {
    width: 18px;
    height: 18px;
}

/* Result Section */
.result-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.result-section.active {
    opacity: 1;
    pointer-events: auto;
}

.result-header {
    margin-bottom: 1rem;
}

.result-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.result-title svg {
    width: 16px;
    height: 16px;
    color: var(--success-color);
}

.digipin-display {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 1rem;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.copy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.copy-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.copy-btn.copied {
    background: var(--success-color);
    border-color: var(--success-color);
    color: white;
}

.copy-btn svg {
    width: 16px;
    height: 16px;
}

.result-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.result-detail {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.result-detail-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.result-detail-value {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
    font-family: 'JetBrains Mono', monospace;
}

.precision-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 100px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    width: fit-content;
}

.precision-badge svg {
    width: 14px;
    height: 14px;
    color: var(--accent-primary);
}

.result-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: auto;
}

.result-actions .btn {
    flex: 1;
    padding: 0.7rem;
    font-size: 0.85rem;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: auto;
}

.sidebar-footer a {
    color: var(--accent-primary);
    text-decoration: none;
}

.sidebar-footer a:hover {
    text-decoration: underline;
}

.sidebar-links {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

/* ========================================
   Map Container
   ======================================== */
.map-container {
    flex: 1;
    position: relative;
    height: 100%;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Map Controls */
.map-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 500;
}

.map-control-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--shadow-color);
}

.map-control-btn:hover {
    background: var(--accent-primary);
    color: white;
    transform: scale(1.05);
}

.map-control-btn svg {
    width: 20px;
    height: 20px;
}

/* Mobile Sidebar Toggle */
.sidebar-toggle {
    display: none;
    position: absolute;
    top: 1rem;
    left: 1rem;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    cursor: pointer;
    color: var(--text-primary);
    z-index: 500;
    box-shadow: 0 4px 15px var(--shadow-color);
}

.sidebar-toggle svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   Toast Notifications
   ======================================== */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 10px 40px var(--shadow-color);
}

.toast.visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.toast.success {
    border-color: var(--success-color);
}

.toast.error {
    border-color: var(--error-color);
}

.toast svg {
    width: 20px;
    height: 20px;
}

.toast.success svg {
    color: var(--success-color);
}

.toast.error svg {
    color: var(--error-color);
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: 100%;
        max-width: 360px;
        height: 100%;
        transform: translateX(-100%);
        box-shadow: 4px 0 30px var(--shadow-color);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: flex;
    }

    .map-controls {
        top: auto;
        bottom: 1rem;
    }
}

/* ========================================
   Leaflet Customizations
   ======================================== */
.leaflet-container {
    font-family: inherit;
}

.leaflet-control-zoom {
    display: none !important;
}

.leaflet-control-attribution {
    background: var(--bg-glass) !important;
    backdrop-filter: blur(10px);
    border-radius: 8px 0 0 0;
    padding: 4px 8px;
    font-size: 10px;
    color: var(--text-muted) !important;
}

.leaflet-control-attribution a {
    color: var(--accent-primary) !important;
}

/* Custom Marker */
.custom-marker-wrapper {
    background: transparent !important;
    border: none !important;
}

.custom-marker {
    width: 40px;
    height: 40px;
    border-radius: 50% 50% 50% 0;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    transform: rotate(-45deg);
    box-shadow: 0 4px 15px var(--accent-glow);
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-marker::after {
    content: '';
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    transform: rotate(45deg);
}

/* Grid Rectangle */
.leaflet-interactive.grid-cell {
    stroke: var(--accent-primary);
    stroke-dasharray: 6, 4;
    fill-opacity: 0.15;
}

/* ========================================
   About Page Styles
   ======================================== */
.about-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.about-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.back-link:hover {
    color: var(--accent-primary);
}

.back-link svg {
    width: 20px;
    height: 20px;
}

.about-content {
    flex: 1;
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
    width: 100%;
}

.about-hero {
    text-align: center;
    padding: 3rem 0;
}

.hero-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 40px var(--accent-glow);
}

.hero-icon svg {
    width: 40px;
    height: 40px;
    color: white;
}

.about-hero h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
}

.about-section {
    margin-bottom: 3rem;
}

.about-section h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

.about-section p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

.about-section strong {
    color: var(--text-primary);
}

.highlight-box {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-top: 2rem;
}

.highlight-item {
    text-align: center;
    padding: 1.5rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.highlight-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--accent-primary);
    margin-bottom: 0.25rem;
}

.highlight-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Steps */
.steps-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.step {
    display: flex;
    gap: 1.5rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.step-number {
    width: 40px;
    height: 40px;
    min-width: 40px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    font-size: 1.25rem;
}

.step-content h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.step-content p {
    margin-bottom: 0.75rem;
}

.step-content p:last-child {
    margin-bottom: 0;
}

.symbol-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 0.5rem;
    margin: 1rem 0;
}

.symbol-grid span {
    padding: 0.5rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: var(--accent-primary);
}

.note {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-style: italic;
}

.digipin-example {
    display: flex;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 1rem;
}

.digipin-char {
    width: 36px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border: 2px solid var(--accent-primary);
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-primary);
}

.digipin-sep {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--text-muted);
    padding: 0 0.25rem;
}

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.feature-card {
    padding: 1.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px var(--shadow-color);
}

.feature-icon {
    width: 48px;
    height: 48px;
    background: var(--accent-glow);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.feature-icon svg {
    width: 24px;
    height: 24px;
    color: var(--accent-primary);
}

.feature-card h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.feature-card p {
    font-size: 0.9rem;
    margin: 0;
}

/* Use Cases */
.use-cases-list {
    list-style: none;
    padding: 0;
}

.use-cases-list li {
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-secondary);
    position: relative;
    padding-left: 1.5rem;
}

.use-cases-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent-primary);
    border-radius: 4px 0 0 4px;
}

.use-cases-list strong {
    color: var(--text-primary);
}

/* Links Box */
.links-box {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1.5rem;
}

.resource-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.resource-link:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: translateY(-2px);
}

.resource-link svg {
    width: 20px;
    height: 20px;
}

/* CTA */
.about-cta {
    text-align: center;
    padding: 3rem 0;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

/* About Footer */
.about-footer {
    padding: 1.5rem;
    text-align: center;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Responsive for About Page */
@media (max-width: 768px) {
    .about-header {
        padding: 1rem;
    }

    .about-content {
        padding: 1rem;
    }

    .about-hero h1 {
        font-size: 1.75rem;
    }

    .highlight-box {
        grid-template-columns: repeat(2, 1fr);
    }

    .step {
        flex-direction: column;
        gap: 1rem;
    }

    .symbol-grid {
        grid-template-columns: repeat(4, 1fr);
    }

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

    .links-box {
        flex-direction: column;
    }

    .resource-link {
        justify-content: center;
    }
}