/* ============================================================
   WSP-Sitter Portal — Stylesheet
   Mobile-first, responsive, WSP-Farbschema
   ============================================================ */

/* === Farben (aus dem Logo) === */
:root {
    --green-dark:  #2d5a27;
    --green-mid:   #3a7a32;
    --green-light: #5a9e50;
    --green-pale:  #e8f5e4;
    --gold:        #d4a017;
    --gold-light:  #f5e6b8;
    --blue:        #4a9ec7;
    --blue-light:  #daeef7;
    --blue-pale:   #eaf6fc;
    --red:         #c0392b;
    --red-light:   #fdeaea;
    --white:       #ffffff;
    --gray-50:     #f9fafb;
    --gray-100:    #f3f4f6;
    --gray-200:    #e5e7eb;
    --gray-300:    #d1d5db;
    --gray-400:    #9ca3af;
    --gray-500:    #6b7280;
    --gray-600:    #4b5563;
    --gray-700:    #374151;
    --gray-800:    #1f2937;
    --gray-900:    #111827;

    --radius:      8px;
    --radius-lg:   12px;
    --shadow:      0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg:   0 4px 12px rgba(0,0,0,.12);
    --transition:  .2s ease;

    --nav-width:   260px;
    --header-h:    56px;
}

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--gray-800);
    background: var(--gray-50);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
}

a { color: var(--green-mid); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 1rem; color: var(--green-dark); }
h2 { font-size: 1.2rem; font-weight: 600; margin-bottom: .75rem; color: var(--gray-800); }
h3 { font-size: 1rem; font-weight: 600; }

/* === Loading === */
.loading-screen, .loading {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 3rem; color: var(--gray-400); gap: .75rem;
}
.loading-screen { height: 100vh; height: 100dvh; }
.loading-logo { width: 80px; height: 80px; object-fit: contain; animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }

/* === Header === */
.app-header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: var(--header-h);
    background: var(--green-dark);
    color: var(--white);
    display: flex; align-items: center;
    padding: 0 1rem;
    box-shadow: var(--shadow);
}

.header-logo {
    display: flex; align-items: center; gap: .5rem;
    font-weight: 700; font-size: 1.1rem;
}
.header-logo-img { width: 32px; height: 32px; object-fit: contain; border-radius: 50%; }

.header-user {
    margin-left: auto;
    font-size: .85rem; opacity: .85;
}

/* Hamburger-Menü */
.menu-toggle {
    background: none; border: none; cursor: pointer;
    width: 36px; height: 36px;
    display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 5px;
    margin-right: .75rem;
}
.menu-toggle span {
    display: block; width: 22px; height: 2px;
    background: var(--white); border-radius: 2px;
    transition: var(--transition);
}

/* === Navigation === */
.app-nav {
    position: fixed; top: var(--header-h); left: 0; bottom: 0;
    width: var(--nav-width);
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    padding: 1rem 0;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 90;
}
.app-nav.open { transform: translateX(0); }

.nav-link {
    display: block;
    padding: .65rem 1.25rem;
    color: var(--gray-700);
    font-size: .9rem;
    transition: background var(--transition);
    text-decoration: none;
}
.nav-link:hover { background: var(--green-pale); text-decoration: none; }
.nav-link.active { color: var(--green-dark); font-weight: 600; background: var(--green-pale); border-left: 3px solid var(--green-dark); }
.nav-link-external { color: var(--gray-400); }
.nav-logout { color: var(--red); margin-top: .5rem; }
.nav-divider {
    padding: .75rem 1.25rem .25rem;
    font-size: .75rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .05em;
    color: var(--gray-400);
}

/* === Main === */
.app-main {
    padding-top: var(--header-h);
    min-height: 100vh; min-height: 100dvh;
}

.page-content { padding: 1.25rem; max-width: 900px; }

/* === Login === */
.login-page {
    min-height: 100vh; min-height: 100dvh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-mid) 100%);
    padding: 1rem;
}
.login-card {
    background: var(--white); border-radius: var(--radius-lg);
    padding: 2rem; width: 100%; max-width: 380px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.login-logo { width: 80px; height: 80px; object-fit: contain; margin-bottom: 1rem; }
.login-card h1 { color: var(--green-dark); margin-bottom: 1.5rem; }

/* === Formulare === */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .25rem; color: var(--gray-600); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: .6rem .75rem;
    border: 1px solid var(--gray-300); border-radius: var(--radius);
    font-size: .95rem; font-family: inherit; color: var(--gray-800);
    background: var(--white);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-group input:focus, .form-group select:focus {
    outline: none; border-color: var(--green-mid);
    box-shadow: 0 0 0 3px rgba(58,122,50,.15);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-inline { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; margin-bottom: 1.5rem; }
.form-hint { font-size: .8rem; color: var(--gray-400); margin-bottom: 1rem; }

.form-error { color: var(--red); background: var(--red-light); padding: .5rem .75rem; border-radius: var(--radius); font-size: .85rem; margin-bottom: .75rem; }
.form-success { color: var(--green-dark); background: var(--green-pale); padding: .5rem .75rem; border-radius: var(--radius); font-size: .85rem; margin-bottom: .75rem; }

/* === Buttons === */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
    padding: .55rem 1.1rem;
    font-size: .9rem; font-family: inherit; font-weight: 500;
    border: 1px solid transparent; border-radius: var(--radius);
    cursor: pointer; transition: all var(--transition);
    text-decoration: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--green-dark); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--green-mid); }
