/* =====================================================================
   BAZA I TYPOGRAFIA (Nowoczesny System Fontów)
   ===================================================================== */
body { 
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
    margin: 0; 
    padding: 0; 
    background: #f1f5f9; /* Miękka, nowoczesna szarość */
    color: #1e293b; 
}
        
/* Ekrany */
#login-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; }
#app-screen { display: none; height: 100vh; flex-direction: column; }

/* =====================================================================
   FORMULARZE I PRZYCISKI (Flat Design & Soft Shadows)
   ===================================================================== */
.login-box { 
    background: white; 
    padding: 40px 30px; 
    border-radius: 16px; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.05); 
    width: 320px; 
    text-align: center; 
}

/* Miękkie pola tekstowe */
input[type="text"], input[type="password"], input[type="number"], select, textarea { 
    width: 90%; 
    padding: 10px 14px; 
    margin: 8px 0 16px 0; 
    border: 1px solid #cbd5e1; 
    border-radius: 6px; 
    box-sizing: border-box; 
    background-color: #f8fafc;
    transition: all 0.2s ease;
    color: #334155;
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #3b82f6;
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Przyciski z efektem uniesienia */
button { 
    padding: 10px 16px; 
    border: none; 
    border-radius: 6px; 
    cursor: pointer; 
    font-size: 13px; 
    font-weight: 600; 
    transition: all 0.2s ease; 
}
button:hover { transform: translateY(-1px); box-shadow: 0 4px 6px rgba(0,0,0,0.08); }
button:active { transform: translateY(0); box-shadow: none; }

.btn-primary { background: #3b82f6; color: white; }
.btn-primary:hover { background: #2563eb; }
.btn-success { background: #10b981; color: white; }
.btn-success:hover { background: #059669; }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-purple { background: #8b5cf6; color: white; }
.btn-purple:hover { background: #7c3aed; }

/* Przycisk poboczny - uspokaja interfejs */
.btn-dark { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.btn-dark:hover { background: #e2e8f0; color: #0f172a; }

/* Akcenty informacyjne */
.btn-info { background: #e0f2fe; color: #0369a1; }
.btn-info:hover { background: #bae6fd; }
.btn-warning { background: #fef3c7; color: #b45309; }
.btn-warning:hover { background: #fde047; }

/* =====================================================================
   LAYOUT (Top Bar & Mapa)
   ===================================================================== */
#top-bar { 
    background: #1e293b; /* Głęboki, elegancki granat zamiast szarego */
    color: white; 
    padding: 12px 20px; 
    display: flex; 
    gap: 10px; 
    align-items: center; 
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
#map { flex-grow: 1; width: 100%; z-index: 1; }

/* =====================================================================
   PANEL ADMINA (Czyste Karty bez twardych ramek)
   ===================================================================== */
.admin-card { 
    background: white; 
    border: none; 
    border-radius: 12px; 
    padding: 24px; 
    margin-bottom: 24px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.03); 
}
.admin-card h3 { 
    margin-top: 0; 
    color: #0f172a; 
    border-bottom: 2px solid #f1f5f9; 
    padding-bottom: 12px; 
    font-size: 16px; 
}
.action-row { 
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap; 
    margin-bottom: 15px; background: #f8fafc; padding: 12px; 
    border-radius: 8px; border: 1px solid transparent; 
}
.action-label { font-size: 11px; text-transform: uppercase; color: #64748b; font-weight: 700; min-width: 140px; letter-spacing: 0.5px; }
.divider { border-left: 1px solid #e2e8f0; height: 24px; margin: 0 5px; }

/* Narzędzia JSON i Edytor */
#json-viewer { background: #1e1e1e; padding: 15px; height: 300px; overflow: auto; font-size: 13px; border-radius: 8px; color: #569cd6; font-family: 'Consolas', monospace; margin: 0; white-space: pre-wrap; box-shadow: inset 0 2px 4px rgba(0,0,0,0.2); }
.editor-container { display: flex; gap: 20px; }
.editor-box { flex-grow: 1; }
.hints-box { width: 300px; background: #f8fafc; padding: 15px; border-radius: 8px; font-size: 12px; color: #334155; }
.hints-box code { background: #e2e8f0; padding: 2px 6px; border-radius: 4px; font-weight: bold; color: #db2777; }

/* Grupy Formularz */
.group-form { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; background: #f8fafc; padding: 20px; border-radius: 8px; margin-bottom: 15px; }
.checkbox-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-height: 150px; overflow-y: auto; background: white; border: 1px solid #e2e8f0; padding: 12px; border-radius: 6px; }
.checkbox-grid label { font-size: 12px; display: flex; align-items: center; gap: 6px; color: #475569; }

/* =====================================================================
   MODUŁ TRAS (Lewy Panel Boczny)
   ===================================================================== */
.app-layout { display: flex; flex-grow: 1; overflow: hidden; position: relative; }
#routes-sidebar { 
    width: 420px; 
    background: white; 
    border-right: none; 
    display: none; 
    flex-direction: column; 
    
    /* Na stałe włączony tryb pływający */
    position: absolute;
    top: 0; left: 0; 
    height: 100%; 
    border-radius: 0; 
    box-shadow: 5px 0 25px rgba(0,0,0,0.15); 
    z-index: 1000; 
}
.sidebar-header { 
    background: #3b82f6; /* Przywrócony mocny kolor nagłówka */
    color: #ffffff; 
    padding: 15px 20px; 
    font-weight: 800; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}

.sidebar-content { padding: 15px; overflow-y: auto; flex-grow: 1; }
.route-points-list { list-style: none; padding: 0; margin: 10px 0; }
.route-point-item { 
    background: #f8fafc; 
    border: 1px solid #e2e8f0; 
    padding: 10px 14px; 
    margin-bottom: 8px; 
    border-radius: 6px; 
    display: flex; justify-content: space-between; align-items: center; font-size: 13px; 
}
.summary-badge { background: #eef2ff; border: 1px solid #c7d2fe; padding: 12px; border-radius: 8px; margin-top: 15px; font-size: 13px; color: #1e3a8a; }

/* STYLIZACJA ZAKŁADEK KREATOR / ZAPISANE TRASY */
#routes-sidebar > div:nth-child(2) {
    background: #ffffff !important;
    border-bottom: 1px solid #e2e8f0 !important;
    padding: 0 10px;
    gap: 5px;
}
#tab-route-creator-btn, #tab-route-list-btn {
    background: transparent !important;
    border: none !important;
    color: #64748b !important;
    font-weight: 700 !important;
    border-bottom: 3px solid transparent !important;
    transition: all 0.2s ease;
}
#tab-route-creator-btn:hover, #tab-route-list-btn:hover { color: #0f172a !important; background: #f8fafc !important; }

/* Cienki suwak dla lewego panelu */
.sidebar-content::-webkit-scrollbar { width: 8px; }
.sidebar-content::-webkit-scrollbar-track { background: #f8fafc; border-left: 1px solid #e2e8f0; }
.sidebar-content::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.sidebar-content::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* =====================================================================
   🎨 NOWA SEKCJA: SYSTEM MODULARNYCH ZAKŁADEK W PANELU ADMINISTRATORA
   ===================================================================== */
#admin-tabs-nav { display: flex; gap: 8px; }

.admin-tab-btn {
    padding: 10px 16px; 
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 12px; 
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
    border-radius: 6px 6px 0 0;
}

.admin-tab-btn:hover { color: #f8fafc; background: #334155; }
.admin-tab-btn.active { color: #3b82f6; border-bottom: 3px solid #3b82f6; background: #1e293b; }

.admin-tab-content { display: flex; flex-direction: column; gap: 20px; width: 100%; }

/* --- SYSTEM ZWIJANIA GRUP (AKORDEON) --- */
.group-collapse-content { display: flex; flex-direction: column; gap: 12px; margin-top: 15px; }
.group-collapse-content.collapsed { display: none !important; }

.btn-toggle-collapse {
    background: #f1f5f9; color: #334155; border: 1px solid #e2e8f0;
    padding: 6px 12px; font-size: 11px; border-radius: 6px; cursor: pointer; font-weight: bold; transition: all 0.2s ease;
}
.btn-toggle-collapse:hover { background: #e2e8f0; color: #0f172a; }

/* =====================================================================
   🚀 SYSTEM NOWOCZESNYCH POWIADOMIEŃ (BETTSO TOASTS)
   ===================================================================== */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 999999; display: flex; flex-direction: column; gap: 10px; }

.bettso-toast {
    min-width: 280px; max-width: 350px; padding: 14px 20px; border-radius: 8px; color: #fff; font-size: 13px; font-weight: bold;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15); display: flex; align-items: center; justify-content: space-between;
    animation: toastSlideIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.bettso-toast.success { background: #10b981; border-left: 6px solid #059669; }
.bettso-toast.error { background: #ef4444; border-left: 6px solid #b91c1c; }
.bettso-toast.warning { background: #f59e0b; color: #fff; border-left: 6px solid #d97706; }
.bettso-toast.info { background: #0ea5e9; border-left: 6px solid #0284c7; }

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

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

/* =====================================================================
   📊 SYMETRYCZNY PRAWY PANEL ANALITYCZNY (ANALYTICS SIDEBAR)
   ===================================================================== */
#top-bar { position: relative !important; z-index: 9999 !important; }

#analytics-sidebar {
    position: fixed; top: 87px; right: -420px; width: 400px; height: calc(100vh - 70px);
    background: #ffffff; box-shadow: -4px 0 25px rgba(0, 0, 0, 0.1); z-index: 990;
    transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex; flex-direction: column; padding: 0 !important; box-sizing: border-box;
    border-left: 1px solid #f1f5f9; border-radius: 0; overflow: hidden !important; 
}

#analytics-sidebar.active { right: 0 !important; }

#analytics-sidebar > div:first-child {
    display: flex; justify-content: space-between; align-items: center;
    background: #3b82f6; /* Zmieniono tło na mocny niebieski, żeby pasowało do lewego panelu */
    color: #ffffff; /* Zmieniono tekst na biały */
    padding: 15px 20px; 
    box-sizing: border-box; width: 100%; height: 55px; flex-shrink: 0;
}

#analytics-sidebar-content {
    overflow-y: auto !important; flex-grow: 1; width: 100%;
    padding: 0 10px 30px 0; box-sizing: border-box; direction: rtl; 
}

#analytics-sidebar-content > * { direction: ltr; padding-left: 15px; }

#analytics-sidebar-content::-webkit-scrollbar { width: 8px; }
#analytics-sidebar-content::-webkit-scrollbar-track { background: #f8fafc; border-right: 1px solid #e2e8f0; }
#analytics-sidebar-content::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
#analytics-sidebar-content::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* =====================================================================
   🗺️ MODYFIKACJE MAPY (NUMEROWANE PUNKTY I PRZESUWANIE ZOOMU)
   ===================================================================== */
.custom-svg-pin, .numbered-route-point { transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1); }
.custom-svg-pin:hover, .numbered-route-point:hover { transform: scale(1.15); z-index: 1000 !important; }

.leaflet-control-zoom { transition: transform 0.3s ease; }
.leaflet-control-zoom.zoom-shifted { transform: translateX(430px); }

/* =====================================================================
   🔧 FIX KONTRASTU: DYNAMICZNE PRZYCISKI W PODGLĄDZIE BAZY DANYCH
   ===================================================================== */
#dynamic-schema-buttons button {
    color: #ffffff !important; 
    text-shadow: 0 1px 2px rgba(0,0,0,0.3); 
    border: none !important; 
}