﻿/* =========================================
   PANIK UI CORE - FINAL FIX
   ========================================= */

:root {
    --panik-accent-subtle: rgba(0, 123, 255, 0.12);
    --panik-success-bg: rgba(40, 167, 69, 0.15);
    --panik-success-text: #28a745;
    --panik-error-bg: rgba(220, 53, 69, 0.15);
    --panik-error-text: #dc3545;
    --panik-border-radius: 40px;
}

.panik-container {
    width: 100% !important;
    /*max-width: 1200px !important;*/
    /*margin: 40px auto;*/
}


/* --- PANIK UI LAYOUT CORE --- */
/* Der begrenzte Container: Immer mittig, nie ganz am Rand */
.panik-container-limited {
    display: flex;
    flex-direction: column;
    width: 80% !important;
    max-width: 1500px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding: 0 !important;
}

/* Tabellen-Design: Funktioniert in Light & Dark Mode */
.panik-custom-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg);
    color: var(--text) !important;
    table-layout: auto;
}

    .panik-custom-table thead th {
        background: var(--hover);
        color: var(--muted) !important;
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 1px;
        padding: 18px 25px;
        border: none;
        text-align: left;
    }

    .panik-custom-table td {
        padding: 16px 25px;
        border-bottom: 1px solid var(--border);
        vertical-align: middle;
        color: var(--text) !important;
        white-space: nowrap;
    }

    /* Zeilen-Hover Effekt */
    .panik-custom-table tbody tr:hover {
        background: var(--hover);
        transition: background 0.2s ease;
    }

/* --- BUTTON MODERNISIERUNG --- */
.panik-table-action {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px; /* Leicht abgerundet statt Kreis wirkt moderner */
    background: var(--hover);
    color: var(--text);
    border: 1px solid var(--border);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    cursor: pointer;
}

    .panik-table-action:hover {
        background: var(--accent);
        color: white !important;
        border-color: var(--accent);
        transform: translateY(-2px);
        box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    }

    /* Spezial-Farbe für Delete */
    .panik-table-action.action-delete:hover {
        background: #ff4757 !important;
        border-color: #ff4757 !important;
    }

    .panik-table-action .material-icons-outlined {
        font-size: 19px;
        line-height: 1;
    }

/* Texte erzwingen (Wichtig für Darkmode-Stabilität) */
.panik-text-main {
    color: var(--text) !important;
}

.panik-text-muted {
    color: var(--muted) !important;
}

/* Mobile Optimierung */
@media (max-width: 768px) {
    /* Container-Abstand auf Handy optimieren */
    .panik-container-limited {
        width: 95% !important;
        margin: 20px auto !important;
    }

    /* Tabelle in Karten-Ansicht umwandeln */
    .panik-custom-table,
    .panik-custom-table thead,
    .panik-custom-table tbody,
    .panik-custom-table th,
    .panik-custom-table td,
    .panik-custom-table tr {
        display: block;
    }

        /* Kopfzeile komplett verstecken */
        .panik-custom-table thead {
            display: none;
        }

        /* Jede Zeile wird zu einer kleinen Karte innerhalb der Panik-Card */
        .panik-custom-table tr {
            border-bottom: 1px solid var(--border);
            padding: 15px 10px;
            position: relative;
        }

            .panik-custom-table tr:last-child {
                border-bottom: none;
            }

        /* Zellen-Styling auf Mobile */
        .panik-custom-table td {
            border: none !important;
            padding: 4px 15px !important;
            display: flex;
            justify-content: space-between; /* Label links, Wert rechts */
            align-items: center;
            text-align: right;
            font-size: 0.9rem;
        }

            /* Labels für die mobile Ansicht (wird über data-label gesteuert) */
            .panik-custom-table td::before {
                content: attr(data-label);
                font-weight: 800;
                text-transform: uppercase;
                font-size: 0.7rem;
                color: var(--muted);
                text-align: left;
            }

            /* Die Aktions-Buttons am Ende zentrieren */
            .panik-custom-table td[data-label="Optionen"] {
                margin-top: 10px;
                justify-content: center;
                gap: 15px;
            }

                .panik-custom-table td[data-label="Optionen"]::before {
                    display: none; /* Wort 'Optionen' auf Mobile verstecken */
                }
}

