/** =============== */
/* Kontext-menü  */
/* ================ */
.context-menu {
    position: absolute;
    min-width: 200px;
    background: #ffffff;
    border: 1px solid var(--stroke);
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(20,30,40,0.12), 0 1px 0 rgba(0,0,0,0.02) inset;
    z-index: 1200;
    padding: 6px 6px;
    display: none;
}

/* sichtbar */
.context-menu.show {
    display: flex;
    flex-direction: column;

}

/* layout */
.context-menu__item {
    min-width: 100%; /* warum??? */
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    border: 0;
    text-align: left;
    padding: 8px 12px;
    font-weight: normal;
    color: #222;
    cursor: pointer;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 0.95rem;
}

/* icon */
.context-menu__item i {
    width: 18px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
}

/* hover, focus */
.context-menu__item:hover,
.context-menu__item:focus {
    background: #f6f7f9;
    outline: none;
    color: #111;
}

/* divider support */
.context-menu__divider {
    height: 1px;
    background: var(--stroke);
    margin: 6px 0;
    border-radius: 1px;
}

/* 2. text */
.context-menu__meta {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--muted);
}

/* keyboard */
.context-menu__item[tabindex] {
    outline: none;
}

/* Modal */
.modal-overlay {
    position:fixed;
    inset:0;
    background:rgba(10,10,12,0.45);
    display:none;
    align-items:center;
    justify-content:center;
    z-index:1300;
    padding: 20px; /* Bessere Mobile-Darstellung */
}
.modal-overlay.show,
.modal-overlay.open {
    display:flex;
}
.modal {
    background:#fff;
    border-radius:12px;
    width:420px;
    max-width:100%;
    padding:18px;
    box-shadow:0 20px 50px rgba(20,30,40,0.15);
    max-height: 90vh;
    overflow-y: auto;
}
.modal h3 {
    margin:0 0 8px 0;
    font-size:1.05rem;
}
.modal .modal-body {
    margin-top:8px;
    display:flex;
    flex-direction:column;
    gap:10px;
}
.modal .modal-actions {
    display:flex;
    justify-content:flex-end;
    gap:8px;
    margin-top:12px;
}

.modal-wide {
    width: 780px;
    max-width:100%;
}

.modal .import-modal-body {
    margin-top:8px;
    display:flex;
    flex-direction:column;
    gap:10px;
    max-height: 60vh;
    overflow-y: auto;
}


