/* ===================================================
   VOLUNTA — Design System
   Moderne, brugervenligt admin interface
   =================================================== */

/* --- CSS Variabler --- */
:root {
    --primary:        #4F63D2;
    --primary-dark:   #3A4FB8;
    --primary-light:  #EEF0FD;
    --primary-rgb:    79, 99, 210;

    --secondary:  #10B981;
    --warning:    #F59E0B;
    --danger:     #EF4444;
    --info:       #3B82F6;

    --sidebar-bg:          #1A1F36;
    --sidebar-text:        #8892b0;
    --sidebar-hover-bg:    rgba(255,255,255,0.07);
    --sidebar-active-bg:   var(--primary);
    --sidebar-active-text: #ffffff;
    --sidebar-section:     #4a5568;
    --sidebar-width:       240px;

    --body-bg:    #F0F2F8;
    --card-bg:    #ffffff;
    --text-main:  #1A1F36;
    --text-muted: #64748B;
    --border:     #E2E8F0;
    --border-dark: #CBD5E1;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow:    0 4px 12px rgba(0,0,0,0.08);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.12);
    --shadow-lg: 0 16px 40px rgba(0,0,0,0.16);

    --radius-sm: 6px;
    --radius:    8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --transition: all 0.2s ease;
    --topbar-h:   60px;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--body-bg);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; display: block; }

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width 0.25s ease, transform 0.25s ease;
    overflow: hidden;
}


.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 64px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    overflow: hidden;
    white-space: nowrap;
}

.logo-icon {
    width: 34px; height: 34px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.logo-icon svg { width: 22px; height: 22px; }

.logo-titles {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}
.logo-org-name {
    font-size: 1rem;
    font-weight: 500;
    letter-spacing: -0.2px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}
.logo-powered {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.45);
    letter-spacing: 0.02em;
    white-space: nowrap;
    line-height: 1.2;
}


