/* ═══════════════════════════════════════════════════════════
   Jahrbacher PIM System - Stylesheet
   Warm, elegant design for antiques & precious metals
   ═══════════════════════════════════════════════════════════ */

:root {
    /* Farbpalette */
    --sidebar-bg: #1a1a2e;
    --sidebar-hover: #16213e;
    --sidebar-active: #0f3460;
    --gold: #c9a84c;
    --gold-light: #e8d48b;
    --gold-dark: #a07c1c;
    --accent: #c9a84c;
    --bg-main: #f5f3f0;
    --bg-card: #ffffff;
    --bg-card-hover: #faf8f5;
    --text-primary: #2d2d2d;
    --text-secondary: #6b6b6b;
    --text-light: #999;
    --text-sidebar: #b8b8cc;
    --text-sidebar-active: #ffffff;
    --border-color: #e8e4df;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;

    /* Status-Farben */
    --status-active: #22c55e;
    --status-draft: #f59e0b;
    --status-sold: #3b82f6;
    --status-reserved: #8b5cf6;
    --status-archived: #94a3b8;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    margin: 0;
    min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 260px;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1050;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--gold);
    font-size: 1.25rem;
    font-weight: 700;
}

.logo i { font-size: 1.5rem; }
.logo small {
    font-weight: 300;
    opacity: 0.7;
    font-size: 0.85rem;
}

.sidebar-nav {
    list-style: none;
    padding: 12px 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}

.sidebar-nav .nav-section {
    padding: 16px 20px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.3);
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 400;
    border-left: 3px solid transparent;
    transition: all 0.2s;
}

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

.sidebar-nav a.active {
    background: var(--sidebar-active);
    color: var(--text-sidebar-active);
    border-left-color: var(--gold);
    font-weight: 500;
}

.sidebar-nav a i { font-size: 1.1rem; width: 22px; text-align: center; }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-sidebar);
    font-size: 0.85rem;
}

.btn-logout {
    color: var(--text-sidebar);
    text-decoration: none;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
}
.btn-logout:hover { color: #ef4444; background: rgba(239,68,68,0.1); }

.btn-sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-sidebar);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px;
}

/* ── Main Content ─────────────────────────────────────────── */

.main-content {
    margin-left: 260px;
    min-height: 100vh;
}

.page-content {
    padding: 32px;
    max-width: 1400px;
}

.topbar {
    padding: 12px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar .btn-sidebar-toggle {
    color: var(--text-primary);
    font-size: 1.4rem;
}

.topbar-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

/* ── Auth Page ────────────────────────────────────────────── */

.auth-content {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo i {
    font-size: 2.5rem;
    color: var(--gold);
}

.login-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 8px 0 4px;
    color: var(--text-primary);
}

.login-logo p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 0;
}

/* ── Page Headers ─────────────────────────────────────────── */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.page-header .subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 2px;
}

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

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-bottom: 14px;
}

