/* ============================================================
   MediQueue — Premium Design System
   Dark medical theme with glassmorphism & micro-animations
   ============================================================ */

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

/* ─── CSS Custom Properties ─────────────────────────────── */
:root {
    /* Brand Palette */
    --clr-bg: #080f1a;
    --clr-surface: #0d1829;
    --clr-surface-2: #111f33;
    --clr-glass: rgba(13, 24, 41, 0.72);
    --clr-border: rgba(255, 255, 255, 0.07);

    --clr-primary: #00c6a7;
    --clr-primary-dim: rgba(0, 198, 167, 0.12);
    --clr-accent: #3d8bff;
    --clr-accent-dim: rgba(61, 139, 255, 0.12);

    --clr-danger: #ff5677;
    --clr-danger-dim: rgba(255, 86, 119, 0.12);
    --clr-warn: #ffb731;
    --clr-warn-dim: rgba(255, 183, 49, 0.12);
    --clr-success: #22d3a6;
    --clr-success-dim: rgba(34, 211, 166, 0.12);

    /* Text */
    --txt-100: #e8f0ff;
    --txt-200: #a8b8d0;
    --txt-300: #6680a0;

    /* Shadows & Glow */
    --shadow-card: 0 4px 32px rgba(0, 0, 0, 0.5);
    --glow-primary: 0 0 18px rgba(0, 198, 167, 0.4);
    --glow-accent: 0 0 18px rgba(61, 139, 255, 0.4);
    --glow-danger: 0 0 18px rgba(255, 86, 119, 0.4);

    /* Spacing */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
}

/* ─── Reset & Base ───────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--clr-bg);
    color: var(--txt-100);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ─── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--clr-surface);
}

::-webkit-scrollbar-thumb {
    background: var(--clr-primary);
    border-radius: 3px;
}

/* ─── Background Mesh ────────────────────────────────────── */
.bg-mesh {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(ellipse 60% 50% at 20% 10%, rgba(0, 198, 167, .08) 0%, transparent 70%),
        radial-gradient(ellipse 50% 60% at 80% 80%, rgba(61, 139, 255, .07) 0%, transparent 70%),
        var(--clr-bg);
}

/* ─── Layout ──────────────────────────────────────────────── */
.page-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.center-box {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

/* ─── Glass Card ─────────────────────────────────────────── */
.card {
    background: var(--clr-glass);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-card);
    padding: 2rem;
}

.card-sm {
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius-md);
}

.card-xl {
    padding: 2.5rem 3rem;
}

/* ─── Logo / Brand ───────────────────────────────────────── */
.brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -.5px;
    color: var(--txt-100);
}

.brand-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--clr-primary), var(--clr-accent));
    display: grid;
    place-items: center;
    font-size: 1.2rem;
    box-shadow: var(--glow-primary);
    flex-shrink: 0;
}

.brand span.hl {
    color: var(--clr-primary);
}

/* ─── Typography ─────────────────────────────────────────── */
h1 {
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 800;
}

h2 {
    font-size: 1.4rem;
    font-weight: 700;
}

h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.sub {
    color: var(--txt-200);
    font-size: .9rem;
}

.text-primary {
    color: var(--clr-primary);
}

.text-accent {
    color: var(--clr-accent);
}

.text-danger {
    color: var(--clr-danger);
}

.text-warn {
    color: var(--clr-warn);
}

.text-success {
    color: var(--clr-success);
}

/* ─── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .65rem 1.4rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .18s ease;
    white-space: nowrap;
    text-decoration: none;
}

.btn:active {
    transform: scale(.97);
}

.btn:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    background: linear-gradient(135deg, var(--clr-primary), #00a88e);
    color: #000;
    box-shadow: 0 0 0 0 rgba(0, 198, 167, 0);
}

.btn-primary:hover {
    box-shadow: var(--glow-primary);
    transform: translateY(-1px);
}

.btn-accent {
    background: linear-gradient(135deg, var(--clr-accent), #2a6fd6);
    color: #fff;
    box-shadow: 0 0 0 0 rgba(61, 139, 255, 0);
}

.btn-accent:hover {
    box-shadow: var(--glow-accent);
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, var(--clr-danger), #e03355);
    color: #fff;
}

.btn-danger:hover {
    box-shadow: var(--glow-danger);
    transform: translateY(-1px);
}

.btn-warn {
    background: linear-gradient(135deg, var(--clr-warn), #e6963a);
    color: #000;
}

.btn-warn:hover {
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--clr-border);
    color: var(--txt-200);
}

.btn-ghost:hover {
    border-color: var(--clr-primary);
    color: var(--clr-primary);
}

.btn-sm {
    padding: .4rem .9rem;
    font-size: .82rem;
}

.btn-lg {
    padding: .85rem 2rem;
    font-size: 1rem;
}

.btn-full {
    width: 100%;
}

/* ─── Form Elements ──────────────────────────────────────── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.form-label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--txt-200);
    letter-spacing: .03em;
    text-transform: uppercase;
}

.form-input,
.form-select,
.form-textarea {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-sm);
    padding: .7rem 1rem;
    color: var(--txt-100);
    font-family: inherit;
    font-size: .95rem;
    transition: border-color .15s, box-shadow .15s;
    width: 100%;
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--txt-300);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--clr-primary);
    box-shadow: 0 0 0 3px rgba(0, 198, 167, .15);
}

.form-select {
    cursor: pointer;
    appearance: auto;
}

.form-select option {
    background: var(--clr-surface-2);
}

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

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

/* Toggle switch */
.toggle-row {
    display: flex;
    align-items: center;
    gap: .75rem;
}

