/* styles.css */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Brand Theme Colors */
    --brand-primary: #ff0091;
    --brand-primary-rgb: 255, 0, 145;
    --brand-primary-hover: #e6007e;
    --brand-primary-light: rgba(255, 0, 145, 0.08);
    --brand-primary-glow: rgba(255, 0, 145, 0.25);

    /* Light Theme Palette (Default) */
    --bg-app: #f6f8fb;
    --bg-panel: #ffffff;
    --bg-panel-rgb: 255, 255, 255;
    --bg-header: #ffffff;
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --text-inverse: #ffffff;
    --border-color: #e5e7eb;
    --input-bg: #ffffff;
    --input-border: #d1d5db;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.5);

    /* Status Colors */
    --color-success: #10b981;
    --color-success-bg: #ecfdf5;
    --color-success-border: #a7f3d0;
    --color-success-text: #065f46;
    
    --color-error: #ef4444;
    --color-error-bg: #fef2f2;
    --color-error-border: #fecaca;
    --color-error-text: #991b1b;

    --color-warning: #f59e0b;
    --color-warning-bg: #fffbeb;
    --color-warning-border: #fde68a;
    --color-warning-text: #92400e;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark Mode Overrides */
[data-theme="dark"] {
    --bg-app: #0b0f19;
    --bg-panel: #111827;
    --bg-panel-rgb: 17, 24, 39;
    --bg-header: #111827;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-inverse: #111827;
    --border-color: #1f2937;
    --input-bg: #1f2937;
    --input-border: #374151;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
    --glass-bg: rgba(17, 24, 39, 0.85);
    --glass-border: rgba(31, 41, 55, 0.5);

    --color-success-bg: rgba(16, 185, 129, 0.1);
    --color-success-border: rgba(16, 185, 129, 0.2);
    --color-success-text: #34d399;

    --color-error-bg: rgba(239, 68, 68, 0.1);
    --color-error-border: rgba(239, 68, 68, 0.2);
    --color-error-text: #f87171;

    --color-warning-bg: rgba(245, 158, 11, 0.1);
    --color-warning-border: rgba(245, 158, 11, 0.2);
    --color-warning-text: #fbbf24;
}

/* Global Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-col: column;
    flex-direction: column;
    overflow: hidden;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
}

/* Header Styles */
header {
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    position: relative;
    box-shadow: var(--shadow-sm);
    transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-main);
}

.header-brand i {
    font-size: 28px;
    color: var(--brand-primary);
    filter: drop-shadow(0 2px 4px var(--brand-primary-glow));
}

.header-brand h1 {
    font-size: 22px;
    letter-spacing: -0.5px;
}

.header-brand span {
    color: var(--brand-primary);
    font-weight: 300;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.badge {
    font-size: 11px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background-color: var(--brand-primary-light);
    color: var(--brand-primary);
    border: 1px solid rgba(var(--brand-primary-rgb), 0.15);
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--color-error);
    display: inline-block;
    box-shadow: 0 0 8px var(--color-error);
}

.status-dot.active {
    background-color: var(--color-success);
    box-shadow: 0 0 8px var(--color-success);
    animation: pulseGlow 2s infinite;
}

.btn-header {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 13px;
    transition: all var(--transition-fast);
}

.btn-header:hover {
    background-color: var(--border-color);
    transform: translateY(-1px);
}

.theme-toggle {
    font-size: 18px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    cursor: pointer;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    transition: all var(--transition-fast);
}

.theme-toggle:hover {
    background-color: var(--border-color);
    transform: translateY(-1px);
}

/* Layout App */
.app-container {
    display: flex;
    flex: 1;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* Sidebar Panels */
aside {
    width: 420px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 10;
    box-shadow: var(--shadow-lg);
    transition: width var(--transition-normal), background-color var(--transition-normal), border-color var(--transition-normal);
    position: relative;
    overflow: hidden;
}

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

.aside-header h2 {
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.aside-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* Tabs System */
.tab-container {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-panel);
    position: sticky;
    top: 0;
    z-index: 20;
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 16px 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-fast);
    border-bottom: 2px solid transparent;
}

.tab-btn i {
    font-size: 18px;
}

.tab-btn:hover {
    color: var(--text-main);
    background-color: var(--brand-primary-light);
}

.tab-btn.active {
    color: var(--brand-primary);
    border-bottom-color: var(--brand-primary);
    background-color: var(--brand-primary-light);
}

/* Panel Sections */
.panel-section {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel-card {
    background-color: var(--bg-app);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
}

.panel-card:hover {
    box-shadow: var(--shadow-md);
    border-color: rgba(var(--brand-primary-rgb), 0.2);
}

.panel-card h3 {
    font-size: 15px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
}

.panel-card h3 i {
    color: var(--brand-primary);
    font-size: 18px;
}

.panel-card p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 16px;
}

/* Forms & Inputs */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.form-group label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.input-row {
    display: flex;
    gap: 10px;
}

select, input[type="text"], input[type="password"] {
    width: 100%;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-main);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    outline: none;
    transition: all var(--transition-fast);
}

select:focus, input[type="text"]:focus, input[type="password"]:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-primary-glow);
}

select:disabled, input:disabled {
    opacity: 0.6;
    background-color: var(--border-color);
    cursor: not-allowed;
}

.relative-input {
    position: relative;
    flex: 1;
}

.input-clear-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.input-clear-btn:hover {
    color: var(--text-main);
    background-color: var(--border-color);
}

