/* ---------------------------------------------------------------------------
   Arbeitszeit - eigenes Stylesheet oberhalb von Bootstrap 5.
   Aufbau:
   1. Farben und Grundwerte
   2. Grundgerüst (Sidebar, Topbar, Inhalt)
   3. Bausteine (Karten, Kennzahlen, Timer, Tabellen)
   4. Dunkles Design
   5. Responsive Anpassungen
   --------------------------------------------------------------------------- */

/* 1. Farben und Grundwerte ------------------------------------------------ */
:root {
    --az-primary: #4f6ef7;
    --az-primary-soft: rgba(79, 110, 247, .12);
    --az-success: #2fb344;
    --az-warning: #f7b32b;
    --az-danger: #e0384a;
    --az-body-bg: #f4f6fb;
    --az-surface: #ffffff;
    --az-surface-muted: #f8fafc;
    --az-border: #e6e9f2;
    --az-text: #1f2733;
    --az-text-muted: #6b7688;
    --az-sidebar-width: 264px;
    --az-radius: 14px;
    --az-shadow: 0 1px 2px rgba(20, 30, 60, .04), 0 8px 24px rgba(20, 30, 60, .05);
}

body {
    background-color: var(--az-body-bg);
    color: var(--az-text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: .94rem;
}

a {
    text-decoration: none;
}

/* 2. Grundgerüst ---------------------------------------------------------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--az-sidebar-width);
    flex: 0 0 var(--az-sidebar-width);
    background: var(--az-surface);
    border-right: 1px solid var(--az-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1045;
    transition: transform .2s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: 1.15rem 1.25rem;
    border-bottom: 1px solid var(--az-border);
    min-height: 66px;
}

.sidebar-brand img {
    max-height: 34px;
    max-width: 120px;
}

.sidebar-brand-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--az-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
}

.sidebar-brand-text {
    font-weight: 600;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-close {
    margin-left: auto;
    border: 0;
    background: transparent;
    color: var(--az-text-muted);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 1rem .75rem 1.5rem;
}

.sidebar-group-title {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--az-text-muted);
    font-weight: 600;
    padding: .85rem .75rem .35rem;
}

.sidebar-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .6rem .75rem;
    border-radius: 10px;
    color: var(--az-text);
    font-weight: 500;
    transition: background-color .15s ease, color .15s ease;
}

.sidebar-link i {
    font-size: 1.05rem;
    color: var(--az-text-muted);
    width: 1.2rem;
    text-align: center;
}

.sidebar-link:hover {
    background: var(--az-surface-muted);
    color: var(--az-primary);
}

.sidebar-link:hover i,
.sidebar-link.active i {
    color: inherit;
}

.sidebar-link.active {
    background: var(--az-primary-soft);
    color: var(--az-primary);
}

.sidebar-footer {
    border-top: 1px solid var(--az-border);
    padding: .85rem 1rem;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: .7rem;
    color: var(--az-text);
}

.sidebar-user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    overflow: hidden;
}

.sidebar-user-info strong {
    font-size: .88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-info small {
    color: var(--az-text-muted);
    font-size: .74rem;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex: 0 0 36px;
}

.avatar-initials {
    background: var(--az-primary-soft);
    color: var(--az-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: .8rem;
}

.avatar-sm {
    width: 28px;
    height: 28px;
    flex-basis: 28px;
    font-size: .7rem;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    z-index: 1040;
    display: none;
}

.sidebar-backdrop.show {
    display: block;
}

.app-main {
    flex: 1;
    margin-left: var(--az-sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    gap: .5rem;
    background: var(--az-surface);
    border-bottom: 1px solid var(--az-border);
    padding: .75rem 1.5rem;
    min-height: 66px;
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.app-content {
    padding: 1.5rem;
    flex: 1;
}

.app-footer {
    display: flex;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    color: var(--az-text-muted);
    font-size: .8rem;
    border-top: 1px solid var(--az-border);
}

/* 3. Bausteine ------------------------------------------------------------ */
.card {
    background: var(--az-surface);
    border: 1px solid var(--az-border);
    border-radius: var(--az-radius);
    box-shadow: var(--az-shadow);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--az-border);
    padding: .9rem 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.card-header .card-header-actions {
    margin-left: auto;
    display: flex;
    gap: .4rem;
    align-items: center;
}

.card-body {
    padding: 1.15rem;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1.25rem;
}

.page-header h2 {
    font-size: 1.35rem;
    font-weight: 600;
    margin: 0;
}

.page-header .page-header-actions {
    margin-left: auto;
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
}

/* Große Stundenübersicht auf dem Dashboard */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.stat-card {
    background: var(--az-surface);
    border: 1px solid var(--az-border);
    border-radius: var(--az-radius);
    box-shadow: var(--az-shadow);
    padding: 1.25rem 1.35rem;
}

.stat-card .stat-label {
    display: flex;
    align-items: center;
    gap: .45rem;
    color: var(--az-text-muted);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 600;
}

.stat-card .stat-value {
    font-size: 2.1rem;
    font-weight: 700;
    line-height: 1.15;
    margin: .35rem 0 .1rem;
    font-variant-numeric: tabular-nums;
}

.stat-card .stat-meta {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
    font-size: .82rem;
    color: var(--az-text-muted);
    border-top: 1px dashed var(--az-border);
    margin-top: .75rem;
    padding-top: .6rem;
}

.stat-card .stat-meta strong {
    font-variant-numeric: tabular-nums;
}

.progress-thin {
    height: 6px;
    border-radius: 999px;
    background: var(--az-surface-muted);
}

/* Timer in der Topbar */
.timer-widget {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: var(--az-surface-muted);
    border: 1px solid var(--az-border);
    border-radius: 999px;
    padding: .25rem .35rem .25rem .8rem;
}

.timer-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--az-success);
    animation: timer-pulse 1.6s infinite;
}

