/* =====================================================================
   QR Vault — Dashboard / Auth shell
   ---------------------------------------------------------------------
   Shared styling for the authenticated application (/app), the admin
   panel (/admin) and the auth screens (/auth). The public marketing
   page keeps its own inline styles.

   Table of contents
     01. Tokens
     02. Base
     03. App shell (sidebar + topbar + content)
     04. Cards / stats
     05. Tables
     06. Forms
     07. Badges, buttons, misc
     08. Auth layout
     09. Responsive
   ===================================================================== */

/* ---------------------------------------------------------------------
   01. Tokens
   ------------------------------------------------------------------ */
:root {
    --brand:      #2563EB;
    --brand-600:  #1D4ED8;
    --brand-soft: #EFF6FF;
    --brand-line: rgba(37, 99, 235, .18);
    --ink:        #111827;
    --body:       #374151;
    --muted:      #6B7280;
    --line:       #E5E7EB;
    --surface:    #F8FAFC;
    --white:      #FFFFFF;
    --success:    #059669;
    --success-soft: #ECFDF5;
    --warning:    #B45309;
    --warning-soft: #FFFBEB;
    --danger:     #DC2626;
    --danger-soft: #FEF2F2;
    --radius:     18px;
    --radius-sm:  12px;
    --shadow-sm:  0 1px 2px rgba(17, 24, 39, .05);
    --shadow-md:  0 12px 30px -14px rgba(17, 24, 39, .18);
    --shadow-lg:  0 30px 60px -28px rgba(17, 24, 39, .30);
    --ease:       cubic-bezier(.22, .61, .36, 1);
    --sidebar-w:  268px;
}

/* ---------------------------------------------------------------------
   02. Base
   ------------------------------------------------------------------ */
* { box-sizing: border-box; }

body.qv-body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI",
                 Inter, Roboto, Helvetica, Arial, sans-serif;
    background: var(--surface);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { letter-spacing: -.02em; font-weight: 700; color: var(--ink); }
a { text-decoration: none; }
.text-muted-2 { color: var(--muted) !important; }

/* ---------------------------------------------------------------------
   03. App shell
   ------------------------------------------------------------------ */
.qv-shell { display: flex; min-height: 100vh; }

.qv-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--white);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 1rem;
    z-index: 1040;
    transition: transform .32s var(--ease);
}

.qv-sidebar__brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-weight: 800;
    font-size: 1.12rem;
    letter-spacing: -.03em;
    color: var(--ink);
    padding: .35rem .5rem 1.1rem;
}

.qv-logo-mark {
    width: 36px; height: 36px;
    display: grid; place-items: center;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--brand), #7C3AED);
    color: #fff;
    font-size: 1.05rem;
    box-shadow: 0 8px 18px -8px rgba(37, 99, 235, .9);
}

.qv-nav-label {
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: #9CA3AF;
    padding: 1rem .75rem .4rem;
}

.qv-menu { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .18rem; }

.qv-menu a {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .62rem .75rem;
    border-radius: 11px;
    color: var(--body);
    font-size: .93rem;
    font-weight: 500;
    transition: background-color .2s var(--ease), color .2s var(--ease), transform .2s var(--ease);
}
.qv-menu a i { font-size: 1.05rem; color: var(--muted); transition: color .2s var(--ease); }
.qv-menu a:hover { background: var(--surface); color: var(--ink); transform: translateX(2px); }
.qv-menu a:hover i { color: var(--brand); }

.qv-menu a.is-active {
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 600;
}
.qv-menu a.is-active i { color: var(--brand); }
.qv-menu a.is-active::after {
    content: "";
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--brand);
    margin-left: auto;
}

.qv-menu a.is-danger:hover { background: var(--danger-soft); color: var(--danger); }
.qv-menu a.is-danger:hover i { color: var(--danger); }

.qv-sidebar__foot { margin-top: auto; padding-top: 1rem; }

/* Upgrade promo inside the sidebar */
.qv-upsell {
    border-radius: var(--radius-sm);
    padding: 1rem;
    background: linear-gradient(150deg, var(--brand-soft), #fff);
    border: 1px solid var(--brand-line);
}
.qv-upsell h6 { font-size: .86rem; margin: 0 0 .3rem; }
.qv-upsell p { font-size: .76rem; color: var(--muted); margin: 0 0 .7rem; line-height: 1.5; }

.qv-main {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
}

.qv-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: .85rem 1.5rem;
    background: rgba(255, 255, 255, .82);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--line);
}

.qv-content { padding: 1.75rem 1.5rem 3rem; flex: 1; }
.qv-content__head { margin-bottom: 1.5rem; }
.qv-content__head h1 { font-size: clamp(1.35rem, 2.4vw, 1.75rem); margin: 0 0 .3rem; }
.qv-content__head p { color: var(--muted); margin: 0; font-size: .93rem; }

.qv-sidebar-toggle { display: none; }

/* ---------------------------------------------------------------------
   04. Cards / stats
   ------------------------------------------------------------------ */