.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}
.user-name { color: #fff; font-size: 0.85rem; font-weight: 600; white-space: nowrap; }
.user-role-label { color: var(--sidebar-text); font-size: 0.75rem; white-space: nowrap; }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.nav-section { padding: 16px 0 4px; }
.nav-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sidebar-section);
    padding: 0 16px 6px;
    display: block;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--sidebar-text);
    border-radius: 0;
    margin: 1px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    text-decoration: none;
    font-size: 0.9rem;
    white-space: nowrap;
    position: relative;
}
.nav-item:hover { background: var(--sidebar-hover-bg); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item.active .nav-icon { color: #fff; }

.nav-icon { width: 18px; text-align: center; font-size: 0.9rem; flex-shrink: 0; }

.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 100px;
}

.sidebar-footer {
    padding: 8px;
    border-top: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}
.nav-logout:hover { background: rgba(239,68,68,0.15); color: #EF4444; }

/* --- Main wrapper --- */
.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.25s ease;
}
.sidebar.collapsed ~ .main-wrapper,

/* --- Topbar --- */
.topbar {
    height: var(--topbar-h);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 12px;
    position: sticky;
    top: 0; z-index: 50;
    box-shadow: var(--shadow-sm);
}

.topbar-menu-btn {
    display: none;
    background: none; border: none;
    font-size: 1.1rem; cursor: pointer;
    color: var(--text-muted);
    padding: 6px 8px;
    border-radius: var(--radius-sm);
}
.topbar-menu-btn:hover { background: var(--body-bg); }

.topbar-breadcrumb {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.875rem; color: var(--text-muted);
    flex: 1;
}
.topbar-breadcrumb a { color: var(--text-muted); }
.topbar-breadcrumb a:hover { color: var(--primary); }
.breadcrumb-sep { color: var(--border-dark); }

.topbar-right { display: flex; align-items: center; gap: 4px; }

.topbar-btn {
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 1rem;
    transition: var(--transition);
    position: relative;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    text-decoration: none;
}
.topbar-btn:hover { background: var(--body-bg); color: var(--primary); }

.topbar-divider { width: 1px; height: 24px; background: var(--border); margin: 0 8px; }

.topbar-user {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 8px 4px 4px;
    border-radius: var(--radius);
    transition: var(--transition);
}
.topbar-user:hover { background: var(--body-bg); }
.topbar-user-info { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; }
.topbar-username { font-size: 0.85rem; font-weight: 600; color: var(--text-main); line-height: 1.2; }
.topbar-userrole { font-size: 0.72rem; color: var(--text-muted); line-height: 1.2; }

/* --- Page header --- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 24px 0;
    gap: 16px;
    flex-wrap: wrap;
}
.page-title { font-size: 1.5rem; font-weight: 700; color: var(--text-main); line-height: 1.2; }
.page-subtitle { font-size: 0.875rem; color: var(--text-muted); margin-top: 2px; }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* --- Page content --- */
.page-content { padding: 20px 24px 40px; flex: 1; }

/* --- Flash / Alerts --- */
.flash-container { padding: 12px 24px 0; }
.alert {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    font-size: 0.875rem;
    animation: slideDown 0.2s ease;
}
.alert-success { background: #ECFDF5; border: 1px solid #A7F3D0; color: #065F46; }
.alert-error   { background: #FEF2F2; border: 1px solid #FECACA; color: #991B1B; }
.alert-warning { background: #FFFBEB; border: 1px solid #FDE68A; color: #92400E; }
.alert-info    { background: #EFF6FF; border: 1px solid #BFDBFE; color: #1E40AF; }
.alert-icon { font-weight: 700; font-size: 1rem; }
.alert-close {
    margin-left: auto; background: none; border: none;
    cursor: pointer; font-size: 1.2rem; opacity: 0.6;
    line-height: 1; color: inherit;
}
.alert-close:hover { opacity: 1; }

/* --- Cards --- */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--text-main); }
.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); background: #FAFBFC; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* --- Stat cards (Dashboard) --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex; align-items: flex-start; gap: 16px;
    transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-icon {
    width: 48px; height: 48px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; flex-shrink: 0;
}
.stat-icon.blue   { background: #EFF6FF; color: #2563EB; }
.stat-icon.green  { background: #ECFDF5; color: #059669; }
.stat-icon.yellow { background: #FFFBEB; color: #D97706; }
.stat-icon.red    { background: #FEF2F2; color: #DC2626; }
.stat-icon.purple { background: var(--primary-light); color: var(--primary); }
.stat-icon.teal   { background: #F0FDFA; color: #0D9488; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; color: var(--text-main); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.stat-change { font-size: 0.75rem; margin-top: 6px; }
.stat-change.up   { color: var(--secondary); }
.stat-change.down { color: var(--danger); }

/* --- Buttons --- */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 18px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}
.btn:focus { outline: none; box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.25); }
.btn i { font-size: 0.875rem; }

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }

.btn-secondary { background: var(--card-bg); color: var(--text-main); border-color: var(--border-dark); }
.btn-secondary:hover { background: var(--body-bg); border-color: var(--border-dark); color: var(--text-main); }

.btn-success { background: var(--secondary); color: #fff; border-color: var(--secondary); }
.btn-success:hover { background: #059669; color: #fff; }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #DC2626; color: #fff; }

.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-warning:hover { background: #D97706; color: #fff; }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-icon { padding: 8px; min-width: 36px; justify-content: center; }
.btn-block { width: 100%; justify-content: center; }

/* --- Tables --- */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; background: var(--card-bg); }
thead th {
    background: #F8FAFC;
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    text-align: left;
}
tbody td {
    padding: 13px 16px;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: var(--transition); }
tbody tr:hover { background: #FAFBFD; }
.td-actions { display: flex; gap: 6px; align-items: center; }

/* --- Forms --- */
.form-grid { display: grid; gap: 20px; }
.form-grid-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.form-grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }

label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: 0.01em;
}
label .req { color: var(--danger); margin-left: 2px; }

.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-dark);
    border-radius: var(--radius);
    font-size: 0.9rem;
    color: var(--text-main);
    background: #fff;
    transition: var(--transition);
    line-height: 1.5;
    font-family: inherit;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}
.form-control::placeholder { color: #B0B9C8; }
.form-control:disabled { background: #F8FAFC; cursor: not-allowed; color: var(--text-muted); }

textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748B' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.form-hint { font-size: 0.775rem; color: var(--text-muted); }
.form-error { font-size: 0.775rem; color: var(--danger); }
.form-control.is-invalid { border-color: var(--danger); }

/* --- Search/Filter bar --- */
.filter-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 16px 0 20px;
    flex-wrap: wrap;
}
.search-input-wrap {
    position: relative; flex: 1; min-width: 200px;
}
.search-input-wrap .fa {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); pointer-events: none;
}
.search-input-wrap input {
    padding-left: 36px;
}

/* --- Badges --- */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-success   { background: #DCFCE7; color: #166534; }
.badge-danger    { background: #FEE2E2; color: #991B1B; }
.badge-warning   { background: #FEF9C3; color: #854D0E; }
.badge-info      { background: #DBEAFE; color: #1E40AF; }
.badge-secondary { background: #F1F5F9; color: #475569; }
.badge-primary   { background: var(--primary-light); color: var(--primary-dark); }

/* --- Avatar --- */
.user-avatar-sm {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 700;
    color: #fff; flex-shrink: 0;
    object-fit: cover;
}
.user-avatar-lg {
    width: 72px; height: 72px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; font-weight: 700;
    color: #fff;
    object-fit: cover;
}

/* --- Pagination --- */
.pagination {
    display: flex; align-items: center; gap: 4px;
    margin-top: 20px; justify-content: center;
}
.page-btn {
    min-width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--border-dark);
    border-radius: var(--radius);
    color: var(--text-main);
    font-size: 0.875rem;
    transition: var(--transition);
    background: var(--card-bg);
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* --- Layout helpers --- */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
@media (max-width: 1200px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 900px)  { .grid-3 { grid-template-columns: repeat(2, 1fr); } .grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 600px)  { .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 20px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 20px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8rem; }
.text-center { text-align: center; }
.fw-600 { font-weight: 600; }
.w-100 { width: 100%; }
.d-none-mobile { }

/* --- Empty state --- */
.empty-state {
    text-align: center; padding: 60px 24px;
    color: var(--text-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.3; }
.empty-state h3 { font-size: 1.1rem; font-weight: 600; color: var(--text-main); margin-bottom: 8px; }
.empty-state p { font-size: 0.875rem; margin-bottom: 20px; }

/* --- Modal --- */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    animation: fadeIn 0.15s ease;
}
.modal {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%; max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.2s ease;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1.05rem; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modal-close:hover { color: var(--text-main); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* --- Login page --- */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--sidebar-bg) 0%, #2d3561 100%);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.login-card {
    background: var(--card-bg);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%; max-width: 420px;
    padding: 40px;
}
.login-logo {
    display: flex; align-items: center; gap: 12px;
    justify-content: center; margin-bottom: 32px;
}
.login-logo .logo-icon { width: 44px; height: 44px; }
.login-logo .logo-text { font-size: 1.6rem; color: var(--text-main); }
.login-title { font-size: 1.3rem; font-weight: 700; text-align: center; margin-bottom: 6px; }
.login-sub { text-align: center; color: var(--text-muted); font-size: 0.875rem; margin-bottom: 28px; }

/* --- Kalender --- */
#calendar { min-height: 600px; }
.fc .fc-toolbar-title { font-size: 1.1rem; font-weight: 600; color: var(--text-main); }
.fc .fc-button-primary { background: var(--primary); border-color: var(--primary); }
.fc .fc-button-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.fc .fc-button-primary:disabled { background: var(--primary); border-color: var(--primary); }
.fc-event { border-radius: var(--radius-sm) !important; border: none !important; padding: 2px 6px !important; font-size: 0.8rem !important; }
.fc-day-today { background: var(--primary-light) !important; }

/* --- Rich text --- */
.ql-toolbar { border-radius: var(--radius) var(--radius) 0 0 !important; border-color: var(--border-dark) !important; }
.ql-container { border-radius: 0 0 var(--radius) var(--radius) !important; border-color: var(--border-dark) !important; min-height: 200px; font-size: 0.9rem; }

/* --- File upload --- */
.file-drop {
    border: 2px dashed var(--border-dark);
    border-radius: var(--radius-lg);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: #FAFBFC;
}
.file-drop:hover, .file-drop.drag-over {
    border-color: var(--primary);
    background: var(--primary-light);
}
.file-drop-icon { font-size: 2rem; color: var(--text-muted); margin-bottom: 12px; }
.file-drop p { font-size: 0.875rem; color: var(--text-muted); }
.file-drop strong { color: var(--primary); }

/* --- Progress --- */
.progress { background: var(--border); border-radius: 100px; height: 8px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 100px; background: var(--primary); transition: width 0.4s ease; }
.progress-bar.green  { background: var(--secondary); }
.progress-bar.yellow { background: var(--warning); }
.progress-bar.red    { background: var(--danger); }

/* --- Timeline (aktivitetslog) --- */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ''; position: absolute; left: 10px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-dot { position: absolute; left: -23px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--primary); border: 2px solid var(--card-bg); }
.timeline-content { font-size: 0.875rem; }
.timeline-time { font-size: 0.75rem; color: var(--text-muted); }

/* --- Chips / Tags --- */
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 12px;
    background: var(--body-bg);
    border: 1px solid var(--border-dark);
    border-radius: 100px;
    font-size: 0.8rem;
    color: var(--text-main);
}
.chip .remove-chip { cursor: pointer; opacity: 0.6; margin-left: 2px; }
.chip .remove-chip:hover { opacity: 1; }

/* --- Detail view --- */
.detail-grid { display: grid; grid-template-columns: 180px 1fr; gap: 12px 20px; }
.detail-label { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); padding-top: 2px; }
.detail-value { font-size: 0.9rem; }
@media (max-width: 600px) { .detail-grid { grid-template-columns: 1fr; } .detail-label { margin-bottom: -8px; } }

/* --- Animations --- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideDown { from { transform: translateY(-8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; }

/* --- Dropdowns --- */
.dropdown { position: relative; display: inline-flex; }
.dropdown-menu {
    position: absolute; top: calc(100% + 6px); right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    min-width: 180px;
    z-index: 60;
    display: none;
    overflow: hidden;
    animation: slideDown 0.15s ease;
}
.dropdown-menu.open { display: block; }
.dropdown-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px;
    font-size: 0.875rem;
    color: var(--text-main);
    transition: var(--transition);
    cursor: pointer;
}
.dropdown-item:hover { background: var(--body-bg); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: #FEF2F2; }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* --- Responsive --- */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5); z-index: 99;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }
    .sidebar.mobile-open { transform: translateX(0); }
    .sidebar-overlay.active { display: block; }
    .main-wrapper { margin-left: 0 !important; }
    .topbar-menu-btn { display: flex; }
    .d-none-mobile { display: none; }
    .page-header { padding: 16px 16px 0; }
    .page-content { padding: 16px 16px 32px; }
    .flash-container { padding: 8px 16px 0; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .topbar { padding: 0 16px; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .login-card { padding: 28px 24px; }
}

/* --- Print --- */
@media print {
    .sidebar, .topbar, .page-header-actions, .filter-bar, .btn, .pagination { display: none !important; }
    .main-wrapper { margin-left: 0; }
    .page-content { padding: 0; }
}

/* ===================================================
   CHAT – Slack-inspireret chat interface
   =================================================== */

/* Override page-content layout for chat page */
/* Hide the generic page header on chat page */
body.chat-page .page-header  { display: none; }
body.chat-page .page-content {
    padding: 0 !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}
body.chat-page .main-wrapper {
    height: 100vh;
    overflow: hidden;
    min-height: 0;
}

/* --- Chat layout container --- */
.chat-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    height: 100%;
}

/* --- Left sidebar (channel/DM list) — light theme --- */
.chat-left {
    width: 240px;
    min-width: 200px;
    background: #F0F2F8;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
}

.chat-left-inner {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex: 1;
    padding: 8px 0;
}

.chat-left-scrollable {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.chat-section { margin-bottom: 4px; }

.chat-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 4px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    color: var(--text-muted);
    text-transform: uppercase;
}

.chat-section-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}
.chat-section-btn:hover { background: var(--border); color: var(--text-main); }

.chat-nav-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    cursor: pointer;
    border-radius: 6px;
    margin: 1px 6px;
    color: var(--text-muted);
    font-size: 0.88rem;
    transition: background 0.15s, color 0.15s;
    min-width: 0;
    position: relative;
}
.chat-nav-item:hover       { background: var(--border); color: var(--text-main); }
.chat-nav-item.active      { background: var(--primary); color: #fff; }
.chat-nav-item.has-unread  { color: var(--text-main); font-weight: 600; }

.chat-hash { font-size: 1rem; flex-shrink: 0; color: currentColor; opacity: 0.6; }

.chat-nav-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-badge {
    background: var(--danger);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.chat-dm-av {
    width: 22px; height: 22px;
    border-radius: 5px;
    background: var(--primary);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    object-fit: cover;
}

.chat-empty-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 4px 14px;
    font-style: italic;
}

/* --- Right panel --- */
.chat-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: var(--card-bg);
}

/* --- Welcome state --- */
.chat-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-muted);
    padding: 40px;
    text-align: center;
}
.chat-welcome-icon {
    font-size: 3rem;
    color: var(--border-dark);
}
.chat-welcome h2 { font-size: 1.2rem; color: var(--text-main); }
.chat-welcome p  { max-width: 320px; font-size: 0.9rem; }

/* --- Channel view --- */
.chat-channel-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Channel header */
.chat-ch-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: #fff;
    flex-shrink: 0;
    gap: 12px;
}
.chat-ch-header-left { display: flex; align-items: center; gap: 6px; }
.chat-ch-prefix  { color: var(--text-muted); font-size: 1.1rem; line-height: 1; }
.chat-ch-name    { font-size: 1rem; font-weight: 600; color: var(--text-main); }
.chat-ch-header-right { display: flex; gap: 8px; }

