/* MyTaag – Basis-Styles. Farben: Schwarz, Weiß, Blau. */
:root {
    --blue:        #1d4ed8;
    --blue-dark:   #1741ac;
    --black:       #0b1220;
    --white:       #ffffff;
    --bg:          #f2f4f8;
    --muted:       #64748b;
    --border:      #e2e8f0;
    --error-bg:    #fef2f2;
    --error-fg:    #b91c1c;
    --success-bg:  #ecfdf5;
    --success-fg:  #047857;
    --info-bg:     #eff6ff;
    --info-fg:     #1d4ed8;
    --radius:      14px;
    --shadow:      0 10px 30px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--black);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    line-height: 1.5;
}

/* Main / Layout */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 16px;
}

/* Logo (ersetzt die Kopfleiste) */
.logo {
    display: block;
    margin-bottom: 28px;
}
.logo img {
    display: block;
    height: 40px;
    width: auto;
    max-height: 40px;
    max-width: 160px;
}
.auth-wrap, .dash-wrap {
    width: 100%;
    max-width: 420px;
}
.dash-wrap { max-width: 560px; }

/* ---------------------------------------------------------------------------
 *  Einstellungen
 * ------------------------------------------------------------------------- */
.settings-wrap {
    width: 100%;
    max-width: 560px;
}
.settings-head { margin-bottom: 24px; }
.settings-head h1 {
    margin: 0 0 6px;
    font-size: 28px;
    letter-spacing: -.025em;
}
.settings-head p { margin: 0; color: var(--muted); }

/* Panel = eine Einstellungsgruppe */
.panel {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px 26px;
    margin-bottom: 16px;
}
.panel-head { margin-bottom: 18px; }
.panel-head h2 {
    margin: 0 0 4px;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -.01em;
}
.panel-head p {
    margin: 0;
    font-size: 14px;
    color: var(--muted);
    line-height: 1.5;
}
.panel-head strong { color: var(--black); font-weight: 600; }

/* Formularfelder in Panels */
.field { margin-bottom: 16px; }
.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--black);
}
.field input { margin-top: 0; }

.panel-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Danger-Zone */
.panel-danger {
    border-color: #fca5a5;
    background: linear-gradient(0deg, var(--error-bg), var(--error-bg)) padding-box, var(--white);
    background: #fff8f8;
}
.panel-danger .panel-head h2 { color: var(--error-fg); }

.settings-back {
    margin: 8px 0 0;
    text-align: center;
    font-size: 14px;
}
.settings-back a { color: var(--blue); text-decoration: none; font-weight: 600; }
.settings-back a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------------------
 *  Modal
 * ------------------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(11, 18, 32, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
    animation: overlay-in .15s ease;
}
.modal-overlay[hidden] { display: none; }
.modal {
    width: 100%;
    max-width: 440px;
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .3);
    padding: 26px;
    animation: modal-in .18s ease;
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.modal-head h2 {
    margin: 0;
    font-size: 19px;
    letter-spacing: -.01em;
    color: var(--error-fg);
}
.modal-close {
    border: none;
    background: transparent;
    font-size: 26px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    padding: 0 4px;
}
.modal-close:hover { color: var(--black); }
.modal-text {
    margin: 0 0 20px;
    font-size: 14px;
    color: var(--muted);
    line-height: 1.55;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 8px;
}
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
    from { opacity: 0; transform: translateY(8px) scale(.98); }
    to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    .modal-overlay, .modal { animation: none; }
}

/* Card */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px;
}
.card h1 {
    margin: 0 0 6px;
    font-size: 24px;
    letter-spacing: -.02em;
}
.muted { color: var(--muted); margin: 0 0 20px; }

/* Forms */
form label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 14px;
    color: var(--black);
}
form input {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 12px 14px;
    font-size: 15px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--white);
    color: var(--black);
    transition: border-color .15s, box-shadow .15s;
}
form input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, .15);
}

