/* public/css/style.css */
@import url('https://fonts.googleapis.com/css2?family=Albert+Sans:wght@400;500;700&family=Libre+Franklin:wght@300;400;500;600&display=swap');

:root {
    --primary-blue: #00247f;
    --brand-cyan: #00adea;
    --bg-light: #f4f7fa;
    --card-bg: #ffffff;
    --text-main: #1a202c;
    --text-muted: #718096;
    --border-color: #e2e8f0;
    
    --radius-card: 16px;
    --radius-btn: 8px;
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

body {
    font-family: 'Libre Franklin', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

h1, h2, h3, h4 { font-family: 'Albert Sans', sans-serif; margin-top: 0; }

/* --- APP LAYOUT & RESPONSIVE --- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    transition: all 0.3s ease;
}

/* Sidebar Desktop */
.sidebar {
    width: 260px;
    background-color: var(--primary-blue);
    color: white;
    padding: 25px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    box-sizing: border-box;
    z-index: 100;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 30px;
    background-color: var(--bg-light);
    overflow-x: hidden;
    width: 100%;
    box-sizing: border-box;
}

/* --- MOBILE OPTIMIERUNG --- */
@media (max-width: 768px) {
    .app-wrapper { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        padding: 15px;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
    }
    .sidebar-logo img { height: 40px; width: auto; margin-bottom: 0 !important; }
    .sidebar-logo h2, .sidebar-logo small { display: none; }
    .sidebar nav {
        margin-top: 0 !important;
        display: flex;
        gap: 10px;
        width: 100%;
        overflow-x: auto;
        padding-top: 15px;
		-webkit-overflow-scrolling: touch;
		padding-bottom: 5px; /* Platz für Scrollbar */
		scrollbar-width: none;
    }
	.sidebar nav::-webkit-scrollbar { 
		display: none; /* Chrome/Safari */ 
	}

	.nav-link { 
		/* Größere Touch-Area für Finger */
		padding: 10px 16px; 
		font-size: 0.9rem; 
	}

    .main-content { padding: 15px; }
    .header-bar { flex-direction: column; align-items: flex-start; gap: 10px; }
    .review-item { flex-direction: column; }
    .review-meta { width: 100%; flex: none; margin-bottom: 15px; padding-bottom: 15px; border-bottom: 1px solid #eee; }
}

/* --- UI ELEMENTS --- */
.sidebar-logo img { max-width: 160px; margin-bottom: 30px; }

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    border-radius: var(--radius-btn);
    margin-bottom: 5px;
    font-weight: 500;
    transition: 0.2s;
}
.nav-link:hover, .nav-link.active { background-color: var(--brand-cyan); color: white; }
.nav-link i { margin-right: 10px; width: 20px; text-align: center; }

.header-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }

.card {
    background: var(--card-bg);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-soft);
    padding: 25px;
    margin-bottom: 25px;
    border: 1px solid var(--border-color);
	overflow: hidden;
}

/* Spezifisch für die Branch-Tabelle */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Flüssiges Scrollen auf iOS */
    margin-bottom: 15px;
}

/* Damit die Tabelle nicht gequetscht wird */
table.branch-table {
    min-width: 600px; /* Erzwingt eine Mindestbreite, damit Scrollbalken erscheint */
}

/* --- FILTER MODERN --- */
.filter-bar {
    background: white;
    padding: 20px;
    border-radius: var(--radius-card);
    margin-bottom: 30px;
    box-shadow: var(--shadow-soft);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    align-items: end;
}

@media (max-width: 480px) {
    .filter-bar {
        grid-template-columns: 1fr; /* Auf Mobile immer 1 Spalte für Filter */
        padding: 15px;
        gap: 15px;
    }
    
    /* Inputs besser bedienbar machen */
    select.modern-select, input.modern-input {
        font-size: 16px; /* Verhindert Auto-Zoom auf iPhones bei Inputs */
        padding: 12px;
    }
}

.filter-group label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 8px;
}

/* Select Styling */
select.modern-select, input.modern-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-btn);
    background-color: #fff;
    font-size: 0.9rem;
    color: var(--text-main);
    cursor: pointer;
    box-sizing: border-box;
    font-family: inherit;
}

