/* Reset and Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-dark: #090d16;
    --panel-bg: rgba(13, 20, 35, 0.82);
    --border-color: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --primary: #2563eb;
    --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    --accent: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

#app-container {
    display: flex;
    position: relative;
    width: 100vw;
    height: 100vh;
}

/* Control Panel / Sidebar */
#control-panel {
    width: 380px;
    flex-shrink: 0;
    z-index: 10;
    background: #111827; /* Deep gray-900 for modern, high-contrast dark UI */
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100vh;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.logo-icon {
    width: 28px;
    height: 28px;
    color: #60a5fa;
}

.logo-area h1 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.5rem;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, #ffffff 0%, #a5f3fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge {
    font-size: 0.65rem;
    font-family: var(--font-body);
    padding: 2px 6px;
    background: var(--primary);
    border-radius: 4px;
    color: white;
    font-weight: 700;
    letter-spacing: 0.05em;
    vertical-align: middle;
    text-shadow: none;
    -webkit-text-fill-color: initial;
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Scrollbar styling for sidebar */
.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Control Groups */
.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #93c5fd;
}

.label-with-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.info-tooltip {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    width: 16px;
    height: 16px;
    font-size: 0.7rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    transition: all 0.2s;
}

.info-tooltip:hover {
    background: var(--primary);
    color: white;
}

/* Inputs & Selects */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.select-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
}

.select-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

select, input[type="text"] {
    background: rgba(17, 24, 39, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 10px 14px;
    font-family: var(--font-body);
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s ease;
    width: 100%;
}

select:focus, input[type="text"]:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
    background: rgba(17, 24, 39, 0.8);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='rgba(156, 163, 175, 0.8)' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 36px;
}

/* Search Box */
.search-box {
    display: flex;
    position: relative;
}

.search-box input {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: none;
}

.search-box button {
    background: var(--primary-gradient);
    border: none;
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    width: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.search-box button:hover {
    filter: brightness(1.1);
}

.search-box button svg {
    width: 18px;
    height: 18px;
}

/* Search Results list */
.search-results-list {
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    max-height: 180px;
    overflow-y: auto;
    list-style: none;
    z-index: 1020;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

.search-results-list li {
    padding: 10px 14px;
    font-size: 0.8rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    transition: all 0.2s;
}

.search-results-list li:hover {
    background: rgba(59, 130, 246, 0.15);
    color: var(--text-primary);
}

.search-results-list li:last-child {
    border-bottom: none;
}

.hidden {
    display: none !important;
}

.helper-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.highlight {
    color: #60a5fa;
    font-weight: 600;
}

/* Info Card */
.info-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 16px;
}

.info-card h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-weight: 600;
}

.info-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    font-size: 0.8rem;
    line-height: 1.4;
    gap: 4px;
}

.info-label {
    color: var(--text-secondary);
}

.info-val {
    color: var(--text-primary);
    text-align: right;
}

.font-semibold {
    font-weight: 600;
}

/* Status Indicator Colors */
.text-quality-excellent {
    color: var(--accent);
}
.text-quality-good {
    color: #34d399;
}
.text-quality-medium {
    color: var(--warning);
}
.text-quality-low {
    color: var(--danger);
}

/* Warning Banner */
.warning-banner {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 8px;
    padding: 10px;
    margin-top: 12px;
    font-size: 0.75rem;
    color: #fbd38d;
}

.warning-banner.danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.warning-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Primary Button */
.btn-primary {
    background: var(--primary-gradient);
    border: none;
    border-radius: 10px;
    color: white;
    cursor: pointer;
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
    transition: all 0.2s ease;
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.4);
    filter: brightness(1.05);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-primary:disabled {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-icon {
    width: 18px;
    height: 18px;
}

/* Progress Tracker */
#progress-container {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    font-weight: 600;
}

#progress-status {
    color: #60a5fa;
}

.progress-bar-bg {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
    height: 8px;
    overflow: hidden;
    width: 100%;
}

#progress-bar-fill {
    background: linear-gradient(90deg, #3b82f6 0%, #10b981 100%);
    border-radius: 9999px;
    height: 100%;
    width: 0%;
    transition: width 0.1s ease;
}

.progress-subtext {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: center;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: center;
    background: rgba(9, 13, 22, 0.4);
}

.sidebar-footer a {
    color: #60a5fa;
    text-decoration: none;
}

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

/* Main Map Layout */
#map-section {
    flex: 1;
    height: 100vh;
    position: relative;
    z-index: 1; /* Establishes a stacking context so crop-box shadow stays behind the sidebar control panel */
}

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

