/* Premium Dark Theme Variables */
:root {
    --bg-dark: #0f172a;
    --bg-glass: rgba(15, 23, 42, 0.75);
    --border-glass: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-primary: #10b981; /* Emerald */
    --accent-glow: rgba(16, 185, 129, 0.5);
    --accent-sand: #fbbf24;
    --accent-silt: #a78bfa;
    --accent-clay: #f43f5e;
    --card-bg: rgba(30, 41, 59, 0.7);
    --card-hover: rgba(51, 65, 85, 0.9);
}

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

body {
    font-family: 'Outfit', sans-serif;
    color: var(--text-main);
    background-color: var(--bg-dark);
    overflow: hidden;
}

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

/* Map Styling */
.map-container {
    flex-grow: 1;
    height: 100%;
    z-index: 1;
}

/* Custom Leaflet Controls */
.leaflet-bar {
    border: none !important;
    border-radius: 8px !important;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2) !important;
}

.leaflet-bar a, .leaflet-bar a:hover {
    background-color: var(--bg-dark) !important;
    color: var(--text-main) !important;
    border-bottom: 1px solid var(--border-glass) !important;
    transition: all 0.2s ease;
}

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

/* Sidebar Styling (Glassmorphism) */
.sidebar {
    width: 400px;
    height: 100vh;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-left: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
    position: absolute;
    right: 0;
    top: 0;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-header {
    padding: 2rem 1.5rem 1.5rem;
    border-bottom: 1px solid var(--border-glass);
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.5px;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--accent-primary);
}

.sidebar-header p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* States */
.state-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--border-glass);
    display: block;
}

.hidden {
    display: none !important;
}

/* Loader */
.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(16, 185, 129, 0.2);
    border-radius: 50%;
    border-top-color: var(--accent-primary);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 1.5rem;
    box-shadow: 0 0 15px var(--accent-glow);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Results Content */
.results-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* Custom Scrollbar */
.results-container::-webkit-scrollbar {
    width: 6px;
}
.results-container::-webkit-scrollbar-track {
    background: transparent;
}
.results-container::-webkit-scrollbar-thumb {
    background: var(--border-glass);
    border-radius: 10px;
}

.location-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--card-bg);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--accent-primary);
    border: 1px solid var(--border-glass);
    margin-bottom: 2rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 1.5rem 0 1rem;
    color: white;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 1px;
}

.properties-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.properties-grid-small {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.property-card {
    background: var(--card-bg);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    transition: all 0.3s ease;
}

.property-card:hover {
    background: var(--card-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.3);
    border-color: rgba(255,255,255,0.2);
}

.prop-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.prop-info {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.prop-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    white-space: nowrap;
}

.prop-value {
    font-size: 1.2rem;
    font-weight: 600;
    color: white;
}

.small-card {
    flex-direction: column;
    padding: 0.75rem;
    align-items: center;
    text-align: center;
}
.small-card .prop-label {
    margin-bottom: 0.5rem;
}

/* Texture Bars */
.texture-bars {
    background: var(--card-bg);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.texture-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.texture-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 500;
}

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

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.sand-fill { background-color: var(--accent-sand); box-shadow: 0 0 10px rgba(251, 191, 36, 0.5); }
.silt-fill { background-color: var(--accent-silt); box-shadow: 0 0 10px rgba(167, 139, 250, 0.5); }
.clay-fill { background-color: var(--accent-clay); box-shadow: 0 0 10px rgba(244, 63, 94, 0.5); }

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

.sidebar-footer a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
}
.sidebar-footer a:hover {
    text-decoration: underline;
}

/* Notifications */
.notification-container {
    position: absolute;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.notification {
    background: rgba(220, 38, 38, 0.9);
    backdrop-filter: blur(8px);
    color: white;
    padding: 1rem 2rem;
    border-radius: 30px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    pointer-events: auto;
}

.notification.success {
    background: rgba(16, 185, 129, 0.9);
}

@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Source Selector */
.source-selector {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border-glass);
}

.source-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border-glass);
    background: transparent;
    color: var(--text-muted);
    font-family: 'Outfit', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.source-btn:hover {
    border-color: rgba(255,255,255,0.25);
    color: var(--text-main);
    background: var(--card-bg);
}

.source-btn.active {
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.source-badge {
    font-size: 0.65rem;
    font-weight: 600;
    background: rgba(255,255,255,0.1);
    padding: 1px 5px;
    border-radius: 4px;
    letter-spacing: 0.3px;
}

.source-btn.active .source-badge {
    background: rgba(16, 185, 129, 0.25);
}

.source-badge-warn {
    background: rgba(244, 63, 94, 0.2) !important;
    color: #f43f5e !important;
}

/* API Key Config */
.api-config {
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border-glass);
    background: rgba(16, 185, 129, 0.03);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.api-config.hidden {
    display: none !important;
}

.api-config label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.25rem;
}

#isda-logged-out {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

#isda-logged-out input {
    background: var(--card-bg);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    padding: 0.4rem 0.75rem;
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    font-size: 0.82rem;
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
}

#isda-logged-out input:focus {
    border-color: var(--accent-primary);
}

#isda-logged-out input::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

#isda-login-btn {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid var(--accent-primary);
    border-radius: 8px;
    color: var(--accent-primary);
    padding: 0.45rem 0.75rem;
    cursor: pointer;
    font-size: 0.82rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

#isda-login-btn:hover {
    background: rgba(16, 185, 129, 0.3);
}

#isda-login-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.isda-session {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-main);
}

.isda-session span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--accent-primary);
    font-weight: 500;
}

#isda-logout-btn {
    background: transparent;
    border: 1px solid var(--border-glass);
    border-radius: 6px;
    color: var(--text-muted);
    padding: 0.2rem 0.5rem;
    cursor: pointer;
    font-size: 0.78rem;
    transition: all 0.2s;
}

#isda-logout-btn:hover {
    border-color: var(--accent-clay);
    color: var(--accent-clay);
}

.api-config small a {
    color: var(--accent-primary);
    font-size: 0.75rem;
    text-decoration: none;
}

.api-config small a:hover {
    text-decoration: underline;
}