.panik-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--panik-border-radius);
    padding: clamp(1.5rem, 5vw, 3rem);
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    position: relative;
    z-index: 1; /* Niedriger als Navbar */
}

/* DROPDOWN MIT ELLIPSIS (...) */
.panik-dropdown-wrapper {
    display: block;
    position: relative;
    width: 100%; /* Füllt den Platz der Spalte */
}

.panik-dropdown-btn {
    background: var(--hover);
    border-radius: 50px;
    padding: 14px 25px;
    border: 2px solid transparent;
    color: var(--text);
    font-weight: 600;
    width: 100%; /* Volle Breite der Spalte */
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    overflow: hidden;
}

    /* Das Wort abschneiden, wenn es zu lang ist */
    .panik-dropdown-btn span {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
        flex: 1;
        text-align: left;
    }

/* Darkmode Textfarben für das Menü */
.panik-dropdown-menu {
    z-index: 1000;
    background: var(--bg); /* Nutzt deine Hintergrund-Variable */
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
    width: 100%;
    max-height: 300px;
    overflow-y: auto;
}

.panik-dropdown-item {
    color: var(--text) !important; /* Erzwingt Darkmode-Textfarbe */
    border-radius: 12px;
    padding: 10px 15px;
    transition: all 0.2s ease;
}

.panik-dropdown-item:hover {
    background: var(--hover); /* Nutzt deine Hover-Variable */
    color: var(--accent) !important; /* Text wird beim Hovern in Akzentfarbe (Gold/Gelb) */
}

/* Scrollbar für das Menü (Darkmode-Look) */
.panik-dropdown-menu::-webkit-scrollbar {
    width: 6px;
}
.panik-dropdown-menu::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

/* RESTLICHE KOMPONENTEN */
.panik-label {
    font-weight: 700;
    font-size: 0.75rem;
    color: var(--muted);
    margin-left: 20px;
    margin-bottom: 8px;
    display: block;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.panik-input {
    width: 100%;
    background: var(--hover);
    border: 2px solid transparent;
    border-radius: 50px;
    padding: 14px 25px;
    color: var(--text);
    transition: 0.2s;
    outline: none;
}

    .panik-input:focus {
        border-color: var(--accent);
        background: var(--bg);
    }

.panik-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 30px;
    border-radius: 50px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: 0.2s;
    text-decoration: none !important;
}

.panik-btn-save {
    background: var(--panik-success-bg);
    color: var(--panik-success-text) !important;
    border: 1px solid rgba(40, 167, 69, 0.2);
}

    .panik-btn-save:hover {
        background: var(--panik-success-text);
        color: white !important;
    }

.panik-btn-cancel {
    background: var(--panik-error-bg);
    color: var(--panik-error-text) !important;
    border: 1px solid rgba(220, 53, 69, 0.2);
}

    .panik-btn-cancel:hover {
        background: var(--panik-error-text);
        color: white !important;
    }

.panik-dropzone {
    border: 2px dashed var(--border);
    background: var(--hover);
    border-radius: 30px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.panik-preview-container {
    display: none;
    margin-bottom: 15px;
}

.panik-image-preview {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 20px;
    border: 2px solid var(--accent);
}


/* =========================================
   PANIK UI FOOTER
   ========================================= */

.panik-footer {
    background: var(--bg);
    border-top: 1px solid var(--border);
    padding: 60px 0 30px 0;
    margin-top: 100px;
    color: var(--text);
    transition: background 0.3s, color 0.3s;
}

/* Optional: Wenn du den "Sticky" Look willst, wie deine Navbar */
/* .panik-footer { margin-bottom: 20px; border-radius: 40px; ... } */

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 30px;
    margin-bottom: 40px;
}

.brand-text {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    display: block;
}

.footer-tagline {
    color: var(--muted);
    font-size: 0.9rem;
    margin-top: 5px;
}

.footer-links {
    display: flex;
    gap: 25px;
}

    .footer-links a {
        text-decoration: none;
        color: var(--text);
        font-weight: 500;
        font-size: 0.95rem;
        transition: color 0.2s;
    }

        .footer-links a:hover {
            color: var(--accent);
        }

.footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 25px;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--muted);
}