/* Leaflet Custom Style Overrides */
.leaflet-container {
    background-color: var(--bg-dark);
}

.leaflet-bar {
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-lg) !important;
    border-radius: 8px !important;
    overflow: hidden;
}

.leaflet-bar a {
    background-color: rgba(13, 20, 35, 0.9) !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border-color) !important;
    transition: all 0.2s;
}

.leaflet-bar a:hover {
    background-color: var(--primary) !important;
    color: white !important;
}

.leaflet-control-attribution {
    display: none !important; /* Managed in footer */
}

/* Crop Box Overlay */
#crop-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 2px dashed #3b82f6;
    box-shadow: 0 0 0 9999px rgba(9, 13, 22, 0.65);
    pointer-events: none; /* Mouse actions transparently hit the Leaflet map */
    z-index: 999; /* Just below controls */
    border-radius: 4px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Corner Crop Handles (Visual only since map slides behind crop box) */
.crop-corner {
    position: absolute;
    width: 18px;
    height: 18px;
    border: 3px solid #60a5fa;
    pointer-events: none;
}

.top-left {
    top: -3px;
    left: -3px;
    border-right: none;
    border-bottom: none;
}

.top-right {
    top: -3px;
    right: -3px;
    border-left: none;
    border-bottom: none;
}

.bottom-left {
    bottom: -3px;
    left: -3px;
    border-right: none;
    border-top: none;
}

.bottom-right {
    bottom: -3px;
    right: -3px;
    border-left: none;
    border-top: none;
}

/* Aspect Ratio Indicator Badge */
.crop-aspect-ratio-indicator {
    position: absolute;
    top: -26px;
    left: 50%;
    transform: translateX(-50%);
    background: #3b82f6;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 3px 10px;
    border-radius: 4px;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Rule of Thirds Guide Lines (subtle) */
.guide-line {
    position: absolute;
    background-color: rgba(96, 165, 250, 0.15);
    pointer-events: none;
}

.guide-line.v1 {
    top: 0;
    bottom: 0;
    left: 33.33%;
    width: 1px;
}

.guide-line.v2 {
    top: 0;
    bottom: 0;
    left: 66.66%;
    width: 1px;
}

.guide-line.h1 {
    left: 0;
    right: 0;
    top: 33.33%;
    height: 1px;
}

.guide-line.h2 {
    left: 0;
    right: 0;
    top: 66.66%;
    height: 1px;
}


/* Toast Notification */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(16, 185, 129, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    z-index: 2000;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.error {
    background: rgba(239, 68, 68, 0.9);
}

/* Responsive Styles */
@media (max-width: 768px) {
    #app-container {
        flex-direction: column-reverse;
    }
    
    #control-panel {
        position: relative;
        top: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        height: 50vh;
        border-radius: 16px 16px 0 0;
        border-width: 1px 0 0 0;
    }
    
    #map-section {
        height: 50vh;
    }
}
    


/* Checkbox styling */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    font-size: 0.8rem !important;
    font-weight: 500 !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    color: #93c5fd !important;
    background: rgba(59, 130, 246, 0.06);
    border: 1px dashed rgba(96, 165, 250, 0.25);
    padding: 10px 12px;
    border-radius: 8px;
    margin-top: 10px;
    transition: all 0.2s ease;
}

.checkbox-wrapper:hover {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(96, 165, 250, 0.4);
}



/* Neighborhood Selection List and Items */
.neighborhood-list {
    list-style: none !important;
    list-style-type: none !important;
    padding-left: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
    max-height: 150px;
    overflow-y: auto;
    padding-right: 4px;
}

.neighborhood-list::-webkit-scrollbar {
    width: 4px;
}

.neighborhood-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
}

.neighborhood-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.8rem;
}

.nb-info {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
}

.color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}

.nb-name {
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-remove-nb {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-remove-nb:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

.btn-secondary-sm {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-body);
    transition: all 0.2s;
    width: 100%;
}

.btn-secondary-sm:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.15);
}

.checkbox-wrapper input[type="checkbox"] {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: #3b82f6;
    margin: 0;
}

/* Custom Leaflet Tooltip for Neighborhood Labels */
.neighborhood-label {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: var(--text-primary) !important;
    font-family: var(--font-body) !important;
    font-weight: 700 !important;
    font-size: 0.5rem !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8), 0 0 5px rgba(0, 0, 0, 0.6) !important;
    pointer-events: none !important;
    white-space: nowrap !important;
}

/* Hide the tooltip arrow */
.neighborhood-label::before {
    display: none !important;
}

/* Class to toggle visibility based on checkbox */
.hide-neighborhood-labels .neighborhood-label {
    display: none !important;
}

