/* ==========================================================================
   Video Call System – Admin Design
   Dunkelblau als Hauptfarbe, weisser Hintergrund, hellgraue Flaechen.
   ========================================================================== */

:root {
    --color-primary: #1e3a8a;        /* Dunkelblau */
    --color-primary-dark: #172554;
    --color-primary-light: #2563eb;
    --color-accent: #3b82f6;

    --color-bg: #ffffff;             /* Weisser Hintergrund */
    --color-surface: #f1f5f9;        /* Hellgraue Flaeche */
    --color-surface-2: #f8fafc;
    --color-border: #e2e8f0;
    --color-border-strong: #cbd5e1;

    --color-text: #0f172a;
    --color-text-muted: #64748b;
    --color-text-invert: #ffffff;

    --color-success: #16a34a;        /* Gruen */
    --color-success-bg: #dcfce7;
    --color-danger: #dc2626;         /* Rot */
    --color-danger-bg: #fee2e2;
    --color-warning: #d97706;        /* Gelb/Orange */
    --color-warning-bg: #fef3c7;
    --color-info: #0284c7;
    --color-info-bg: #e0f2fe;

    --radius: 10px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.16);

    --sidebar-width: 256px;
    --topbar-height: 62px;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    color: var(--color-text);
    background: var(--color-surface-2);
    font-size: 15px;
    line-height: 1.5;
}

a { color: var(--color-primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .5rem; font-weight: 650; color: var(--color-text); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }

/* ---- Layout Grid ------------------------------------------------------- */

.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

/* Backdrop nur auf Mobil sichtbar. Auf Desktop ausblenden, sonst wird es
   ein zusaetzliches Grid-Item und verschiebt Sidebar/Inhalt. */
.sidebar-backdrop { display: none; }

/* ---- Sidebar ----------------------------------------------------------- */

.sidebar {
    background: var(--color-primary-dark);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1.15rem 1.25rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar__brand .logo {
    width: 32px; height: 32px;
    display: grid; place-items: center;
    background: var(--color-primary-light);
    border-radius: 8px;
    flex-shrink: 0;
}

.sidebar__nav { padding: .75rem 0; flex: 1; }

.sidebar__section {
    padding: .9rem 1.25rem .35rem;
    font-size: .68rem;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #94a3b8;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .6rem 1.25rem;
    color: #cbd5e1;
    font-size: .92rem;
    border-left: 3px solid transparent;
    transition: background .12s, color .12s;
}
.sidebar__link:hover { background: rgba(255,255,255,0.06); color: #fff; text-decoration: none; }
.sidebar__link.active {
    background: rgba(37, 99, 235, 0.18);
    border-left-color: var(--color-primary-light);
    color: #fff;
    font-weight: 600;
}
.sidebar__link .icon { width: 18px; text-align: center; opacity: .9; }

/* ---- Main -------------------------------------------------------------- */

.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: var(--topbar-height);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar__title { font-size: 1.05rem; font-weight: 650; }

.topbar__user {
    display: flex; align-items: center; gap: .75rem;
}
.topbar__user .avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--color-primary); color: #fff;
    display: grid; place-items: center; font-weight: 600; font-size: .85rem;
    overflow: hidden; text-decoration: none; flex-shrink: 0;
}
.topbar__user .avatar img { width: 100%; height: 100%; object-fit: cover; }
.topbar__user .meta { text-align: right; line-height: 1.2; }
.topbar__user .meta .name { font-weight: 600; font-size: .9rem; }
.topbar__user .meta .role { font-size: .75rem; color: var(--color-text-muted); }

.content { padding: 1.5rem; width: 100%; max-width: none; }

/* ---- Detail-/Kennwert-Liste (Einstellungen, LiveKit, Meeting-Details) --- */
.meeting-preview {
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: .25rem 1.15rem;
    margin-bottom: 1.25rem;
}
.meeting-preview h2 { font-size: 1.1rem; margin: .7rem 0; }
.meeting-preview .row {
    display: flex; gap: 1.25rem; font-size: .9rem;
    padding: .6rem 0; border-bottom: 1px solid var(--color-border);
    align-items: baseline;
}
.meeting-preview .row:last-child { border-bottom: none; }
.meeting-preview .row .label { color: var(--color-text-muted); min-width: 170px; flex-shrink: 0; }
.meeting-preview .row > span:last-child { overflow-wrap: break-word; min-width: 0; }

/* Auf schmalen Bildschirmen Label ueber Wert stapeln (verhindert das
   buchstabenweise Umbrechen der Werte). */
@media (max-width: 560px) {
    .meeting-preview .row { flex-direction: column; gap: .15rem; padding: .55rem 0; }
    .meeting-preview .row .label { min-width: 0; }
}

.page-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}
.page-head p { color: var(--color-text-muted); margin: .2rem 0 0; }