.timer-widget[data-status="paused"] .timer-dot {
    background: var(--az-warning);
    animation: none;
}

@keyframes timer-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .25; }
}

.timer-value {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: .02em;
}

.timer-project {
    color: var(--az-text-muted);
    font-size: .82rem;
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Großer Timer auf der Zeiterfassungsseite */
.timer-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}

.timer-panel .timer-display {
    font-size: 2.6rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

/* Projektfarbe als Punkt */
.color-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: .4rem;
    vertical-align: middle;
}

.table {
    --bs-table-bg: transparent;
    margin-bottom: 0;
}

.table > :not(caption) > * > * {
    padding: .7rem .85rem;
}

.table thead th {
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--az-text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--az-border);
    white-space: nowrap;
}

.table tbody tr:hover {
    background: var(--az-surface-muted);
}

.table td {
    vertical-align: middle;
    border-color: var(--az-border);
}

.table-numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--az-text-muted);
}

.empty-state i {
    font-size: 2.2rem;
    display: block;
    margin-bottom: .6rem;
    opacity: .5;
}

.badge {
    font-weight: 600;
    padding: .35em .6em;
}

.form-label {
    font-weight: 500;
    font-size: .85rem;
    margin-bottom: .3rem;
}

.form-control, .form-select {
    border-color: var(--az-border);
    border-radius: 10px;
    padding: .5rem .75rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--az-primary);
    box-shadow: 0 0 0 .2rem var(--az-primary-soft);
}

.btn {
    border-radius: 10px;
    font-weight: 500;
}

.btn-primary {
    --bs-btn-bg: var(--az-primary);
    --bs-btn-border-color: var(--az-primary);
    --bs-btn-hover-bg: #3f5cdd;
    --bs-btn-hover-border-color: #3f5cdd;
    --bs-btn-active-bg: #3550c9;
    --bs-btn-active-border-color: #3550c9;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    align-items: flex-end;
}

.filter-bar .form-control,
.filter-bar .form-select {
    min-width: 150px;
}

/* Kalender */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 1px;
    background: var(--az-border);
    border: 1px solid var(--az-border);
    border-radius: var(--az-radius);
    overflow: hidden;
}

.calendar-weekday {
    background: var(--az-surface-muted);
    padding: .5rem;
    text-align: center;
    font-size: .75rem;
    font-weight: 600;
    color: var(--az-text-muted);
    text-transform: uppercase;
}