.qv-card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 1.4rem;
    transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s var(--ease);
}
.qv-card--hover:hover {
    transform: translateY(-4px);
    border-color: var(--brand-line);
    box-shadow: var(--shadow-md);
}

.stat-card { position: relative; overflow: hidden; }
.stat-card__icon {
    width: 46px; height: 46px;
    display: grid; place-items: center;
    border-radius: 14px;
    font-size: 1.25rem;
    background: var(--brand-soft);
    color: var(--brand);
    border: 1px solid var(--brand-line);
}
.stat-card__value { font-size: 1.9rem; font-weight: 800; letter-spacing: -.03em; margin: .9rem 0 .15rem; line-height: 1; }
.stat-card__label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.stat-card__meta  { font-size: .75rem; color: var(--muted); margin-top: .55rem; }

.progress-thin { height: 6px; border-radius: 999px; background: #EEF2F7; overflow: hidden; }
.progress-thin > span {
    display: block; height: 100%; border-radius: 999px;
    background: linear-gradient(90deg, var(--brand), #7C3AED);
    transition: width .6s var(--ease);
}

/* ---------------------------------------------------------------------
   05. Tables
   ------------------------------------------------------------------ */
.qv-table { width: 100%; margin: 0; font-size: .9rem; }
.qv-table thead th {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
    font-weight: 700;
    border-bottom: 1px solid var(--line);
    padding: .8rem .85rem;
    background: var(--surface);
    white-space: nowrap;
}
.qv-table tbody td {
    padding: .85rem;
    border-bottom: 1px solid #F1F5F9;
    vertical-align: middle;
}
.qv-table tbody tr { transition: background-color .18s var(--ease); }
.qv-table tbody tr:hover { background: #FCFDFF; }
.qv-table tbody tr:last-child td { border-bottom: 0; }

.qv-table-wrap { overflow-x: auto; border-radius: var(--radius); }

/* Circular avatar with initials */
.qv-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: .78rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--brand), #7C3AED);
    flex: none;
}

/* ---------------------------------------------------------------------
   06. Forms
   ------------------------------------------------------------------ */
.qv-label { font-size: .84rem; font-weight: 600; margin-bottom: .4rem; color: var(--ink); }

.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    padding: .68rem .9rem;
    font-size: .93rem;
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}
.form-control:focus, .form-select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}
.form-control::placeholder { color: #9CA3AF; }

.input-icon { position: relative; }
.input-icon > i {
    position: absolute;
    left: .9rem; top: 50%;
    transform: translateY(-50%);
    color: #9CA3AF;
    font-size: 1rem;
    pointer-events: none;
}
.input-icon > .form-control { padding-left: 2.5rem; }

.qv-hint { font-size: .78rem; color: var(--muted); margin-top: .35rem; }

/* OTP input */
.otp-input {
    letter-spacing: .55em;
    font-size: 1.5rem;
    font-weight: 700;
    text-align: center;
    padding: .8rem;
}

/* ---------------------------------------------------------------------
   07. Badges / buttons / misc
   ------------------------------------------------------------------ */
.btn { border-radius: 999px; font-weight: 600; transition: transform .2s var(--ease), box-shadow .2s var(--ease); }
.btn:active { transform: translateY(1px); }

.btn-brand {
    background: var(--brand);
    border: 1px solid var(--brand);
    color: #fff;
    box-shadow: 0 10px 22px -12px rgba(37, 99, 235, .85);
}
.btn-brand:hover { background: var(--brand-600); border-color: var(--brand-600); color: #fff; transform: translateY(-1px); }

.btn-soft {
    background: var(--white);
    border: 1px solid var(--line);
    color: var(--ink);
}
.btn-soft:hover { border-color: var(--brand); color: var(--brand); }

.badge-soft {
    display: inline-flex;
    align-items: center;
    gap: .32rem;
    font-size: .72rem;
    font-weight: 700;
    padding: .3rem .6rem;
    border-radius: 999px;
    border: 1px solid transparent;
}
.badge-soft--active   { background: var(--success-soft); color: var(--success); border-color: #A7F3D0; }
.badge-soft--disabled { background: #F3F4F6; color: var(--muted); border-color: var(--line); }
.badge-soft--pending  { background: var(--warning-soft); color: var(--warning); border-color: #FDE68A; }
.badge-soft--danger   { background: var(--danger-soft); color: var(--danger); border-color: #FECACA; }
.badge-soft--brand    { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-line); }

.dropdown-menu {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    padding: .35rem;
    font-size: .9rem;
}
.dropdown-item { border-radius: 8px; padding: .5rem .7rem; }
.dropdown-item:hover { background: var(--surface); }

.qv-flash { border-radius: var(--radius-sm); border: 1px solid; font-size: .9rem; }

.qv-empty {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--muted);
}
.qv-empty i { font-size: 2.6rem; color: #CBD5E1; display: block; margin-bottom: .8rem; }

/* Glass variant used on dashboard headers / checkout summary */
.qv-glass {
    background: rgba(255, 255, 255, .68);
    backdrop-filter: blur(18px) saturate(165%);
    -webkit-backdrop-filter: blur(18px) saturate(165%);
    border: 1px solid rgba(255, 255, 255, .85);
    box-shadow: 0 24px 50px -34px rgba(17, 24, 39, .5), inset 0 1px 0 rgba(255, 255, 255, .9);
}

/* ---------------------------------------------------------------------
   08. Auth layout
   ------------------------------------------------------------------ */
.qv-auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1rem;
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #FFFFFF 0%, #F1F5F9 60%, var(--surface) 100%);
}
.qv-auth::before,
.qv-auth::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: .5;
    pointer-events: none;
}
.qv-auth::before { width: 460px; height: 460px; background: rgba(37, 99, 235, .28); top: -170px; left: -150px; }
.qv-auth::after  { width: 420px; height: 420px; background: rgba(124, 58, 237, .20); bottom: -190px; right: -130px; }

.qv-auth__card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 460px;
    border-radius: 22px;
    padding: 2.25rem;
}

.qv-auth__brand {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    font-weight: 800;
    letter-spacing: -.03em;
    font-size: 1.12rem;
    color: var(--ink);
}

/* ---------------------------------------------------------------------
   09. Responsive
   ------------------------------------------------------------------ */
@media (max-width: 991.98px) {
    .qv-sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .qv-sidebar.is-open { transform: translateX(0); }
    .qv-main { margin-left: 0; }
    .qv-sidebar-toggle { display: inline-flex; }
    .qv-content { padding: 1.25rem 1rem 3rem; }
    .qv-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(17, 24, 39, .45);
        z-index: 1035;
        opacity: 0;
        pointer-events: none;
        transition: opacity .3s var(--ease);
    }
    .qv-backdrop.is-open { opacity: 1; pointer-events: auto; }
}

@media (min-width: 992px) {
    .qv-backdrop { display: none; }
}

@media (max-width: 575.98px) {
    .qv-auth__card { padding: 1.6rem; }
    .stat-card__value { font-size: 1.6rem; }
}

/* ---------------------------------------------------------------------
   Step 3 — QR Designer helpers
   ------------------------------------------------------------------ */
.qv-step {
    display: inline-grid;
    place-items: center;
    width: 22px; height: 22px;
    border-radius: 7px;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: .78rem;
    font-weight: 700;
    margin-right: .35rem;
}

.qv-lock {
    background: repeating-linear-gradient(45deg, #F8FAFC, #F8FAFC 10px, #F1F5F9 10px, #F1F5F9 20px);
    border-color: var(--line) !important;
}

/* Checkerboard behind the preview so transparent QR codes read clearly */
.qv-preview-stage {
    background-image:
        linear-gradient(45deg, #EEF2F7 25%, transparent 25%),
        linear-gradient(-45deg, #EEF2F7 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #EEF2F7 75%),
        linear-gradient(-45deg, transparent 75%, #EEF2F7 75%);
    background-size: 18px 18px;
    background-position: 0 0, 0 9px, 9px -9px, -9px 0;
    background-color: #FFFFFF;
}

/* QR style + type swatch buttons: active state */
.btn-check:checked + .btn-soft {
    background: var(--brand-soft);
    border-color: var(--brand-line);
    color: var(--brand);
    box-shadow: inset 0 0 0 1px var(--brand-line);
}

.form-control-color { height: 42px; padding: .25rem; cursor: pointer; }

/* Animate cards + preview updates */
.qv-card { transition: box-shadow .25s var(--ease), transform .25s var(--ease); }
#qrPreview svg { transition: opacity .15s ease; }

/* ---------------------------------------------------------------------
   Step 3 — PDF / File dropzone
   ------------------------------------------------------------------ */
.qv-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.6rem 1rem;
    border: 2px dashed var(--line);
    border-radius: 14px;
    cursor: pointer;
    transition: border-color .2s var(--ease), background .2s var(--ease);
    width: 100%;
}
.qv-dropzone:hover,
.qv-dropzone.is-drag {
    border-color: var(--brand);
    background: var(--brand-soft);
}

/* Per-type content field groups animate in */
.qv-fields { animation: qvFade .2s var(--ease); }
@keyframes qvFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------------
   Step 3 — Analytics page
   ------------------------------------------------------------------ */
.qv-dot {
    display: inline-block;
    width: 9px; height: 9px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 2px;
}

.qv-range .btn { border-radius: 8px; }
.qv-range .btn + .btn { margin-left: .35rem; }

.qv-geo { position: relative; }
.qv-geo__map { width: 100%; height: auto; display: block; }
.qv-geo__legend { margin-top: 1rem; }

.qv-rank-row { border-bottom: 1px solid var(--line); }
.qv-rank-row:last-child { border-bottom: 0; }

.qv-spark {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    min-width: 60px;
    font-size: 1rem;
}

/* Reuse the stat card look for KPI tiles that put the icon top-right */
.stat-card .stat-card__label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.stat-card .stat-card__meta { font-size: .78rem; margin-top: .4rem; display: flex; align-items: center; gap: .25rem; }
