/* ------------------------------------------------------------------
   modern.css - Design-Layer fuer selfstorage.team Admin
   Wird NACH bootstrap.min.css und style.css geladen.
   Ziel: neuer Look ohne Aenderung am Twig-Markup.
   ------------------------------------------------------------------ */

:root {
    --ss-bg: #f2f5f7;
    --ss-surface: #ffffff;
    --ss-border: #e4e9ee;
    --ss-hairline: #f0f3f6;
    --ss-text: #1e2a33;
    --ss-muted: #77848e;
    --ss-faint: #9aa7b1;
    /* Akzent folgt dem Client-Theme (bs-primary), nicht fest verdrahtet */
    --ss-accent: var(--bs-primary, #44799f);
    --ss-accent-dark: color-mix(in srgb, var(--bs-primary, #44799f) 85%, #000);
    --ss-accent-soft: color-mix(in srgb, var(--bs-primary, #44799f) 12%, #fff);
    --bs-border-radius: 0.5rem;
    --bs-border-radius-sm: 0.4rem;
    --bs-border-radius-lg: 0.75rem;
    /* Grundschrift der Anwendung.
       Ohne diese Zeile haengt jede rem-Angabe an der Browser-Grundschrift
       (bei abweichender Einstellung z. B. 13px statt 16px, dann wirkt die
       gesamte Oberflaeche geschrumpft). Hier zentral einstellbar. */
    --ss-root-size: 15px;
}

html {
    font-size: var(--ss-root-size);
}

body {
    background-color: var(--ss-bg);
    color: var(--ss-text);
}

/* --- Flaechen -------------------------------------------------- */
.card {
    --bs-card-border-color: var(--ss-border);
    --bs-card-border-radius: 12px;
    --bs-card-inner-border-radius: 11px;
    --bs-card-spacer-x: 1.125rem;
    --bs-card-spacer-y: 1rem;
    --bs-card-color: var(--ss-text);
    box-shadow: none;
}

.card-header {
    background: transparent;
    border-bottom: 0;
    padding: 0.9rem 1.125rem 0.35rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--ss-muted);
}

.card-header .badge {
    text-transform: none;
    letter-spacing: 0;
}

.card-body > h2.h5,
.card-body > h5,
.card-body h2.h5:first-child {
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: -0.01em;
    margin-bottom: 0.65rem;
}

/* --- Definitionszeilen (label.col-4 + div.col-8) ---------------- */
/* Das Muster <div class="row"><label class="col-4">..</label><div class="col-8">..</div></div>
   wird ohne Markup-Aenderung zu einer sauberen Zeile mit Trennlinie.  */
#content .card-body .row:has(> label.col-4),
#sidebar .card-body .row:has(> label.col-4) {
    display: grid;
    grid-template-columns: 9.5rem minmax(0, 1fr);
    column-gap: 0.75rem;
    align-items: center;
    margin: 0;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--ss-hairline);
}

#content .card-body .row:has(> label.col-4) > *,
#sidebar .card-body .row:has(> label.col-4) > * {
    width: auto;
    max-width: none;
    flex: none;
    padding-left: 0;
    padding-right: 0;
}

#content .card-body .row:has(> label.col-4) + .row:not(:has(> label.col-4)) {
    margin-top: 0.5rem;
}

label, .label {
    color: var(--ss-muted);
    font-weight: 500;
}

/* Zahlen immer tabellarisch ausrichten */
.card-body, .table, .badge {
    font-variant-numeric: tabular-nums;
}

/* --- Tabellen --------------------------------------------------- */
#content .table {
    --bs-table-bg: transparent;
    --bs-table-striped-bg: transparent;
    border-color: var(--ss-hairline);
    margin-bottom: 0;
}

#content .table > thead th {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--ss-muted);
    border-bottom: 1px solid var(--ss-border);
    padding: 0 0 0.5rem;
    background: transparent;
}

#content .table > tbody td {
    border-bottom: 1px solid var(--ss-hairline);
    padding: 0.55rem 0;
    vertical-align: top;
}
#content .table-sm > tbody td {
    padding: 0.25rem 0;
    font-size: 14px;
}

#content .table > tbody tr:last-child td {
    border-bottom: 0;
}

