/* ═══ 14. UTILITIES / EMPTY STATES ═══ */

/* ─── Utilities ─────────────────────────── */
.loading-placeholder {
    color: var(--text-secondary);
    text-align: center;
    padding: 24px;
    font-size: 14px;
}

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

/* Tablet */
@media (max-width: 1024px) {
    .grid-2col { grid-template-columns: 1fr; }
    .grid-3col { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    #main-content { padding: 20px; }

    /* Widgets etwas kompakter auf Tablet */
    .widget-body { padding: 10px 14px 14px; }
    .widget-header { padding: 10px 14px; }

    /* Touch-Geräte haben kein Hover → Drag-Handle immer sichtbar anzeigen
       und Touch-Target groß genug machen (44px min. laut Apple HIG)           */
    .widget-drag-handle {
        opacity: 0.45;
        font-size: 15px;
        padding: 6px 8px;
        margin: -6px -4px -6px -4px;
        touch-action: none;   /* verhindert Scroll-Interferenz nur auf dem Handle */
    }
    .widget-drag-handle:active { opacity: 1; cursor: grabbing; }
}

/* Mobile */
@media (max-width: 768px) {
    body { overflow: auto; }

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

    /* Sidebar wird zu Bottom-Nav */
    #sidebar {
        width: 100%;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: auto;
        flex-direction: row;
        padding: 0;
        padding-bottom: env(safe-area-inset-bottom, 0);
        border-right: none;
        border-top: 1px solid var(--border);
        z-index: 100;
        background: var(--sidebar-bg);
    }

    /* Sidebar collapse has no effect on mobile bottom-nav */
    #sidebar.collapsed { width: 100%; }
    #sidebar.collapsed .nav-item { justify-content: center; gap: 4px; padding: 8px 12px; }
    #sidebar.collapsed .nav-label { display: block; }
    #sidebar.collapsed .nav-icon { width: auto; }

    .sidebar-logo { display: none; }
    .sidebar-footer { display: none; }
    .nav-mob-action { display: flex; }

    #main-nav {
        flex-direction: row;
        justify-content: space-around;
        width: 100%;
        padding: 8px 0;
    }

    .nav-item {
        flex: 1;
        flex-direction: column;
        gap: 4px;
        padding: 6px 4px;
        font-size: 10px;
        border-right: none;
        border-bottom: 2px solid transparent;
        min-height: 44px;          /* Apple HIG / Material touch target */
        justify-content: center;
        text-align: center;
    }

    .nav-item.active {
        border-right: none;
        border-bottom-color: var(--accent);
    }

    .nav-icon { width: 20px; }

    /* Main Content */
    #main-content {
        padding: 8px;
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 0)); /* Platz für Bottom-Nav + Safe Area */
        overflow-y: auto;
    }

    .page-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .page-header .btn-primary { width: 100%; }

    .total-value { font-size: 28px; }
    .total-pl { flex-wrap: wrap; }

    /* Cards */
    .card { padding: 12px 10px; }

    /* Holdings Table - horizontal scroll */
    .table-container {
        margin: 0 -16px;
        padding: 0 16px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Holdings: Grid wird inline gesetzt — Table scrollt horizontal auf Mobile */
    .table-header { min-width: 0; }

    .holding-row { padding: 12px 0; }

    .asset-logo, .asset-icon { width: 32px; height: 32px; }
    .asset-name { font-size: 13px; }
    .asset-amount { font-size: 11px; }

    /* Transactions List */
    .tx-list-row {
        grid-template-columns: 75px minmax(90px, 1.2fr) 60px minmax(60px, 1fr) minmax(55px, 1fr) minmax(70px, 1fr) minmax(70px, 1fr) 50px;
        font-size: 11px;
        padding: 10px 0;
        min-width: 620px;
        gap: 6px;
    }

    .tx-asset-icon, .tx-asset-icon-fallback {
        width: 16px;
        height: 16px;
    }

    .tx-asset-icon-fallback {
        font-size: 7px;
    }

    .tx-list {
        margin: 0 -16px;
        padding: 0 16px;
        overflow-x: auto;
    }

    /* Modal */
    .modal-content {
        width: 100%;
        max-width: 100%;
        max-height: 90dvh;
        margin: auto 0;
        border-radius: 12px 12px 0 0;
        align-self: flex-end;
    }
    .modal {
        align-items: flex-end;
    }

    .form-row { flex-direction: column; gap: 10px; align-items: stretch; }
    .form-group.flex-2 { flex: 1; }
    /* iOS zoom-fix: Eingaben unter 16px triggern Auto-Zoom beim Fokussieren */
    .input, select.input { font-size: 16px; }

    /* Chart */
    .chart-container { height: clamp(180px, 35vh, 280px); }

    /* Buttons */
    .btn-group { flex-wrap: wrap; }
    .btn-sm { padding: 8px 12px; font-size: 11px; }

    .chart-range-btns { justify-content: center; }
    .chart-range-btns .btn-sm { padding: 6px 10px; font-size: 10px; }

    .chart-stats { padding-right: 10px; }
    .chart-tooltip { font-size: 11px; padding: 6px 10px; }

    /* Import */
    .import-dropzone { padding: 32px 16px; }
    .dropzone-icon { font-size: 28px; }

    /* Stats */
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-box { padding: 10px; }
    .stat-value { font-size: 16px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
    .stat-value .badge-pl { font-size: 12px; }

    /* Settings: stack label + control vertically */
    .setting-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* Small phones */
@media (max-width: 380px) {
    .table-header, .holding-row {
        grid-template-columns: minmax(120px, 2fr) minmax(65px, 1fr) minmax(55px, 1fr) minmax(70px, 1fr) minmax(80px, 1fr);
    }

    .total-value { font-size: 24px; }
    .nav-item { padding: 8px 8px; font-size: 9px; }
    .nav-icon { width: 18px; }
}

/* ═══ 15. AUTH / LOGIN OVERLAY ═══ */

/* ─── Login Overlay ────────────────────────── */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.login-overlay[hidden] { display: none; }

.login-box {
    background: var(--surface);
    border-radius: 12px;
    width: 360px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    overflow: hidden;
}

.login-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 24px 24px;
    background: linear-gradient(135deg, var(--accent), #627EEA);
}

.login-header .logo-icon {
    width: 56px;
    height: 56px;
    font-size: 28px;
    margin-bottom: 12px;
    background: rgba(255,255,255,0.2);
}

.login-header h2 {
    color: #fff;
    font-size: 22px;
    font-weight: 700;
}

.login-body {
    padding: 24px;
}

.login-body .form-group {
    margin-bottom: 16px;
}

.login-body .btn-primary {
    margin-top: 8px;
}

.login-error {
    background: var(--red-bg);
    color: var(--red);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 12px;
}

.login-error[hidden] { display: none; }

.login-link {
    color: var(--text-secondary);
    font-size: 13px;
    text-decoration: none;
    transition: color 0.2s;
}

.login-link:hover {
    color: var(--accent);
}

.full-width { width: 100%; }

/* ─── Password Change ─────────────────────── */
.password-change-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0 12px;
}
.password-change-form .form-row {
    flex: 1;
    min-width: 0;
    align-items: flex-end;
}
.password-change-form .form-actions {
    margin-top: 0;
    flex-shrink: 0;
}
.password-change-form .form-result {
    flex-basis: 100%;
}


/* Settings hint text */
/* Transaction Filter Bar */
.tx-coin-filter {
    margin-bottom: 16px;
}

.tx-coin-select {
    width: 220px;
    font-size: 13px;
}

/* ── Schnell-Verkauf: Prozent-Chips im Modal ── */
.tx-percent-chips {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}
.tx-percent-chips .btn-sm {
    flex: 1;
    padding: 6px 0;
    font-size: 12px;
    height: auto;
    min-height: 28px;
    justify-content: center;
    text-align: center;
}

/* ── Holdings: Verkaufen-Icon in der Reihe ── */
.holding-sell-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.5;
    transition: all 0.15s;
}
.holding-row:hover .holding-sell-btn { opacity: 1; }
.holding-sell-btn:hover {
    background: var(--red-bg);
    color: var(--red);
    opacity: 1;
}

