:root {
    --primary-color: #2563eb;
    /* Royal Blue */
    --primary-hover: #1d4ed8;
    --secondary-color: #1e293b;
    /* Slate 800 */
    --accent-color: #3b82f6;
    --text-light: #f8fafc;
    --text-dark: #334155;
    --bg-sidebar: #0f172a;
    /* Slate 900 */
    --bg-card: #1e293b;
    --border-color: #334155;
    --success-color: #10b981;
}

html {
    height: 100%;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    height: 100vh;
    overflow: hidden;
    color: var(--text-dark);
    margin: 0;
    padding: 0;
}

.app-container {
    display: flex;
    height: 100%;
    width: 100%;
}

/* Map Container */
.map-container {
    flex-grow: 1;
    flex-basis: 0;
    min-width: 0;
    position: relative;
    height: 100%;
    z-index: 1;
    background-color: #e2e8f0;
}

#map {
    height: 100%;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 350px;
    background-color: var(--bg-sidebar);
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 15px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.5) 0%, rgba(15, 23, 42, 0) 100%);
}

.logo-container {
    width: 100px;
    height: 100px;
    margin: 0 auto 1rem;
    background: white;
    /* Fallback if image has transparency */
}

.app-logo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.sidebar-content {
    flex-grow: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.section {
    margin-bottom: 2rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.section h2 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #94a3b8;
    margin-bottom: 1rem;
    font-weight: 600;
}

/* File Input */
.file-input-wrapper {
    margin-bottom: 1rem;
}

.file-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #cbd5e1;
}

.file-label:hover {
    border-color: var(--accent-color);
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-color);
}

.file-name {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: #94a3b8;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Buttons */
.premium-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-family: 'Outfit', sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.95rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.premium-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.premium-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #475569;
}

.premium-btn.secondary {
    background: var(--success-color);
}

/* Layers */
.layer-group {
    margin-bottom: 1.5rem;
}

.layer-group h3 {
    font-size: 0.85rem;
    color: #64748b;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background 0.2s;
    cursor: pointer;
}

.layer-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.layer-item input[type="radio"],
.layer-item input[type="checkbox"] {
    accent-color: var(--accent-color);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.layer-item label {
    cursor: pointer;
    font-size: 0.95rem;
    color: #e2e8f0;
    flex-grow: 1;
}

.empty-state {
    font-size: 0.85rem;
    color: #64748b;
    font-style: italic;
    text-align: center;
    padding: 1rem;
}

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

/* Custom Map Controls */
.custom-controls-overlay {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.map-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: white;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px solid #f1f5f9;
}

.map-btn:last-child {
    border-bottom: none;
}

.map-btn:hover {
    background: #f8fafc;
    color: var(--primary-color);
}

.map-btn.primary {
    background: var(--primary-color);
    color: white;
}

.map-btn.primary:hover {
    background: var(--primary-hover);
}

/* Shapefile Download Overlay */
.shapefile-download-overlay {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .app-container {
        flex-direction: row;
    }

    .sidebar {
        position: fixed;
        right: 0;
        top: 0;
        height: 100%;
        width: 75%;
        max-width: 300px;
        z-index: 3000;
        transition: transform 0.3s ease;
        box-shadow: -4px 0 15px rgba(0, 0, 0, 0.3);
    }

    .sidebar.closed {
        transform: translateX(100%);
    }

    .sidebar.closed .toggle-sidebar-btn svg {
        transform: rotate(180deg);
    }

    .map-container {
        width: 100% !important;
        height: 100% !important;
    }

    .custom-controls-overlay {
        top: 10px;
        left: 10px;
    }

    .toggle-sidebar-btn {
        display: flex !important;
    }

    .close-sidebar-btn {
        display: none !important;
    }
}

/* Modal Styles */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: 16px;
    width: 300px;
    text-align: center;
    color: var(--text-light);
    position: relative;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border-color);
}

.modal-content h3 {
    margin-bottom: 1rem;
    color: var(--text-light);
}

.modal-content p {
    margin-bottom: 1.5rem;
    color: #94a3b8;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.close-modal-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    cursor: pointer;
}

.close-modal-btn:hover {
    color: white;
}

/* Custom Vertex Styles */

/* Corner Markers (Default Leaflet Draw handles) */
.leaflet-editing-icon {
    background: url('resources/vertex_yellow_glow.png') no-repeat center center !important;
    background-size: contain !important;
    background-color: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    width: 16px !important;
    height: 16px !important;
    margin-left: -8px !important;
    margin-top: -8px !important;
    box-shadow: none !important;
}

/* Middle Markers */
.leaflet-edit-middle-marker {
    background: url('resources/vertex_yellow_mid.png') no-repeat center center !important;
    background-size: contain !important;
    background-color: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    width: 12px !important;
    height: 12px !important;
    margin-left: -6px !important;
    margin-top: -6px !important;
    box-shadow: none !important;
    opacity: 1 !important;
    cursor: copy !important;
}

.leaflet-edit-marker {
    cursor: move;
}

/* Toggle Button - Base Styles */
.toggle-sidebar-btn {
    display: flex !important;
    position: absolute !important;
    top: 20px;
    left: -40px;
    width: 40px;
    height: 40px;
    background: var(--bg-sidebar);
    color: var(--text-light);
    border: 1px solid var(--border-color);
    border-right: none;
    border-radius: 8px 0 0 8px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2001;
    box-shadow: -4px 0 6px rgba(0, 0, 0, 0.1);
}

/* Desktop: Hide toggle button */
@media (min-width: 769px) {
    .toggle-sidebar-btn {
        display: none !important;
    }
}

/* Fix for mobile blink on tap */
* {
    -webkit-tap-highlight-color: transparent;
}

/* Correct Mobile Responsiveness */
@media (max-width: 768px) {
    .app-container {
        flex-direction: row;
    }

    .sidebar {
        position: fixed;
        right: 0;
        top: 0;
        height: 100%;
        width: 75%;
        max-width: 300px;
        z-index: 3000;
        transition: transform 0.3s ease;
        box-shadow: -4px 0 15px rgba(0, 0, 0, 0.3);
    }

    .sidebar.closed {
        transform: translateX(100%);
    }

    .sidebar.closed .toggle-sidebar-btn svg {
        transform: rotate(180deg);
    }

    .map-container {
        width: 100% !important;
        height: 100% !important;
    }

    .custom-controls-overlay {
        top: 10px;
        left: 10px;
    }

    .toggle-sidebar-btn {
        display: flex !important;
    }

    .close-sidebar-btn {
        display: none !important;
    }
}