/* ==========================================================================
   Onlineanmeldung – zentrales Stylesheet
   Wird von layouts/app.blade.php und layouts/auth.blade.php eingebunden.
   Farben orientieren sich am RaceTime-PRO-Logo.
   ========================================================================== */

:root {
    --brand: #064c96;
    --brand-dark: #043b75;
    --brand-soft: #e7eef7;
    --accent: #f3e400;

    --ink: #2d2b2d;
    --ink-light: #3d3a3d;
    --ink-muted: #b9b6b9;

    --bg: #f2f4f7;
    --card: #ffffff;
    --text: #23262b;
    --muted: #667085;
    --border: #dfe3e8;
    --row-hover: #f7f9fb;

    --danger: #c8102e;
    --danger-soft: #fdecee;
    --success: #1f7a3a;
    --success-soft: #e8f5ec;
    --excel: #1d6f42;

    --radius: 6px;
    --radius-lg: 10px;

    --font: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-head: 'Barlow Semi Condensed', 'Barlow', system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.45;
    background: var(--bg);
    color: var(--text);
}

a { color: var(--brand); }

h1, h2, h3 {
    font-family: var(--font-head);
    font-weight: 600;
    line-height: 1.2;
}

h1 { margin: 0 0 20px; font-size: 28px; }
h2 { margin: 28px 0 12px; font-size: 21px; }
h3 { margin: 20px 0 10px; font-size: 17px; }

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 28px 0;
}

.text-muted   { color: var(--muted); }
.text-danger  { color: var(--danger); font-weight: 500; }
.text-success { color: var(--success); font-weight: 500; }

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

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--ink);
    color: #fff;
    height: 100vh;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 22px 24px 18px;
    font-family: var(--font-head);
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.content {
    flex: 1;
    min-width: 0;
    padding: 32px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

/* ---------- Navigation ---------------------------------------------------- */

.nav { flex: 1; overflow-y: auto; }

.nav a,
.nav-dropdown-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 11px 24px;
    border: 0;
    border-left: 3px solid transparent;
    background: none;
    color: var(--ink-muted);
    font: inherit;
    font-size: 15px;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}

.nav a:hover,
.nav-dropdown-toggle:hover {
    background: var(--ink-light);
    color: #fff;
}

.nav a.active {
    border-left-color: var(--accent);
    background: var(--ink-light);
    color: #fff;
    font-weight: 500;
}

.nav-dropdown-menu {
    display: none;
    background: rgba(0, 0, 0, 0.18);
}

.nav-dropdown.open .nav-dropdown-menu { display: block; }

.nav-dropdown-menu a {
    padding: 9px 24px 9px 40px;
    font-size: 14px;
}

.caret { transition: transform 0.15s ease; }
.nav-dropdown.open .caret { transform: rotate(180deg); }

.sidebar-footer {
    border-top: 1px solid var(--ink-light);
    padding: 16px 20px;
    font-size: 14px;
}

.sidebar-footer .user-name {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
}

.sidebar-footer-row {
    display: flex;
    gap: 8px;
}

.logout-form {
    flex: 1;
    display: flex;
    margin: 0;
}

.sidebar-footer .btn-logout {
    flex: 1;
    justify-content: center;
    background: var(--ink-light);
    color: #fff;
}

