/* ==========================================================================
   1. GLOBALE VARIABELEN & BASIS INSTELLINGEN
   ========================================================================== */
:root {
    --bg-dark: #0f0f0f;
    --panel-bg: #1a1a1a;
    --card-bg: #242424;
    --accent-red: #c0392b;
    --accent-blue: #3498db;
    --accent-gold: #f1c40f;
    --accent-green: #2ecc71;
    --text-main: #e0e0e0;
    --text-muted: #888888;
    --border: #333333;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    line-height: 1.5;
}

.container,
.lever-container,
.archief-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 15px;
}

@media (min-width: 768px) {

    .container,
    .lever-container,
    .archief-container {
        padding: 25px;
    }
}

/* ==========================================================================
   2. TYPOGRAFIE & KOPPEN
   ========================================================================== */
h1,
h2,
h3 {
    color: #fff;
    margin-top: 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

h1 {
    border-bottom: 3px solid var(--accent-red);
    padding-bottom: 10px;
    font-size: 1.8rem;
}

h2 {
    border-bottom: 2px solid var(--accent-red);
    padding-bottom: 8px;
    font-size: 1.3rem;
    margin-bottom: 15px;
}

/* ==========================================================================
   3. NAVBAR STYLING (STICKY & RESPONSIVE)
   ========================================================================== */
.navbar {
    background: #1a1a1a;
    border-bottom: 3px solid var(--accent-red);
    padding: 12px 20px;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    color: #fff;
    font-size: 1.25rem;
    font-weight: bold;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-menu {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.nav-link {
    color: #bbb;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: bold;
    padding: 8px 14px;
    border-radius: 4px;
    white-space: nowrap;
    transition: all 0.2s ease-in-out;
}

.nav-link:hover,
.nav-link.active {
    background: var(--accent-red);
    color: white;
}

.nav-link.btn-logout {
    background: #333;
    border: 1px solid #444;
    color: #e74c3c;
}

.nav-link.btn-logout:hover {
    background: #e74c3c;
    color: #fff;
    border-color: #e74c3c;
}

.user-badge {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-right: 10px;
    background: rgba(0, 0, 0, 0.3);
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid #222;
    font-weight: 500;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.9rem;
    cursor: pointer;
}

/* ==========================================================================
   4. LAYOUT PANELS, GRIDS & CARDS
   ========================================================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 992px) {
    .dashboard-grid {
        grid-template-columns: 2fr 1fr;
    }
}

.card,
.panel,
.incident-card,
.user-card,
.filter-bar {
    background: var(--panel-bg);
    border-radius: 8px;
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    margin-bottom: 20px;
}

.incident-card {
    border-left: 6px solid var(--accent-red);
    background: var(--card-bg);
}

.pinned {
    border-left-color: var(--accent-gold) !important;
    background: #2a2510;
}

/* Grids voor foto's en media */
.foto-grid,
.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

@media (min-width: 768px) {

    .foto-grid,
    .preview-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 16px;
    }
}

/* ==========================================================================
   5. STATISTIEKEN (SALES DASHBOARDS)
   ========================================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 25px;
}

@media (min-width: 576px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 992px) {
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

.stat-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border);
    border-bottom: 4px solid var(--accent-red);
}

.stat-card h3 {
    border: none;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.stat-card p {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--accent-gold);
    margin: 0;
}

/* ==========================================================================
   6. TABELLEN & DATA PRESENTATIE (RESPONSIVE OVERFLOW)
   ========================================================================== */
.table-container {
    width: 100%;
    overflow-x: auto;
    margin-top: 10px;
    background: #1e1e1e;
    border-radius: 6px;
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 0.95rem;
}

th {
    background: #111;
    color: var(--accent-red);
    font-size: 0.85rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.totaal-row {
    background: #2d2d2d !important;
    font-size: 1.1rem;
    font-weight: bold;
}

.bedrag {
    font-weight: bold;
    color: var(--accent-green);
}

.negatief {
    color: #e74c3c;
}

/* ==========================================================================
   7. FORMULIEREN, INPUTS & BUTTONS
   ========================================================================== */
input,
select,
textarea {
    background: #111;
    border: 1px solid var(--border);
    color: #fff;
    padding: 12px;
    border-radius: 4px;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 10px;
    font-size: 1rem;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent-red);
    outline: none;
}

button,
.btn,
input[type="submit"] {
    background: var(--accent-red);
    color: white;
    border: none;
    min-height: 44px;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.95rem;
    transition: all 0.2s ease-in-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

button:hover,
.btn:hover {
    background: #a93226;
    transform: translateY(-1px);
}

button.secondary,
.btn-secondary {
    background: #28a745;
}

button.secondary:hover,
.btn-secondary:hover {
    background: #218838;
}

button.copy {
    background: #444;
    color: white;
    text-transform: none;
    min-height: auto;
    padding: 6px 12px;
    font-size: 0.85rem;
}

button.copy:hover {
    background: #555;
}

button.active {
    border: 2px solid var(--accent-gold);
    box-shadow: 0 0 10px rgba(241, 196, 15, 0.3);
}

/* ==========================================================================
   8. MODALS & OVERLAYS
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    /* Flex via Javascript openen */
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 15px;
}

.modal-content {
    background: #1a1a1a;
    border: 2px solid var(--accent-red);
    padding: 25px;
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   9. MONITOR & MEDIA LAYOUTS
   ========================================================================== */
.type {
    font-weight: bold;
    color: var(--accent-red);
}

.location {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 500;
}

.time {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.gallery-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.gallery-img,
.preview-item img,
.preview-item video,
.foto-item img {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
}

@media (min-width: 768px) {

    .preview-item img,
    .preview-item video,
    .foto-item img {
        width: 100%;
        height: 180px;
    }
}

.row {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
    align-items: center;
}

.group-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
}

@media (min-width: 768px) {
    .group-header {
        flex-direction: row;
        align-items: center;
    }
}

/* Extra aanpassingen voor ultra-kleine smartphones */
@media (max-width: 480px) {
    body {
        padding: 10px 0;
    }

    h1 {
        font-size: 1.5rem;
    }

    th,
    td {
        padding: 10px 6px;
        font-size: 0.85rem;
    }

    .navbar {
        padding: 10px;
        flex-direction: column;
        gap: 10px;
    }
}

/* ==========================================================================
   10. MOBIELE OPTIMALISATIES (VOOR TELEFOONS)
   ========================================================================== */
@media (max-width: 767px) {

    /* Geef de pagina iets meer ademruimte aan de zijkanten */
    body {
        padding: 10px 5px;
    }

    .container,
    .lever-container,
    .archief-container,
    .card,
    .panel {
        padding: 12px;
        margin: 8px auto;
        border-radius: 6px;
    }

    /* Zorg dat grids (zoals de dashboard-grid) ALTIJD onder elkaar klappen */
    .dashboard-grid,
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    /* Stat-cards compacter maken op mobiel */
    .stat-card {
        padding: 12px;
    }

    .stat-card p {
        font-size: 1.4rem;
    }

    /* Formulier rijen (.row) onder elkaar zetten i.p.v. flex-row */
    .row,
    .group-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }

    .row input,
    .row select,
    .row button {
        width: 100% !important;
        margin-bottom: 5px;
    }

    /* ==========================================================================
       TABELTRANSFORMATIE: Maakt van brede tabellen losse kaarten
       ========================================================================== */
    .table-container {
        background: transparent;
        border: none;
    }

    table,
    create,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    /* Verberg de traditionele tabelkop (th) op mobiel */
    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        background: var(--panel-bg);
        border: 1px solid var(--border) !important;
        border-left: 4px solid var(--accent-red) !important;
        /* Rode indicatielijn */
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 10px;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    }

    td {
        border: none;
        border-bottom: 1px solid #252525;
        position: relative;
        padding: 10px 10px 10px 45% !important;
        /* Ruimte links voor het label */
        text-align: right !important;
        /* Data rechts */
        white-space: normal !important;
        font-size: 0.9rem;
    }

    td:last-child {
        border-bottom: none;
    }

    td::before {
        position: absolute;
        top: 10px;
        left: 10px;
        width: 40%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: bold;
        color: var(--text-muted);
    }

    /* ==========================================================================
       LABELS SPECIFIEK PER TABELTYPE (VOORKOMT VERKEERDE LABELS)
       ========================================================================== */

    /* A. LABELS VOOR P2000 / MONITOR DASHBOARD */
    .p2000-table td:nth-of-type(1)::before {
        content: "⏱️ Tijdstip";
    }

    .p2000-table td:nth-of-type(2)::before {
        content: "📍 Plaats";
    }

    .p2000-table td:nth-of-type(3)::before {
        content: "🚨 Incident";
    }

    .p2000-table td:nth-of-type(4)::before {
        content: "📊 Status";
    }

    .p2000-table td:nth-of-type(5)::before {
        content: "⚡ Acties";
    }


    /* AFNEMERS TABEL */
    .buyers-table td:nth-of-type(1)::before {
        content: "👤 Afnemer";
    }

    .buyers-table td:nth-of-type(2)::before {
        content: "🏷️ Type Afname";
    }

    .buyers-table td:nth-of-type(3)::before {
        content: "📸 Foto Prijs";
    }

    .buyers-table td:nth-of-type(4)::before {
        content: "🎥 Video Prijs";
    }

    /* B. LABELS VOOR MIJN VERKOPEN / FINANCIËLE TABELLEN */
    .sales-table td:nth-of-type(1)::before {
        content: "📅 Datum";
    }

    .sales-table td:nth-of-type(2)::before {
        content: "📸 Item / Titel";
    }

    .sales-table td:nth-of-type(3)::before {
        content: "🏢 Afnemer";
    }

    .sales-table td:nth-of-type(4)::before {
        content: "💰 Bedrag";
    }

    .sales-table td:nth-of-type(5)::before {
        content: "🔄️ Aantal";
    }

    /* C. LABELS VOOR ADMIN GEBRUIKERSBEHEER */
    .users-table td:nth-of-type(1)::before {
        content: "👤 Fotograaf";
    }

    .users-table td:nth-of-type(2)::before {
        content: "📧 Mail Adres";
    }

    .users-table td:nth-of-type(3)::before {
        content: "🔄️ Percentage";
    }

    /* ==========================================================================
       ACTIEKNOPPEN STYLING OP MOBIEL
       ========================================================================== */
    td:last-child {
        text-align: center !important;
        padding-left: 10px !important;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    td button,
    td .btn,
    td a {
        width: 100% !important;
        justify-content: center;
        margin-right: 0 !important;
    }
}