.footer-status {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--hover);
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: 600;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #28a745;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(40, 167, 69, 0.4);
}

@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        text-align: center;
        align-items: center;
    }

    .footer-links {
        flex-direction: column;
        gap: 15px;
    }

    .footer-bottom {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
}


/* --- PANIK UI TOGGLE SLIDER --- */
.panik-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

    /* Verstecke die Standard-Checkbox */
    .panik-switch input {
        opacity: 0;
        width: 0;
        height: 0;
    }

/* Der Hintergrund des Sliders */
.panik-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--hover); /* Nutzt deine Variable */
    transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 34px;
    border: 1px solid var(--border);
}

    /* Der weiße Punkt (Knob) */
    .panik-slider:before {
        position: absolute;
        content: "";
        height: 18px;
        width: 18px;
        left: 2px;
        bottom: 2px;
        background-color: white;
        transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
        border-radius: 50%;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }

/* Zustand: Aktiviert */
.panik-switch input:checked + .panik-slider {
    background-color: var(--panik-success-text); /* Nutzt dein Akzent-Blau/Grau */
    border-color: var(--panik-success-text);
}

    .panik-switch input:checked + .panik-slider:before {
        transform: translateX(20px);
    }

/* Fokus-Effekt für Tastaturnutzung */
.panik-switch input:focus + .panik-slider {
    box-shadow: 0 0 0 2px rgba(var(--accent), 0.2);
}


/*===================================================================================*/
/* =====                              Date Picker                              ===== */
/*===================================================================================*/


.panik-input[type="date"]::-webkit-calendar-picker-indicator {
    background: transparent;
    bottom: 0;
    color: transparent;
    cursor: pointer;
    height: auto;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    width: auto;
    z-index: 2;
}

.panik-date-wrapper {
    position: relative;
    width: 100%;
}

.picker-icon {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
    font-size: 20px;
}

/* --- PANIK UI CALENDAR POPUP --- */
.panik-calendar-popup {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    z-index: 2000;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 15px;
    width: 280px;
    display: none;
    user-select: none;
}

.panik-calendar-popup.is-datetime {
    width: auto;
    min-width: 480px;
}

.panik-popup-body {
    display: flex;
    flex-direction: row;
    gap: 15px;
}

.panik-calendar-section {
    width: 250px;
    flex-shrink: 0;
}

.panik-time-section {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 160px;
    border-left: 1px solid var(--border);
    padding-left: 15px;
    height: 290px;
}

.panik-time-header-row {
    display: flex;
    justify-content: space-around;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 5px;
}

.panik-time-label {
    font-weight: 800;
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
}

.panik-time-columns {
    display: flex;
    flex-grow: 1;
    overflow: hidden;
    gap: 5px;
}

.panik-time-col {
    flex: 1;
    overflow-y: auto;
    text-align: center;
}

.panik-time-col::-webkit-scrollbar { width: 4px; }
.panik-time-col::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.panik-time-item {
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: 0.2s;
}

.panik-time-item:hover { background: var(--hover); color: var(--accent); }
.panik-time-item.selected { background: var(--accent); color: white; font-weight: bold; }

/* Kalender Header & Grid */
.panik-calendar-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 15px;
}

.panik-calendar-nav {
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text);
    width: 34px;
    height: 34px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.month-year-label { font-weight: 800; flex-grow: 1; text-align: center; }
.panik-calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.panik-day-head { font-size: 0.65rem; color: var(--muted); font-weight: 800; text-align: center; padding-bottom: 8px; }
.panik-day { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-radius: 10px; cursor: pointer; font-size: 0.85rem; }
.panik-day:hover:not(.empty) { background: var(--hover); color: var(--accent); }
.panik-day.selected { background: var(--accent) !important; color: white !important; }
.panik-day.today { color: var(--accent); font-weight: 900; position: relative; }
.panik-day.today::after { content: ''; position: absolute; bottom: 4px; width: 4px; height: 4px; background: var(--accent); border-radius: 50%; }
.panik-day.selected.today::after { background: white; }

.panik-popup-footer { margin-top: 15px; display: flex; justify-content: flex-end; border-top: 1px solid var(--border); padding-top: 10px; }
.panik-btn-done { background: var(--accent); color: white; border: none; padding: 10px 25px; border-radius: 12px; font-weight: 600; cursor: pointer; }