/* Buttons */
.btn {
    display: inline-block;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 12px 18px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background .15s, border-color .15s, color .15s;
}
.btn-primary {
    background: var(--blue);
    color: var(--white);
}
.btn-primary:hover { background: var(--blue-dark); }
.btn-ghost {
    background: transparent;
    border-color: var(--border);
    color: var(--black);
}
.btn-ghost:hover { border-color: var(--blue); color: var(--blue); }
.btn-danger {
    background: var(--error-fg);
    color: var(--white);
}
.btn-danger:hover { background: #991b1b; }
.btn-block { width: 100%; margin-top: 6px; }

/* Checkbox-Label */
label.check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-weight: 500;
    margin-bottom: 16px;
}
label.check input {
    width: auto;
    margin: 3px 0 0;
}

/* Dashboard-Buttons nebeneinander */
.dash-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Rows / links */
.row-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    font-size: 14px;
}
.row-between a { color: var(--blue); text-decoration: none; }
.row-between a:hover { text-decoration: underline; }

.auth-alt {
    margin: 20px 0 0;
    text-align: center;
    font-size: 14px;
    color: var(--muted);
}
.auth-alt a { color: var(--blue); text-decoration: none; font-weight: 600; }
.auth-alt a:hover { text-decoration: underline; }

/* Flash-Meldungen */
.flash {
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
}
.flash-error   { background: var(--error-bg);   color: var(--error-fg); }
.flash-success { background: var(--success-bg); color: var(--success-fg); }
.flash-info    { background: var(--info-bg);    color: var(--info-fg); }

/* Dashboard */
.dash-placeholder {
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 24px;
    margin: 20px 0;
    color: var(--muted);
    background: #fafbfd;
}
.dash-placeholder p { margin: 0; }

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--muted);
    font-size: 13px;
}

/* ===========================================================================
 *  App-Shell mit Sidebar (eingeloggter Bereich)
 * ========================================================================= */
body.app { display: block; }

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 248px;
    flex-shrink: 0;
    background: var(--white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-logo {
    display: block;
    padding: 4px 8px 22px;
}
.sidebar-logo img { display: block; height: 34px; width: auto; }

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 12px;
    border-radius: 10px;
    color: var(--black);
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    transition: background .12s, color .12s;
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; color: var(--muted); transition: color .12s; }
.nav-item:hover { background: #f1f5f9; }
.nav-item.is-active { background: var(--info-bg); color: var(--blue); }
.nav-item.is-active svg { color: var(--blue); }

.sidebar-foot {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.sidebar-user { padding: 4px 12px 12px; }
.sidebar-user-name { font-weight: 700; font-size: 14px; }
.sidebar-user-mail {
    font-size: 12px; color: var(--muted);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-logout:hover { background: var(--error-bg); color: var(--error-fg); }
.nav-logout:hover svg { color: var(--error-fg); }

/* Main-Bereich */
.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.app-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 28px;
    border-bottom: 1px solid var(--border);
    background: var(--white);
    position: sticky;
    top: 0;
    z-index: 20;
}
.app-topbar-title { font-size: 18px; font-weight: 800; letter-spacing: -.02em; }
.menu-toggle {
    display: none;
    border: none; background: transparent; cursor: pointer;
    padding: 4px; color: var(--black);
}
.menu-toggle svg { width: 24px; height: 24px; display: block; }
.app-content {
    padding: 28px 32px;
    max-width: 1200px;
    width: 100%;
}
/* Formularlastige Seiten schmal halten (gute Lesbarkeit) */
.content-narrow { max-width: 640px; }

.sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(11, 18, 32, .45);
    z-index: 30;
}
.sidebar-backdrop[hidden] { display: none; }

/* Mobile: Sidebar wird zur Off-Canvas-Leiste */
@media (max-width: 820px) {
    .menu-toggle { display: block; }
    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        height: 100vh;
        z-index: 40;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: 0 10px 40px rgba(15, 23, 42, .18);
    }
    .app-shell.nav-open .sidebar { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
    .sidebar { transition: none; }
}

/* ===========================================================================
 *  Seiten-Header innerhalb der App
 * ========================================================================= */
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}
.page-head h1 { margin: 0 0 4px; font-size: 24px; letter-spacing: -.02em; }
.page-head p { margin: 0; color: var(--muted); font-size: 14px; }