/* Positionen / Buchungen: Mengen- und Betragsspalte schmal und rechts */
#content .table th:first-child,
#content .table td:first-child {
    width: 3.5rem;
    color: var(--ss-muted);
}

#content .table th:last-child,
#content .table td:last-child {
    text-align: right;
    font-weight: 600;
    white-space: nowrap;
    width: 8rem;
}

#content .table > tfoot td {
    border-top: 1px solid var(--ss-border);
    border-bottom: 0;
    padding-top: 0.65rem;
    font-size: 0.95rem;
    font-weight: 800;
}

#content .table > tfoot td:last-child {
    font-weight: 800;
}

/* Card-Kopf mit Titel + Nebenangabe (z. B. "3 Positionen") in einer Zeile */
.card-title-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.65rem;
}

.card-title-row > h2.h5,
.card-title-row > h5 {
    margin: 0;
}

.card-title-row > .card-title-meta {
    font-size: 0.78rem;
    color: var(--ss-muted);
    white-space: nowrap;
}


/* Zebra-Streifen der Positionsliste durch Haarlinien ersetzen */
#content .card-body .row.bg-body-tertiary {
    background: transparent !important;
}

#content .card-body .fs-7 > .row {
    border-bottom: 1px solid var(--ss-hairline);
    padding: 0.4rem 0;
    margin: 0;
}

#content .card-body .fs-7 > .row:last-child {
    border-bottom: 0;
}

/* --- Formulare -------------------------------------------------- */
.form-control, .form-select {
    border-color: var(--ss-border);
    border-radius: 8px;
    color: var(--ss-text);
}

.form-control:focus, .form-select:focus {
    border-color: var(--ss-accent);
    box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb, 68, 121, 159), 0.12);
}

.input-group > .form-control,
.input-group > .form-select {
    border-radius: 8px 0 0 8px;
}

.input-group > .btn:last-child {
    border-radius: 0 8px 8px 0;
}

.input-group-text {
    background: #f7fafc;
    border-color: var(--ss-border);
}

/* --- SSX Formular-Bausteine (z. B. Mieter-Stammdaten) ------------ */
.ssx-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.ssx-field > label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--ss-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ssx-input,
.ssx-select,
.ssx-textarea {
    border: 1px solid var(--ss-border);
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--ss-text);
    background: var(--ss-surface);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.ssx-input:focus,
.ssx-select:focus,
.ssx-textarea:focus {
    outline: none;
    border-color: var(--ss-accent);
    box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb, 68, 121, 159), 0.14);
}

.ssx-input[readonly] {
    background: #f7fafc;
    color: #5c6b76;
}

.ssx-textarea {
    resize: vertical;
    min-height: 54px;
}

.ssx-grid2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    min-width: 0;
}

.ssx-inpgrp {
    display: flex;
    min-width: 0;
    width: 100%;
}

.ssx-inpgrp .ssx-input {
    border-radius: 8px 0 0 8px;
    border-right: 0;
    min-width: 0;
    flex: 1 1 auto;
}

.ssx-inpgrp-btn {
    border: 1px solid var(--ss-accent);
    background: var(--ss-accent);
    color: #fff;
    width: 38px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    font-size: 0.8rem;
    text-decoration: none;
}

.ssx-inpgrp-btn:hover {
    background: var(--ss-accent-dark);
    border-color: var(--ss-accent-dark);
    color: #fff;
}

.ssx-inpgrp-btn:last-child {
    border-radius: 0 8px 8px 0;
}

.ssx-inpgrp-btn + .ssx-inpgrp-btn {
    border-left: 1px solid rgba(255, 255, 255, 0.35);
}

.ssx-sec-h {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.ssx-sec-h .ico {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--ss-accent-soft);
    color: var(--ss-accent);
    display: grid;
    place-items: center;
    font-size: 0.85rem;
    flex: 0 0 auto;
}

.ssx-sec-h h3 {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 800;
}

.ssx-check {
    border: 1px solid var(--ss-border);
    border-radius: 8px 0 0 8px;
    border-right: 0;
    background: var(--ss-surface);
    width: 40px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
}

.ssx-form-card {
    padding: 22px 24px;
    overflow: hidden;
}

.ssx-form-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
    gap: 28px 32px;
    min-width: 0;
}