/* ---- Cards ------------------------------------------------------------- */

.card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card__head {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--color-border);
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.card__body { padding: 1.25rem; }
.card__body.p0 { padding: 0; }

/* ---- Dashboard Stat Cards ---------------------------------------------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.15rem 1.25rem;
    box-shadow: var(--shadow-sm);
    display: flex; align-items: center; gap: 1rem;
}
.stat__icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: grid; place-items: center; font-size: 1.3rem; flex-shrink: 0;
}
.stat__icon.blue { background: #dbeafe; color: var(--color-primary); }
.stat__icon.green { background: var(--color-success-bg); color: var(--color-success); }
.stat__icon.amber { background: var(--color-warning-bg); color: var(--color-warning); }
.stat__icon.slate { background: var(--color-surface); color: var(--color-text-muted); }
.stat__value { font-size: 1.7rem; font-weight: 700; line-height: 1; }
.stat__label { color: var(--color-text-muted); font-size: .85rem; margin-top: .2rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---- Tables ------------------------------------------------------------ */

.table-tools {
    display: flex; align-items: center; gap: .75rem;
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--color-border);
    flex-wrap: wrap;
}
.search-box {
    position: relative; flex: 1; min-width: 200px; max-width: 360px;
}
.search-box input {
    width: 100%; padding: .55rem .75rem .55rem 2.1rem;
    border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm);
    font-size: .9rem;
}
.search-box .icon {
    position: absolute; left: .7rem; top: 50%; transform: translateY(-50%);
    color: var(--color-text-muted);
}

.table-wrap { overflow-x: auto; }
table.data {
    width: 100%; border-collapse: collapse; font-size: .9rem;
}
table.data th, table.data td {
    padding: .75rem 1.25rem; text-align: left; border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}
table.data th {
    background: var(--color-surface-2); color: var(--color-text-muted);
    font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em;
    white-space: nowrap;
}
table.data tbody tr:hover { background: var(--color-surface-2); }
table.data td.actions { text-align: right; white-space: nowrap; }
.empty-row td { text-align: center; color: var(--color-text-muted); padding: 2.5rem; }

/* ---- Badges ------------------------------------------------------------ */

