/* ============================================================
   Drostei Kontakte – Neue Oberfläche (css2.css)
   ============================================================ */

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

:root {
    --color-bg:       #f5f3ef;
    --color-surface:  #ffffff;
    --color-nav-bg:   #1e3a2f;
    --color-nav-text: #c8d8c8;
    --color-nav-hover:#4a7c59;
    --color-accent:   #4a7c59;
    --color-accent-lt:#e6ede8;
    --color-text:     #1a1a1a;
    --color-muted:    #6b7a72;
    --color-border:   #d8d3cb;
    --color-row-even: #f9f8f6;
    --color-row-odd:  #ffffff;
    --color-row-hover:#ecf3ee;
    --radius:         6px;
    --shadow-sm:      0 1px 3px rgba(0,0,0,.08);
    --shadow-md:      0 2px 8px rgba(0,0,0,.12);
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
}

/* ── Layout ───────────────────────────────────────────────── */

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────────── */

#header2 {
    background: var(--color-nav-bg);
    color: var(--color-nav-text);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 0 2rem;
    height: 52px;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

#header2 .logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

#header2 .logo img {
    height: 32px;
    width: auto;
    filter: brightness(0) invert(1) opacity(.85);
}

#header2 nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
    align-self: stretch;
}

#header2 nav a,
#header2 nav .nav-group > a {
    color: var(--color-nav-text);
    text-decoration: none;
    padding: 0.35rem 0.9rem;
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

#header2 nav a svg,
#header2 nav .nav-group > a svg {
    flex-shrink: 0;
    opacity: 0.7;
}

#header2 nav a:hover,
#header2 nav a.active {
    background: var(--color-nav-hover);
    color: #fff;
}

#header2 nav a:hover svg,
#header2 nav a.active svg {
    opacity: 1;
}

/* Dropdown */
.nav-group {
    position: relative;
    align-self: stretch;
    display: flex;
    align-items: center;
}

.nav-group ul {
    display: none;
    position: absolute;
    top: calc(100% - 4px);
    left: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    min-width: 180px;
    list-style: none;
    z-index: 200;
    padding: 0.35rem 0.5rem;
}

.nav-group:hover ul,
.nav-group:focus-within ul {
    display: block;
}

.nav-group ul li a {
    color: var(--color-text) !important;
    display: block;
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
    border-radius: var(--radius);
}

.nav-group ul li a:hover,
.nav-group ul li a.active {
    background: var(--color-accent-lt) !important;
    color: var(--color-accent) !important;
}

.nav-group ul li.nav-divider {
    height: 1px;
    background: var(--color-border);
    margin: 0.3rem 0.5rem;
    padding: 0;
}

.nav-count {
    margin-left: auto;
    font-size: 0.72rem;
    color: var(--color-muted);
    background: var(--color-row-even);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 0 6px;
    line-height: 1.6;
    flex-shrink: 0;
}

.nav-group ul li a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ── Quicksearch ──────────────────────────────────────────── */

.quicksearch {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: var(--radius);
    padding: 0.3rem 0.65rem;
    transition: background 0.15s, width 0.2s;
    width: 200px;
}

.quicksearch:focus-within {
    background: rgba(255,255,255,.18);
    width: 260px;
}

.quicksearch svg {
    flex-shrink: 0;
    color: var(--color-nav-text);
    opacity: 0.6;
}

.quicksearch input {
    background: none;
    border: none;
    outline: none;
    color: var(--color-nav-text);
    font-size: 0.85rem;
    font-family: inherit;
    width: 100%;
    padding: 0;
}

.quicksearch input::placeholder {
    color: rgba(200,216,200,.5);
}

/* User info + theme toggle */
.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

.header-right .user-name {
    font-size: 0.82rem;
    color: var(--color-nav-text);
    opacity: 0.8;
}

.btn-theme-switch {
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.2);
    color: var(--color-nav-text);
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.78rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
    white-space: nowrap;
}

.btn-theme-switch:hover {
    background: rgba(255,255,255,.22);
}

/* ── Main content ─────────────────────────────────────────── */

#main2 {
    flex: 1;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 2rem 4rem;
}

/* ── Page title ───────────────────────────────────────────── */

.page-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text);
}

.page-header .meta {
    font-size: 0.85rem;
    color: var(--color-muted);
}

/* ── Page header right side ───────────────────────────────── */

.page-header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.filter-reset-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: #fdf0ee;
    border: 1px solid #e8b4ad;
    color: #c0392b;
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.12s, border-color 0.12s;
    white-space: nowrap;
}

.filter-reset-btn:hover {
    background: #fae0dc;
    border-color: #c0392b;
}