.ssx-form-col {
    display: flex;
    flex-direction: column;
    gap: 26px;
    min-width: 0;
}

@media (max-width: 575.98px) {
    .ssx-form-card {
        padding: 16px;
    }

    .ssx-form-layout {
        gap: 22px;
    }

    .ssx-grid2 {
        grid-template-columns: 1fr;
    }
}

/* --- Buttons ---------------------------------------------------- */
.btn {
    --bs-btn-border-radius: 8px;
    font-weight: 600;
}

.btn-primary {
    --bs-btn-bg: var(--ss-accent);
    --bs-btn-border-color: var(--ss-accent);
    --bs-btn-hover-bg: var(--ss-accent-dark);
    --bs-btn-hover-border-color: var(--ss-accent-dark);
    --bs-btn-active-bg: var(--ss-accent-dark);
    --bs-btn-active-border-color: var(--ss-accent-dark);
    box-shadow: none;
}

.btn-outline-primary,
.btn-outline-secondary,
.btn-outline-danger {
    --bs-btn-border-color: var(--ss-border);
    --bs-btn-color: #5c6b76;
}

.btn-outline-primary {
    --bs-btn-color: var(--ss-accent);
    --bs-btn-hover-bg: var(--ss-accent);
    --bs-btn-hover-border-color: var(--ss-accent);
}

.btn-outline-danger {
    --bs-btn-hover-bg: #c2373b;
    --bs-btn-hover-border-color: #c2373b;
}

.btn-danger {
    --bs-btn-bg: #c2373b;
    --bs-btn-border-color: #c2373b;
    --bs-btn-hover-bg: #a92e32;
    --bs-btn-hover-border-color: #a92e32;
}

.btn-success {
    --bs-btn-bg: #2e7d32;
    --bs-btn-border-color: #2e7d32;
}

/* --- Badges ----------------------------------------------------- */
.badge {
    border-radius: 99px;
    padding: 0.25em 0.7em;
    font-weight: 700;
    font-size: 0.72rem;
}

.badge.bg-danger { background: #fbeced !important; color: #a92e32 !important; }
.badge.bg-warning { background: #fdf3e3 !important; color: #8a5a12 !important; }
.badge.bg-success { background: #e9f3ea !important; color: #276b2b !important; }
.badge.bg-secondary { background: #f2f5f7 !important; color: #5c6b76 !important; }

/* --- Kopfzeile -------------------------------------------------- */
.page > .bg-white {
    border-bottom: 1px solid var(--ss-border);
}

/* Logo nur so breit wie noetig, dadurch rueckt die Suche nach links */
.page > .bg-white > .container-fluid > .row {
    flex-wrap: nowrap;
}

.page > .bg-white > .container-fluid > .row > .col:first-child {
    flex: 0 0 auto;
    width: auto;
}

.page > .bg-white > .container-fluid > .row > form.d-flex {
    flex: 0 1 64rem;
    min-width: 0;
    margin-left: 1.75rem;
}

/* Icon-Gruppe rechts, bricht nicht um */
.page > .bg-white > .container-fluid > .row > .col.text-end {
    flex: 1 1 auto;
    min-width: max-content;
}

/* Profil-Menue an den rechten Rand der Hauptnavigation */
@media (min-width: 992px) {
    .navbar .navbar-nav > .nav-item:last-child {
        margin-left: auto;
    }
}

#searchInput {
    border-radius: 8px 0 0 8px !important;
    background: #f7fafc;
    border-color: var(--ss-border);
}

#searchInput + #searchResult { border-radius: 0 0 8px 8px; }

form.d-flex > .btn[type="submit"] {
    border-radius: 0 8px 8px 0 !important;
    border-color: var(--ss-border);
}

/* --- Hauptnavigation -------------------------------------------- */
.navbar {
    --bs-navbar-padding-y: 0.3rem;
    box-shadow: none;
}

.navbar .navbar-nav .nav-link {
    padding: 0.35rem 0.75rem !important;
    border-radius: 7px;
    font-size: 0.92rem;
    transition: background 0.12s ease;
}

.navbar .navbar-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.14);
}

.dropdown-menu {
    border-color: var(--ss-border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(30, 42, 51, 0.1);
    padding: 0.35rem;
}

.dropdown-item {
    border-radius: 6px;
    font-size: 0.9rem;
}

/* --- Kopfleiste mit Seitenaktionen (#page-head) ------------------
   Gehoert zu Schritt 1: der Block sidebarTopText wird in layout.twig
   ueber den Inhalt gerendert. Die Regeln hier legen den Karten-Wrapper
   der Detailseiten flach, damit aus der Karte eine Werkzeugleiste wird.
   Kein Detail-Template muss angefasst werden.                        */
/* --- Kopfleiste mit Titel und Seitenaktionen (#page-head) --------
   Liegt in der Content-Spalte, damit die Seitenleiste (Notizen) auf
   gleicher Hoehe beginnt. Hintergrund bleibt der Seitenhintergrund.  */
#page-head {
    background: transparent;
    border-bottom: 0;
    padding: 0.25rem 0 0.85rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Fallback: liegt die Leiste (noch) ausserhalb von #content,
   braucht sie eine eigene seitliche Polsterung. */
.page > #page-head {
    padding-left: 1rem;
    padding-right: 1rem;
    padding-top: 1rem;
}

/* Seitentitel, vom Skript aus dem Inhalt hierher gehoben */
#page-head-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

#page-head-title > .fs-4 {
    margin: 0 !important;
    font-size: 1.5rem !important;
    font-weight: 800 !important;
    letter-spacing: -0.015em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#page-head-title a {
    color: var(--ss-faint);
}