.badge {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .2rem .6rem; border-radius: 999px;
    font-size: .75rem; font-weight: 600; line-height: 1.4;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.gray { background: var(--color-surface); color: var(--color-text-muted); }
.badge.green { background: var(--color-success-bg); color: #15803d; }
.badge.red { background: var(--color-danger-bg); color: #b91c1c; }
.badge.amber { background: var(--color-warning-bg); color: #b45309; }
.badge.blue { background: #dbeafe; color: var(--color-primary); }
.badge.no-dot::before { display: none; }

/* Status-Badges fuer Meetings */
.status-planned  { background: #dbeafe; color: var(--color-primary); }
.status-active   { background: var(--color-success-bg); color: #15803d; }
.status-finished { background: var(--color-surface); color: var(--color-text-muted); }
.status-cancelled{ background: var(--color-danger-bg); color: #b91c1c; }

/* ---- Buttons ----------------------------------------------------------- */

.btn {
    display: inline-flex; align-items: center; gap: .45rem;
    padding: .55rem 1rem; border-radius: var(--radius-sm);
    font-size: .9rem; font-weight: 600; cursor: pointer;
    border: 1px solid transparent; background: var(--color-surface); color: var(--color-text);
    transition: background .12s, box-shadow .12s, opacity .12s;
    text-decoration: none; line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.rec-opt { display: flex; gap: .6rem; align-items: flex-start; padding: .7rem .8rem; border: 1px solid var(--color-border); border-radius: 10px; margin-bottom: .6rem; cursor: pointer; }
.rec-opt:hover { border-color: var(--color-primary-light); }
.rec-opt input { margin-top: .25rem; flex-shrink: 0; }
.btn-secondary { background: var(--color-bg); border-color: var(--color-border-strong); color: var(--color-text); }
.btn-secondary:hover { background: var(--color-surface); }
.btn-success { background: var(--color-success); color: #fff; }
.btn-success:hover { filter: brightness(.95); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { filter: brightness(.95); }
.btn-ghost { background: transparent; color: var(--color-text-muted); }
.btn-ghost:hover { background: var(--color-surface); color: var(--color-text); }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---- Icons (Inline-SVG) ------------------------------------------------ */
.ico { display: inline-block; vertical-align: middle; flex-shrink: 0; stroke: currentColor; }
.btn .ico { margin: 0; }
.sidebar__link .ico { opacity: .9; transition: opacity .12s; }
.sidebar__link:hover .ico, .sidebar__link.active .ico { opacity: 1; }
.sidebar__brand .logo .ico { color: #fff; }
.sidebar__brand .brand-logo { width: 34px; height: 34px; border-radius: 9px; display: block; flex-shrink: 0; }
.stat__icon .ico { display: block; }
.search-box .icon { display: inline-flex; align-items: center; }
.search-box .icon .ico { display: block; }

/* ---- Forms ------------------------------------------------------------- */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.25rem; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: .35rem; }
.field label { font-size: .85rem; font-weight: 600; color: #334155; }
.field .hint { font-size: .78rem; color: var(--color-text-muted); }
.field input[type=text], .field input[type=email], .field input[type=password],
.field input[type=tel], .field input[type=number], .field input[type=date],
.field input[type=time], .field input[type=datetime-local],
.field select, .field textarea {
    width: 100%; padding: .6rem .75rem;
    border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm);
    font-size: .92rem; font-family: inherit; background: #fff; color: var(--color-text);
}
.field textarea { resize: vertical; min-height: 84px; }
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--color-primary-light);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.checkbox-row { display: flex; align-items: center; gap: .55rem; }
.checkbox-row input { width: 18px; height: 18px; }
.checkbox-row label { font-weight: 500; }

.days-row { display: flex; flex-wrap: wrap; gap: .45rem; }
.day-chip {
    display: inline-flex; align-items: center; gap: .35rem;
    background: var(--color-surface); border: 1px solid var(--color-border-strong);
    border-radius: 8px; padding: .35rem .65rem; font-size: .85rem; cursor: pointer; user-select: none;
}
.day-chip input { width: 16px; height: 16px; }

/* ---- Kalender (Monatsansicht) ----------------------------------------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--color-border); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--color-border); }
.cal-dow { background: var(--color-surface-2); padding: .5rem; text-align: center; font-size: .72rem; font-weight: 600; color: var(--color-text-muted); text-transform: uppercase; }
.cal-cell { background: #fff; min-height: 98px; padding: .35rem; display: flex; flex-direction: column; gap: .2rem; overflow: hidden; }
.cal-cell.out { background: var(--color-surface-2); }
.cal-cell.today { background: #eff6ff; }
.cal-daynum { font-size: .8rem; color: var(--color-text-muted); font-weight: 600; }
.cal-cell.today .cal-daynum { color: var(--color-primary-light); }
.cal-chip { display: block; font-size: .72rem; padding: .15rem .4rem; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-chip:hover { text-decoration: none; opacity: .88; }
.cal-time { font-weight: 700; }
@media (max-width: 680px) {
    .cal-cell { min-height: 60px; padding: .2rem; }
    .cal-chip { font-size: .58rem; padding: .1rem .25rem; }
    .cal-dow { font-size: .58rem; padding: .3rem; }
}

/* ---- Statistik-Balken (Dashboard) ------------------------------------- */
.chart { display: flex; align-items: flex-end; gap: .5rem; height: 160px; padding: .5rem 0; }
.chart__col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .35rem; min-width: 0; }
.chart__bar { width: 100%; max-width: 42px; background: var(--color-primary-light); border-radius: 6px 6px 0 0; transition: height .3s; min-height: 3px; }
.chart__bar.alt { background: var(--color-success); }
.chart__val { font-size: .75rem; font-weight: 700; color: var(--color-text); }
.chart__lbl { font-size: .68rem; color: var(--color-text-muted); white-space: nowrap; }

.form-actions {
    display: flex; justify-content: flex-end; gap: .75rem;
    margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--color-border);
}

/* ---- Flash / Alerts ---------------------------------------------------- */

.alert {
    padding: .8rem 1rem; border-radius: var(--radius-sm);
    margin-bottom: 1rem; font-size: .9rem; display: flex; gap: .6rem; align-items: flex-start;
    border: 1px solid transparent;
}
.alert .icon { flex-shrink: 0; }
.alert-success { background: var(--color-success-bg); color: #166534; border-color: #bbf7d0; }
.alert-error   { background: var(--color-danger-bg); color: #991b1b; border-color: #fecaca; }
.alert-warning { background: var(--color-warning-bg); color: #92400e; border-color: #fde68a; }
.alert-info    { background: var(--color-info-bg); color: #075985; border-color: #bae6fd; }

/* ---- Modal ------------------------------------------------------------- */

.modal-backdrop {
    position: fixed; inset: 0; background: rgba(15, 23, 42, 0.55);
    display: none; align-items: flex-start; justify-content: center;
    z-index: 100; padding: 3rem 1rem; overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg);
    width: 100%; max-width: 640px; animation: modal-in .16s ease-out;
}
.modal.wide { max-width: 860px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.modal__head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.1rem 1.35rem; border-bottom: 1px solid var(--color-border);
}
.modal__head h3 { margin: 0; }
.modal__body { padding: 1.35rem; }
.modal__close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--color-text-muted); line-height: 1; }

/* ---- Misc -------------------------------------------------------------- */

.muted { color: var(--color-text-muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .85em; }
.text-sm { font-size: .85rem; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mb-0 { margin-bottom: 0; }
.flex { display: flex; } .items-center { align-items: center; } .gap { gap: .5rem; }
.tag-copy {
    display: inline-flex; align-items: center; gap: .4rem;
    background: var(--color-surface); border: 1px solid var(--color-border);
    padding: .3rem .55rem; border-radius: var(--radius-sm); font-size: .8rem; cursor: pointer;
    max-width: 100%;
}
.tag-copy .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }

.divider { height: 1px; background: var(--color-border); margin: 1.25rem 0; }

/* ---- Barrierefreiheit: sichtbarer Tastaturfokus + reduzierte Bewegung --- */
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; border-radius: var(--radius-sm); }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}

.pagination { display: flex; gap: .4rem; justify-content: center; padding: 1rem; }
.pagination a, .pagination span {
    padding: .4rem .7rem; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
    font-size: .85rem; color: var(--color-text); background: #fff;
}
.pagination .current { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.pagination .disabled { opacity: .5; pointer-events: none; }

/* ---- Permission Matrix ------------------------------------------------- */

.perm-matrix { width: 100%; border-collapse: collapse; font-size: .85rem; }
.perm-matrix th, .perm-matrix td { padding: .6rem .8rem; border-bottom: 1px solid var(--color-border); text-align: center; }
.perm-matrix th:first-child, .perm-matrix td:first-child { text-align: left; }
.perm-matrix tbody tr:hover { background: var(--color-surface-2); }
.perm-group-row td { background: #eef2ff; font-weight: 700; color: var(--color-primary); text-align: left; }

/* ---- Responsive Sidebar (Tablet) --------------------------------------- */

.menu-toggle { display: none; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--color-text); }

@media (max-width: 1024px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; left: 0; top: 0; z-index: 200;
        width: var(--sidebar-width); transform: translateX(-100%);
        transition: transform .2s ease;
    }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .menu-toggle { display: inline-flex; }
    .sidebar-backdrop {
        display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 150;
    }
    .sidebar-backdrop.open { display: block; }
}
