/* ============================================================
   DROPGIFT SaaS — Design System
   Premium dark theme with emerald accents
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg-deep: #06070a;
    --bg-base: #0a0b10;
    --bg-card: #111318;
    --bg-card-hover: #161820;
    --bg-elevated: #1a1c24;
    --bg-input: #0d0e13;
    --border: rgba(255,255,255,0.06);
    --border-hover: rgba(255,255,255,0.12);
    --border-focus: #10B981;
    --text-primary: #f0f1f3;
    --text-secondary: #8b8e98;
    --text-muted: #5a5d66;
    --emerald: #10B981;
    --emerald-dark: #059669;
    --emerald-glow: rgba(16, 185, 129, 0.15);
    --purple: #8B5CF6;
    --purple-glow: rgba(139, 92, 246, 0.15);
    --red: #EF4444;
    --red-glow: rgba(239, 68, 68, 0.1);
    --amber: #F59E0B;
    --amber-glow: rgba(245, 158, 11, 0.1);
    --blue: #3B82F6;
    --sidebar-w: 260px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --font: 'DM Sans', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font);
    background: var(--bg-deep);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--emerald); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--emerald-dark); }

/* ============================================================
   LAYOUT: Sidebar + Main
   ============================================================ */

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

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg-base);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex; align-items: center; gap: 10px;
}

.sidebar-logo span { color: var(--emerald); }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }

.nav-section { margin-bottom: 24px; }
.nav-section-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); padding: 0 12px; margin-bottom: 8px; font-weight: 600; }

.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    color: var(--text-secondary); font-weight: 500; font-size: 14px;
    transition: all var(--transition); cursor: pointer;
    text-decoration: none;
    margin-bottom: 2px;
}
.nav-item i { width: 20px; text-align: center; font-size: 16px; }
.nav-item:hover { color: var(--text-primary); background: var(--bg-card); }
.nav-item.active { color: var(--emerald); background: var(--emerald-glow); }

.nav-badge { margin-left: auto; background: var(--red); color: white; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 10px; }

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: var(--radius-sm);
}
.sidebar-user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--emerald-glow); color: var(--emerald);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px;
}
.sidebar-user-info { flex: 1; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.sidebar-user-role { font-size: 11px; color: var(--text-muted); }

.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: 32px;
    min-height: 100vh;
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 32px;
}