/* Messages scroll area */
.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    scroll-behavior: smooth;
    padding: 8px 0 4px;
}

#chatMessagesInner { display: flex; flex-direction: column; }

/* Loading / error states inside message area */
.chat-loading, .chat-error, .chat-no-msg {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 32px 20px;
}
.chat-error { color: var(--danger); }

/* --- Date separator --- */
.chat-date-sep {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px 4px;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
}
.chat-date-sep::before,
.chat-date-sep::after {
    content: '';
    flex: 1;
    border-top: 1px solid var(--border);
}

/* --- Individual message --- */
.chat-msg {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 2px 20px;
    position: relative;
}
.chat-msg:hover { background: var(--primary-light); }
.chat-msg:hover .chat-msg-actions { opacity: 1; }
.chat-msg:hover .chat-msg-hover-time { opacity: 1; }

.chat-msg-full    { padding-top: 8px; }
.chat-msg-compact { padding-top: 1px; }

.chat-msg-gutter {
    width: 36px;
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 2px;
}

.chat-msg-av {
    width: 36px; height: 36px;
    border-radius: 8px;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.chat-msg-hover-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.15s;
    white-space: nowrap;
    line-height: 1.8;
}

.chat-msg-body { flex: 1; min-width: 0; }

.chat-msg-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 2px;
}
.chat-msg-name { font-weight: 600; font-size: 0.9rem; color: var(--text-main); }
.chat-msg-time { font-size: 0.72rem; color: var(--text-muted); }