.toggle-label {
    font-size: .9rem;
    font-weight: 500;
    color: var(--txt-200);
    cursor: pointer;
}

.toggle {
    position: relative;
    width: 44px;
    height: 24px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, .1);
    border-radius: 24px;
    cursor: pointer;
    transition: .2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--txt-300);
    border-radius: 50%;
    transition: .2s;
}

.toggle input:checked+.toggle-slider {
    background: var(--clr-danger);
}

.toggle input:checked+.toggle-slider::before {
    transform: translateX(20px);
    background: #fff;
}

/* ─── Stat Cards ─────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--clr-glass);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: .3rem;
    position: relative;
    overflow: hidden;
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    transition: transform .2s, box-shadow .2s;
}

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

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.stat-card.c-primary::before {
    background: var(--clr-primary);
}

.stat-card.c-accent::before {
    background: var(--clr-accent);
}

.stat-card.c-danger::before {
    background: var(--clr-danger);
}

.stat-card.c-warn::before {
    background: var(--clr-warn);
}

.stat-card.c-success::before {
    background: var(--clr-success);
}

.stat-icon {
    font-size: 1.4rem;
    margin-bottom: .2rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -.5px;
}

.stat-label {
    font-size: .78rem;
    color: var(--txt-200);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* ─── Table ──────────────────────────────────────────────── */
.tbl-wrap {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--clr-border);
}

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

thead tr {
    background: rgba(255, 255, 255, .03);
}

th {
    text-align: left;
    padding: .85rem 1rem;
    font-size: .78rem;
    font-weight: 600;
    color: var(--txt-300);
    text-transform: uppercase;
    letter-spacing: .06em;
    border-bottom: 1px solid var(--clr-border);
}

td {
    padding: .9rem 1rem;
    font-size: .9rem;
    border-bottom: 1px solid rgba(255, 255, 255, .03);
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr {
    transition: background .15s;
}

tbody tr:hover {
    background: rgba(255, 255, 255, .025);
}

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .2rem .65rem;
    border-radius: 100px;
    font-size: .75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.badge-primary {
    background: var(--clr-primary-dim);
    color: var(--clr-primary);
}

.badge-accent {
    background: var(--clr-accent-dim);
    color: var(--clr-accent);
}

.badge-danger {
    background: var(--clr-danger-dim);
    color: var(--clr-danger);
}

.badge-warn {
    background: var(--clr-warn-dim);
    color: var(--clr-warn);
}

.badge-success {
    background: var(--clr-success-dim);
    color: var(--clr-success);
}

.badge-muted {
    background: rgba(255, 255, 255, .06);
    color: var(--txt-300);
}

/* ─── Sidebar Layout ─────────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--clr-surface);
    border-right: 1px solid var(--clr-border);
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 1.5rem 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 0 1.5rem 1.5rem;
    border-bottom: 1px solid var(--clr-border);
    margin-bottom: .5rem;
}

.sidebar-nav {
    flex: 1;
    padding: .5rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem 1.5rem;
    font-size: .9rem;
    font-weight: 500;
    color: var(--txt-300);
    cursor: pointer;
    transition: all .15s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    color: var(--txt-100);
    background: rgba(255, 255, 255, .04);
}

.nav-item.active {
    color: var(--clr-primary);
    background: var(--clr-primary-dim);
    border-left-color: var(--clr-primary);
}

.nav-icon {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 0 1.5rem 0;
}

.main-content {
    flex: 1;
    padding: 2rem 2.5rem;
    overflow-y: auto;
    background: transparent;
}

/* ─── Page Header ─────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--clr-border);
}

.page-title {
    font-size: 1.5rem;
    font-weight: 800;
}

.page-sub {
    font-size: .87rem;
    color: var(--txt-200);
    margin-top: .15rem;
}

/* ─── Section ────────────────────────────────────────────── */
.section {
    display: none;
}

.section.active {
    display: block;
}

/* ─── Token Card (Patient success) ──────────────────────── */
.token-card {
    text-align: center;
    padding: 2.5rem 2rem;
    background: linear-gradient(135deg, rgba(0, 198, 167, .1), rgba(61, 139, 255, .08));
    border: 1px solid rgba(0, 198, 167, .25);
    border-radius: var(--radius-xl);
    animation: fadeUp .4s ease;
}

.token-number {
    font-size: 5rem;
    font-weight: 900;
    line-height: 1;
    background: linear-gradient(135deg, var(--clr-primary), var(--clr-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
}

.token-label {
    font-size: .85rem;
    color: var(--txt-200);
    margin-top: .4rem;
    text-transform: uppercase;
    letter-spacing: .08em;
}

/* ─── Now Serving Banner ─────────────────────────────────── */
.serving-banner {
    text-align: center;
    padding: 2rem 1.5rem;
    background: linear-gradient(135deg, rgba(0, 198, 167, .12), rgba(0, 198, 167, .04));
    border: 1px solid rgba(0, 198, 167, .3);
    border-radius: var(--radius-lg);
    animation: pulse-border 2s infinite;
}

.serving-token {
    font-size: 4rem;
    font-weight: 900;
    line-height: 1;
    color: var(--clr-primary);
    text-shadow: var(--glow-primary);
}

.serving-tag {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--clr-primary);
    margin-bottom: .5rem;
    opacity: .8;
}

.serving-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--txt-100);
    margin-top: .5rem;
}