.btn-outline { background: var(--white); color: var(--gray-700); border-color: var(--gray-300); }
.btn-outline:hover:not(:disabled) { background: var(--gray-100); }
.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover:not(:disabled) { background: #a93226; }
.btn-small { padding: .3rem .6rem; font-size: .8rem; }
.btn-full { width: 100%; }

/* === Cards === */
.card {
    background: var(--white); border-radius: var(--radius-lg);
    padding: 1.25rem; margin-bottom: 1rem;
    box-shadow: var(--shadow);
}
.card-action { cursor: pointer; transition: transform var(--transition), box-shadow var(--transition); }
.card-action:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.card-icon { font-size: 2rem; margin-bottom: .5rem; }

.dashboard-cards {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem; margin-top: 1rem;
}

.card-inactive { opacity: .5; }

/* === Badges === */
.badge {
    display: inline-block; font-size: .7rem; font-weight: 600;
    padding: .15rem .5rem; border-radius: 999px;
    text-transform: uppercase; letter-spacing: .03em;
}
.badge-green { background: var(--green-pale); color: var(--green-dark); }
.badge-red { background: var(--red-light); color: var(--red); }

/* === Alert === */
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.alert-error { background: var(--red-light); color: var(--red); }

.info-text { font-size: .85rem; color: var(--gray-500); margin-bottom: 1rem; }
.empty-state { color: var(--gray-400); font-style: italic; padding: 2rem 0; text-align: center; }

/* === Tabellen === */
.table-responsive { overflow-x: auto; margin: 1rem 0; }
.data-table {
    width: 100%; border-collapse: collapse;
    font-size: .85rem;
}
.data-table th, .data-table td {
    padding: .5rem .65rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}
.data-table th {
    font-weight: 600; color: var(--gray-600);
    background: var(--gray-50);
    font-size: .8rem; text-transform: uppercase; letter-spacing: .03em;
    position: sticky; top: 0;
}
.data-table-compact td, .data-table-compact th { padding: .3rem .5rem; }
.row-inactive { opacity: .5; }
.row-weekend { background: var(--green-pale); }
.row-reserve { background: var(--blue-pale); }

.actions { white-space: nowrap; display: flex; gap: .25rem; }

/* === Dienstplan === */
.monat-gruppe { margin-bottom: 2rem; }
.monat-header {
    display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
    padding: .75rem 0;
    border-bottom: 2px solid var(--green-dark);
    margin-bottom: .75rem;
}
.monat-header h2 { margin: 0; }
.monat-info { font-size: .8rem; color: var(--gray-400); }

.tag-gruppe {
    background: var(--white);
    border-radius: var(--radius);
    margin-bottom: .5rem;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.tag-wochenende { border-left: 3px solid var(--green-light); }
.tag-header {
    padding: .6rem .75rem;
    background: var(--gray-50);
    display: flex; align-items: center; gap: .75rem;
    border-bottom: 1px solid var(--gray-200);
}
.tag-typ { font-size: .75rem; color: var(--gray-400); }

.tag-dienste { padding: .5rem .75rem; }

.zeit-block { margin-bottom: .5rem; }
.zeit-label {
    font-size: .75rem; font-weight: 600;
    color: var(--gray-500);
    margin-bottom: .25rem;
    padding-bottom: .15rem;
    border-bottom: 1px dashed var(--gray-200);
}

.dienst-slot {
    display: flex; align-items: center; gap: .5rem;
    padding: .35rem .5rem;
    border-radius: var(--radius);
    margin-bottom: .2rem;
    min-height: 36px;
}
.dienst-reserve { background: var(--blue-pale); }
.dienst-mein { background: var(--gold-light); font-weight: 600; }
.dienst-belegt { }
.dienst-frei { }

.dienst-status { font-size: .85rem; }
.dienst-status.mein { color: var(--green-dark); font-weight: 700; }
.dienst-status.belegt { color: var(--gray-600); }
.dienst-status.blockiert { color: var(--gray-400); font-style: italic; }
.dienst-status.gesperrt { color: var(--gray-400); font-size: .8rem; font-style: italic; }

.dienst-select {
    flex: 1;
    padding: .3rem .5rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: .8rem;
    background: var(--white);
}
.dienst-select.dienst-reserve { background: var(--blue-pale); }

/* === Kontaktliste (Mobile Cards) === */
.mobile-cards { display: none; }
.contact-card {
    background: var(--white); border-radius: var(--radius);
    padding: 1rem; margin-bottom: .75rem;
    box-shadow: var(--shadow);
}
.contact-name { font-weight: 600; margin-bottom: .5rem; }
.contact-detail { font-size: .85rem; color: var(--gray-600); margin-bottom: .25rem; }
.contact-detail a { color: var(--green-mid); }
.contact-actions { display: flex; gap: .5rem; margin-top: .75rem; }

/* === Monate verwalten === */
.monate-list { margin-top: 1rem; }
.monat-card { margin-bottom: 1rem; }
.monat-card-header { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }
.monat-card-details { font-size: .85rem; color: var(--gray-500); display: flex; gap: 1rem; margin-bottom: .75rem; }
.monat-card-actions { display: flex; flex-wrap: wrap; gap: .5rem; }

/* === Tagestypen === */
.typ-card { margin-top: 1rem; }
.typ-card-header { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }
.typ-count { font-size: .8rem; color: var(--gray-400); }
.typ-actions { margin-left: auto; display: flex; gap: .25rem; }
.typ-desc { font-size: .85rem; color: var(--gray-500); margin-bottom: .5rem; }

/* === Tage-Editor === */
.tage-editor { margin: 1rem 0; max-height: 60vh; overflow-y: auto; }
.tage-editor select { padding: .3rem .4rem; font-size: .85rem; }

/* === Modal === */
.modal-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(0,0,0,.4);
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
}
.modal {
    background: var(--white); border-radius: var(--radius-lg);
    padding: 1.5rem; width: 100%; max-width: 500px;
    max-height: 90vh; max-height: 90dvh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal-wide { max-width: 700px; }
.modal h2 { margin-bottom: 1rem; }
.modal-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* === Positionen-Editor (im Modal) === */
.pos-row {
    display: flex; align-items: center; gap: .5rem;
    padding: .35rem 0;
    border-bottom: 1px solid var(--gray-100);
    flex-wrap: wrap;
}
.pos-row input[type="time"] { width: 7em; padding: .3rem; font-size: .85rem; border: 1px solid var(--gray-300); border-radius: var(--radius); }
.pos-row input[type="text"] { flex: 1; min-width: 60px; padding: .3rem; font-size: .85rem; border: 1px solid var(--gray-300); border-radius: var(--radius); }
.pos-row input[type="number"] { padding: .3rem; font-size: .85rem; border: 1px solid var(--gray-300); border-radius: var(--radius); }
.pos-reserve-label { font-size: .8rem; display: flex; align-items: center; gap: .25rem; white-space: nowrap; }

/* === Druckansicht === */
.print-page { padding: 1.25rem; max-width: 1000px; }
.print-header { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.print-header h1 { margin: 0; }
.print-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.print-table th, .print-table td { padding: .35rem .5rem; border: 1px solid var(--gray-300); }
.print-table th { background: var(--gray-100); font-weight: 600; }
.print-weekend { background: var(--green-pale); }
.print-frei { color: var(--gray-400); font-style: italic; }
.print-blockiert { color: var(--gray-400); }
.print-reserve { background: var(--blue-pale); }

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

/* Tablet (>= 768px) */
@media (min-width: 768px) {
    .menu-toggle { display: none; }
    .app-nav {
        transform: translateX(0);
        box-shadow: none;
    }
    .app-main {
        margin-left: var(--nav-width);
    }

    .page-content { padding: 1.5rem 2rem; }

    .mobile-cards { display: none !important; }
}

/* Mobile (<768px) */
@media (max-width: 767px) {
    .data-table { display: none; }
    .mobile-cards { display: block; }
    .hide-mobile { display: none; }

    .form-row { grid-template-columns: 1fr; }
    .form-inline { flex-direction: column; align-items: stretch; }

    .monat-card-actions { flex-direction: column; }

    .pos-row { font-size: .8rem; }

    .print-table { font-size: .7rem; }
    .print-table td, .print-table th { padding: .2rem .3rem; }
}

/* === Print Styles === */
@media print {
    .no-print, .app-header, .app-nav { display: none !important; }
    .app-main { margin-left: 0; padding-top: 0; }
    .print-page { padding: 0; }
    body { background: white; }
}