.chat-msg-text {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-main);
    word-break: break-word;
    white-space: pre-wrap;
}
.chat-msg-text a { color: var(--primary); text-decoration: underline; }

.msg-edited {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Reactions row */
.chat-msg-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.reaction-pill {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: var(--body-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    color: var(--text-main);
    line-height: 1.4;
}
.reaction-pill:hover { background: var(--primary-light); border-color: var(--primary); }
.reaction-pill.mine  { background: var(--primary-light); border-color: var(--primary); color: var(--primary); font-weight: 600; }

/* Hover action buttons (appear on message hover) */
.chat-msg-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.15s;
    position: absolute;
    top: 0;
    right: 16px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    padding: 2px;
}

.msg-act-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}
.msg-act-btn:hover       { background: var(--primary-light); color: var(--primary); }
.msg-act-btn.danger:hover{ background: #fee2e2; color: var(--danger); }

/* --- Input area --- */
.chat-input-area {
    padding: 12px 20px 14px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    background: #fff;
}

.chat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--body-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 12px;
    transition: border-color 0.2s;
}
.chat-input-wrap:focus-within { border-color: var(--primary); }

.chat-textarea {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-main);
    outline: none;
    max-height: 120px;
    overflow-y: auto;
}
.chat-textarea::placeholder { color: var(--text-muted); }