.stat-card .stat-icon.gold { background: rgba(201,168,76,0.12); color: var(--gold-dark); }
.stat-card .stat-icon.green { background: rgba(34,197,94,0.12); color: #16a34a; }
.stat-card .stat-icon.blue { background: rgba(59,130,246,0.12); color: #2563eb; }
.stat-card .stat-icon.purple { background: rgba(139,92,246,0.12); color: #7c3aed; }

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

/* ── Product Grid (Kachel-Ansicht) ────────────────────────── */

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

.product-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all 0.25s ease;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-3px);
    border-color: var(--gold);
}

.product-card .card-image {
    aspect-ratio: 4/3;
    background: #f0ece6;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.product-card .card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-card .card-image .no-image {
    color: var(--text-light);
    font-size: 2.5rem;
}

.product-card .card-badges {
    position: absolute;
    top: 10px;
    left: 10px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.product-card .card-body {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-card .card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 6px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card .card-category {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.product-card .card-footer-info {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.product-card .card-price {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--gold-dark);
}

.product-card .card-sku {
    font-size: 0.7rem;
    color: var(--text-light);
    font-family: monospace;
}

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

.badge-status {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-active { background: rgba(34,197,94,0.15); color: #16a34a; }
.badge-draft { background: rgba(245,158,11,0.15); color: #d97706; }
.badge-sold { background: rgba(59,130,246,0.15); color: #2563eb; }
.badge-reserved { background: rgba(139,92,246,0.15); color: #7c3aed; }
.badge-archived { background: rgba(148,163,184,0.15); color: #64748b; }

.badge-category {
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 500;
    background: rgba(201,168,76,0.12);
    color: var(--gold-dark);
}

/* ── Filter Bar ───────────────────────────────────────────── */

.filter-bar {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: end;
}

.filter-bar .form-group {
    flex: 1;
    min-width: 180px;
}

.filter-bar label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    display: block;
}

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

.form-control, .form-select {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.9rem;
    transition: all 0.2s;
    background: var(--bg-card);
}

.form-control:focus, .form-select:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(201,168,76,0.15);
}

.form-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

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

.btn-gold {
    background: var(--gold);
    color: #1a1a2e;
    border: none;
    font-weight: 600;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.btn-gold:hover {
    background: var(--gold-dark);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-outline-gold {
    border: 1.5px solid var(--gold);
    color: var(--gold-dark);
    background: transparent;
    font-weight: 600;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.btn-outline-gold:hover {
    background: var(--gold);
    color: #1a1a2e;
}

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

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

.content-card .card-header-custom {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.content-card .card-header-custom h2 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
}

.content-card .card-body-custom {
    padding: 24px;
}

/* ── Tables ────────────────────────────────────────────────── */

.table-custom {
    width: 100%;
    border-collapse: collapse;
}

.table-custom th {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    padding: 12px 16px;
    border-bottom: 2px solid var(--border-color);
    text-align: left;
}

.table-custom td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    vertical-align: middle;
}

.table-custom tr:last-child td { border-bottom: none; }

.table-custom tr:hover { background: var(--bg-card-hover); }

/* ── Product Detail ───────────────────────────────────────── */

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.photo-gallery {
    position: relative;
}

.photo-main {
    aspect-ratio: 4/3;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #f0ece6;
    margin-bottom: 12px;
}

.photo-main img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.photo-thumbs {
    display: flex;
    gap: 8px;
}

.photo-thumbs .thumb {
    width: 72px;
    height: 54px;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.photo-thumbs .thumb.active,
.photo-thumbs .thumb:hover {
    border-color: var(--gold);
}

.photo-thumbs .thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.detail-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.detail-value {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.price-display {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gold-dark);
}

.price-purchase {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

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

.export-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.export-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    text-align: center;
    transition: all 0.2s;
}

.export-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--gold);
}

.export-card .platform-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 16px;
    background: rgba(201,168,76,0.1);
    color: var(--gold-dark);
}

.export-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.export-card .count {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 16px;
}

/* ── Pagination ───────────────────────────────────────────── */

.pagination-wrapper {
    display: flex;
    justify-content: center;
    margin-top: 32px;
}

.pagination .page-link {
    color: var(--text-primary);
    border-color: var(--border-color);
    padding: 8px 14px;
    font-size: 0.85rem;
    border-radius: 8px !important;
    margin: 0 3px;
}

.pagination .page-item.active .page-link {
    background: var(--gold);
    border-color: var(--gold);
    color: #1a1a2e;
}

/* ── Print Styles ─────────────────────────────────────────── */

.btn-print {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

@media print {
    /* Alles Unnoetige ausblenden */
    .sidebar, .topbar, .filter-bar, .btn-print,
    .btn-gold, .btn-outline-gold, .btn-outline-danger,
    .sidebar-overlay, .flash-container, .pagination-wrapper,
    .no-print, form[action*="sell"], form[action*="delete"],
    #zvabResults, .card-header-custom button { display: none !important; }

    /* KI-Analyse im Druck komplett ausblenden */
    .ai-panel, .content-card:has(.ai-panel) { display: none !important; }

    /* Layout zuruecksetzen */
    .main-content { margin-left: 0 !important; }
    .page-content { padding: 0 !important; margin: 0 !important; }
    body { font-size: 9pt !important; line-height: 1.3 !important; color: #000 !important; }

    /* Druck-Header anzeigen */
    .product-print-header {
        display: flex !important;
        justify-content: space-between;
        border-bottom: 2px solid #333;
        padding-bottom: 8px;
        margin-bottom: 10px;
    }

    /* Detail-Grid: Foto oben gross, dann Beschreibung, dann Eigenschaften + Preis */
    .detail-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
    }

    /* Foto-Bereich: grosses Hauptfoto */
    .photo-gallery { margin: 0 !important; }
    .photo-main { max-height: 420px !important; border-radius: 0 !important; text-align: center !important; }
    .photo-main img { max-height: 400px !important; max-width: 100% !important; object-fit: contain !important; }
    .photo-thumbs {
        display: flex !important;
        gap: 6px !important;
        margin-top: 6px !important;
    }
    .photo-thumbs .thumb { width: 90px !important; height: 90px !important; border-radius: 0 !important; }
    .photo-thumbs .thumb img { width: 90px !important; height: 90px !important; object-fit: cover !important; }

    /* ZVAB-Preisrecherche ausblenden */
    .detail-grid > div:first-child > .content-card { display: none !important; }

    /* Cards kompakt */
    .content-card {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
        margin-bottom: 6px !important;
        break-inside: avoid;
    }
    .card-header-custom { padding: 3px 8px !important; }
    .card-header-custom h2 { font-size: 10pt !important; margin: 0 !important; }
    .card-body-custom { padding: 4px 8px !important; }

    /* Preisbox kompakt */
    .price-display { font-size: 14pt !important; margin: 0 !important; }
    .price-purchase { font-size: 8pt !important; }

    /* Beschreibung gut lesbar */
    .content-card p { font-size: 9pt !important; margin: 3px 0 !important; }

    /* Eigenschaften kompakt */
    .detail-label { font-size: 7pt !important; margin-top: 1px !important; margin-bottom: 0 !important; }
    .detail-value { font-size: 9pt !important; margin-bottom: 1px !important; }

    /* Seiten-Einstellungen A4 */
    @page {
        size: A4 portrait;
        margin: 10mm 12mm;
    }

    /* Page-Header kompakt */
    .page-header { margin-bottom: 6px !important; }
    .page-header h1 { font-size: 13pt !important; margin: 0 !important; }
    .page-header .subtitle { font-size: 8pt !important; }
    .page-header .d-flex { display: none !important; }

    /* Tabellen kompakt */
    .table-custom { font-size: 8pt !important; }
    .table-custom th, .table-custom td { padding: 1px 4px !important; }

    /* Verkauf-Formular und Aktionen ausblenden */
    .content-card:last-child form,
    .d-flex.gap-2:last-child { display: none !important; }
}

.product-print-header { display: none; }

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

.flash-container {
    padding: 16px 32px 0;
}

.flash-container .alert {
    border-radius: var(--radius-sm);
    border: none;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1040;
        display: none;
    }
    .sidebar.open ~ .sidebar-overlay {
        display: block;
    }
    .main-content {
        margin-left: 0;
    }
    .page-content {
        padding: 20px 16px;
    }
    .detail-grid {
        grid-template-columns: 1fr;
    }
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;
    }
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

@media (max-width: 575.98px) {
    .stat-grid {
        grid-template-columns: 1fr;
    }
    .product-grid {
        grid-template-columns: 1fr 1fr;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* ── Animations ───────────────────────────────────────────── */

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.product-card { animation: fadeIn 0.3s ease forwards; }
.product-card:nth-child(2) { animation-delay: 0.05s; }
.product-card:nth-child(3) { animation-delay: 0.1s; }
.product-card:nth-child(4) { animation-delay: 0.15s; }
.product-card:nth-child(5) { animation-delay: 0.2s; }
.product-card:nth-child(6) { animation-delay: 0.25s; }

/* ── AI Analysis ──────────────────────────────────────────── */

.ai-panel {
    background: linear-gradient(135deg, rgba(201,168,76,0.05), rgba(201,168,76,0.12));
    border: 1px solid rgba(201,168,76,0.25);
    border-radius: var(--radius-md);
    padding: 20px;
}

.ai-panel h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--gold-dark);
    font-size: 0.95rem;
    margin-bottom: 12px;
}

.ai-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
    padding: 20px;
}

.spinner-gold {
    color: var(--gold);
}