/* ========== MOBILE OPTIMIERUNG ========== */
@media (max-width: 600px) {
    .panik-calendar-popup.is-datetime {
        min-width: 280px;
        width: 95vw; /* Fast volle Breite auf dem Handy */
        left: 50%;
        transform: translateX(-50%); /* Zentriert das Popup */
        max-height: 80vh;
        overflow-y: auto;
    }

    .panik-popup-body {
        flex-direction: column; /* Stapelt Kalender und Zeit */
        gap: 20px;
    }

    .panik-calendar-section {
        width: 100%;
    }

    .panik-time-section {
        border-left: none; /* Entfernt vertikale Linie */
        border-top: 1px solid var(--border); /* Fügt horizontale Linie hinzu */
        padding-left: 0;
        padding-top: 15px;
        height: 200px; /* Etwas kleiner auf Mobile */
    }

    .panik-time-columns {
        height: 150px;
    }
}

/* =========================================
   PANIK UI BUILDER & MODALS
   ========================================= */

/* --- BUILDER HIERARCHIE --- */
.panik-builder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 15px;
}

.panik-builder-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 24px; /* Etwas kleiner als die Haupt-Card (40px) für bessere Proportionen */
    padding: 20px 25px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.03);
    transition: all 0.2s ease;
}

.panik-builder-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.panik-builder-title {
    font-weight: 800;
    font-size: 1.25rem;
    margin: 0;
    color: var(--text);
}

.panik-builder-subtitle {
    font-weight: 700;
    font-size: 1.1rem;
    margin: 0;
    color: var(--text);
}

/* Gestrichelte Linie für die Einrückung der Kind-Elemente (Kontingente) */
.panik-builder-nested {
    margin-top: 20px;
    margin-left: 30px;
    border-left: 2px dashed var(--border);
    padding-left: 25px;
}

.panik-empty-state {
    text-align: center;
    padding: 50px 20px;
    background: var(--hover);
    border-radius: 24px;
    border: 2px dashed var(--border);
    color: var(--muted);
    font-weight: 600;
}

/* --- MODALS IM PANIK-LOOK --- */
.panik-modal-content {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--panik-border-radius);
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    padding: 10px;
}

    .panik-modal-content .modal-header {
        border-bottom: 1px solid var(--border);
        padding-bottom: 15px;
    }

    .panik-modal-content .modal-footer {
        border-top: 1px solid var(--border);
        padding-top: 15px;
    }

    .panik-modal-content .modal-title {
        font-weight: 800;
        color: var(--text);
    }

@media (max-width: 768px) {
    .panik-builder-nested {
        margin-left: 10px;
        padding-left: 15px;
    }
}


/* --- PANIK CUSTOM SELECT --- */
.panik-select-wrapper {
    position: relative;
    width: 100%;
}

.panik-select {
    appearance: none; /* Versteckt den hässlichen Standard-Pfeil des Browsers */
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    padding-right: 50px !important; /* Macht rechts Platz, damit der Text nicht unter das Icon rutscht */
}

.panik-select-icon {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none; /* GANZ WICHTIG: Klicks gehen durch das Icon hindurch direkt auf das Select-Feld */
    font-size: 24px;
    transition: color 0.2s;
}

/* Wenn das Select fokussiert ist, leuchtet auch der Pfeil in der Akzentfarbe */
.panik-select:focus + .panik-select-icon {
    color: var(--accent);
}


/* =========================================
   PANIK ACCORDION
   ========================================= */

/* Der Toggle-Button links neben der Überschrift */
.panik-accordion-btn {
    background: var(--hover);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

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

    /* Dreht das Icon um 180 Grad, wenn es geschlossen ist */
    .panik-accordion-btn .material-icons-outlined {
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .panik-accordion-btn.is-closed .material-icons-outlined {
        transform: rotate(-180deg);
    }

/* Butterweiche Animation durch CSS Grid */
.panik-accordion-content {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

    .panik-accordion-content.is-closed {
        grid-template-rows: 0fr;
    }

/* Versteckt den Inhalt, der beim Zuklappen übersteht */
.panik-accordion-inner {
    overflow: hidden;
}