.chat-send-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 0.85rem;
    transition: background 0.15s;
}
.chat-send-btn:hover    { background: var(--primary-dark); }
.chat-send-btn:disabled { opacity: 0.5; cursor: default; }

.chat-input-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 5px;
}

/* --- Emoji picker --- */
.emoji-picker {
    position: fixed;
    z-index: 9999;
    display: none;
    flex-wrap: wrap;
    gap: 2px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 8px;
    width: 220px;
}

.emoji-opt {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
    border-radius: 4px;
    line-height: 1;
    transition: background 0.1s;
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
}
.emoji-opt:hover { background: var(--primary-light); }

/* --- Edit popup --- */
.chat-edit-popup {
    background: var(--body-bg);
    border: 1px solid var(--primary);
    border-radius: var(--radius);
    padding: 8px;
    margin-top: 4px;
}

.chat-edit-ta {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    background: #fff;
}
.chat-edit-ta:focus { border-color: var(--primary); }

.chat-edit-btns {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 6px;
}

/* --- DM user list in modal --- */
.dm-user-list {
    max-height: 340px;
    overflow-y: auto;
    margin: 0;
    padding: 4px 0;
    border-radius: var(--radius);
}

.dm-user-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}
.dm-user-row:hover { background: var(--primary-light); }

