/* ============================================================
   MOONLIGHT HILL - Zentrales Stylesheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Raleway:wght@300;400;500;600&display=swap');

:root {
    --navy:        #0d1b3e;
    --dark-blue:   #1a237e;
    --mid-blue:    #283593;
    --light-blue:  #e8eaf6;
    --ice-blue:    #f0f3ff;
    --accent:      #b0976a;        /* Gold-Ton passend zum Logo */
    --accent-dark: #8c7350;
    --red:         #c62828;
    --green:       #2e7d32;
    --admin:       #455a64;
    --text:        #1c2340;
    --text-muted:  #6b7280;
    --border:      #dde3f0;
    --white:       #ffffff;
    --bg:          #f0f2f8;
    --shadow-sm:   0 2px 8px rgba(13, 27, 62, 0.08);
    --shadow-md:   0 6px 24px rgba(13, 27, 62, 0.13);
    --shadow-lg:   0 16px 48px rgba(13, 27, 62, 0.18);
    --radius:      10px;
    --radius-lg:   16px;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Raleway', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.6;
}

/* ---- Seitenstruktur ---- */
.page-wrapper {
    max-width: 1100px;
    margin: 0 auto;
    padding: 30px 20px 60px;
}

/* ---- Logo & Header ---- */
.site-header {
    text-align: center;
    padding: 40px 20px 30px;
}

.site-header .logo {
    max-width: 260px;
    height: auto;
    margin-bottom: 8px;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.25));
}

.site-header h1,
.page-title {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    color: var(--dark-blue);
    font-size: 1.8em;
    letter-spacing: 3px;
    text-transform: uppercase;
}

.site-header .subtitle {
    font-size: 0.9em;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-top: 4px;
}

/* ---- Karten / Cards ---- */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 30px;
    margin-bottom: 28px;
    border: 1px solid var(--border);
}

.card-title {
    font-family: 'Cinzel', serif;
    font-size: 1.1em;
    color: var(--dark-blue);
    border-bottom: 2px solid var(--light-blue);
    padding-bottom: 12px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 10px 20px;
    border-radius: var(--radius);
    border: none;
    font-family: 'Raleway', sans-serif;
    font-weight: 600;
    font-size: 0.9em;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
}

.btn-primary { background: var(--dark-blue); color: var(--white); }
.btn-primary:hover { background: var(--mid-blue); box-shadow: var(--shadow-sm); transform: translateY(-1px); }

.btn-accent { background: var(--accent); color: var(--white); }
.btn-accent:hover { background: var(--accent-dark); }

.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover { background: #a31515; }

.btn-secondary { background: var(--admin); color: var(--white); }
.btn-secondary:hover { background: #37474f; }

.btn-ghost {
    background: transparent;
    color: var(--dark-blue);
    border: 2px solid var(--border);
}
.btn-ghost:hover { border-color: var(--dark-blue); background: var(--ice-blue); }

.btn-sm { padding: 6px 13px; font-size: 0.82em; }
.btn-full { width: 100%; justify-content: center; margin-top: 8px; }

/* ---- Navigation / Toolbar ---- */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 28px;
}

.toolbar-group { display: flex; gap: 10px; align-items: center; }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--dark-blue);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9em;
    transition: color 0.2s;
    margin-bottom: 20px;
}
.back-link:hover { color: var(--accent); }

/* ---- Formulare ---- */
.form-group { margin-bottom: 18px; }

label {
    display: block;
    font-weight: 600;
    font-size: 0.85em;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: 'Raleway', sans-serif;
    font-size: 0.95em;
    color: var(--text);
    background: #fafbff;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--dark-blue);
    box-shadow: 0 0 0 3px rgba(26, 35, 126, 0.1);
    background: var(--white);
}

textarea { resize: vertical; min-height: 80px; }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    font-size: 0.95em;
    cursor: pointer;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text);
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.checkbox-group .checkbox-label {
    background: var(--ice-blue);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border);
    transition: all 0.15s;
}
.checkbox-group .checkbox-label:hover { border-color: var(--dark-blue); background: var(--light-blue); }

/* ---- Tabellen ---- */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.data-table thead th {
    background: var(--navy);
    color: rgba(255,255,255,0.8);
    font-family: 'Cinzel', serif;
    font-weight: 600;
    font-size: 0.78em;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 12px 14px;
    text-align: left;
}

.data-table thead th:first-child { border-radius: var(--radius) 0 0 0; }
.data-table thead th:last-child { border-radius: 0 var(--radius) 0 0; }

.data-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.data-table tbody tr:hover { background: var(--ice-blue); }

