/* =========================================================
   QRGuru — Design System
   Aesthetic: trust fintech meets safety tech
   Palette: deep ink navy + electric mint + warm sand
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@400;500;600;700;800&family=Inter+Tight:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
    /* Core palette */
    --ink: #0b1220;
    --ink-2: #131b2e;
    --ink-3: #1c2540;
    --ink-line: #233052;

    --paper: #fafaf7;
    --paper-2: #f3f1e9;
    --paper-3: #e8e4d4;

    --mint: #00e5a0;
    --mint-2: #00c98b;
    --mint-3: #00a572;

    --sand: #f5b942;
    --sand-2: #e8a836;

    --coral: #ff6b5b;
    --rose: #ff4f7a;
    --sky: #5cc8ff;
    --plum: #a78bfa;

    --text: #0b1220;
    --text-muted: #5b6680;
    --text-dim: #8a93a8;

    --line: #e3e0d2;
    --line-dark: #2a3454;

    /* Effects */
    --shadow-sm: 0 1px 2px rgba(11,18,32,.06);
    --shadow-md: 0 8px 24px -8px rgba(11,18,32,.18);
    --shadow-lg: 0 24px 48px -16px rgba(11,18,32,.25);
    --shadow-mint: 0 12px 32px -8px rgba(0,229,160,.45);

    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 22px;
    --radius-xl: 32px;

    --font-display: 'Sora', system-ui, sans-serif;
    --font-body: 'Inter Tight', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, monospace;

    --transition: 220ms cubic-bezier(.4, 0, .2, 1);
    --transition-slow: 480ms cubic-bezier(.4, 0, .2, 1);
}

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

html, body {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.55;
    color: var(--text);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

h1 { font-size: clamp(2.2rem, 5vw, 4rem); }
h2 { font-size: clamp(1.8rem, 3.2vw, 2.6rem); }
h3 { font-size: 1.4rem; }
h4 { font-size: 1.1rem; }

a { color: inherit; text-decoration: none; }

img { max-width: 100%; display: block; }

button, input, select, textarea {
    font: inherit; color: inherit;
    border: none; outline: none; background: none;
}

button { cursor: pointer; }

code, pre, .mono { font-family: var(--font-mono); }

/* ============ Layout primitives ============ */
.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}

.row { display: flex; gap: 16px; flex-wrap: wrap; }
.col { flex: 1; min-width: 0; }