.calendar-day {
    background: var(--az-surface);
    min-height: 108px;
    padding: .45rem .5rem;
    display: flex;
    flex-direction: column;
    gap: .25rem;
}

.calendar-day.is-outside {
    background: var(--az-surface-muted);
    opacity: .6;
}

.calendar-day.is-today .calendar-day-number {
    background: var(--az-primary);
    color: #fff;
}

.calendar-day.is-weekend {
    background: var(--az-surface-muted);
}

.calendar-day.is-holiday {
    background: rgba(247, 179, 43, .1);
}

.calendar-day-number {
    align-self: flex-start;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .78rem;
    font-weight: 600;
}

.calendar-event {
    font-size: .72rem;
    border-radius: 6px;
    padding: .12rem .35rem;
    background: var(--az-primary-soft);
    color: var(--az-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calendar-event.is-absence {
    background: rgba(47, 179, 68, .15);
    color: #1d7a2d;
}

.calendar-event.is-sick {
    background: rgba(224, 56, 74, .13);
    color: #b02734;
}

.calendar-event.is-holiday {
    background: rgba(247, 179, 43, .2);
    color: #8a6410;
}

.calendar-day-total {
    margin-top: auto;
    font-size: .74rem;
    font-weight: 600;
    color: var(--az-text-muted);
    font-variant-numeric: tabular-nums;
}

/* Anmeldeseite */
.auth-body {
    background: linear-gradient(135deg, #eef2ff 0%, #f7f9fc 55%, #eef6ff 100%);
    min-height: 100vh;
}

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.auth-card {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 20px 45px rgba(20, 30, 60, .1);
    padding: 2.25rem;
    width: 100%;
    max-width: 420px;
}

.auth-brand {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-brand h1 {
    font-size: 1.35rem;
    font-weight: 600;
    margin: .75rem 0 .15rem;
}

.auth-brand p {
    color: var(--az-text-muted);
    font-size: .88rem;
    margin: 0;
}

.auth-logo {
    max-height: 52px;
}

.auth-logo-icon {
    width: 54px;
    height: 54px;
    border-radius: 16px;
    background: var(--az-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
}

/* 4. Dunkles Design ------------------------------------------------------- */
[data-bs-theme="dark"] {
    --az-body-bg: #12161f;
    --az-surface: #1a2030;
    --az-surface-muted: #222a3c;
    --az-border: #2b3345;
    --az-text: #e6eaf3;
    --az-text-muted: #96a0b5;
    --az-primary-soft: rgba(79, 110, 247, .2);
    --az-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
}

[data-bs-theme="dark"] body {
    background-color: var(--az-body-bg);
}

[data-bs-theme="dark"] .btn-light {
    --bs-btn-bg: var(--az-surface-muted);
    --bs-btn-border-color: var(--az-border);
    --bs-btn-color: var(--az-text);
    --bs-btn-hover-bg: #2b3345;
    --bs-btn-hover-border-color: #38415a;
    --bs-btn-hover-color: var(--az-text);
}

[data-bs-theme="dark"] .calendar-day.is-holiday {
    background: rgba(247, 179, 43, .12);
}

/* 5. Responsive ----------------------------------------------------------- */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-sidebar.show {
        transform: translateX(0);
        box-shadow: 0 0 40px rgba(15, 23, 42, .2);
    }

    .app-main {
        margin-left: 0;
    }

    .stat-grid {
        grid-template-columns: 1fr;
    }

    .app-content {
        padding: 1rem;
    }

    .app-topbar {
        padding: .65rem 1rem;
    }
}

@media (max-width: 767.98px) {
    .calendar-grid {
        font-size: .8rem;
    }

    .calendar-day {
        min-height: 76px;
    }

    .timer-project {
        display: none;
    }

    .stat-card .stat-value {
        font-size: 1.8rem;
    }
}

@media print {
    .app-sidebar,
    .app-topbar,
    .app-footer,
    .page-header-actions,
    .filter-bar {
        display: none !important;
    }

    .app-main {
        margin-left: 0;
    }

    .card {
        box-shadow: none;
        border-color: #ccc;
    }
}
