/* ==============================================
   DERIK Coupon System — Professional SaaS UI
   Mobile-first responsive stylesheet
   ============================================== */

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: rgba(37,99,235,0.10);
    --sidebar-bg: #1a2332;
    --sidebar-hover: #243043;
    --sidebar-active: #2563eb;
    --sidebar-width: 260px;
    --topbar-h: 60px;
    --mobile-topbar-h: 56px;
    --bg: #f1f5f9;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --subtle: #94a3b8;
    --radius: 0.75rem;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08),0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,.10),0 2px 4px -2px rgba(0,0,0,.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.10),0 4px 6px -4px rgba(0,0,0,.05);
    --ease: all .25s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: .925rem;
    line-height: 1.55;
}

/* ── App Shell ─────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; position: relative; }

/* ── Mobile Top Bar ──────────────────────── */
.mobile-topbar {
    position: fixed; top: 0; left: 0; right: 0;
    z-index: 1050;
    height: var(--mobile-topbar-h);
    background: var(--sidebar-bg);
    display: flex; align-items: center;
    padding: 0 .75rem; gap: .5rem;
    box-shadow: var(--shadow-md);
}

.hamburger-btn {
    background: transparent; border: none;
    color: #fff; font-size: 1.6rem;
    cursor: pointer;
    min-width: 44px; min-height: 44px;
    border-radius: .4rem;
    display: flex; align-items: center; justify-content: center;
    transition: var(--ease); flex-shrink: 0;
}
.hamburger-btn:hover { background: var(--sidebar-hover); }

.mobile-brand {
    flex: 1; display: flex; align-items: center;
    gap: .5rem; color: #fff; text-decoration: none;
    font-weight: 700; font-size: .95rem;
    overflow: hidden; white-space: nowrap;
}
.mobile-brand i { color: #60a5fa; font-size: 1.15rem; flex-shrink: 0; }

.mobile-user-info { display: flex; align-items: center; gap: .4rem; margin-left: auto; flex-shrink: 0; }

/* ── Backdrop ────────────────────────────── */
.sidebar-backdrop {
    display: none; position: fixed; inset: 0;
    z-index: 1040;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity .25s ease;
}
.sidebar-backdrop.active { display: block; opacity: 1; }

/* ── Sidebar ─────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #f1f5f9;
    display: flex; flex-direction: column;
    flex-shrink: 0;
    z-index: 1045;
    height: 100vh;
    overflow-y: auto; overflow-x: hidden;
    position: sticky; top: 0;
    transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 4px; }

@media (max-width:767.98px) {
    .sidebar {
        position: fixed; top: 0; left: 0;
        transform: translateX(-100%);
        box-shadow: none;
    }
    .sidebar.sidebar-open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }
    body.sidebar-is-open { overflow: hidden; }
}

.sidebar-brand {
    padding: 1.1rem 1.4rem;
    font-size: 1.05rem; font-weight: 700;
    color: #fff; text-decoration: none;
    display: flex; align-items: center; gap: .65rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0; min-height: 62px;
    background: rgba(0,0,0,.15);
    transition: var(--ease);
}
.sidebar-brand:hover { color: #bfdbfe; }
.sidebar-brand i { font-size: 1.35rem; color: #60a5fa; flex-shrink: 0; }

.sidebar-nav { list-style: none; padding: .5rem 0; margin: 0; flex-grow: 1; }

.nav-section-title {
    padding: .9rem 1.4rem .25rem;
    font-size: .68rem; text-transform: uppercase;
    letter-spacing: .08em; color: #475569;
    font-weight: 700; pointer-events: none;
}

.sidebar-nav .nav-link {
    display: flex; align-items: center; gap: .65rem;
    padding: .6rem 1.4rem;
    color: #94a3b8; text-decoration: none;
    font-size: .875rem; font-weight: 500;
    transition: var(--ease);
    border-left: 3px solid transparent;
    min-height: 44px;
}
.sidebar-nav .nav-link:hover {
    background: var(--sidebar-hover);
    color: #e2e8f0;
    border-left-color: rgba(96,165,250,.45);
}
.sidebar-nav .nav-link.active {
    background: var(--sidebar-active);
    color: #fff; font-weight: 600;
    border-left-color: #93c5fd;
}
.sidebar-nav .nav-link i {
    font-size: 1rem; width: 1.35rem;
    text-align: center; flex-shrink: 0;
}

.sidebar-footer {
    padding: .85rem 1.1rem;
    border-top: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0; background: rgba(0,0,0,.12);
}
.sidebar-user { display: flex; align-items: center; gap: .65rem; }
.sidebar-user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem; flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
    font-size: .82rem; font-weight: 600; color: #e2e8f0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-logout {
    color: #475569; font-size: 1.05rem;
    transition: var(--ease); padding: .2rem .35rem;
    border-radius: .35rem; flex-shrink: 0;
    display: flex; align-items: center; text-decoration: none;
}
.sidebar-logout:hover { color: #ef4444; background: rgba(239,68,68,.1); }

/* ── Main Content ──────────────────────── */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }

.topbar {
    background: #fff; border-bottom: 1px solid var(--border);
    padding: 0 1.5rem; height: var(--topbar-h);
    display: flex; justify-content: space-between; align-items: center;
    position: sticky; top: 0; z-index: 100;
    box-shadow: var(--shadow-sm); flex-shrink: 0;
}

.content-body { padding: 1.5rem; flex-grow: 1; }

@media (max-width:767.98px) {
    .content-body {
        padding: .875rem;
        padding-top: calc(var(--mobile-topbar-h) + .875rem);
    }
}

/* ── Auth Layout ─────────────────────────── */
.auth-page {
    min-height: 100vh;
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    background: linear-gradient(135deg, #1a2332 0%, #1e3a8a 50%, #1d4ed8 100%);
    padding: 1.5rem;
}
.auth-container { width: 100%; max-width: 420px; }

/* ── KPI Cards ───────────────────────────── */
.kpi-card {
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 1.15rem;
    box-shadow: var(--shadow-sm);
    transition: transform .2s ease, box-shadow .2s ease;
    height: 100%;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-title {
    font-size: .7rem; text-transform: uppercase;
    font-weight: 700; letter-spacing: .07em;
    color: var(--muted); margin-bottom: .35rem;
}
.kpi-value {
    font-size: 1.7rem; font-weight: 800;
    color: var(--text); line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.kpi-icon {
    width: 42px; height: 42px; border-radius: .5rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem; flex-shrink: 0;
}

/* ── Status Badges ───────────────────────── */
.badge-sm { font-size: .68rem !important; padding: .22em .5em !important; }
.badge-status {
    padding: .28rem .6rem; font-size: .73rem;
    font-weight: 600; border-radius: .375rem;
    display: inline-flex; align-items: center; gap: .25rem; white-space: nowrap;
}
.badge-available  { background:#dcfce7; color:#15803d; }
.badge-redeemed   { background:#dbeafe; color:#1d4ed8; }
.badge-partial    { background:#fef3c7; color:#92400e; }
.badge-expired    { background:#fee2e2; color:#b91c1c; }
.badge-cancelled  { background:#f1f5f9; color:#475569; }
.badge-issued     { background:#fef9c3; color:#92400e; }
.badge-sales      { background:#fef3c7; color:#b45309; }
.badge-service    { background:#e0e7ff; color:#4338ca; }
.badge-both       { background:#f3e8ff; color:#7e22ce; }

/* ── Table Wrapper ───────────────────────── */
.table-wrapper {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
}
.table-wrapper .table { margin-bottom: 0; font-size: .875rem; }
.table-wrapper .table thead th {
    background: #f8fafc; color: #475569;
    font-size: .72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .05em;
    padding: .8rem 1rem;
    border-bottom: 2px solid var(--border); white-space: nowrap;
}
.table-wrapper .table tbody td {
    padding: .8rem 1rem; vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
}
.table-wrapper .table tbody tr:last-child td { border-bottom: none; }
.table-wrapper .table tbody tr:hover { background: #f8fafc; }

/* ── Form Controls ───────────────────────── */
.form-control, .form-select {
    border-color: #d1d5db; border-radius: .5rem;
    padding: .475rem .875rem;
    font-size: .9rem; transition: var(--ease); min-height: 42px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.input-group-text { background: #f8fafc; border-color: #d1d5db; color: var(--muted); }
.form-label { font-size: .83rem; font-weight: 600; color: var(--text); margin-bottom: .35rem; }

/* ── Buttons ─────────────────────────────── */
.btn {
    font-weight: 500; border-radius: .5rem;
    font-size: .875rem; transition: var(--ease);
    min-height: 38px;
    display: inline-flex; align-items: center; gap: .35rem;
}
.btn-lg { min-height: 48px; font-size: 1rem; }
.btn-sm { min-height: 32px; font-size: .8rem; }

@media (max-width:767.98px) {
    .btn:not(.btn-sm) { min-height: 44px; }
}

/* ── Page Header ─────────────────────────── */
.page-header {
    display: flex; justify-content: space-between;
    align-items: flex-start; gap: .75rem;
    margin-bottom: 1.35rem; flex-wrap: wrap;
}
.page-title {
    font-size: 1.3rem; font-weight: 700;
    color: var(--text); margin: 0 0 .2rem;
    display: flex; align-items: center; gap: .45rem;
}
.page-subtitle { font-size: .82rem; color: var(--muted); margin: 0; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

@media (max-width:575.98px) {
    .page-header { flex-direction: column; }
    .page-title { font-size: 1.1rem; }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1; justify-content: center; }
}

/* ── Filter Bar ──────────────────────────── */
.filter-bar {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem 1.15rem;
    margin-bottom: 1.15rem; box-shadow: var(--shadow-sm);
}

/* ── Receipt / Voucher Slip ──────────────── */
.receipt-card {
    max-width: 560px; margin: 0 auto;
    background: var(--card); border: 2px dashed #cbd5e1;
    border-radius: 1rem; padding: 2rem; box-shadow: var(--shadow-md);
}
.receipt-header {
    text-align: center; border-bottom: 2px solid var(--border);
    padding-bottom: 1.15rem; margin-bottom: 1.35rem;
}
.receipt-row {
    display: flex; justify-content: space-between;
    align-items: flex-start; padding: .45rem 0;
    border-bottom: 1px dotted var(--border);
    font-size: .9rem; gap: 1rem;
}
.receipt-row .label { color: var(--muted); font-weight: 500; flex-shrink: 0; }
.receipt-row .value { color: var(--text); font-weight: 600; text-align: right; }
.offer-chip {
    display: inline-flex; align-items: center; gap: .25rem;
    padding: .3rem .65rem; border-radius: 2rem;
    font-size: .78rem; font-weight: 500;
    background: #eff6ff; color: #1d4ed8;
    border: 1px solid #bfdbfe; margin: .2rem;
}

/* ── Alerts ──────────────────────────────── */
.alert { border-radius: .6rem; font-size: .875rem; border: none; padding: .8rem 1rem; }
.alert-success { background: #f0fdf4; color: #15803d; border-left: 4px solid #16a34a; }
.alert-danger  { background: #fef2f2; color: #b91c1c; border-left: 4px solid #dc2626; }
.alert-warning { background: #fffbeb; color: #92400e; border-left: 4px solid #d97706; }
.alert-info    { background: #eff6ff; color: #1e40af; border-left: 4px solid #3b82f6; }

/* ── Utilities ───────────────────────────── */
.cursor-pointer { cursor: pointer; }
.font-monospace { font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace; }

/* ── Print ───────────────────────────────── */
@media print {
    body * { visibility: hidden; }
    .print-area, .print-area * { visibility: visible; }
    .print-area {
        position: absolute; left: 0; top: 0;
        width: 100%; margin: 0; padding: 20px;
        border: none !important; box-shadow: none !important;
    }
    .no-print, .sidebar, .topbar, .mobile-topbar { display: none !important; }
}