/* Forms */
.form-grid {
    display:grid;
    gap:12px;
    margin-top:8px;
}
.form-field {
    display:flex;
    flex-direction:column;
    gap:6px;
}
.form-field label {
    font-weight:700;
    font-size:0.9rem;
    color:#333;
}
.form-field input, .form-field select {
    border-radius:8px;
    border:1px solid var(--stroke);
    padding:10px 12px;
    font-size:0.95rem;
    background:#fff;

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

.form-feedback {
    text-align: center;
    font-size: 0.9rem;
    font-weight: normal;
    color: #1f6f3f;
    min-height: 1.2em;
}

.form-field input[type="file"] {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.form-field-group {
    display: grid;
    gap: 0.5rem;
}

.form-field-group .form-field-group__title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.form-field-group .form-field-group__item {
    display: grid;
    gap: 0.25rem;
}

.form-field-group .form-field-group__subtitle {
    font-weight: normal;
    font-size: small;
    margin-bottom: 0.1rem;
}


/* icon action button */
.action-btn, .multi-action-btn {
    box-sizing: border-box;

    inline-size: 44px;
    min-inline-size: 44px;
    width: 44px;
    max-width: 44px;
    height: 44px;

    padding: 0;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;

    background: transparent;
    cursor: pointer;
    transition: background .12s ease, box-shadow .12s ease, transform .08s ease;
}

.action-btn i, .multi-action-btn i {
    display: block;
    width: 100%;
    text-align: center;
    line-height: 1;
    font-size: 1.05rem;
    color: #666;
}

.action-btn:hover, .multi-action-btn:hover {
    background: rgba(252,109,38,0.06);
    transform: translateY(-2px);
    /*box-shadow: 0 8px 20px rgba(33,40,44,0.06);*/
}
.action-btn:hover i, .multi-action-btn:hover i {
    color: var(--primary);
}

/* Abbrechen / Speichern nutzen diese Klassen */
.btn {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    min-height: 40px;
    box-sizing: border-box;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: .5rem .75rem;
    border-radius: 4px
}

.btn-secondary {
    background: #f0f0f0;
    color: #222;
    border: 1px solid #ccc;
    padding: .45rem .7rem;
    border-radius: 4px
}


/* Sort indicator */
.sort-indicator {
    margin-left:8px;
    font-size:0.95rem;
    color:var(--muted);
}

/* util */
.hint {
    font-size: .875rem;
    color: #555
}

.note {font-size:.85rem;color:#666;margin-top:.25rem}
.alert {padding:.5rem .75rem;border-radius:4px;margin-top:.5rem}
.alert-success {background:#ecf8ef;color:#1f6f3f;border:1px solid #bfe6c7}
.alert-error {background:#fff0f0;color:#8b1f1f;border:1px solid #f3c2c2}

/* misc */
.vis-toggle, .tutorial-trigger {
    background: transparent;
    border: none;
    color: #0057b7;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0;
}

.vis-toggle:hover, .tutorial-trigger:hover {
    background: none;
    color: var(--link-color-primary);
    text-decoration: underline;
}



input[type="password"], input[type="text"] {
    padding: .5rem;
    border:1px solid #ccc;
    border-radius: 4px
}

#user-search, #search-input {
    border: none;
}

/* tutorials */
.tutorial-trigger {
    border: none;
    background: none;
    color: var(--link-color-primary, #0057b7);
    font-size: 0.8rem;
    margin-left: 8px;
    cursor: pointer;
    font-weight: inherit;
    text-decoration: underline;
    padding: 0;
}

.tutorial-trigger:hover {
    color: var(--link-color-primary, #003f86);
}

.tutorial-modal .modal-body {
    font-size: 0.9rem;
    line-height: 1.4;
}

.tutorial-modal {
    width: 75ch;
}

.tutorial-modal ul {
    padding-left: 1.2rem;
    margin: 0.4rem 0 0.2rem;
}


/* pagination */
.pagination-nav {
    margin-top: 12px;
    display: flex;
    justify-content: center;
}
.pagination {
    list-style: none;
    display: flex;
    gap: 6px;
    padding: 0;
    margin: 0;
    flex-wrap: wrap;
}
.page-item {
    font-size: small;
    border: 1px solid var(--stroke);
    border-radius: 6px;
    background: #fff;
}
.page-item.disabled {
    opacity: 0.6;
    pointer-events: none;
}
.page-item.active {
    border-color: var(--primary);
}
.page-link {
    display: inline-block;
    padding: 8px 12px;
    color: #333;
    text-decoration: none;
}
.page-item.active .page-link {
    color: var(--primary);
    font-weight: 700;
}
.page-item:hover:not(.active):not(.disabled) {
    background: rgba(0,0,0,0.03);
}

/* CSV download action below pagination */
.pagination-actions {
    margin-top: 14px;
    display: flex;
    justify-content: flex-end;
}
.pagination-actions form {
    margin: 0;
}

/* ========================================= */
/* MOBILE RESPONSIVE STYLES                  */
/* ========================================= */

@media (max-width: 768px) {
    /* Modal-Anpassungen für Tablets */
    .modal-overlay {
        padding: 16px;
    }

    .modal {
        width: 90%;
        max-width: 500px;
        padding: 16px;
        max-height: 85vh;
    }

    .modal-wide {
        width: 95%;
        max-width: 95%;
    }

    .modal h3 {
        font-size: 1rem;
    }

    .tutorial-modal {
        width: 90%;
    }

    /* Formulare */
    .form-field input, .form-field select {
        font-size: 16px; /* Verhindert Zoom auf iOS */
        padding: 10px;
    }

    /* Buttons */
    .btn {
        min-height: 44px; /* Touch-freundliche Größe */
        font-size: 0.95rem;
    }

    /* Table-Scroll für CSV-Preview */
    .table-scroll {
        max-height: 300px;
    }
}

@media (max-width: 640px) {
    /* Kontextmenü volle Breite auf kleinen Bildschirmen */
    .context-menu {
        min-width: 160px;
        max-width: 90vw;
    }

    .context-menu__item {
        padding: 10px 12px;
        font-size: 0.9rem;
        min-height: 44px; /* Touch-freundlich */
    }

    /* Modal kompakter */
    .modal-overlay {
        padding: 12px;
    }

    .modal {
        width: 95%;
        max-width: 95%;
        padding: 14px;
        max-height: 88vh;
    }

    .modal h3 {
        font-size: 0.95rem;
        margin-bottom: 10px;
    }

    .modal .modal-body {
        gap: 8px;
    }

    .modal .modal-actions {
        flex-direction: column;
        gap: 8px;
        margin-top: 10px;
    }

    .modal .modal-actions button {
        width: 100%;
        min-height: 44px;
    }

    /* Formulare stapeln */
    .form-grid {
        gap: 10px;
    }

    .form-actions {
        flex-direction: column;
        gap: 8px;
    }

    .form-actions button {
        width: 100%;
        min-height: 44px;
    }

    /* Form-Field-Group anpassen */
    .form-field-group .form-field-group__item {
        gap: 0.5rem;
    }

    .form-field-group .form-field-group__title {
        font-size: 0.9rem;
    }

    .form-field-group .form-field-group__subtitle {
        font-size: 0.8rem;
    }

    /* CSV-Preview-Table als Karten */
    .csv-preview-table thead {
        display: none;
    }

    .csv-preview-table tbody,
    .csv-preview-table tr,
    .csv-preview-table td {
        display: block;
        width: 100%;
    }

    .csv-preview-table tr {
        border: 1px solid var(--stroke);
        border-radius: 8px;
        padding: 10px;
        margin-bottom: 10px;
        background: #fff;
    }

    .csv-preview-table td {
        padding: 6px 0;
        text-align: left !important;
    }

    .csv-preview-table td::before {
        content: attr(data-label) ": ";
        font-weight: 700;
        color: var(--muted);
        display: inline-block;
        min-width: 80px;
    }

    .csv-preview-table td:first-child::before {
        content: "";
        min-width: 0;
    }

    /* Pagination kompakter */
    .pagination {
        gap: 4px;
        justify-content: center;
    }

    .page-link {
        padding: 6px 8px;
        font-size: 0.85rem;
    }

    /* Verstecke "Erste/Letzte" auf sehr kleinen Bildschirmen */
    .page-item:first-child,
    .page-item:last-child {
        display: none;
    }
}

@media (max-width: 480px) {
    /* Kontextmenü noch kompakter */
    .context-menu {
        min-width: 140px;
    }

    .context-menu::before {
        display: none;
    }

    .context-menu__item {
        padding: 10px;
        font-size: 0.85rem;
        gap: 8px;
        min-height: 44px;
    }

    .context-menu__item i {
        width: 16px;
        font-size: 13px;
    }

    /* Modal volle Höhe nutzen wenn nötig */
    .modal-overlay {
        padding: 8px;
    }

    .modal {
        max-height: 92vh;
        overflow-y: auto;
        padding: 12px;
        border-radius: 8px;
    }

    .modal h3 {
        font-size: 0.9rem;
    }

    .modal .import-modal-body {
        max-height: 50vh;
    }

    /* Tutorial-Modal anpassen */
    .tutorial-modal {
        width: 95%;
        max-width: 95%;
    }

    .tutorial-modal .modal-body {
        font-size: 0.85rem;
        line-height: 1.5;
    }

    /* Formulare */
    .form-field label {
        font-size: 0.85rem;
    }

    .form-field input,
    .form-field select {
        padding: 10px;
        font-size: 16px; /* Verhindert Zoom auf iOS */
    }

    /* Buttons größer für Touch */
    .btn {
        padding: 10px 14px;
        min-height: 46px;
        font-size: 0.9rem;
    }

    .vis-toggle,
    .tutorial-trigger {
        font-size: 0.85rem;
        padding: 4px 0;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* Action Buttons */
    .action-btn,
    .multi-action-btn {
        width: 44px;
        height: 44px;
        min-inline-size: 44px;
    }

    /* Hints und Notes */
    .hint,
    .note {
        font-size: 0.8rem;
        line-height: 1.4;
    }

    /* Table-Scroll reduzieren */
    .table-scroll {
        max-height: 250px;
    }

    /* Pagination nur wenige Seiten zeigen */
    .pagination .page-item:not(.active):not(:first-child):not(:last-child):not(:nth-child(2)):not(:nth-last-child(2)) {
        display: none;
    }

    /* Alert-Boxen kompakter */
    .alert {
        padding: 8px 10px;
        font-size: 0.85rem;
    }

    /* Form-Feedback */
    .form-feedback {
        font-size: 0.85rem;
    }
}

/* Landscape-Modus für kleine Geräte */
@media (max-height: 600px) and (orientation: landscape) {
    .modal-overlay {
        padding: 8px;
        align-items: flex-start;
        overflow-y: auto;
    }

    .modal {
        max-height: 92vh;
        overflow-y: auto;
        margin: auto;
    }

    .modal .import-modal-body {
        max-height: 35vh;
    }

    .table-scroll {
        max-height: 200px;
    }

    /* Kompaktere Buttons im Landscape */
    .btn {
        min-height: 40px;
        padding: 8px 12px;
    }

    /* Kompaktere Formulare */
    .form-grid {
        gap: 8px;
    }

    .form-field {
        gap: 4px;
    }
}

/* Extra-kleiner Landscape-Modus */
@media (max-height: 480px) and (orientation: landscape) {
    .modal {
        max-height: 95vh;
        padding: 10px;
    }

    .modal h3 {
        font-size: 0.9rem;
        margin-bottom: 6px;
    }

    .modal .modal-body {
        gap: 6px;
    }

    .modal .import-modal-body {
        max-height: 30vh;
    }

    .form-actions {
        margin-top: 8px;
        gap: 6px;
    }

    .btn {
        min-height: 38px;
        padding: 6px 10px;
    }
}