/* ===========================================================================
 *  Karten-Liste (cards.php)
 * ========================================================================= */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}
.card-tile {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    flex-direction: column;
}
.card-tile-head { display: flex; align-items: center; gap: 14px; }
.card-avatar {
    width: 52px; height: 52px; border-radius: 50%;
    object-fit: cover; flex-shrink: 0;
    background: #e2e8f0;
}
.card-avatar-fallback {
    width: 52px; height: 52px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--info-bg); color: var(--blue);
    font-weight: 800; font-size: 20px; flex-shrink: 0;
}
.card-tile-name { font-weight: 700; font-size: 16px; }
.card-tile-headline { color: var(--muted); font-size: 13px; }
.card-tile-url {
    margin: 14px 0 16px;
    font-size: 12px; color: var(--muted);
    word-break: break-all;
}
.card-tile-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 8px; }

.empty-state {
    text-align: center;
    padding: 48px 24px;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: #fafbfd;
    color: var(--muted);
}
.empty-state h2 { margin: 0 0 6px; color: var(--black); font-size: 18px; }
.empty-state p { margin: 0 0 18px; }

/* ===========================================================================
 *  Karten-Editor (card-edit.php)
 * ========================================================================= */
.editor-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.edit-photo { display: flex; align-items: center; gap: 16px; }
.edit-photo img, .edit-photo .card-avatar-fallback { width: 72px; height: 72px; }
.edit-photo img { border-radius: 50%; object-fit: cover; }

.fields-list { display: flex; flex-direction: column; gap: 10px; }
.field-row {
    display: grid;
    grid-template-columns: 150px 1fr 40px;
    gap: 10px;
    align-items: center;
}
.field-row select, .field-row input {
    margin: 0;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    background: var(--white);
    width: 100%;
}
.field-remove {
    border: 1px solid var(--border);
    background: var(--white);
    border-radius: 10px;
    height: 40px; cursor: pointer;
    color: var(--muted); font-size: 18px; line-height: 1;
}
.field-remove:hover { border-color: #fca5a5; color: var(--error-fg); }
.color-row { display: flex; align-items: center; gap: 12px; }
.color-row input[type=color] {
    width: 46px; height: 40px; padding: 2px; border: 1px solid var(--border);
    border-radius: 10px; background: var(--white); cursor: pointer;
}

/* Vier Farbwähler (Design-Panel) */
.color-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.color-swatch {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 600; color: var(--muted);
}
.color-swatch input[type=color] {
    width: 100%; height: 44px; padding: 2px;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--white); cursor: pointer;
}
@media (max-width: 480px) { .color-grid { grid-template-columns: repeat(2, 1fr); } }

/* Feld-Typ-Auswahl im Modal */
.ci { width: 20px; height: 20px; }
#field-modal .modal { max-width: 470px; }
#field-modal .modal-head h2 { color: var(--black); }
#field-step-type { max-height: 62vh; overflow-y: auto; }
.type-group-label {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .05em; color: var(--muted); margin: 14px 0 8px;
}
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.type-option {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 12px; border: 1px solid var(--border); border-radius: 11px;
    background: var(--white); cursor: pointer; font-size: 14px; font-weight: 600;
    text-align: left; color: var(--black);
}
.type-option:hover { border-color: var(--blue); background: var(--info-bg); }
.type-option-icon {
    width: 24px; height: 24px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--blue);
}
.type-option-icon .ci { width: 20px; height: 20px; }
.chosen-type { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 17px; }
.chosen-type .type-option-icon { width: 42px; height: 42px; background: var(--info-bg); border-radius: 11px; }
.chosen-type .type-option-icon .ci { width: 22px; height: 22px; }
.editor-actions {
    display: flex; gap: 12px; justify-content: flex-end;
    margin-top: 8px;
}
@media (max-width: 560px) {
    .field-row { grid-template-columns: 1fr 40px; }
    .field-row select { grid-column: 1 / -1; }
}