/* ── Transaktions-Filter-Bar ── */
.tx-filter-bar .btn-sm {
    height: 34px;
    padding: 0 14px;
}

.tx-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

/* Desktop: Rows transparent — Items fließen direkt in tx-filter-bar */
.tx-filter-row1,
.tx-filter-row2 { display: contents; }

.tx-filter-select {
    background: var(--input-bg);
    color: var(--text-secondary);
    border: none;
    border-radius: 6px;
    padding: 0 10px;
    height: 34px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    max-width: 180px;
    transition: all 0.2s;
}
.tx-filter-select:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.tx-filter-group {
    display: flex;
    gap: 4px;
}

.tx-filter-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}


.tx-date-range {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tx-date-sep {
    color: var(--text-secondary);
    font-size: 13px;
}

.tx-date-input {
    width: 134px;
    padding: 5px 8px;
    font-size: 13px;
    font-weight: 500;
    height: 34px;
    cursor: pointer;
    color-scheme: var(--color-scheme, dark);
}

.tx-chip {
    background: var(--input-bg);
    color: var(--text-secondary);
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-body);
    padding: 5px 14px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.tx-chip:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.tx-chip.active {
    background: var(--accent);
    color: #fff;
}
.tx-chip.active:hover {
    background: var(--accent);
    color: #fff;
    opacity: 0.9;
}

.tx-filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid currentColor;
    opacity: 0.8;
}

