/* ================================================================
   Buchungssystem – application stylesheet.
   Light, minimal design; primary color #2563eb.
   ================================================================ */

*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #e5e7eb;
    --secondary-hover: #d1d5db;
    --success: #16a34a;
    --error: #dc2626;
    --warning: #d97706;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
    --radius: 8px;
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

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

a:hover {
    text-decoration: underline;
}

h1, h2, h3 {
    margin: 0 0 12px;
    font-weight: 600;
}

h1 {
    font-size: 22px;
}

h2 {
    font-size: 18px;
}

.muted {
    color: var(--muted);
    font-size: 13px;
}

.mt {
    margin-top: 24px;
}

/* ============ Navigation ============ */

.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-brand {
    font-weight: 700;
    color: var(--text);
    font-size: 17px;
    text-decoration: none;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text);
    margin-left: auto;
}

.nav-links {
    list-style: none;
    padding: 0;
    margin: 0 0 0 auto;
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.nav-links a {
    color: var(--text);
    text-decoration: none;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 14px;
}

.nav-links a:hover {
    background: var(--secondary);
    text-decoration: none;
}

.nav-sep {
    color: var(--border);
}

.nav-user {
    color: var(--muted);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.role-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 999px;
    background: var(--secondary);
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.role-badge.role-sysadmin {
    background: #7c3aed;
    color: #fff;
}

.role-badge.role-admin {
    background: #2563eb;
    color: #fff;
}

.role-badge.role-room_admin {
    background: #0891b2;
    color: #fff;
}

/* ============ Container / Cards ============ */

.container {
    max-width: 1200px;
    margin: 24px auto;
    padding: 0 16px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.card.centered {
    max-width: 480px;
    margin: 40px auto;
    text-align: center;
}

.card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.info-card {
    background: #eff6ff;
    border-color: #bfdbfe;
    padding: 12px 16px;
    margin: 12px 0;
}

/* ============ Forms ============ */

.form-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}

.form-inline-check {
    justify-content: flex-end;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

label {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 4px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
select,
textarea {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    width: 100%;
    max-width: 100%;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text);
    margin-bottom: 0;
}

.checkbox input {
    width: auto;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 6px;
    background: #f8fafc;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

/* ============ Buttons ============ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s;
    font-family: inherit;
}

.btn:hover {
    text-decoration: none;
}

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

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

.btn-secondary {
    background: var(--secondary);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--secondary-hover);
    color: var(--text);
}

.btn-danger {
    background: var(--error);
    color: #fff;
}

.btn-danger:hover {
    background: #b91c1c;
    color: #fff;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

.btn-block {
    display: flex;
    width: 100%;
    margin-top: 8px;
}

/* ============ Alerts ============ */

.alert {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 14px;
    font-size: 14px;
    border: 1px solid;
}

.alert-success {
    background: #dcfce7;
    color: #14532d;
    border-color: #86efac;
}

.alert-error {
    background: #fee2e2;
    color: #7f1d1d;
    border-color: #fca5a5;
}

.alert-warning {
    background: #fef3c7;
    color: #78350f;
    border-color: #fde68a;
}

.alert-info {
    background: #dbeafe;
    color: #1e3a8a;
    border-color: #93c5fd;
}

/* ============ Badges ============ */

.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 12px;
    border-radius: 999px;
    font-weight: 500;
}

.badge-confirmed {
    background: #dcfce7;
    color: #166534;
}

.badge-cancelled {
    background: #fee2e2;
    color: #991b1b;
}

.badge-primary { background: #dbeafe; color: var(--primary); }
.badge-success { background: #dcfce7; color: var(--success); }
.badge-muted   { background: var(--secondary); color: var(--muted); }

/* ============ Tables ============ */

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th,
.table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.table th {
    background: #f8fafc;
    color: var(--muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.table tbody tr:nth-child(even) {
    background: #f8fafc;
}

.table tbody tr:hover {
    background: #eff6ff;
}

.table-vertical th {
    width: 220px;
    background: #f8fafc;
}

/* ============ Auth ============ */

.auth-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 200px);
}

.auth-card {
    width: 100%;
    max-width: 400px;
}

/* ============ Quota Management ============ */

.quota-month-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0;
}

.quota-month-label {
    font-size: 18px;
    font-weight: 600;
    min-width: 200px;
    text-align: center;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.quota-info {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
}

.row-selected td { background: #eff6ff; }

/* ============ Dashboard ============ */

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(0, 2fr);
    grid-template-areas:
        "quota bookings"
        "minical minical";
    gap: 20px;
}

@media (max-width: 680px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        grid-template-areas:
            "quota"
            "bookings"
            "minical";
    }
}

.quota-widget   { grid-area: quota; }
.bookings-widget { grid-area: bookings; min-width: 0; overflow-x: auto; }
.mini-cal-card  { grid-area: minical; }

.quota-widget .quota-big {
    font-size: 34px;
    font-weight: 700;
    margin: 8px 0 12px;
    color: var(--primary);
}

.quota-widget .quota-big .muted {
    font-size: 14px;
    color: var(--muted);
    font-weight: 400;
    margin-left: 6px;
}

.progress {
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
    height: 10px;
    margin: 8px 0;
}

.progress-bar {
    background: var(--primary);
    height: 100%;
    transition: width .25s;
}

.mini-cal {
    background: #f8fafc;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    margin-bottom: 10px;
}

.mini-cal-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: 4px;
}

.mini-cal-dow {
    font-size: 11px;
    color: var(--muted);
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.mini-cal-body {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.mini-cal-day {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 4px;
    height: 44px;
    padding: 4px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    font-size: 12px;
}

.mini-cal-day.empty {
    background: transparent;
    border-color: transparent;
}

.mini-cal-day.today {
    border-color: var(--primary);
}

.mini-cal-day.has-bookings {
    background: #dbeafe;
    border-color: #93c5fd;
}

.mini-cal-count {
    font-size: 10px;
    background: var(--primary);
    color: #fff;
    padding: 1px 5px;
    border-radius: 999px;
}

.mini-cal-num {
    font-weight: 500;
}

/* ============ Calendar ============ */

.cal-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.cal-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.cal-view-toggle {
    display: flex;
    gap: 4px;
}

.cal-title {
    font-weight: 600;
    margin-left: 8px;
}

.cal-filter {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 12px;
    background: #f8fafc;
    border-radius: 6px;
    margin-bottom: 16px;
}

.cal-filter label {
    color: var(--text);
    display: flex;
    flex-direction: column;
    font-size: 12px;
}

.cal-month-header,
.cal-month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.cal-dow {
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    text-align: center;
    padding: 4px 0;
}

.cal-month-grid {
    grid-auto-rows: minmax(96px, auto);
}

.cal-cell {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12px;
    min-height: 90px;
}

.cal-cell.out-of-month {
    background: #f8fafc;
    color: var(--muted);
}

.cal-cell.today {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.cal-cell-head {
    font-weight: 600;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 2px;
}

.cal-event {
    display: block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: var(--primary);
}

.cal-event.busy {
    background: var(--muted);
}

.cal-event.own {
    background: var(--success);
}

.cal-event.admin {
    background: var(--primary);
}

.cal-event:hover {
    opacity: .9;
    text-decoration: none;
    color: #fff;
}

.cal-event-more {
    font-size: 11px;
    color: var(--muted);
    padding: 2px 4px;
}

/* week/day time grid */
.cal-time-grid {
    display: flex;
    align-items: stretch;
    min-width: 700px;
}

.cal-time-grid.day {
    min-width: 500px;
}

.cal-hour-col {
    flex: 0 0 60px;
    background: #f8fafc;
    border-right: 1px solid var(--border);
}

.cal-hour {
    height: 40px;
    padding: 2px 6px;
    font-size: 11px;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
}

.cal-corner {
    height: 32px;
    border-bottom: 1px solid var(--border);
}

.cal-day-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    position: relative;
}

.cal-day-head {
    height: 32px;
    padding: 4px 6px;
    font-size: 12px;
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}

.cal-day-head.today {
    color: var(--primary);
    background: #eff6ff;
}

.cal-day-body {
    position: relative;
    height: calc(24 * 40px);
    background: #fff;
}

.cal-slot {
    position: absolute;
    left: 0;
    right: 0;
    height: 40px;
    border-bottom: 1px dashed var(--border);
}

.cal-booking {
    position: absolute;
    left: 2px;
    right: 2px;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 11px;
    line-height: 1.2;
    overflow: hidden;
    z-index: 2;
}

.cal-booking.own {
    background: var(--success);
}

.cal-booking.busy {
    background: var(--muted);
}

.cal-booking.admin {
    background: var(--primary);
}

.cal-booking:hover {
    color: #fff;
    opacity: .92;
    text-decoration: none;
}

.cal-legend {
    display: flex;
    gap: 12px;
    margin-top: 12px;
    font-size: 12px;
    color: var(--muted);
}

.cal-legend-item::before {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 5px;
    vertical-align: middle;
}

.cal-legend-item.own::before {
    background: var(--success);
}

.cal-legend-item.busy::before {
    background: var(--muted);
}

.cal-legend-item.admin::before {
    background: var(--primary);
}


.quick-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin: 12px 0;
}

/* ============ Filter/inline forms ============ */

.filter-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-end;
    background: #f8fafc;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 16px;
}

.filter-bar .form-group {
    margin-bottom: 0;
}

.inline-form {
    display: flex;
    gap: 4px;
    align-items: center;
}

.inline-form input[type="text"] {
    padding: 4px 6px;
    font-size: 12px;
    width: 140px;
}

.cancel-form {
    background: #fef2f2;
    border: 1px solid #fecaca;
    padding: 12px;
    border-radius: 6px;
    margin-top: 16px;
}

/* ============ Footer ============ */

.footer {
    margin-top: 40px;
    padding: 16px;
    border-top: 1px solid var(--border);
    background: var(--surface);
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

/* ============ Responsive ============ */

@media (max-width: 720px) {
    .nav-toggle {
        display: inline-block;
    }
    .nav-links {
        display: none;
        flex-direction: column;
        align-items: flex-start;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: #fff;
        border-bottom: 1px solid var(--border);
        padding: 12px 16px;
        gap: 8px;
    }
    .nav-links.open {
        display: flex;
    }
    .nav-sep {
        display: none;
    }
    .container {
        padding: 0 10px;
    }
    .card {
        padding: 14px;
    }
    .cal-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .cal-month-grid {
        grid-auto-rows: minmax(70px, auto);
    }
    .cal-cell {
        min-height: 70px;
    }
    .table th,
    .table td {
        padding: 6px 8px;
        font-size: 13px;
    }
}