/* ─── Toast Notifications ─────────────────────────────────── */
#toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
    max-width: 380px;
    width: calc(100vw - 3rem);
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: rgba(13, 24, 41, 0.95);
    border: 1px solid var(--clr-border);
    border-left: 4px solid var(--clr-primary);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 2px 10px rgba(0, 0, 0, 0.4);
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.5;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    pointer-events: auto;
    position: relative;
    overflow: hidden;
    transform: translateX(120%);
    opacity: 0;
    animation: toastSlideIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.toast.toast-exit {
    animation: toastFadeOut 0.4s ease forwards;
}

@keyframes toastSlideIn {
    0% { transform: translateX(120%); opacity: 0; }
    100% { transform: translateX(0); opacity: 1; }
}

@keyframes toastFadeOut {
    0% { transform: translateX(0); opacity: 1; }
    100% { transform: translateX(20px); opacity: 0; }
}

.toast-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.toast-body {
    flex: 1;
    color: var(--txt-100);
}

.toast-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 0.15rem;
    letter-spacing: 0.02em;
}

.toast-close {
    background: transparent;
    border: none;
    color: var(--txt-300);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.toast-close:hover {
    color: var(--txt-100);
}

/* Coloured left bar per type */
.toast.success { border-left-color: var(--clr-success); }
.toast.success .toast-title { color: var(--clr-success); }
.toast.error { border-left-color: var(--clr-danger); }
.toast.error .toast-title { color: var(--clr-danger); }
.toast.warn { border-left-color: var(--clr-warn); }
.toast.warn .toast-title { color: var(--clr-warn); }
.toast.info { border-left-color: var(--clr-accent); }
.toast.info .toast-title { color: var(--clr-accent); }

/* Progress bar */
.toast::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: currentColor;
    opacity: 0.3;
    animation: toastProgress var(--toast-duration, 4000ms) linear forwards;
}

@keyframes toastProgress {
    0% { width: 100%; }
    100% { width: 0%; }
}

/* ─── Loading Spinner ─────────────────────────────────────── */
.spinner {
    width: 22px;
    height: 22px;
    border: 2.5px solid rgba(255, 255, 255, .15);
    border-top-color: var(--clr-primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    flex-shrink: 0;
}

.loading-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999;
    background: rgba(8, 15, 26, .75);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    place-items: center;
}

.loading-overlay.show {
    display: grid;
}

/* ─── Empty State ─────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--txt-300);
}

.empty-icon {
    font-size: 2.5rem;
    margin-bottom: .75rem;
    opacity: .5;
    animation: float-empty 3s ease-in-out infinite;
}

@keyframes float-empty {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* ─── Divider ─────────────────────────────────────────────── */
.divider {
    height: 1px;
    background: var(--clr-border);
    margin: 1.5rem 0;
}

/* ─── Tag / Pill ──────────────────────────────────────────── */
.pill {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .3rem .8rem;
    background: var(--clr-primary-dim);
    border: 1px solid rgba(0, 198, 167, .2);
    border-radius: 100px;
    font-size: .8rem;
    font-weight: 600;
    color: var(--clr-primary);
}

/* ─── Animations ──────────────────────────────────────────── */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(110%) scale(0.92);
    }

    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
        max-height: 120px;
        margin-bottom: 0;
    }

    to {
        opacity: 0;
        transform: translateX(110%) scale(0.92);
        max-height: 0;
        margin-bottom: -.55rem;
        padding-top: 0;
        padding-bottom: 0;
    }
}

@keyframes toastProgress {
    from {
        transform: scaleX(1);
    }

    to {
        transform: scaleX(0);
    }
}

@keyframes pulse-border {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(0, 198, 167, .3);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(0, 198, 167, 0);
    }
}

@keyframes ticker {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(-100%);
    }
}

.fade-in {
    animation: fadeUp .35s ease both;
}

/* ─── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 1rem;
    }

    .sidebar-nav {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 0;
    }

    .nav-item {
        border-left: none;
        border-bottom: 3px solid transparent;
        padding: .5rem .9rem;
        font-size: .82rem;
    }

    .nav-item.active {
        border-bottom-color: var(--clr-primary);
        border-left-color: transparent;
    }

    .main-content {
        padding: 1.25rem 1rem;
    }

    .form-grid-2,
    .form-grid-3 {
        grid-template-columns: 1fr;
    }
}