.page-title { font-size: 28px; font-weight: 700; }
.page-subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: border-color var(--transition);
}
.card:hover { border-color: var(--border-hover); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.card-title { font-size: 16px; font-weight: 600; }

/* Stat Cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 28px; }

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
    overflow: hidden;
}
.stat-card::after {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.stat-card.emerald::after { background: var(--emerald); }
.stat-card.purple::after { background: var(--purple); }
.stat-card.amber::after { background: var(--amber); }
.stat-card.red::after { background: var(--red); }
.stat-card.blue::after { background: var(--blue); }

.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }
.stat-value { font-size: 32px; font-weight: 700; margin-top: 8px; line-height: 1; }
.stat-value.emerald { color: var(--emerald); }
.stat-value.purple { color: var(--purple); }
.stat-value.amber { color: var(--amber); }
.stat-value.red { color: var(--red); }
.stat-value.blue { color: var(--blue); }
.stat-change { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

/* ============================================================
   TABLES
   ============================================================ */
.table-container { overflow-x: auto; }

table.dg-table { width: 100%; border-collapse: collapse; }
table.dg-table thead th {
    text-align: left; padding: 12px 16px;
    font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
    color: var(--text-muted); font-weight: 600;
    border-bottom: 1px solid var(--border);
    background: var(--bg-base);
    position: sticky; top: 0;
}
table.dg-table tbody td {
    padding: 14px 16px; border-bottom: 1px solid var(--border);
    font-size: 14px; color: var(--text-secondary);
    vertical-align: middle;
}
table.dg-table tbody tr { transition: background var(--transition); }
table.dg-table tbody tr:hover { background: var(--bg-card-hover); }
table.dg-table tbody tr:last-child td { border-bottom: none; }

/* ============================================================
   BADGES / PILLS
   ============================================================ */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px; border-radius: 20px;
    font-size: 12px; font-weight: 600;
}
.badge-emerald { background: var(--emerald-glow); color: var(--emerald); }
.badge-purple { background: var(--purple-glow); color: var(--purple); }
.badge-amber { background: var(--amber-glow); color: var(--amber); }
.badge-red { background: var(--red-glow); color: var(--red); }
.badge-blue { background: rgba(59,130,246,0.12); color: var(--blue); }
.badge-gray { background: rgba(255,255,255,0.05); color: var(--text-muted); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600; cursor: pointer;
    border: 1px solid transparent;
    transition: all var(--transition);
    text-decoration: none; line-height: 1.4;
    font-family: var(--font);
}
.btn-primary { background: var(--emerald); color: white; }
.btn-primary:hover { background: var(--emerald-dark); color: white; }
.btn-secondary { background: var(--bg-elevated); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--border-hover); background: var(--bg-card-hover); }
.btn-danger { background: var(--red-glow); color: var(--red); border-color: rgba(239,68,68,0.2); }
.btn-danger:hover { background: var(--red); color: white; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-card); }
.btn-purple { background: var(--purple); color: white; }
.btn-purple:hover { background: #7C3AED; color: white; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.form-input, .form-select, .form-textarea {
    width: 100%; padding: 10px 14px;
    background: var(--bg-input); color: var(--text-primary);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-size: 14px; font-family: var(--font);
    transition: border-color var(--transition);
    outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--emerald); box-shadow: 0 0 0 3px var(--emerald-glow); }
.form-input::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 100px; }
.form-select { cursor: pointer; }
.form-select option { background: var(--bg-card); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ============================================================
   ALERTS / FLASH
   ============================================================ */
.alert {
    padding: 14px 18px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 500;
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 20px;
}
.alert-success { background: var(--emerald-glow); color: var(--emerald); border: 1px solid rgba(16,185,129,0.2); }
.alert-error { background: var(--red-glow); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.alert-warning { background: var(--amber-glow); color: var(--amber); border: 1px solid rgba(245,158,11,0.2); }
.alert-info { background: rgba(59,130,246,0.1); color: var(--blue); border: 1px solid rgba(59,130,246,0.2); }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.75); backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center; justify-content: center;
}
.modal-overlay.active { display: flex; }
.modal {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 28px;
    max-width: 600px; width: 90%; max-height: 90vh; overflow-y: auto;
}
.modal-title { font-size: 20px; font-weight: 700; margin-bottom: 20px; }
.modal-close { cursor: pointer; color: var(--text-muted); font-size: 24px; float: right; }
.modal-close:hover { color: var(--text-primary); }

/* ============================================================
   WALLET CARD
   ============================================================ */
.wallet-hero {
    background: linear-gradient(135deg, #0d1117 0%, #111827 50%, #0f1a15 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 32px;
    position: relative; overflow: hidden;
}
.wallet-hero::before {
    content: ''; position: absolute; top: -50%; right: -20%;
    width: 300px; height: 300px;
    background: radial-gradient(circle, var(--emerald-glow) 0%, transparent 70%);
    border-radius: 50%; pointer-events: none;
}
.wallet-balance-label { font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; position: relative; }
.wallet-balance-value { font-size: 48px; font-weight: 700; color: var(--emerald); position: relative; margin-top: 8px; }

/* ============================================================
   CODE BOX / WEBHOOK URL
   ============================================================ */
.code-box {
    background: var(--bg-deep); border: 1px solid var(--border);
    padding: 14px 18px; border-radius: var(--radius-sm);
    font-family: var(--font-mono); font-size: 13px;
    color: var(--emerald);
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    word-break: break-all;
}

/* ============================================================
   CATALOG GRID
   ============================================================ */
.catalog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }

.product-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); overflow: hidden;
    transition: all var(--transition); cursor: pointer;
}
.product-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }

.product-card-img {
    width: 100%; aspect-ratio: 1; object-fit: cover;
    background: var(--bg-base);
}
.product-card-body { padding: 16px; }
.product-card-sku { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }
.product-card-name { font-size: 15px; font-weight: 600; margin: 6px 0 12px; line-height: 1.3; }
.product-card-prices { display: flex; justify-content: space-between; align-items: flex-end; }
.product-card-cost { font-size: 20px; font-weight: 700; color: var(--emerald); }
.product-card-pvp { font-size: 13px; color: var(--purple); }

/* ============================================================
   STEP WIZARD (Onboarding)
   ============================================================ */
.wizard-steps { display: flex; gap: 0; margin-bottom: 32px; }
.wizard-step {
    flex: 1; text-align: center; padding: 16px 8px;
    position: relative; cursor: default;
}
.wizard-step::after {
    content: ''; position: absolute; top: 24px; right: -50%;
    width: 100%; height: 2px; background: var(--border);
}
.wizard-step:last-child::after { display: none; }
.wizard-step.active::after { background: var(--emerald); }
.wizard-step.done::after { background: var(--emerald); }

.wizard-step-number {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--bg-elevated); border: 2px solid var(--border);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px; color: var(--text-muted);
    position: relative; z-index: 1;
    transition: all var(--transition);
}
.wizard-step.active .wizard-step-number { border-color: var(--emerald); color: var(--emerald); background: var(--emerald-glow); }
.wizard-step.done .wizard-step-number { border-color: var(--emerald); color: white; background: var(--emerald); }
.wizard-step-label { font-size: 12px; color: var(--text-muted); margin-top: 8px; font-weight: 500; }
.wizard-step.active .wizard-step-label { color: var(--emerald); }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.3; }
.empty-state-title { font-size: 18px; font-weight: 600; color: var(--text-secondary); }
.empty-state-desc { font-size: 14px; color: var(--text-muted); margin-top: 6px; max-width: 400px; margin-inline: auto; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
.mobile-toggle { display: none; }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 20px 16px; }
    .mobile-toggle { display: block; position: fixed; top: 16px; left: 16px; z-index: 101; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; color: var(--text-primary); cursor: pointer; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .catalog-grid { grid-template-columns: 1fr 1fr; }
    .wizard-step-label { font-size: 10px; }
}

@media (max-width: 480px) {
    .catalog-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   AUTH PAGES (Login / Register / Landing)
   ============================================================ */
.auth-page {
    min-height: 100vh; display: flex;
    background: var(--bg-deep);
}
.auth-left {
    flex: 1; display: flex; align-items: center; justify-content: center;
    padding: 40px;
}
.auth-right {
    flex: 1; background: linear-gradient(135deg, #0a1a12 0%, #0d1117 100%);
    display: flex; align-items: center; justify-content: center;
    padding: 40px; position: relative; overflow: hidden;
}
.auth-right::before {
    content: ''; position: absolute; inset: 0;
    background: radial-gradient(ellipse at 30% 50%, var(--emerald-glow) 0%, transparent 60%);
}

.auth-box { max-width: 420px; width: 100%; }
.auth-logo { font-size: 32px; font-weight: 700; margin-bottom: 8px; }
.auth-logo span { color: var(--emerald); }
.auth-tagline { color: var(--text-muted); margin-bottom: 36px; }

.auth-promo { position: relative; z-index: 1; max-width: 450px; }
.auth-promo h2 { font-size: 36px; font-weight: 700; line-height: 1.2; margin-bottom: 20px; }
.auth-promo h2 em { font-style: normal; color: var(--emerald); }
.auth-promo p { color: var(--text-secondary); font-size: 16px; line-height: 1.7; }

@media (max-width: 900px) {
    .auth-right { display: none; }
}