.tx-filter-pill button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 11px;
    padding: 0;
    line-height: 1;
    opacity: 0.7;
}

.tx-filter-pill button:hover { opacity: 1; }

.tx-filter-clear {
    order: 99;
    margin-left: auto;
    background: var(--input-bg);
    border: none;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    font-family: var(--font-body);
    padding: 0 12px;
    height: 34px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.tx-filter-clear:hover {
    background: var(--red-bg);
    color: var(--red);
}

/* Preset-Dropdown + Mobile-Reset: nur auf Mobile sichtbar */
.tx-preset-select { display: none; }
.tx-filter-reset-mob { display: none; }
.tx-preset-btns   { display: contents; }

.settings-hint {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 16px;
}

#privacyLockStatus,
#lockTimeoutRow { border-bottom: none; border-top: none; }

/* Konsistenter Abstand: setting-row nach password-change-form (Sicherheit + App-Sperre) */
.password-change-form + .setting-row { margin-top: 10px; }
#btnSavePin, #btnRemovePin { min-width: 130px; }

.settings-active-check {
    color: var(--green);
    font-weight: 700;
    font-size: 13px;
    margin-left: 4px;
}



.settings-info-box {
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.settings-info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.settings-info-item strong {
    color: var(--text);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Settings import dropzone */
.settings-group .import-dropzone {
    padding: 32px 24px;
}

@media (max-width: 768px) {
    /* ── Settings cards ── */
    .settings-card-wrap { gap: 8px; }
    .settings-group { padding: 16px; }
    .settings-group-header { margin: -16px -16px 12px; padding: 11px 16px 10px; }

    /* ── Info-Box 1-spaltig ── */
    .settings-info-box { grid-template-columns: 1fr; gap: 12px; }

    /* ── Import-Chips umbrechen ── */
    .import-col-chips { display: flex; flex-wrap: wrap; }

    /* ── Passwort-/PIN-Form: Button unter Felder ── */
    .password-change-form {
        flex-direction: column;
        align-items: stretch;
    }
    .password-change-form .form-row {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        width: 100%;
    }
    .password-change-form .form-actions { width: 100%; justify-content: stretch; }
    .password-change-form .form-group { width: 100%; }
    .password-change-form .btn-secondary { width: 100%; }

    /* ── Settings: controls use the full card width on touch screens ── */
    #page-settings .settings-group-header .widget-drag-handle,
    #page-settings .settings-group-header .widget-remove { display: none; }
    #page-settings .setting-row > :first-child,
    #page-settings .setting-row > :last-child { width: 100%; max-width: 100%; }
    #page-settings #themeToggle2 {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
        gap: 6px;
    }
    #page-settings #themeToggle2 .btn-secondary {
        width: 100%;
        min-width: 0;
        justify-content: center;
    }
    #page-settings #sg-security .setting-row > div:last-child {
        display: flex !important;
        width: 100%;
        gap: 6px !important;
    }
    #page-settings #sg-security .setting-row > div:last-child > button {
        flex: 1;
        min-width: 0;
        justify-content: center;
    }

    /* ── Setting-Rows: Buttons voll breite ── */
    #lockTimeoutRow { flex-direction: column; align-items: flex-start; gap: 10px; }
    #lockTimeoutBtns { width: 100%; }
    #page-settings #lockTimeoutBtns {
        display: grid;
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 4px;
    }
    #page-settings #lockTimeoutBtns .btn-sm {
        min-width: 0;
        padding: 8px 4px;
        justify-content: center;
        white-space: nowrap;
    }
    #pinRemoveRow button,
    #btnClearData,
    #btnDeleteAccount { width: 100%; }
    #page-settings .settings-action-item .btn-secondary {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 600px) {
    /* ── Alle Alert-Banner: vertikal stapeln ── */
    .price-alert-banner {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        position: relative;
        padding: 14px 40px 14px 14px;
        box-sizing: border-box;
        width: 100%;
    }
    .price-alert-icon { display: none; }
    .price-alert-close {
        position: absolute;
        top: 10px;
        right: 10px;
    }
    .price-alert-btn,
    .price-alert-btn-sec {
        width: 100%;
        justify-content: center;
    }

    /* MFA badge + button nebeneinander lassen */
    #btnMfaBegin { width: auto; }

    /* Settings-Dropzone kompakter */
    .settings-group .import-dropzone { padding: 24px 16px; }
}