.stack { display: flex; flex-direction: column; gap: 16px; }
.flex { display: flex; gap: 12px; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.flex-end { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

@media (max-width: 860px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .hide-mobile { display: none !important; }
}

/* ============ Typography helpers ============ */
.eyebrow {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    color: var(--mint-3);
    font-weight: 600;
}

.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.text-mint { color: var(--mint-3); }
.text-coral { color: var(--coral); }
.text-sm { font-size: .9rem; }
.text-xs { font-size: .8rem; }
.text-lg { font-size: 1.15rem; }

.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

/* ============ Buttons ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: var(--radius);
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--ink);
    color: var(--paper);
    box-shadow: var(--shadow-md);
}
.btn-primary:hover { background: var(--ink-2); box-shadow: var(--shadow-lg); }

.btn-mint {
    background: var(--mint);
    color: var(--ink);
    box-shadow: var(--shadow-mint);
}
.btn-mint:hover { background: var(--mint-2); transform: translateY(-1px); }

.btn-outline {
    background: transparent;
    color: var(--ink);
    border-color: var(--ink);
}
.btn-outline:hover { background: var(--ink); color: var(--paper); }

.btn-ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--line);
}
.btn-ghost:hover { background: var(--paper-2); border-color: var(--ink); }

.btn-danger {
    background: var(--coral);
    color: white;
}
.btn-danger:hover { background: #ff5544; }

.btn-sm { padding: 8px 14px; font-size: 0.85rem; }
.btn-lg { padding: 16px 32px; font-size: 1.05rem; }
.btn-block { width: 100%; }

/* ============ Forms ============ */
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.field label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}

.input, .select, .textarea {
    padding: 12px 14px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    background: white;
    font-size: 0.95rem;
    transition: var(--transition);
    width: 100%;
}

.input:focus, .select:focus, .textarea:focus {
    border-color: var(--ink);
    box-shadow: 0 0 0 3px rgba(11,18,32,.08);
}

.textarea { resize: vertical; min-height: 96px; }

.field-error { color: var(--coral); font-size: 0.8rem; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }

/* ============ Badges ============ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-mono);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.badge-mint    { background: rgba(0,229,160,.15); color: var(--mint-3); }
.badge-sand    { background: rgba(245,185,66,.18); color: #946700; }
.badge-coral   { background: rgba(255,107,91,.15); color: #c53d2e; }
.badge-sky     { background: rgba(92,200,255,.18); color: #006a9b; }
.badge-plum    { background: rgba(167,139,250,.18); color: #6b4cd6; }
.badge-ink     { background: var(--ink); color: var(--paper); }
.badge-outline { background: transparent; border: 1px solid var(--line); color: var(--text-muted); }

/* role-specific badges */
.role-ADMIN              { background: #1a1a1a; color: var(--mint); }
.role-MASTER_DISTRIBUTOR { background: var(--plum); color: white; }
.role-SUPER_DISTRIBUTOR  { background: var(--sky); color: white; }
.role-DISTRIBUTOR        { background: var(--mint-3); color: white; }
.role-RETAILER           { background: var(--sand); color: var(--ink); }
.role-CUSTOMER           { background: var(--paper-3); color: var(--ink); }

/* ============ Cards ============ */
.card {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
}

.card-flat {
    background: var(--paper-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
}

.card-dark {
    background: var(--ink);
    color: var(--paper);
    border-radius: var(--radius);
    padding: 24px;
}

.card-elevated {
    background: white;
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-lg);
}

/* ============ Tables ============ */
.table-wrap {
    overflow-x: auto;
    background: white;
    border-radius: var(--radius);
    border: 1px solid var(--line);
}

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

.table th, .table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    font-size: 0.92rem;
}

.table th {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    font-weight: 600;
    background: var(--paper-2);
}

.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: var(--paper-2); }
.table tbody tr:last-child td { border-bottom: none; }

.table-actions { display: flex; gap: 8px; }

/* ============ Toast / notifications ============ */
#toast-stack {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 360px;
}

.toast {
    background: var(--ink);
    color: var(--paper);
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastIn .3s ease-out;
}

.toast.success { background: var(--mint-3); }
.toast.error { background: var(--coral); }
.toast.warning { background: var(--sand-2); color: var(--ink); }

@keyframes toastIn {
    from { transform: translateX(120%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

/* ============ Modal ============ */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(11,18,32,.55);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
    padding: 20px;
    animation: fadeIn .2s ease-out;
}

.modal {
    background: white;
    border-radius: var(--radius-lg);
    max-width: 520px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn .25s cubic-bezier(.4,0,.2,1);
}

.modal-header {
    padding: 24px 24px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body { padding: 16px 24px 24px; }
.modal-footer { padding: 0 24px 24px; display: flex; gap: 12px; justify-content: flex-end; }

.modal-close {
    background: var(--paper-2);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
    from { opacity: 0; transform: translateY(20px) scale(.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============ Utilities ============ */
.mt-0 { margin-top: 0; }   .mt-1 { margin-top: 8px; }   .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; } .mt-5 { margin-top: 48px; } .mt-6 { margin-top: 64px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; } .mb-4 { margin-bottom: 32px; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; } .gap-3 { gap: 24px; }
.p-0 { padding: 0; } .p-1 { padding: 8px; } .p-2 { padding: 16px; } .p-3 { padding: 24px; }

.text-center { text-align: center; }
.text-right { text-align: right; }

.divider { height: 1px; background: var(--line); margin: 24px 0; }
.divider-dark { height: 1px; background: var(--line-dark); margin: 24px 0; }

.skeleton {
    background: linear-gradient(90deg, var(--paper-2) 0%, var(--paper-3) 50%, var(--paper-2) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    border-radius: 4px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.hover-lift { transition: transform var(--transition), box-shadow var(--transition); }
.hover-lift:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

/* ============ Grain overlay (subtle) ============ */
.grain::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .12 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    pointer-events: none;
    opacity: .5;
    mix-blend-mode: multiply;
    z-index: 1;
}