.dm-user-av {
    width: 36px; height: 36px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    object-fit: cover;
}

.dm-user-name { font-size: 0.9rem; font-weight: 500; color: var(--text-main); }
.dm-user-role { font-size: 0.75rem; color: var(--text-muted); }

/* --- Mobile chat drawer toggle button (hidden on desktop) --- */
.chat-mobile-menu-btn {
    display: none;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.82rem;
    cursor: pointer;
    padding: 5px 10px;
    line-height: 1;
    flex-shrink: 0;
    white-space: nowrap;
}
.chat-mobile-menu-btn:hover { color: var(--text-main); background: var(--primary-light); border-color: var(--primary); }
.chat-mobile-menu-label { font-weight: 500; }

/* Drawer close button + header (hidden on desktop) */
.chat-mobile-drawer-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-main);
    flex-shrink: 0;
}
.chat-mobile-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    border-radius: 4px;
}
.chat-mobile-close-btn:hover { color: var(--text-main); background: var(--border); }

/* "Vis kanaler" button in welcome state (hidden on desktop) */
.chat-mobile-show-channels { display: none; }

/* Backdrop overlay (hidden on desktop) */
.chat-mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 499;
}
.chat-mobile-overlay.visible { display: block; }

/* --- Responsive chat --- */
@media (max-width: 640px) {
    /* Sidebar becomes a slide-in drawer */
    .chat-left {
        position: fixed;
        top: 0;
        left: -100%;
        width: 82%;
        max-width: 300px;
        height: 100%;
        z-index: 500;
        transition: left 0.25s ease;
        box-shadow: 4px 0 24px rgba(0,0,0,0.18);
        border-right: none;
    }
    .chat-left.mobile-open { left: 0; }

    /* Show mobile-only elements */
    .chat-mobile-menu-btn      { display: flex; }
    .chat-mobile-drawer-header { display: flex; }
    .chat-mobile-show-channels { display: inline-flex; }

    .chat-msg        { padding-left: 12px; padding-right: 12px; }
    .chat-input-area { padding: 10px 12px 12px; }
    .chat-ch-header  { padding: 10px 12px; }
}