/* ─── Privacy Mode: Beträge blurren ────────── */
[data-privacy="on"] .total-value,
[data-privacy="on"] .total-pl,
[data-privacy="on"] .total-pl-amount,
[data-privacy="on"] .total-pl-pct,
[data-privacy="on"] .wgt-cost-hint,
[data-privacy="on"] .wgt-perf-val,
[data-privacy="on"] .wgt-perf-num,
[data-privacy="on"] .chart-stats,
[data-privacy="on"] .chart-tooltip,
[data-privacy="on"] .holding-row .text-right,
[data-privacy="on"] .holding-row .asset-amount,
[data-privacy="on"] .legend-pct,
[data-privacy="on"] .badge-pl,
[data-privacy="on"] .top-perf-row .badge-pl,
[data-privacy="on"] .tx-right,
[data-privacy="on"] .tx-total,
[data-privacy="on"] .tx-detail,
[data-privacy="on"] .tax-total-val,
[data-privacy="on"] .tax-col {
    filter: blur(8px);
    user-select: none;
    transition: filter 0.2s;
}

#coinChartArea {
    height: 200px;
}

[data-privacy="on"] #chartArea text,
[data-privacy="on"] #coinChartArea text {
    filter: blur(6px);
}

[data-privacy="on"] .donut-center-group {
    filter: blur(6px);
    user-select: none;
}

[data-privacy="on"] .stat-value {
    filter: blur(8px);
    user-select: none;
}

[data-privacy="on"] .tx-list-body .text-right,
[data-privacy="on"] .tx-list-body .tx-date,
[data-privacy="on"] .tx-pagination-info,
[data-privacy="on"] .tx-merged-amt {
    filter: blur(8px);
    user-select: none;
}

/* Mobile Holdings: Werte blurren */
[data-privacy="on"] .mob-h-sub,
[data-privacy="on"] .mob-h-value,
[data-privacy="on"] .mob-h-cost,
[data-privacy="on"] .mob-h-pl {
    filter: blur(8px);
    user-select: none;
}

/* Metric-Widgets: unrealized_gain, irr_widget, risk_volatility, risk_drawdown, risk_sharpe */
[data-privacy="on"] .wgt-metric-val,
[data-privacy="on"] .wgt-metric-hint {
    filter: blur(8px);
    user-select: none;
}

/* Benchmark-Widget: Stat-Spalte + Hover-Tooltip */
[data-privacy="on"] .bench-stat-val,
[data-privacy="on"] .dot-tip-row {
    filter: blur(8px);
    user-select: none;
}

/* ─── Empty State ──────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 24px;
    gap: 12px;
}

.empty-state-compact {
    padding: 24px 16px;
    gap: 10px;
}


.empty-state-icon {
    margin-bottom: 4px;
    opacity: 0.7;
    animation: emptyPulse 3s ease-in-out infinite;
}

@keyframes emptyPulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 0.85; transform: scale(1.05); }
}

.empty-state-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.empty-state-text {
    font-size: 13px;
    color: var(--text-secondary);
    max-width: 380px;
    line-height: 1.5;
}

.empty-state-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-demo {
    border: 1px dashed var(--accent) !important;
    color: var(--accent) !important;
    background: transparent !important;
}

.btn-demo:hover {
    background: var(--accent-bg) !important;
}

.btn-demo:disabled {
    opacity: 0.6;
    cursor: wait;
}