.data-table tbody td {
    padding: 11px 14px;
    vertical-align: top;
}

/* ---- Meldungen / Alerts ---- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-weight: 600;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: #e8f5e9; color: #1b5e20; border: 1px solid #a5d6a7; }
.alert-error   { background: #ffebee; color: #b71c1c; border: 1px solid #ef9a9a; }
.alert-info    { background: var(--light-blue); color: var(--dark-blue); border: 1px solid #9fa8da; }
.alert-warning { background: #fff8e1; color: #e65100; border: 1px solid #ffcc80; }

/* ---- Badge / Tags ---- */
.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 0.75em;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.badge-blue   { background: var(--light-blue); color: var(--dark-blue); }
.badge-green  { background: #e8f5e9; color: var(--green); }
.badge-red    { background: #ffebee; color: var(--red); }
.badge-orange { background: #fff3e0; color: #e65100; }
.badge-grey   { background: #eceff1; color: var(--admin); }

/* ---- Statusfarben ---- */
.status-ok      { color: var(--green); font-weight: 600; }
.status-soon    { color: #e65100; font-weight: 600; }
.status-overdue { color: var(--red); font-weight: 700; }

/* ---- Trennlinie ---- */
hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}

/* ---- Login-Seite ---- */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, var(--navy) 0%, #1a237e 60%, #283593 100%);
}

.login-box {
    background: var(--white);
    padding: 44px 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-box .logo { max-width: 180px; margin-bottom: 20px; }

.login-box h2 {
    font-family: 'Cinzel', serif;
    color: var(--dark-blue);
    font-size: 1.1em;
    letter-spacing: 2px;
    margin-bottom: 28px;
    text-transform: uppercase;
}

/* ---- Portal Grid ---- */
.portal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    width: 90%;
    max-width: 900px;
    margin: 0 auto 40px;
}

.portal-card {
    background: var(--white);
    padding: 36px 20px;
    border-radius: var(--radius-lg);
    text-align: center;
    text-decoration: none;
    color: var(--dark-blue);
    box-shadow: var(--shadow-sm);
    border: 2px solid transparent;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    font-size: 1em;
    transition: all 0.25s ease;
    letter-spacing: 0.5px;
}

.portal-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--dark-blue);
}

.portal-card .card-icon {
    font-size: 2.4em;
    display: block;
    margin-bottom: 12px;
}

.portal-card.admin-card {
    background: #f8f9fa;
    border-color: var(--admin);
    border-style: dashed;
    color: var(--admin);
}

.portal-card.admin-card:hover { border-style: solid; }

/* ---- Kalender ---- */
.calendar-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.calendar-month {
    font-family: 'Cinzel', serif;
    font-size: 1.3em;
    font-weight: 700;
    color: var(--dark-blue);
    min-width: 180px;
    text-align: center;
}

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

.weekday-header {
    background: var(--navy);
    color: rgba(255,255,255,0.7);
    padding: 10px;
    text-align: center;
    font-size: 0.75em;
    font-family: 'Cinzel', serif;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.cal-day {
    background: var(--white);
    min-height: 100px;
    padding: 8px;
}

.cal-day.today { background: #fffde7; }
.cal-day.empty { background: #f8f9fb; }

.day-num {
    font-weight: 700;
    color: #b0bec5;
    font-size: 1em;
    display: block;
    margin-bottom: 4px;
}

.cal-day.today .day-num { color: var(--dark-blue); }

.event-box {
    background: var(--light-blue);
    border-left: 3px solid var(--dark-blue);
    color: var(--dark-blue);
    font-size: 0.78em;
    padding: 5px 7px;
    margin-top: 4px;
    border-radius: 4px;
    line-height: 1.3;
}

.event-box.own {
    background: #e8f5e9;
    border-left-color: var(--green);
    color: #1b5e20;
}

/* ---- Pferde-Karte ---- */
.horse-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 25px;
    margin-bottom: 28px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    border-top: 4px solid var(--dark-blue);
}

.horse-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

.horse-header h2 {
    font-family: 'Cinzel', serif;
    color: var(--dark-blue);
    font-size: 1.3em;
}

.next-vax {
    color: var(--red);
    font-weight: 700;
    font-size: 0.9em;
}

.admin-form-section {
    background: var(--ice-blue);
    border: 1px dashed var(--admin);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 18px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
    align-items: end;
}

/* ---- Impfübersicht Filter ---- */
.filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 20px;
}

.filter-btn {
    text-decoration: none;
    padding: 7px 16px;
    border-radius: 20px;
    background: var(--ice-blue);
    color: var(--text-muted);
    font-size: 0.85em;
    font-weight: 600;
    transition: all 0.2s;
    border: 1.5px solid transparent;
}

.filter-btn:hover  { background: var(--light-blue); color: var(--dark-blue); }
.filter-btn.active { background: var(--dark-blue); color: var(--white); border-color: var(--dark-blue); }

/* ---- Utility ---- */
.text-center  { text-align: center; }
.text-muted   { color: var(--text-muted); font-size: 0.85em; }
.mt-auto      { margin-top: auto; }
.link-danger  { color: var(--red); text-decoration: none; font-weight: 600; }
.link-danger:hover { text-decoration: underline; }
.link-edit    { color: var(--dark-blue); text-decoration: none; font-weight: 600; }
.link-edit:hover { text-decoration: underline; }

/* ---- Log Tabelle ---- */
.log-row-fail   { color: var(--red); background: #ffebee; }
.log-row-logout { color: var(--text-muted); }

/* ---- Trennlinie Dekorativ ---- */
.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--text-muted);
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.divider::before, .divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ---- Responsive ---- */

/* Tabellen: horizontales Scrollen auf kleinen Screens */
.table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
}

/* Kalender-Tage auf Mobile: Card-Darstellung */
@media (max-width: 768px) {

    /* Allgemein */
    body { font-size: 14px; }

    .page-wrapper { padding: 16px 12px 40px; }

    .site-header { padding: 20px 12px 16px; }
    .site-header .logo { max-width: 180px; }
    .site-header h1, .page-title { font-size: 1.3em; letter-spacing: 1px; }

    /* Cards */
    .card { padding: 16px; }
    .card-title { font-size: 1em; }

    /* Buttons: Touch-freundlicher */
    .btn { padding: 11px 16px; font-size: 0.88em; }
    .btn-sm { padding: 10px 14px; font-size: 0.82em; min-height: 40px; }
    .btn-full { padding: 14px; font-size: 1em; }

    /* Toolbar: Stacken */
    .toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
    .toolbar-group { flex-wrap: wrap; }

    /* Formulare */
    .form-row { grid-template-columns: 1fr; gap: 8px; }
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="date"],
    input[type="number"],
    textarea,
    select { font-size: 16px; /* Verhindert Auto-Zoom auf iOS */ padding: 12px 14px; }

    /* Login */
    .login-box { padding: 28px 20px; }
    .login-box h2 { font-size: 1em; }

    /* Portal Grid */
    .portal-grid {
        grid-template-columns: repeat(2, 1fr);
        width: 100%;
        gap: 12px;
    }
    .portal-card { padding: 24px 12px; font-size: 0.88em; }
    .portal-card .card-icon { font-size: 2em; }

    /* Kalender */
    .calendar-grid { grid-template-columns: repeat(7, 1fr); }
    .weekday-header { padding: 6px 2px; font-size: 0.6em; letter-spacing: 0; }
    .cal-day { min-height: 60px; padding: 4px; }
    .day-num { font-size: 0.85em; }
    .event-box { font-size: 0.65em; padding: 3px 4px; }
    .calendar-nav { flex-direction: column; gap: 10px; align-items: stretch; }
    .calendar-month { font-size: 1.1em; }

    /* Tabellen: horizontales Scrollen */
    .data-table { min-width: 480px; }
    .card:has(.data-table) { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 8px; }

    /* Paginierung */
    .pagination { gap: 4px; }
    .page-btn { padding: 8px 10px; font-size: 0.8em; }

    /* Filter-Bar */
    .filter-bar { gap: 6px; }
    .filter-btn { padding: 8px 12px; font-size: 0.82em; }

    /* Pferde-Karte */
    .horse-header { flex-direction: column; gap: 6px; }
    .horse-header h2 { font-size: 1.1em; }

    /* Systemlogs Stats */
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-box .stat-num { font-size: 1.6em; }

    /* Admin-Form in Pferde */
    .admin-form-section { padding: 12px; }

    /* Back-Link */
    .back-link { font-size: 0.9em; margin-bottom: 12px; }
}