#page-head-title a:hover {
    color: var(--ss-accent);
}

/* Solange kein Titel uebernommen wurde, Leiste nur bei Aktionen zeigen */
#page-head:not(.has-title):has(#page-head-actions:empty) {
    display: none;
}

#page-head-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Karte aus dem sidebarTopText-Block auf eine Leiste reduzieren */
#page-head .card {
    background: transparent;
    border: 0;
    box-shadow: none;
    margin: 0;
}

#page-head .card-body {
    padding: 0 !important;
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

#page-head .card-body > .mb-3 {
    margin-bottom: 0 !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#page-head .card-body > .mb-3 > .btn {
    margin-right: 0 !important;
}

#page-head .input-group {
    width: auto;
    max-width: 22rem;
}

#page-head .input-group > .form-select {
    min-width: 12rem;
}

/* Bedienelemente in der Leiste groesser als btn-sm im Inhalt */
#page-head .btn {
    --bs-btn-padding-y: 0.5rem;
    --bs-btn-padding-x: 1rem;
    --bs-btn-font-size: 0.9rem;
    --bs-btn-line-height: 1.25;
}

#page-head .btn:has(> .fa-fw:only-child) {
    --bs-btn-padding-x: 0.7rem;
}

#page-head .input-group-sm > .form-select,
#page-head .input-group-sm > .form-control,
#page-head .input-group-sm > .btn {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.25;
}

/* Ueberlaufmenue */
#page-head .dropdown-menu {
    min-width: 13rem;
}

#page-head .dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
}

/* Inhalt schliesst direkt an die Leiste an */
#page-head + .layout-flex {
    margin-top: 0 !important;
}

/* Seitenleiste beginnt buendig mit der Kopfleiste */
#sidebar #sidebar-edit-toggle {
    margin-top: 0.25rem;
}

@media (max-width: 767.98px) {
    #page-head {
        padding: 0.25rem 0 0.75rem;
    }
    #page-head-actions,
    #page-head .card-body {
        width: 100%;
    }
    #page-head .input-group {
        flex: 1 1 100%;
        max-width: none;
    }
}

/* --- Seitentitel im Inhalt (Fallback ohne Kopfleiste) ------------ */
#content > .col.fs-4.fw-bold {
    font-size: 1.5rem !important;
    font-weight: 800 !important;
    letter-spacing: -0.015em;
    margin-bottom: 0.85rem !important;
}

/* --- Zuordnungs-Karte: Sprungzeilen ------------------------------
   Markup siehe bills/show.twig (Block "Mieter & Zuordnung").        */
.jump-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.jump-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--ss-border);
    border-radius: 8px;
    background: var(--ss-surface);
    color: inherit;
    text-decoration: none;
}