.btn-export {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-muted);
    padding: 0.3rem 0.85rem;
    border-radius: var(--radius);
    font-size: 0.8rem;
    text-decoration: none;
    transition: border-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.btn-export:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

/* ── Contact table ────────────────────────────────────────── */

.contact-table-wrap {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.contact-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.contact-table thead th {
    background: #f0ede8;
    color: var(--color-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.contact-table thead th a {
    display: block;
    padding: 0.65rem 0.75rem;
    color: var(--color-muted);
    text-decoration: none;
    transition: color 0.15s;
}

.contact-table thead th a:hover {
    color: var(--color-accent);
}

.contact-table thead th.active a {
    color: var(--color-accent);
    font-weight: 700;
}

.contact-table thead th.th-del {
    width: 36px;
}

.contact-table thead th.kid {
    width: 52px;
    text-align: right;
}

.contact-table tbody tr {
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
    transition: background 0.1s;
}

.contact-table tbody tr:last-child {
    border-bottom: none;
}

.contact-table tbody tr:nth-child(even) {
    background: var(--color-row-even);
}

.contact-table tbody tr:hover {
    background: var(--color-row-hover);
}

.contact-table td {
    padding: 0.6rem 0.75rem;
    color: var(--color-text);
    vertical-align: top;
}

.contact-table td.kid {
    color: var(--color-muted);
    font-size: 0.8rem;
    text-align: right;
    width: 52px;
}

.contact-table td.del {
    width: 36px;
    text-align: center;
    padding: 0.4rem 0.35rem;
}

.contact-table td.del a {
    color: var(--color-border);
    font-size: 1rem;
    line-height: 1;
    text-decoration: none;
    transition: color 0.15s;
    display: inline-block;
}

.contact-table tbody tr:hover td.del a {
    color: #c0392b;
}

/* Rücksprung-Highlight */
@keyframes returnHighlight {
    0%   { background: #c8e6c9; }
    100% { background: transparent; }
}

.contact-table tbody tr.highlight-return {
    animation: returnHighlight 1.8s ease-out forwards;
}

/* ── Loading / sentinel ───────────────────────────────────── */

#load-sentinel {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#all-loaded {
    text-align: center;
    padding: 1.5rem;
    color: var(--color-muted);
    font-size: 0.82rem;
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 900px) {
    #main2 { padding: 1rem 1rem 3rem; }
    .contact-table td.anschrift,
    .contact-table th.anschrift { display: none; }
}

@media (max-width: 600px) {
    #header2 { padding: 0 1rem; }
    .contact-table td.plz,
    .contact-table th.plz,
    .contact-table td.lkz,
    .contact-table th.lkz { display: none; }
}

/* ============================================================
   Formular / Suche
   ============================================================ */

/* ── Seitenlayout ─────────────────────────────────────────── */

.form-page {
    max-width: 1100px;
}

.form-layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.form-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-aside {
    width: 200px;
    flex-shrink: 0;
    position: sticky;
    top: 68px;
}

/* ── Breadcrumb / Blättern ────────────────────────────────── */

.form-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.back-link {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 500;
}

.back-link:hover { text-decoration: underline; }

.form-nav-arrows {
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.nav-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    text-decoration: none;
    transition: border-color 0.12s, color 0.12s, background 0.12s;
    user-select: none;
}

.nav-arrow:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    background: var(--color-accent-lt);
}

.nav-arrow-disabled {
    color: var(--color-border);
    cursor: default;
    border-color: transparent;
    background: transparent;
}

.form-kid {
    margin-left: auto;
    color: var(--color-muted);
    font-size: 0.8rem;
}

/* ── Save button feedback ─────────────────────────────────── */

.btn-save--ok {
    background: #2e7d4f !important;
    border-color: #2e7d4f !important;
    transition: background 0.2s, border-color 0.2s;
}

/* ── Cards ────────────────────────────────────────────────── */

.form-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.form-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--color-border);
    background: #f7f5f2;
}

.form-card-header h2 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
}