/* ---- Kalender Mobile-Listenansicht (standardmäßig versteckt) ---- */
.cal-mobile-list { display: none; }

.cal-list-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.cal-list-row:last-child { border-bottom: none; }
.cal-list-row.today { background: #fffde7; margin: 0 -16px; padding: 12px 16px; border-radius: 6px; }

.cal-list-date {
    font-family: 'Cinzel', serif;
    font-size: 0.82em;
    font-weight: 700;
    color: var(--dark-blue);
    min-width: 120px;
    padding-top: 4px;
    flex-shrink: 0;
}

.cal-list-events {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
}

.cal-list-events .event-box {
    font-size: 0.88em;
    padding: 6px 10px;
    margin: 0;
}

.cal-list-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 24px 0;
    font-size: 0.9em;
}

/* Kalender: Grid mit Punkt-Indikator bei Terminen auf sehr kleinen Screens */
.cal-day.has-event .day-num::after {
    content: '';
    display: inline-block;
    width: 5px;
    height: 5px;
    background: var(--dark-blue);
    border-radius: 50%;
    margin-left: 3px;
    vertical-align: middle;
}
.cal-day.today.has-event .day-num::after {
    background: var(--accent);
}

@media (max-width: 480px) {
    .portal-grid { grid-template-columns: repeat(2, 1fr); }

    /* Kalender: Grid ausblenden, Liste einblenden */
    .calendar-grid { display: none; }
    .cal-mobile-list { display: block; }

    /* Navigation kompakter */
    .calendar-nav { gap: 8px; }
    .calendar-month { font-size: 1.05em; }

    /* Login noch kompakter */
    .login-box { padding: 24px 16px; border-radius: 10px; }
    .site-header .logo { max-width: 140px; }

    /* Stats: 2x2 */
    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    /* Impfuebersicht Button */
    .btn-mail { font-size: 0.72em; padding: 6px 8px; }
}