/* Checkbox Buttons (Pills) */
.checkbox-group { display: flex; flex-wrap: wrap; gap: 8px; }
.checkbox-btn { display: none; }
.checkbox-label {
    display: inline-block;
    padding: 6px 12px;
    background: #f1f5f9;
    color: var(--text-muted);
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
    user-select: none;
}
.checkbox-btn:checked + .checkbox-label {
    background-color: var(--brand-cyan);
    color: white;
    box-shadow: 0 2px 5px rgba(0, 173, 234, 0.3);
}

.filter-actions { display: flex; gap: 10px; }

/* --- REVIEWS --- */
.review-item {
    border-bottom: 1px solid var(--border-color);
    padding: 30px 0;
    display: flex;
    gap: 30px;
}
.review-item:last-child { border-bottom: none; }

.review-meta { flex: 0 0 200px; font-size: 0.85rem; color: var(--text-muted); }
.review-content { flex: 1; min-width: 0; }

.review-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

.review-author { font-weight: 700; color: var(--primary-blue); font-size: 1rem; }

.review-text {
    font-style: italic;
    color: #4a5568;
    background: #f8fafc;
    padding: 20px;
    border-radius: 12px;
    margin-top: 15px;
    border-left: 4px solid var(--brand-cyan);
}

/* Status Badges */
.status-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-block;
}
.status-new { background-color: #ebf8ff; color: #3182ce; }
.status-ai { background-color: #fffaf0; color: #dd6b20; }
.status-posted { background-color: #f0fff4; color: #38a169; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-btn);
    cursor: pointer;
    font-family: 'Albert Sans', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    text-transform: uppercase;
    text-decoration: none;
}
.btn i { margin-right: 8px; }
.btn-primary { background-color: var(--brand-cyan); color: white; }
.btn-primary:hover { background-color: #0095c8; transform: translateY(-1px); }
.btn-secondary { background-color: #e2e8f0; color: #4a5568; }
.btn-secondary:hover { background-color: #cbd5e0; }

.btn-copy {
    background: white;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    text-transform: none;
}
.btn-copy:hover { background: #f0fff4; color: #2f855a; border-color: #c6f6d5; }

.copy-feedback {
    display: none;
    font-size: 0.75rem;
    color: #2f855a;
    font-weight: bold;
    margin-left: 10px;
    animation: fadeIn 0.3s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

textarea.form-control {
    width: 100%;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    margin-top: 10px;
    box-sizing: border-box;
    transition: border 0.2s;
}
textarea.form-control:focus {
    outline: none;
    border-color: var(--brand-cyan);
    box-shadow: 0 0 0 3px rgba(0, 173, 234, 0.1);
}

/* --- ADMIN MODALS (Zusatz zu v001) --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: none; /* Hidden by default */
    align-items: center; justify-content: center;
    z-index: 2000;
}

.modal-card {
    background: white;
    width: 90%; 
    max-width: 500px;
    border-radius: var(--radius-card);
    padding: 25px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    position: relative;
    
    /* NEU: Scroll-Verhalten für zu hohe Modals */
    max-height: 90vh; /* Maximal 90% der Bildschirmhöhe */
    overflow-y: auto; /* Scrollbar innen, falls Inhalt zu lang */
    display: flex;
    flex-direction: column;
}

.modal-header {
	position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee; padding-bottom: 10px;
}
.modal-header h3 { margin: 0; color: var(--primary-blue); font-size: 1.2rem; }
.modal-close { font-size: 1.5rem; cursor: pointer; color: #a0aec0; }
.modal-close:hover { color: #e53e3e; }

    /* Heatmap Container */

	.heatmap-wrapper {
            width: 100%;           /* Nimmt maximal die Breite der Karte ein */
            overflow-x: auto;      /* Erzeugt Scrollbalken, wenn Tabelle zu breit */
            margin-top: 15px;
            border: 1px solid #edf2f7;
            border-radius: 6px;
            display: block;        /* Wichtig für korrektes Rendering */
        }

    table.heatmap {
        width: 100%;
        border-collapse: separate; /* Wichtig für Sticky Header/Col */
        border-spacing: 0;
        font-size: 0.85rem;
    }

    /* Fixierte erste Spalte (Filialname) */
    table.heatmap th:first-child,
    table.heatmap td:first-child {
        position: sticky;
        left: 0;
        background: white;
        z-index: 10;
        border-right: 2px solid #e2e8f0;
        min-width: 180px;
        max-width: 180px;
        padding: 10px 15px;
        font-weight: 600;
        color: #2d3748;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Tabellen Header */
    table.heatmap th {
        background: #f7fafc;
        color: #718096;
        text-transform: uppercase;
        font-size: 0.7rem;
        letter-spacing: 0.05em;
        padding: 12px 5px;
        border-bottom: 2px solid #e2e8f0;
    }

    table.heatmap td {
        padding: 0; /* Kein Padding, damit die Zelle voll gefüllt ist */
        border-bottom: 1px solid #edf2f7;
        border-right: 1px solid #edf2f7;
        height: 50px;
        min-width: 70px;
    }

    /* Die eigentliche Datenzelle */
    .h-cell {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        height: 100%;
        width: 100%;
        transition: all 0.2s;
        cursor: default;
    }

    .h-cell:hover {
        transform: scale(1.15);
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        z-index: 20;
        position: relative;
        border-radius: 4px;
    }

    .h-val { font-weight: bold; font-size: 0.95rem; }
    .h-count { font-size: 0.65rem; opacity: 0.8; margin-top: -2px; }

    /* Farbskala (Tailwind-ähnliche Farben) */
    .bg-grade-5 { background-color: #22c55e; color: white; } /* 4.5 - 5.0 (Green-500) */
    .bg-grade-4 { background-color: #84cc16; color: white; } /* 4.0 - 4.4 (Lime-500) */
    .bg-grade-3 { background-color: #facc15; color: #713f12; } /* 3.5 - 3.9 (Yellow-400) */
    .bg-grade-2 { background-color: #fb923c; color: white; } /* 3.0 - 3.4 (Orange-400) */
    .bg-grade-1 { background-color: #ef4444; color: white; } /* < 3.0 (Red-500) */
    .bg-grade-0 { background-color: #f8fafc; color: #cbd5e1; } /* Leer */

.reports-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); /* 300px passt auch auf Handys */
        gap: 25px;
    }
    
    /* Auf ganz kleinen Handys (unter 350px) auf 1 Spalte zwingen */
    @media (max-width: 480px) {
        .reports-grid {
            grid-template-columns: 1fr;
        }
        /* Ränder auf Mobile verkleinern */
        .card { padding: 15px; }
        .main-content { padding: 15px; }
    }
	
	/* --- MOBILE OPTIMIERUNG FÜR HEATMAP --- */
    @media (max-width: 768px) {
        /* Container anpassen */
        .heatmap-wrapper {
            margin-top: 10px;
            border-radius: 4px;
        }

        /* 1. Spalte (Filialname) schmaler machen */
        table.heatmap th:first-child,
        table.heatmap td:first-child {
            min-width: 100px;
            max-width: 100px; /* Von 160px auf 100px reduziert */
            font-size: 0.7rem;
            padding: 5px;
            white-space: normal; /* Erlaubt Umbruch bei langen Namen */
            line-height: 1.2;
        }

        /* Überschriften kleiner */
        table.heatmap th {
            font-size: 0.65rem;
            padding: 5px 2px;
        }

        /* Datenzellen kompakter */
        table.heatmap td {
            height: 35px; /* Flacher */
            min-width: 45px; /* Schmaler */
        }

        /* Inhalt der Zellen anpassen */
        .h-val { font-size: 0.8rem; }
        .h-count { font-size: 0.55rem; display: block; margin-top: 0; }
        
        /* Den Hover-Effekt auf Touch-Geräten abschwächen (stört oft beim Scrollen) */
        .h-cell:hover { transform: none; box-shadow: none; }
    }
	
	table.branch-table {
        width: 100%;
        border-collapse: collapse;
        font-family: 'Segoe UI', sans-serif;
        font-size: 0.9rem;
    }
    
    table.branch-table th {
        background-color: #f1f5f9; /* Helles Grau-Blau */
        color: #1e3a8a; /* Dunkelblau */
        padding: 10px 8px;
        text-align: center;
        border-bottom: 2px solid #cbd5e0;
        font-weight: 700;
    }

    table.branch-table td {
        padding: 8px;
        text-align: center;
        border-bottom: 1px solid #e2e8f0;
        border-right: 1px solid #f1f5f9; /* Zarte vertikale Linien */
    }

    /* Zebra-Streifen: Jede zweite Zeile blau hinterlegt */
    table.branch-table tbody tr:nth-child(even) {
        background-color: #f8fafc; /* Sehr helles Blau */
    }
    
    table.branch-table tbody tr:hover {
        background-color: #e2e8f0;
    }
	
	/* --- FIXES & OPTIMIERUNGEN (Review Additions) --- */

/* 1. Modal Scroll Fix */
.modal-card {
    max-height: 90vh;
    overflow-y: auto;
}

/* 2. Besseres Tabellen-Verhalten */
/* Ergänze im HTML ein <div class="table-container"> um die .branch-table */
.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}
table.branch-table {
    min-width: 600px; /* Erzwingt Scrollen statt Quetschen */
}

/* 3. Mobile Tweaks (< 480px) */
@media (max-width: 480px) {
    .filter-bar {
        grid-template-columns: 1fr; /* Filter untereinander */
    }
    
    /* Verhindert iOS Zoom bei Focus */
    select, input, textarea {
        font-size: 16px !important; 
    }
    
    /* Buttons volle Breite für bessere Erreichbarkeit */
    .filter-actions {
        flex-direction: column;
    }
    .filter-actions .btn {
        width: 100%;
    }
    
    /* Review Header kompakter */
    .review-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .review-header > div {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
}

/* --- FIX: Admin Navigation Mobile --- */
/* Wir sprechen jetzt gezielt die neue Klasse .nav-scroll an */

/* --- FIX: Admin Navigation Mobile --- */
/* Wir sprechen jetzt gezielt die neue Klasse .nav-scroll an */

@media (max-width: 768px) {
    .nav-scroll {
        /* Layout erzwingen */
        display: flex !important;
        flex-wrap: nowrap !important; /* Kein Umbruch! */
        overflow-x: auto !important;  /* Scrollen erlauben */
        -webkit-overflow-scrolling: touch; /* Weiches Scrollen iOS */
        
        /* Optik */
        gap: 10px !important;
        padding: 15px 10px !important; /* Etwas Platz links/rechts */
        justify-content: flex-start !important; /* Startet links */
        width: 100%; /* Volle Breite nutzen */
        box-sizing: border-box; /* Padding einberechnen */
        
        /* Scrollbar ausblenden (optional) */
        scrollbar-width: none; 
        -ms-overflow-style: none;
    }

    .nav-scroll::-webkit-scrollbar {
        display: none;
    }

    /* Die Buttons darin */
    .nav-scroll .btn {
        flex: 0 0 auto; /* WICHTIG: Buttons behalten ihre Breite und schrumpfen nicht */
        white-space: nowrap; /* Text nicht umbrechen */
        margin: 0 !important;
        font-size: 0.85rem;
    }
}

/* --- Social Labz Watermark --- */

/* Container muss relative sein, damit das Wasserzeichen sich daran orientiert */
.chart-card-relative {
    position: relative !important;
}

.sl-watermark {
    position: absolute;
    bottom: 12px;
    right: 15px;
    
    /* Typografie passend zum Dashboard */
    font-size: 0.7rem;        /* Klein, aber lesbar */
    font-weight: 600;         /* Etwas fetter für Lesbarkeit bei Transparenz */
    font-family: inherit;     /* Erbt die Schriftart des Dashboards */
    color: #64748b;           /* Ein mittleres Grau (Slate-500) */
    opacity: 0.4;             /* 40% Deckkraft -> Wirkt edel & stört nicht */
    
    /* UX Magic */
    pointer-events: none;     /* Lässt Mausklicks durch zum Chart (Tooltips funktionieren!) */
    user-select: none;        /* Text kann nicht markiert werden */
    z-index: 10;              /* Liegt über dem Chart */
    white-space: nowrap;      /* Kein Umbruch */
}