.btn-save {
    background: var(--color-accent);
    color: #fff;
    border: none;
    padding: 0.35rem 1.1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-save:hover { background: #3a6347; }

/* ── Form Grid ────────────────────────────────────────────── */

.form-grid {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.fg-row {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.fg-selects { flex-wrap: wrap; }
.fg-selects .fg-field { flex: 1; min-width: 140px; }

.fg-two .fg-field { flex: 1; min-width: 160px; }
.fg-three .fg-field { flex: 1; min-width: 130px; }

.fg-plz-ort { align-items: flex-end; }
.fg-plz { flex: 0 0 90px !important; }
.fg-ort { flex: 1 !important; }

.fg-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.fg-full { width: 100%; }

.fg-field label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.fg-field input[type="text"],
.fg-field input[type="email"],
.fg-field textarea,
.fg-field select,
select.f2-select {
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.88rem;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.fg-field input:focus,
.fg-field textarea:focus,
.fg-field select:focus,
select.f2-select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(74,124,89,.15);
}

.fg-field textarea { resize: vertical; }

.fg-field select,
select.f2-select { padding: 0.4rem 0.5rem; }

/* Website-Feld mit Link-Icon */
.field-with-icon {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.field-with-icon input { flex: 1; }

.field-icon {
    color: var(--color-accent);
    text-decoration: none;
    font-size: 1rem;
    line-height: 1;
    padding: 0.35rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    transition: background 0.15s;
}

.field-icon:hover { background: var(--color-accent-lt); }

/* ── Metadaten ────────────────────────────────────────────── */

.form-meta {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
    color: var(--color-muted);
    border-top: 1px solid var(--color-border);
    background: #faf9f7;
}

/* ── Verteiler ────────────────────────────────────────────── */

.form-card-verteiler .form-card-header { border-bottom: 1px solid var(--color-border); }

.verteiler-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
}

.verteiler-list li label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.83rem;
    color: var(--color-text);
    padding: 0.3rem 0.65rem;
    background: var(--color-row-even);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}

.verteiler-list li label:hover {
    background: var(--color-accent-lt);
    border-color: var(--color-accent);
}

.verteiler-list li input[type="checkbox"] {
    accent-color: var(--color-accent);
}

/* ── Aside ────────────────────────────────────────────────── */

.aside-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.aside-card h3 {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--color-border);
    background: #f7f5f2;
}

.aside-links {
    list-style: none;
    padding: 0.5rem 0;
}

.aside-links li a,
.aside-submit {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    color: var(--color-text);
    text-decoration: none;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.12s, color 0.12s;
}

.aside-links li a:hover,
.aside-submit:hover {
    background: var(--color-accent-lt);
    color: var(--color-accent);
}

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 700px) {
    .form-layout { flex-direction: column; }
    .form-aside { width: 100%; position: static; }
    .fg-selects .fg-field { min-width: 100%; }
}

/* ============================================================
   Admin-Tabellen
   ============================================================ */

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.admin-table thead th {
    background: #f0ede8;
    color: var(--color-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

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

.admin-table tbody tr:last-child { border-bottom: none; }
.admin-table tbody tr:hover { background: var(--color-row-hover); }

.admin-table td {
    padding: 0.55rem 0.75rem;
    color: var(--color-text);
    vertical-align: middle;
}

.admin-actions {
    text-align: right;
    white-space: nowrap;
    width: 1%;
}

.admin-btn {
    display: inline-block;
    padding: 0.25rem 0.65rem;
    font-size: 0.78rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-muted);
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.12s, color 0.12s, background 0.12s;
    margin-left: 0.35rem;
}

.admin-btn:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    background: var(--color-accent-lt);
}

.admin-btn-del:hover {
    border-color: #c0392b;
    color: #c0392b;
    background: #fdf0ee;
}

/* ── Adress-Übersicht ─────────────────────────────────────── */

.overview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.overview-list {
    list-style: none;
    padding: 0.5rem 0;
    max-height: 400px;
    overflow-y: auto;
}

.overview-list li {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.3rem 0.75rem;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--color-border);
}

.overview-list li:last-child { border-bottom: none; }

.overview-alt {
    color: var(--color-muted);
    font-size: 0.78rem;
}

.overview-lkz {
    font-size: 0.75rem;
    color: var(--color-muted);
    background: var(--color-row-even);
    border: 1px solid var(--color-border);
    border-radius: 3px;
    padding: 0 4px;
}

/* ── Verteiler-Übersicht ──────────────────────────────────── */

.verteiler-grid {
    column-count: 4;
    column-gap: 0.75rem;
}

@media (max-width: 900px) {
    .verteiler-grid { column-count: 3; }
}
@media (max-width: 600px) {
    .verteiler-grid { column-count: 2; }
}

.verteiler-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 1rem 1.25rem;
    break-inside: avoid;
    margin-bottom: 0.75rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    text-decoration: none;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
}

.verteiler-card:hover {
    border-color: var(--color-accent);
    background: var(--color-accent-lt);
    box-shadow: var(--shadow-md);
}

.verteiler-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text);
}

.verteiler-anzahl {
    font-size: 0.78rem;
    color: var(--color-muted);
}