/* Querformat: wieder Grid anzeigen */
@media (max-width: 480px) and (orientation: landscape) {
    .calendar-grid { display: grid; }
    .cal-mobile-list { display: none; }
    .weekday-header { font-size: 0.55em; padding: 5px 1px; }
    .cal-day { min-height: 50px; padding: 3px; }
    .event-box { font-size: 0.6em; padding: 2px 3px; }
}

@media print {
    .filter-bar, .back-link, .btn, .toolbar,
    .pagination, .admin-form-section { display: none; }
    .card { box-shadow: none; border: 1px solid #ccc; }
    body { background: white; font-size: 12px; }
}

/* ---- KALENDER LISTENANSICHT (überschreibt alte .cal-mobile-list Regeln) ---- */

/* cal-list ist die neue korrekte Klasse */
.cal-list { display: none; }

.cal-list .cal-list-row {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.cal-list .cal-list-row:last-child { border-bottom: none; }

.cal-list .cal-list-today {
    background: #fffde7;
    margin: 0 -16px;
    padding: 12px 16px;
    border-radius: var(--radius);
}

.cal-list .cal-list-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 46px;
    background: var(--light-blue);
    border-radius: var(--radius);
    padding: 8px 6px;
    flex-shrink: 0;
}
.cal-list .cal-list-today .cal-list-date {
    background: var(--dark-blue);
}
.cal-list .cal-list-day {
    font-family: 'Cinzel', serif;
    font-size: 1.4em;
    font-weight: 700;
    color: var(--dark-blue);
    line-height: 1;
}
.cal-list .cal-list-today .cal-list-day { color: #fff; }
.cal-list .cal-list-wt {
    font-size: 0.68em;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 3px;
}
.cal-list .cal-list-today .cal-list-wt { color: rgba(255,255,255,0.7); }

.cal-list .cal-list-events { flex: 1; padding-top: 2px; }
.cal-list .cal-list-events .event-box {
    font-size: 0.92em;
    padding: 8px 10px;
    margin-top: 6px;
}
.cal-list .cal-list-events .event-box:first-child { margin-top: 0; }
.cal-list .cal-list-empty-day {
    color: var(--text-muted);
    font-size: 0.85em;
    font-style: italic;
    padding-top: 6px;
}
.cal-list .cal-list-none {
    text-align: center;
    color: var(--text-muted);
    padding: 30px 0;
    font-style: italic;
}

/* Ab 600px Hochformat: Listenansicht */
@media (max-width: 600px) {
    #cal-grid        { display: none !important; }
    .cal-list        { display: block !important; }
    .cal-mobile-list { display: none !important; } /* alte Klasse deaktivieren */
    .calendar-nav { gap: 8px; }
    .calendar-month { font-size: 1.1em; text-align: left; }
}

/* Querformat auf kleinen Phones: wieder Grid */
@media (max-width: 600px) and (orientation: landscape) {
    #cal-grid { display: grid !important; }
    .cal-list { display: none !important; }
    .weekday-header { font-size: 0.55em; padding: 5px 1px; }
    .cal-day { min-height: 50px; padding: 3px; }
    .event-box { font-size: 0.6em; padding: 2px 3px; }
}
