/* =============================================================================
   Reitverein Bad Windsheim – Stylesheet
   Farben:  Dunkelgruen #1D4D48 · Gelb #FFDE59
   ========================================================================== */

:root {
    --green:        #1D4D48;
    --green-dark:   #163b37;
    --green-darker: #102b28;
    --yellow:       #FFDE59;
    --yellow-soft:  #FFF3B0;
    --bg:           #F7F6F0;
    --text:         #172B29;
    --text-muted:   #5b6b68;
    --card:         #ffffff;
    --border:       #e4e2d8;

    --success:      #2E7D32;
    --success-bg:   #E8F5E9;
    --open-bg:      #FFF8D6;
    --open-border:  #f0d97a;
    --error:        #B3261E;
    --error-bg:     #fbe9e7;

    --whatsapp:     #25D366;

    --radius:    16px;
    --radius-sm: 10px;
    --shadow:    0 2px 10px rgba(23, 43, 41, 0.08);
    --shadow-lg: 0 6px 24px rgba(23, 43, 41, 0.14);

    --nav-height: 64px;
    --header-height: 60px;
    --maxw: 720px;

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

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 16px;
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
}

code {
    background: #eceadf;
    padding: 1px 6px;
    border-radius: 6px;
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 0.9em;
}

.hidden { display: none !important; }
.muted  { color: var(--text-muted); }

/* =========================== Buttons ==================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: var(--radius-sm);
    padding: 13px 18px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.1;
    transition: background .15s, transform .05s, box-shadow .15s, opacity .15s;
    -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn svg { flex: 0 0 auto; }

.btn-primary   { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-primary:disabled { background: #a9b6b3; cursor: not-allowed; opacity: .8; }

.btn-secondary { background: var(--yellow); color: var(--green-darker); }
.btn-secondary:hover { background: #ffd633; }

.btn-ghost {
    background: transparent;
    color: var(--green);
    border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: #efeee5; }

.btn-danger      { background: var(--error); color: #fff; }
.btn-danger:hover{ background: #911c16; }
.btn-danger-ghost{ color: var(--error); border-color: #e6bcb8; }
.btn-danger-ghost:hover { background: var(--error-bg); }

.btn-whatsapp { background: var(--whatsapp); color: #fff; }
.btn-whatsapp:hover { background: #1fbe5a; }
.btn-whatsapp:disabled { background: #bfe6cd; color: #eafff2; cursor: not-allowed; }

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

.btn-block { width: 100%; }
.btn-lg    { padding: 16px 20px; font-size: 17px; }
.btn-sm    { padding: 9px 12px; font-size: 14px; border-radius: 8px; }

/* =========================== Auth-Seiten =============================== */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--green) 0%, var(--green-darker) 100%);
    padding: 24px 16px;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 28px 24px 30px;
}
.auth-logo {
    width: 130px;
    height: 130px;
    margin: 0 auto 12px;
    background: var(--green);
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.auth-logo img { width: 100%; height: 100%; object-fit: contain; }
.auth-title    { text-align: center; margin: 6px 0 2px; font-size: 24px; color: var(--green); }
.auth-subtitle { text-align: center; margin: 0 0 18px; color: var(--text-muted); }

/* =========================== Formulare ================================= */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-weight: 600; font-size: 14px; color: var(--text); }
.field-label-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.field-inline { flex: 1; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="date"],
input[type="search"],
select {
    width: 100%;
    padding: 13px 14px;
    font-size: 16px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(29, 77, 72, .12);
}
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%231D4D48' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}
.search-input { margin-bottom: 6px; }

.checkbox-field {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    cursor: pointer;
    user-select: none;
}
.checkbox-field.small { font-size: 14px; color: var(--text-muted); margin: 8px 0; }
.checkbox-field input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--green); }