.jump-item:hover {
    border-color: var(--ss-accent);
    background: color-mix(in srgb, var(--bs-primary, #44799f) 4%, #fff);
    color: inherit;
    text-decoration: none;
}

.jump-item:hover .jump-chev {
    color: var(--ss-accent);
    transform: translateX(2px);
}

.jump-icon {
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 8px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    background: color-mix(in srgb, var(--bs-primary, #44799f) 12%, #fff);
    color: var(--ss-accent);
}

.jump-text {
    min-width: 0;
}

.jump-text strong {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.jump-text span {
    display: block;
    font-size: 0.8rem;
    color: var(--ss-muted);
}

.jump-chev {
    color: #b3bec7;
    transition: transform 0.12s ease, color 0.12s ease;
}

.jump-contact {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--ss-hairline);
    font-size: 0.85rem;
}

.jump-contact a {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

/* --- Sidebar ---------------------------------------------------- */
#sidebar .card {
    --bs-card-border-radius: 10px !important;
}

#sidebar .note-body {
    font-size: 0.87rem;
    line-height: 1.45;
}

#sidebar-edit-toggle {
    color: var(--ss-faint);
}

/* --- Notizen ----------------------------------------------------
   Nur Optik. Edit-Modus, Anpinnen, Farbmarkierung, Erinnerung und
   Archivieren laufen unveraendert ueber note/card.twig + note.js.   */

/* Abschnittsueberschrift "Notizen" */
#sidebar > .border-bottom.fw-bold {
    border-bottom: 0 !important;
    font-size: 0.78rem;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--ss-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.6rem !important;
}

#sidebar > .border-bottom.fw-bold .cursor-pointer:hover {
    color: var(--ss-accent);
}

/* Notizkarte */
#sidebar [id^="note-"].card {
    border-color: var(--ss-border);
    box-shadow: none;
    margin-bottom: 0.6rem !important;
    overflow: hidden;
}

#sidebar [id^="note-"].card .note-body {
    padding: 0.8rem 0.9rem !important;
    color: var(--ss-text);
}

/* Farbmarkierungen: ruhiger Ton statt flaechigem Pastell */
#sidebar [id^="note-"].bg-warning-subtle {
    background: #fffaf0 !important;
    border-color: #f3e0bd;
}

#sidebar [id^="note-"].bg-danger-subtle {
    background: #fdf4f4 !important;
    border-color: #f0cdcf;
}

#sidebar [id^="note-"].bg-info-subtle {
    background: #f4f8fb !important;
    border-color: #cfdfea;
}

#sidebar [id^="note-"].border-light {
    background: transparent !important;
    border-style: dashed;
}

/* Griff zum Umschalten in den Bearbeiten-Modus: erst beim Hover sichtbar */
#sidebar [id^="note-"] .fa-grip-dots {
    opacity: 0 !important;
    transition: opacity 0.12s ease;
    padding: 0.35rem;
    margin: 0 !important;
    color: var(--ss-faint);
}

#sidebar [id^="note-"]:hover .fa-grip-dots,
#sidebar [id^="note-"].edit .fa-grip-dots {
    opacity: 1 !important;
}

/* Erinnerungs-Kopf */
#sidebar [id^="note-"] .card-header.text-bg-danger {
    background: #fbeced !important;
    color: #a92e32 !important;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0.5rem 0.9rem;
    border-bottom: 1px solid #f0cdcf;
}

/* Bearbeiten-Modus */
#sidebar [id^="note-"] textarea.form-control {
    border: 1px solid var(--ss-border) !important;
    border-radius: 8px;
    font-size: 0.87rem;
    line-height: 1.45;
}

#sidebar [id^="note-"] .card-footer {
    background: transparent;
    border-top: 1px solid var(--ss-hairline);
    padding: 0.5rem 0.9rem !important;
}

#sidebar [id^="note-"] .card-footer .btn {
    --bs-btn-border-radius: 6px;
}

/* Neue Notiz */
#note-new.card {
    padding: 0 !important;
    border-color: var(--ss-border);
}

#note-new textarea {
    margin: 0.75rem !important;
    width: calc(100% - 1.5rem) !important;
    border-radius: 8px;
}

#note-new .row {
    align-items: center;
    padding: 0 0.75rem 0.75rem;
    margin: 0;
}

#note-new .row .col i {
    color: var(--ss-muted);
    padding: 0.25rem;
}

#note-new .row .col i:hover {
    color: var(--ss-accent);
}