/* File Upload Area */
.file-upload-label {
    display: block;
    width: 100%;
    border: 2px dashed var(--input-border);
    background-color: var(--input-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.file-upload-label:hover {
    border-color: var(--brand-primary);
    background-color: var(--brand-primary-light);
}

.file-upload-label i {
    font-size: 32px;
    color: var(--brand-primary);
    margin-bottom: 8px;
}

.file-upload-label span {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

.file-upload-label p {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    margin-bottom: 0;
}

/* Buttons */
.btn {
    background-color: var(--brand-primary);
    color: white;
    font-weight: 700;
    font-size: 14px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 6px -1px rgba(var(--brand-primary-rgb), 0.2), 0 2px 4px -1px rgba(var(--brand-primary-rgb), 0.1);
}

.btn:hover {
    background-color: var(--brand-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 8px 12px -1px rgba(var(--brand-primary-rgb), 0.3), 0 4px 6px -1px rgba(var(--brand-primary-rgb), 0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background-color: var(--border-color);
    color: var(--text-main);
    box-shadow: var(--shadow-md);
}

.btn-danger {
    background-color: var(--color-error);
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background-color: #dc2626;
    box-shadow: 0 8px 12px -1px rgba(239, 68, 68, 0.3);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--bg-panel);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    text-align: left;
}

th {
    background-color: var(--bg-app);
    padding: 12px 16px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: var(--brand-primary-light);
}

.pill-active {
    background-color: var(--color-success-bg);
    border: 1px solid var(--color-success-border);
    color: var(--color-success-text);
    padding: 2px 8px;
    border-radius: 50px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
}

/* Map area */
main {
    flex: 1;
    position: relative;
    background-color: var(--bg-app);
    height: 100%;
}

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

/* Leaflet Overrides for Theme Alignment */
.leaflet-bar {
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-md) !important;
}

.leaflet-bar a {
    background-color: var(--bg-panel) !important;
    color: var(--text-main) !important;
    border-bottom: 1px solid var(--border-color) !important;
}

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

.leaflet-control-layers {
    background-color: var(--bg-panel) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-main) !important;
    box-shadow: var(--shadow-md) !important;
    border-radius: var(--radius-md) !important;
    font-family: 'Inter', sans-serif !important;
    font-weight: 500 !important;
}

.leaflet-popup-content-wrapper {
    background-color: var(--bg-panel) !important;
    color: var(--text-main) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-lg) !important;
    border: 1px solid var(--border-color);
}

.leaflet-popup-tip {
    background-color: var(--bg-panel) !important;
}

/* Result Card */
.result-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-app);
    box-shadow: var(--shadow-sm);
    animation: slideUp 0.3s ease-out;
}

.result-card.success {
    background-color: var(--color-success-bg);
    border-color: var(--color-success-border);
}

.result-card.success .result-icon {
    color: var(--color-success);
    animation: bounce 1s infinite alternate;
}

.result-card.success h3 {
    color: var(--color-success-text);
}

.result-card.error {
    background-color: var(--color-error-bg);
    border-color: var(--color-error-border);
}

.result-card.error .result-icon {
    color: var(--color-error);
    animation: shake 0.5s ease-in-out;
}

.result-card.error h3 {
    color: var(--color-error-text);
}

.result-icon {
    font-size: 48px;
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
}

.result-card h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.result-card p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

.result-card.success p {
    color: var(--color-success-text);
    opacity: 0.9;
}

.result-card.error p {
    color: var(--color-error-text);
    opacity: 0.9;
}

.initial-instruction {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    opacity: 0.7;
    margin-top: auto;
    margin-bottom: auto;
}

.initial-instruction i {
    font-size: 44px;
    color: var(--brand-primary);
    margin-bottom: 12px;
    filter: drop-shadow(0 2px 4px var(--brand-primary-glow));
}

.initial-instruction p {
    font-size: 13px;
    line-height: 1.5;
}

/* Modals */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-xl);
    text-align: center;
    transform: scale(0.9);
    transition: transform var(--transition-normal);
    position: relative;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-brand-icon {
    font-size: 54px;
    color: var(--brand-primary);
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
    filter: drop-shadow(0 4px 8px var(--brand-primary-glow));
}

.modal-content h2 {
    font-size: 24px;
    margin-bottom: 6px;
    color: var(--text-main);
}

.modal-content p {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.modal-actions button {
    flex: 1;
}

/* Spinner Overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(var(--bg-panel-rgb), 0.8);
    backdrop-filter: blur(2px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.spinner {
    font-size: 38px;
    color: var(--brand-primary);
    animation: spin 1s linear infinite;
    display: inline-block;
}

.loading-overlay p {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}

/* Toast System */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background-color: var(--text-main);
    color: var(--bg-panel);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transition: opacity 0.3s ease;
}

.toast i {
    font-size: 16px;
}

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

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

/* Mobile Sidebar Toggle */
.sidebar-toggle-btn {
    display: none;
    position: absolute;
    left: 20px;
    bottom: 20px;
    z-index: 15;
    background-color: var(--brand-primary);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    font-size: 22px;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.sidebar-toggle-btn:hover {
    background-color: var(--brand-primary-hover);
    transform: scale(1.05);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Animations */
@keyframes pulseGlow {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

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

@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-8px); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

/* Media Queries (Responsive) */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column-reverse;
    }

    aside {
        width: 100%;
        height: 60vh;
        max-height: 450px;
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        border-right: none;
        border-top: 1px solid var(--border-color);
        border-radius: var(--radius-xl) var(--radius-xl) 0 0;
        transform: translateY(100%);
        transition: transform var(--transition-normal);
    }

    aside.active {
        transform: translateY(0);
    }

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

    header {
        padding: 10px 16px;
    }

    .header-brand h1 {
        font-size: 18px;
    }

    .status-text {
        display: none;
    }
}