.form-row { display: flex; gap: 12px; }
.form-row .field { flex: 1; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* =========================== Alerts ==================================== */
.alert {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    font-size: 15px;
    border: 1px solid transparent;
}
.alert-error   { background: var(--error-bg);   color: var(--error);   border-color: #eebfba; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: #b6dfba; }
.alert-warning { background: var(--open-bg);    color: #8a6d0d;        border-color: var(--open-border); }

/* =========================== App-Kopf ================================== */
.app-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--green);
    color: #fff;
    box-shadow: var(--shadow);
    padding-top: env(safe-area-inset-top);
}
.app-header-inner {
    max-width: var(--maxw);
    margin: 0 auto;
    height: var(--header-height);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
}
.app-logo {
    width: 40px; height: 40px;
    object-fit: contain;
    background: #fff;
    border-radius: 10px;
    padding: 3px;
    flex: 0 0 auto;
}
.app-titles { display: flex; flex-direction: column; line-height: 1.15; flex: 1; min-width: 0; }
.app-title { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-subtitle { font-size: 12px; color: var(--yellow); }
.header-logout {
    color: #fff; background: rgba(255,255,255,.12);
    width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex: 0 0 auto;
}
.header-logout:hover { background: rgba(255,255,255,.22); }

/* =========================== Hauptbereich ============================== */
.app-main {
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 16px 16px calc(var(--nav-height) + 28px + env(safe-area-inset-bottom));
}
.view-title { font-size: 20px; margin: 4px 0 14px; color: var(--green-darker); }

/* =========================== Karten =================================== */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-title { font-size: 16px; margin: 0; color: var(--green-darker); }

/* =========================== Reitlehrer-Auswahl ======================= */
.instructor-picker { display: flex; flex-wrap: wrap; gap: 10px; }
.instructor-chip {
    flex: 1 1 auto;
    min-width: 44%;
    padding: 16px 14px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    background: #fff;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    text-align: center;
    transition: all .12s;
}
.instructor-chip:hover { border-color: var(--green); }
.instructor-chip.selected {
    background: var(--green);
    border-color: var(--green);
    color: #fff;
    box-shadow: var(--shadow);
}

/* =========================== Reiter-Auswahl (Karten) ================== */
.counter-badge {
    background: var(--yellow-soft);
    color: var(--green-darker);
    font-size: 13px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
}
.rider-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 8px;
}
.rider-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 12px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    background: #fff;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    transition: all .12s;
    user-select: none;
}
.rider-chip:hover { border-color: var(--green); }
.rider-chip.selected {
    background: var(--success-bg);
    border-color: var(--success);
    color: var(--success);
    font-weight: 600;
}
.rider-chip .check {
    width: 22px; height: 22px; border-radius: 6px;
    border: 2px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    flex: 0 0 auto;
    background: #fff;
}
.rider-chip.selected .check { background: var(--success); border-color: var(--success); }
.rider-chip.selected .check svg { display: block; }
.rider-chip .check svg { display: none; width: 14px; height: 14px; stroke: #fff; }

/* =========================== Save-Bar ================================= */
.save-bar { margin: 4px 0 18px; }

/* =========================== Letzte Eintraege ========================= */
.recent-list, .manage-list { display: flex; flex-direction: column; gap: 8px; }
.recent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 11px 12px;
    background: #fbfaf5;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.recent-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.recent-name { font-weight: 600; font-size: 15px; }
.recent-meta { font-size: 13px; color: var(--text-muted); }
.recent-right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.recent-amount { font-weight: 700; color: var(--green); font-size: 14px; }
.icon-btn {
    border: 0; background: transparent; cursor: pointer;
    width: 34px; height: 34px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: var(--error);
}
.icon-btn:hover { background: var(--error-bg); }
.icon-btn:disabled { color: #bbb; cursor: not-allowed; }
.recent-locked { font-size: 12px; color: var(--text-muted); font-style: italic; }

/* =========================== Quartalsansicht ========================== */
.quarter-selectors { display: flex; gap: 12px; }
#quarter-status-bar { margin-top: 10px; }
.status-pill {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 13px; font-weight: 700;
    padding: 5px 12px; border-radius: 999px;
}
.status-pill.open   { background: var(--open-bg);    color: #8a6d0d; }
.status-pill.closed { background: var(--green); color: #fff; }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
.summary-card {
    background: var(--card);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    padding: 14px;
}
.summary-card .label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.summary-card .value { font-size: 22px; font-weight: 800; color: var(--green-darker); margin-top: 3px; }
.summary-card.highlight { background: var(--green); }
.summary-card.highlight .label { color: var(--yellow); }
.summary-card.highlight .value { color: #fff; }
.summary-card.paid  .value { color: var(--success); }
.summary-card.open  .value { color: #b58a0d; }

.quarter-actions { display: flex; flex-direction: column; gap: 10px; }

/* Reiterkarten in der Quartalsansicht */
.quarter-riders { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.qrider {
    background: var(--open-bg);
    border: 1.5px solid var(--open-border);
    border-radius: var(--radius);
    padding: 14px;
    transition: background .15s, border-color .15s;
}
.qrider.paid {
    background: var(--success-bg);
    border-color: #b6dfba;
}
.qrider-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.qrider-name { font-weight: 700; font-size: 16px; }
.qrider-sub  { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.qrider-amount { font-size: 20px; font-weight: 800; color: var(--green-darker); white-space: nowrap; }
.qrider-status {
    display: inline-block; margin-top: 6px;
    font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
}
.qrider-status.st-open { background: #f6e6a8; color: #8a6d0d; }
.qrider-status.st-paid { background: var(--success); color: #fff; }
.qrider-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.qrider-actions .btn { flex: 1 1 auto; }
.qrider-actions .btn-sm { min-width: 0; }
.qrider-detail-btn {
    background: transparent; border: 0; color: var(--green);
    font-size: 13px; font-weight: 600; cursor: pointer; padding: 6px 0 0;
    text-decoration: underline;
}
.qrider-locked-note { font-size: 12px; color: var(--text-muted); margin-top: 8px; font-style: italic; }

/* Reitlehrer-Zusammenfassung */
.ins-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 4px; border-bottom: 1px solid var(--border);
    font-size: 15px;
}
.ins-row:last-child { border-bottom: 0; }
.ins-row .ins-name { font-weight: 600; }
.ins-row .ins-vals { color: var(--text-muted); font-size: 14px; }
.ins-row .ins-amount { font-weight: 700; color: var(--green); }

/* =========================== Verwaltungslisten ======================== */
.manage-item {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: #fbfaf5;
}
.manage-item.inactive { opacity: .62; }
.manage-info { min-width: 0; }
.manage-name { font-weight: 600; font-size: 15px; }
.manage-meta { font-size: 13px; color: var(--text-muted); }
.manage-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.tag-inactive {
    display: inline-block; font-size: 11px; font-weight: 700;
    background: #e7e5da; color: #6b6b60; padding: 2px 8px; border-radius: 999px; margin-left: 6px;
}

/* =========================== Untere Navigation ======================== */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 50;
    background: #fff;
    border-top: 1px solid var(--border);
    display: flex;
    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 12px rgba(23,43,41,.06);
}
.nav-btn {
    flex: 1;
    border: 0; background: transparent; cursor: pointer;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px;
    color: var(--text-muted);
    font-size: 11px; font-weight: 600;
    font-family: inherit;
    padding: 6px 2px;
    -webkit-tap-highlight-color: transparent;
}
.nav-btn svg { width: 24px; height: 24px; }
.nav-btn.active { color: var(--green); }
.nav-btn.active svg { stroke: var(--green); }

/* =========================== Toast ==================================== */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--nav-height) + 18px + env(safe-area-inset-bottom));
    transform: translateX(-50%) translateY(20px);
    background: var(--green-darker);
    color: #fff;
    padding: 13px 18px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    font-size: 15px;
    font-weight: 500;
    max-width: 90%;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s, transform .25s;
    z-index: 80;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error   { background: var(--error); }

/* =========================== Modal =================================== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(16, 27, 25, .55);
    display: flex; align-items: flex-end; justify-content: center;
    z-index: 90;
    padding: 0;
}
.modal {
    background: #fff;
    width: 100%;
    max-width: var(--maxw);
    border-radius: 20px 20px 0 0;
    max-height: 82vh;
    display: flex; flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: slideup .2s ease;
}
@keyframes slideup { from { transform: translateY(40px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 17px; color: var(--green-darker); }
.modal-close { border: 0; background: transparent; font-size: 28px; line-height: 1; cursor: pointer; color: var(--text-muted); width: 40px; height: 40px; }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.detail-row {
    display: flex; justify-content: space-between; gap: 10px;
    padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 15px;
}
.detail-row:last-child { border-bottom: 0; }
.detail-row .d-date { font-weight: 600; }
.detail-row .d-ins { color: var(--text-muted); }

/* =========================== Empty-States ============================= */
.empty-state {
    text-align: center; color: var(--text-muted);
    padding: 24px 12px; font-size: 15px;
}

/* =========================== Desktop-Anpassungen ====================== */
@media (min-width: 620px) {
    .rider-grid { grid-template-columns: repeat(3, 1fr); }
    .summary-grid { grid-template-columns: repeat(4, 1fr); }
    .instructor-chip { min-width: 30%; }
}
@media (min-width: 900px) {
    .app-main { padding-bottom: 40px; }
}

/* =============================================================================
   QUARTALSBERICHT  (report.php)
   ========================================================================== */
.report-body { background: #fff; color: #000; }
.report-toolbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    background: var(--green); color: #fff;
    padding: 12px 16px;
    box-shadow: var(--shadow);
}
.report-toolbar-hint { flex: 1; font-size: 14px; min-width: 200px; }
.report-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 28px 32px 40px;
}
.report-header {
    display: flex; align-items: center; gap: 20px;
    border-bottom: 3px solid var(--green);
    padding-bottom: 16px; margin-bottom: 14px;
}
.report-logo {
    width: 96px; height: 96px; object-fit: contain;
    background: var(--green); border-radius: 12px; padding: 5px;
    flex: 0 0 auto;
}
.report-heading h1 { margin: 0 0 2px; font-size: 22px; color: var(--green); }
.report-heading h2 { margin: 0 0 6px; font-size: 16px; font-weight: 600; color: #333; }
.report-period { margin: 0; font-size: 14px; color: #333; }
.report-meta {
    display: flex; flex-wrap: wrap; gap: 8px 22px;
    font-size: 13px; color: #444; margin-bottom: 18px;
}
.report-closed-badge {
    background: var(--green); color: #fff; padding: 2px 10px; border-radius: 999px; font-weight: 700;
}
.report-empty { padding: 30px 0; text-align: center; color: #555; font-size: 15px; }

.report-table {
    width: 100%; border-collapse: collapse; margin-bottom: 14px; font-size: 14px;
}
.report-table th, .report-table td {
    padding: 8px 10px; border-bottom: 1px solid #ddd; text-align: left;
}
.report-table thead th {
    background: var(--green); color: #fff; font-weight: 700;
    border-bottom: 2px solid var(--green);
}
.report-table tbody tr:nth-child(even) { background: #f6f5ee; }
.report-table .col-num    { width: 40px; text-align: center; color: #666; }
.report-table .col-center { text-align: center; }
.report-table .col-right  { text-align: right; white-space: nowrap; }
.report-table .col-status { width: 90px; }
.report-inactive { color: #999; font-size: 12px; }
.report-paid { color: var(--success); font-weight: 700; }
.report-open { color: #b07d00; font-weight: 700; }
.report-sum-row td { font-weight: 800; background: #eceadf !important; border-top: 2px solid var(--green); }
.report-table-compact { max-width: 480px; }

.report-total-box {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--yellow); color: var(--green-darker);
    padding: 16px 20px; border-radius: 10px; margin: 6px 0 22px;
    border: 2px solid #e9c831;
}
.report-total-label { font-size: 16px; font-weight: 700; }
.report-total-value { font-size: 24px; font-weight: 900; }

.report-subheading { font-size: 16px; color: var(--green); margin: 20px 0 8px; }
.report-payment-summary {
    display: flex; flex-wrap: wrap; gap: 6px 26px;
    font-size: 13px; color: #444;
    border-top: 1px solid #ddd; padding-top: 12px; margin-top: 18px;
}
.report-footer { margin-top: 26px; font-size: 12px; color: #666; border-top: 1px solid #ddd; padding-top: 12px; }
.report-footer p { margin: 4px 0; }
.report-generated { color: #999; }

/* ---------------------------- Print ---------------------------------- */
@media print {
    @page { size: A4; margin: 16mm 14mm; }
    html, body { background: #fff !important; }
    .no-print { display: none !important; }
    .report-page { max-width: none; margin: 0; padding: 0; }
    .report-header { break-inside: avoid; }
    .report-total-box { break-inside: avoid; }
    .report-table { break-inside: auto; }
    .report-table thead { display: table-header-group; } /* Kopf auf Folgeseiten wiederholen */
    .report-table tfoot { display: table-footer-group; }
    .report-table tr    { break-inside: avoid; page-break-inside: avoid; }
    .report-subheading, .report-payment-summary, .report-footer { break-inside: avoid; }
    .report-table thead th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .report-total-box, .report-closed-badge, .report-paid, .report-sum-row td {
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
    .report-logo { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
