/* ══════════════════════════════════════════════════════════════════════════════
   StorefrontSpy - KPI Dashboard Stylesheet
   ══════════════════════════════════════════════════════════════════════════════ */

:root {
    --primary: #1a2b4a;
    --primary-light: #2d4a7a;
    --bg: #ffffff;
    --bg-alt: #f8f9fb;
    --border: #e2e5ea;
    --text: #1a1a1a;
    --text-muted: #6b7280;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

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

html {
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text);
    background: var(--bg-alt);
    line-height: 1.5;
}

/* ── Navbar ───────────────────────────────────────────────────────────────── */

.navbar {
    background: var(--primary);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    height: 52px;
}

.nav-brand {
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
    margin-right: 2rem;
}

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

.nav-links a {
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
}

.nav-links a:hover,
.nav-links a.active {
    background: rgba(255,255,255,0.12);
    color: #fff;
}

.nav-logout {
    margin-left: auto;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    margin-left: auto;
    padding: 0.25rem;
}

/* ── Container ────────────────────────────────────────────────────────────── */

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* ── Flash Messages ───────────────────────────────────────────────────────── */

.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.flash-success {
    background: #ecfdf5;
    color: var(--success);
    border: 1px solid #bbf7d0;
}

.flash-error {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

/* ── Auth Pages ───────────────────────────────────────────────────────────── */

.auth-container {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.auth-box h1 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 0.25rem;
    text-align: center;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* ── Forms ─────────────────────────────────────────────────────────────────── */

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.3rem;
    color: var(--text);
    font-size: 0.85rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.15s;
    background: var(--bg);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,43,74,0.08);
}

.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.form-row .form-group {
    flex: 1;
    min-width: 150px;
}

.form-group-btn {
    display: flex;
    align-items: flex-end;
    padding-bottom: 0;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
    line-height: 1.4;
}

.btn:hover {
    background: var(--bg-alt);
    border-color: var(--text-muted);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-light);
}

.btn-danger {
    color: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover {
    background: #fef2f2;
}

.btn-success {
    color: var(--success);
    border-color: var(--success);
}

.btn-success:hover {
    background: #ecfdf5;
}

.btn-full {
    width: 100%;
    text-align: center;
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

/* ── Section Labels ────────────────────────────────────────────────────────── */

.section-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    margin-top: 0.5rem;
}

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

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.summary-grid-5 {
    grid-template-columns: repeat(5, 1fr);
}

/* ── Kapitalfluss-Balken ──────────────────────────────────────────────────── */

.capital-flow-bar {
    display: flex;
    height: 32px;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.5rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: #fff;
}

.cf-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2%;
    transition: width 0.3s;
    white-space: nowrap;
    overflow: hidden;
}

.cf-fba { background: var(--success); }
.cf-inbound { background: var(--warning); }
.cf-reserved { background: #3b82f6; }
.cf-defekt { background: var(--danger); }

.summary-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.summary-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.3rem;
}

.summary-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.summary-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

.summary-detail {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    padding: 0.2rem 0;
    border-bottom: 1px solid var(--border);
}

.summary-detail:last-child {
    border-bottom: none;
}

.card-highlight {
    border-left: 3px solid var(--primary);
}

/* ── Progress Bars ────────────────────────────────────────────────────────── */

.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    margin-top: 0.6rem;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

.progress-success { background: var(--success); }
.progress-warning { background: var(--warning); }
.progress-danger { background: var(--danger); }

/* ── Row Status ───────────────────────────────────────────────────────────── */

.row-dead td {
    background: #fef2f2 !important;
}

.row-slow td {
    background: #fffbeb !important;
}

/* ── Tabs ──────────────────────────────────────────────────────────────────── */

.tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}

.tab {
    padding: 0.5rem 1rem;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

/* ── Table ─────────────────────────────────────────────────────────────────── */

.table-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: center;
}

.search-input {
    flex: 1;
    max-width: 400px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

.table-wrapper {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
    box-shadow: var(--shadow);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.data-table th {
    background: var(--primary);
    color: #fff;
    padding: 0.6rem 0.75rem;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    position: sticky;
    top: 0;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.data-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.data-table th.sortable:hover {
    background: var(--primary-light);
}

.data-table th.num,
.data-table td.num {
    text-align: right;
}

.data-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr:nth-child(even) {
    background: var(--bg-alt);
}

.data-table tbody tr:hover {
    background: #eef2f7;
}

/* Produkt-Zelle */
.product-cell {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 250px;
}

.product-img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    border-radius: 4px;
    background: var(--bg-alt);
    flex-shrink: 0;
}

.product-info {
    min-width: 0;
}

.product-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.product-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state a {
    color: var(--primary);
}

/* ── Status-Farben ────────────────────────────────────────────────────────── */

.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.roi-actual {
    font-weight: 600;
}

/* ── Badges ───────────────────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-active {
    background: #ecfdf5;
    color: var(--success);
}

.badge-inactive {
    background: #fef2f2;
    color: var(--danger);
}

/* ── Settings ─────────────────────────────────────────────────────────────── */

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.settings-section {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.settings-section h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--primary);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

/* ── Charts ───────────────────────────────────────────────────────────────── */

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.chart-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.chart-card h3 {
    font-size: 0.9rem;
    color: var(--primary);
    margin-bottom: 1rem;
}

/* ── Sync Status ──────────────────────────────────────────────────────────── */

.sync-status {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.info-bar {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: var(--primary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* ── Admin Actions ────────────────────────────────────────────────────────── */

.actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.inline {
    display: inline;
}

.inline-form {
    width: 100%;
}

/* ── Error Page ───────────────────────────────────────────────────────────── */

.error-page {
    text-align: center;
    padding: 4rem 1rem;
}

.error-page h1 {
    font-size: 4rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.error-page p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* ══════════════════════════════════════════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
    .summary-grid,
    .summary-grid-4,
    .summary-grid-5 {
        grid-template-columns: repeat(2, 1fr);
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    html {
        font-size: 13px;
    }

    .nav-toggle {
        display: block;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 52px;
        left: 0;
        right: 0;
        background: var(--primary);
        flex-direction: column;
        padding: 0.5rem;
        box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    }

    .nav-links.open {
        display: flex;
    }

    .nav-links a {
        padding: 0.6rem 1rem;
    }

    .nav-logout {
        margin-left: 0;
        border-top: 1px solid rgba(255,255,255,0.1);
        margin-top: 0.25rem;
        padding-top: 0.25rem;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }

    .container {
        padding: 1rem;
    }

    .table-controls {
        flex-direction: column;
    }

    .search-input {
        max-width: 100%;
    }

    .form-row {
        flex-direction: column;
    }

    .product-title {
        max-width: 150px;
    }
}

@media (max-width: 480px) {
    .summary-value {
        font-size: 1.25rem;
    }

    .data-table {
        font-size: 0.78rem;
    }

    .data-table td,
    .data-table th {
        padding: 0.4rem 0.5rem;
    }
}