.sidebar-footer .btn-logout:hover { background: #4d4a4d; }

.lang-btn {
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    color: var(--ink-muted);
    background: var(--ink-light);
}

.lang-btn:hover { color: #fff; }

.lang-btn.active {
    background: var(--accent);
    color: var(--ink);
}

/* ---------- Seitenkopf / Toolbar ----------------------------------------- */

.page-header,
.header-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.page-header h1,
.page-header h2 { margin: 0 auto 0 0; }

.search-form {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.page-header .search-form { margin-left: 0; }

.search-form input { width: 240px; }
.search-form input[type="date"] { width: auto; }

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

.btn,
.btn-save,
.btn-cancel,
.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 14px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: var(--brand);
    color: #fff;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.btn:hover,
.btn-primary:hover { background: var(--brand-dark); }

.btn-primary { background: var(--brand); }

.btn-secondary,
.btn-cancel {
    background: #fff;
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover,
.btn-cancel:hover {
    background: var(--row-hover);
    border-color: #c5cbd3;
}

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #a50d26; }

.btn-save,
.btn-success { background: var(--success); }
.btn-save:hover,
.btn-success:hover { background: #18622e; }

/* Export-Buttons bewusst ruhig, nur das Icon trägt die Farbe (PDF rot, Excel grün) */
.btn-pdf,
.btn-excel {
    background: #fff;
    border-color: var(--border);
}

.btn-pdf   { color: var(--danger); }
.btn-excel { color: var(--excel); }

.btn-pdf:hover,
.btn-excel:hover {
    background: var(--row-hover);
    border-color: #c5cbd3;
}

.btn-icon {
    width: 34px;
    min-height: 34px;
    padding: 0;
    justify-content: center;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn:disabled,
.btn-save:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-group {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.btn-group form { margin: 0; }

.icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

/* ---------- Formulare ----------------------------------------------------- */

input,
select,
textarea {
    width: 100%;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    font: inherit;
    font-size: 14px;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}

input[type="checkbox"],
input[type="radio"] {
    width: auto;
    min-height: 0;
    accent-color: var(--brand);
}

input[type="file"] {
    padding: 6px;
    background: var(--row-hover);
}

label {
    display: inline-block;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
}

.form-group { margin-bottom: 16px; }

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.form-checkbox-inline { align-self: center; }

.form-checkbox label {
    margin: 0;
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
}

.checkbox-grid {
    grid-column: span 2;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px 16px;
    margin-top: 8px;
}

.event-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 32px;
}

.event-form-grid h3 {
    grid-column: span 2;
    margin: 24px 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    font-size: 16px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* ---------- Meldungen ----------------------------------------------------- */

.alert {
    margin-bottom: 20px;
    padding: 12px 16px;
    border: 1px solid;
    border-radius: var(--radius);
    font-size: 14px;
}

.alert ul { margin: 6px 0 0; padding-left: 20px; }

.alert-success {
    background: var(--success-soft);
    border-color: #b7dcc3;
    color: #17552a;
}

.alert-error {
    background: var(--danger-soft);
    border-color: #f2b8c1;
    color: #8f0b21;
}

/* ---------- Tabellen ------------------------------------------------------ */

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    font-variant-numeric: tabular-nums;
}

th,
td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 14px;
    vertical-align: middle;
}

th {
    background: var(--row-hover);
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

tbody tr:hover { background: var(--row-hover); }

td.nowrap,
th.nowrap { white-space: nowrap; }

.empty-row td {
    padding: 28px 12px;
    color: var(--muted);
    text-align: center;
}

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

.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger  { background: var(--danger-soft); color: var(--danger); }
.badge-neutral { background: var(--bg); color: var(--muted); }

/* ---------- Pagination ---------------------------------------------------- */

.pagination-bar,
.pagination-wrapper {
    display: flex;
    justify-content: flex-end;
    margin-top: 20px;
}

.pagination {
    display: flex;
    gap: 4px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.pagination li a,
.pagination li span {
    display: block;
    min-width: 34px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--brand);
    font-size: 14px;
    text-align: center;
    text-decoration: none;
}

.pagination li a:hover { background: var(--brand-soft); }

.pagination li.active span {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    font-weight: 600;
}

.pagination li.disabled span {
    color: #a3aab5;
    cursor: default;
}

/* ---------- Modals -------------------------------------------------------- */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    background: rgba(20, 24, 31, 0.55);
}

.modal-box {
    width: 700px;
    max-width: 95%;
    max-height: 90vh;
    overflow: auto;
    padding: 24px;
    border-radius: var(--radius-lg);
    background: #fff;
}

.modal-form {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 15px;
}

.modal-form-submit { align-self: end; }

.modal-results {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

/* ---------- Aufklappbare Bereiche (Einstellungen, Spaltenauswahl) -------- */

.settings-box,
.column-settings {
    margin-bottom: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--row-hover);
}

.settings-box > summary,
.column-settings > summary {
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.settings-box[open] > summary,
.column-settings[open] > summary { border-bottom: 1px solid var(--border); }

.settings-box > .event-form-grid { padding: 16px; }

.column-settings > summary { list-style: none; }
.column-settings > summary::-webkit-details-marker { display: none; }

.column-settings-body { padding: 16px; }

.column-settings-hint {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--muted);
}

.column-settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 8px 16px;
}

.column-settings-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: inherit;
    font-size: 13px;
    cursor: pointer;
}

.column-settings-item input { margin: 0; }

.column-settings-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

/* ---------- Logs ---------------------------------------------------------- */

.log-time {
    width: 180px;
    color: var(--muted);
    white-space: nowrap;
}

/* ---------- Login / Passwort vergessen ------------------------------------ */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    border-top: 4px solid var(--brand);
}

.auth-logo {
    display: block;
    width: 180px;
    max-width: 70%;
    margin: 4px auto 24px;
}

.auth-card h1 {
    font-size: 24px;
    text-align: center;
}

.auth-links {
    margin-top: 16px;
    font-size: 14px;
    text-align: center;
}

/* ---------- Mobile -------------------------------------------------------- */

.burger-btn {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 1200;
    padding: 8px 10px;
    border: 0;
    border-radius: var(--radius);
    background: var(--ink);
    color: #fff;
    cursor: pointer;
}

.burger-btn .icon { width: 22px; height: 22px; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(0, 0, 0, 0.4);
}

@media (max-width: 960px) {
    .sidebar {
        position: fixed;
        left: 0;
        z-index: 1201;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.active { display: block; }
    .burger-btn { display: block; }

    .content { padding: 72px 16px 16px; }
    .card { padding: 18px; }

    .search-form { width: 100%; margin-left: 0; }
    .search-form input { flex: 1; width: auto; }

    .event-form-grid,
    .modal-form { grid-template-columns: 1fr; }

    .event-form-grid h3,
    .checkbox-grid { grid-column: auto; }

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

    /* Tabellen werden auf kleinen Bildschirmen zu Karten */
    table thead { display: none; }

    table,
    table tbody,
    table tr {
        display: block;
        width: 100%;
    }

    table tr {
        margin-bottom: 12px;
        padding: 10px 12px;
        border: 1px solid var(--border);
        border-radius: var(--radius-lg);
        background: #fff;
    }

    table td {
        display: block;
        padding: 4px 0;
        border: 0;
    }

    .col-name { font-weight: 600; }
    .col-actions,
    .col-export { padding-top: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
