/* ============================================
   Notificaties App - BBA Pompen & Buizen
   ============================================ */

:root {
    --primary: #1a5276; --primary-light: #2980b9; --primary-dark: #0e3a53; --primary-bg: #eaf2f8;
    --status-green: #00B050; --status-yellow: #FFC000; --status-orange: #FF8C00; --status-red: #FF0000;
    --bg: #f0f2f5; --surface: #ffffff; --border: #d5dbe3; --border-light: #e8ecf1;
    --text: #1a2332; --text-secondary: #5a6577; --text-muted: #8b95a5;
    --success: #0d9f6e; --warning: #e67e22; --danger: #e53e3e; --info: #3182ce;
    --header-h: 60px; --tab-h: 44px; --radius: 6px; --radius-lg: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1); --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --font: 'Source Sans 3', -apple-system, BlinkMacSystemFont, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; min-height: 100vh; }

/* ---- Header ---- */
.app-header { display: flex; align-items: center; justify-content: space-between; height: var(--header-h); padding: 0 24px; background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.15); position: sticky; top: 0; z-index: 100; }
.header-left { display: flex; align-items: center; gap: 16px; }
.logo-area { display: flex; align-items: center; gap: 12px; }
.logo-icon { width: 40px; height: 40px; background: rgba(255,255,255,0.15); border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.app-title { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.app-subtitle { font-size: 0.75rem; opacity: 0.7; font-weight: 400; }
.bba-logo { font-size: 1.1rem; font-weight: 700; letter-spacing: 0.05em; }
.bba-logo span { font-weight: 400; font-size: 0.75rem; margin-left: 6px; opacity: 0.7; }

/* ---- Header User Info ---- */
.header-right { display: flex; align-items: center; gap: 20px; }
.user-info { display: flex; align-items: center; gap: 12px; }
.user-avatar { width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center; font-size: 0.85rem; font-weight: 700; letter-spacing: 0.03em; color: #fff; flex-shrink: 0; }
.user-avatar-sm { width: 32px; height: 32px; border-radius: 50%; background: var(--primary-bg); color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 700; }
.user-details { display: flex; flex-direction: column; line-height: 1.3; }
.user-name { font-size: 0.9rem; font-weight: 600; color: #fff; }
.user-role { font-size: 0.75rem; opacity: 0.7; text-transform: uppercase; letter-spacing: 0.04em; }
.logout-link { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; color: #fff; transition: all 0.2s; }
.logout-link:hover { background: rgba(255,255,255,0.15); }

/* ---- Alert Bar ---- */
.alert-bar { display: flex; align-items: center; gap: 8px; padding: 10px 24px; font-size: 0.85rem; font-weight: 500; }
.alert-bar.alert-warning { background: #fef3cd; color: #856404; border-bottom: 1px solid #ffc107; }

/* ---- Tab Navigation ---- */
.tab-nav { display: flex; gap: 2px; background: var(--surface); padding: 0 24px; border-bottom: 2px solid var(--border); position: sticky; top: var(--header-h); z-index: 90; }
.tab-link { display: flex; align-items: center; gap: 6px; padding: 12px 20px; font-size: 0.875rem; font-weight: 500; color: var(--text-secondary); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; white-space: nowrap; }
.tab-link:hover { color: var(--primary); background: var(--primary-bg); }
.tab-link.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---- Main ---- */
.main-content { padding: 24px; max-width: 1800px; margin: 0 auto; }

/* ---- Cards ---- */
.card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); border: 1px solid var(--border-light); overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; background: linear-gradient(135deg, var(--primary-bg) 0%, #f5f8fb 100%); border-bottom: 1px solid var(--border); }
.card-header h2 { font-size: 1rem; font-weight: 600; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.card-body { padding: 20px; }

/* ---- Form ---- */
.form-grid { display: grid; grid-template-columns: 160px 1fr; gap: 0; align-items: stretch; }
.form-grid.two-col { grid-template-columns: 160px 1fr 160px 1fr; }
.form-label { display: flex; align-items: center; padding: 8px 12px; font-weight: 500; font-size: 0.85rem; background: #f8f9fb; border: 1px solid var(--border); margin: -1px 0 0 0; }
.form-field { padding: 4px 8px; border: 1px solid var(--border); margin: -1px 0 0 -1px; display: flex; align-items: center; }
.form-field input, .form-field select, .form-field textarea { width: 100%; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-family: var(--font); font-size: 0.85rem; background: #fff; color: var(--text); transition: border-color 0.2s, box-shadow 0.2s; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(41,128,185,0.15); }
.form-field textarea { resize: vertical; min-height: 80px; }

/* ---- Department grid ---- */
.dept-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 0; width: 100%; }
.dept-grid .dept-header { padding: 6px 4px; text-align: center; font-weight: 600; font-size: 0.75rem; background: #e8ecf1; border: 1px solid var(--border); }
.dept-grid .dept-cell { padding: 4px; text-align: center; border: 1px solid var(--border); margin-top: -1px; }
.dept-grid .dept-cell select { width: 100%; padding: 4px 2px; font-size: 0.75rem; border: 1px solid var(--border); border-radius: 3px; background: #fff; text-align: center; }
.dept-grid .dept-cell input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }

/* ---- Phase table ---- */
.phase-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.phase-table th { padding: 8px 12px; text-align: left; font-weight: 600; background: #e8ecf1; border: 1px solid var(--border); font-size: 0.8rem; white-space: nowrap; }
.phase-table td { padding: 4px 8px; border: 1px solid var(--border); vertical-align: middle; }
.phase-table td:first-child { font-weight: 500; background: #f8f9fb; white-space: nowrap; width: 200px; }
.phase-table .status-cell select, .phase-table .uitvoerende-cell select, .phase-table .datum-cell input, .phase-table .actie-cell input { width: 100%; padding: 4px 6px; border: 1px solid var(--border); border-radius: 3px; font-size: 0.8rem; }
.phase-table .status-cell select { cursor: pointer; }

/* ---- Status ---- */
.status-legend { display: flex; gap: 12px; padding: 8px 0; }
.status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 4px; font-size: 0.8rem; font-weight: 600; color: #fff; }
.status-badge.small { padding: 2px 8px; font-size: 0.7rem; }
select.status-select { font-weight: 600; color: #fff; text-align: center; border: none; padding: 4px 6px; border-radius: 3px; cursor: pointer; appearance: none; -webkit-appearance: none; text-align-last: center; }
select.status-select option { color: #000; background: #fff; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 20px; border: none; border-radius: var(--radius); font-family: var(--font); font-size: 0.85rem; font-weight: 600; cursor: pointer; transition: all 0.2s; text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: var(--shadow-md); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c53030; }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background: var(--primary-bg); }
.btn-sm { padding: 4px 12px; font-size: 0.8rem; }
.btn-group { display: flex; gap: 8px; justify-content: flex-end; padding: 16px 20px; border-top: 1px solid var(--border-light); background: #fafbfc; }

/* ---- Overview table ---- */
.overview-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.overview-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; min-width: 1400px; }
.overview-table thead th { padding: 8px 6px; text-align: center; font-weight: 600; background: #e8ecf1; border: 1px solid var(--border); font-size: 0.72rem; white-space: nowrap; cursor: pointer; user-select: none; position: sticky; top: 0; z-index: 5; }
.overview-table thead th:hover { background: #dde3ea; }
.overview-table thead th.sorted-asc::after { content: ' ▲'; font-size: 0.6rem; }
.overview-table thead th.sorted-desc::after { content: ' ▼'; font-size: 0.6rem; }

/* Horizontal phase headers */
.overview-table thead th.phase-header-hz { min-width: 44px; max-width: 80px; padding: 6px 3px; font-size: 0.62rem; line-height: 1.2; white-space: normal; word-break: break-word; hyphens: auto; text-align: center; vertical-align: bottom; }

.overview-table tbody td { padding: 5px 6px; border: 1px solid var(--border); vertical-align: middle; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.overview-table tbody tr:hover { background: #f0f4f8; }
.overview-table tbody tr.row-green { background: #e6f9ef; }
.overview-table tbody tr.filter-hidden { display: none; }

.phase-cell { width: 32px; min-width: 32px; max-width: 32px; text-align: center; padding: 2px !important; font-size: 0.7rem; font-weight: 600; }
.notif-link { color: var(--primary); font-weight: 600; text-decoration: none; cursor: pointer; }
.notif-link:hover { text-decoration: underline; color: var(--primary-dark); }

.toggle-afgehandeld { padding: 3px 8px; border: 1px solid var(--border); border-radius: 3px; font-size: 0.75rem; font-weight: 600; cursor: pointer; background: #fff; min-width: 40px; text-align: center; }
.toggle-afgehandeld.ja { background: var(--status-green); color: #fff; border-color: var(--status-green); }
.toggle-afgehandeld.nee { background: #fff; color: var(--text); }

.prio-badge { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.overview-legend { display: flex; gap: 16px; justify-content: flex-end; }
.overview-legend .legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 600; }
.legend-color { width: 28px; height: 16px; border-radius: 3px; border: 1px solid rgba(0,0,0,0.1); }
.record-count { font-size: 0.8rem; color: var(--text-muted); font-weight: 400; }

/* ---- Column filter row ---- */
.filter-row th { padding: 4px 3px !important; background: #f4f6f9 !important; cursor: default !important; }
.filter-row th:hover { background: #f4f6f9 !important; }
.col-filter { width: 100%; padding: 3px 5px !important; border: 1px solid var(--border) !important; border-radius: 3px !important; font-size: 0.7rem !important; font-family: var(--font) !important; background: #fff !important; color: var(--text) !important; }
.col-filter:focus { outline: none !important; border-color: var(--primary-light) !important; box-shadow: 0 0 0 2px rgba(41,128,185,0.15) !important; }

/* ---- Image paste area ---- */
.paste-area { border: 2px dashed var(--border); border-radius: var(--radius); padding: 24px; text-align: center; cursor: pointer; color: var(--text-muted); font-size: 0.85rem; transition: border-color 0.2s, background 0.2s; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.paste-area:hover, .paste-area:focus { border-color: var(--primary-light); background: var(--primary-bg); outline: none; }
.paste-area.drag-over { border-color: var(--primary); background: var(--primary-bg); }

/* ---- Image gallery ---- */
.image-gallery { display: flex; flex-wrap: wrap; gap: 12px; }
.image-thumb { position: relative; width: 120px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fafbfc; }
.image-thumb img { width: 100%; height: 80px; object-fit: cover; cursor: pointer; display: block; }
.image-thumb img:hover { opacity: 0.85; }
.img-delete { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--danger); color: #fff; border: none; font-size: 0.7rem; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; }
.img-name { display: block; padding: 2px 4px; font-size: 0.65rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Admin page ---- */
.admin-tabs { display: flex; gap: 0; background: var(--surface); border-bottom: 1px solid var(--border); }
.admin-tab { padding: 10px 20px; font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); text-decoration: none; border-bottom: 2px solid transparent; transition: all 0.2s; }
.admin-tab:hover { color: var(--primary); background: var(--primary-bg); }
.admin-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; background: var(--primary-bg); }

.admin-section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.admin-section-header h3 { font-size: 1rem; font-weight: 600; color: var(--primary); }

.admin-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.admin-table th { padding: 8px 10px; text-align: left; font-weight: 600; background: #e8ecf1; border: 1px solid var(--border); font-size: 0.8rem; }
.admin-table td { padding: 4px 6px; border: 1px solid var(--border); vertical-align: middle; }
.admin-table tbody tr:hover { background: #f0f4f8; }
.admin-table tbody tr[data-new="1"] { background: #fffde7; }
.admin-input { width: 100%; padding: 4px 8px; border: 1px solid var(--border); border-radius: 3px; font-family: var(--font); font-size: 0.8rem; background: #fff; }
.admin-input:focus { outline: none; border-color: var(--primary-light); box-shadow: 0 0 0 2px rgba(41,128,185,0.15); }

/* ---- Toast ---- */
.toast { position: fixed; bottom: 24px; right: 24px; padding: 12px 24px; border-radius: var(--radius); font-weight: 600; font-size: 0.875rem; color: #fff; box-shadow: var(--shadow-lg); z-index: 1000; transition: all 0.3s; }
.toast.hidden { transform: translateY(100px); opacity: 0; pointer-events: none; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ---- Misc ---- */
.section-gap { margin-top: 20px; }
.section-title { font-size: 0.9rem; font-weight: 700; color: var(--primary); padding: 10px 16px; background: var(--primary-bg); border-left: 3px solid var(--primary); }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 500; }
.overlay.hidden { display: none; }
.dialog { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 24px; max-width: 420px; width: 90%; }
.dialog h3 { font-size: 1rem; font-weight: 700; margin-bottom: 12px; }
.dialog p { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 20px; }
.dialog-btns { display: flex; gap: 8px; justify-content: flex-end; }

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.d-flex { display: flex; }
.gap-2 { gap: 16px; }
.items-center { align-items: center; }

/* ---- Responsive ---- */
@media (max-width: 1200px) { .form-grid.two-col { grid-template-columns: 160px 1fr; } }
@media (max-width: 768px) { .main-content { padding: 12px; } .tab-nav { overflow-x: auto; padding: 0 12px; } .form-grid, .form-grid.two-col { grid-template-columns: 1fr; } }

/* User management styles */
.status-indicator { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; font-size: 0.85rem; font-weight: 600; }
.status-indicator.active { background: #d4edda; color: #155724; }
.status-indicator.inactive { background: #f8d7da; color: #721c24; }
.row-inactive { opacity: 0.5; background: #fafafa; }
.badge-you { font-size: 0.7rem; background: var(--primary-bg); color: var(--primary); padding: 2px 8px; border-radius: 4px; margin-left: 8px; font-weight: 600; }
.role-select { font-size: 0.9rem !important; padding: 6px 10px !important; }
.role-select.role-admin { background: #fff3cd; border-color: #ffc107; color: #856404; }
.role-select.role-user { background: #e2e8f0; border-color: #cbd5e0; color: #4a5568; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }
.btn-outline:hover { background: var(--border-light); }