@tailwind base;
@tailwind components;
@tailwind utilities;

/* ================================================================
   HMS — DESIGN SYSTEM v3
   Theme: Gray-900 Sidebar · White Content · Violet Accent
   Rules: No pale text on content. Min font 14px. Mobile-first.
   ================================================================ */

@layer base {
    :root {
        --violet:     #7c3aed;
        --violet-dk:  #6d28d9;
        --violet-lt:  #ede9fe;
        --navy:       #111827;
        --white:      #ffffff;
    }

    html {
        scroll-behavior: smooth;
        font-size: 16px;
    }

    body {
        font-family: 'Inter', system-ui, sans-serif;
        background-color: #f3f4f6;
        color: #111827;
        -webkit-tap-highlight-color: transparent;
        overflow-x: hidden;
    }

    .dark body { background-color: #030712; color: #f9fafb; }

    *:focus-visible {
        outline: 2px solid #7c3aed;
        outline-offset: 2px;
    }
}

/* ═══════════════════════════════════════
   CARD / PANEL
═══════════════════════════════════════ */
.card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.dark .card {
    background: #111827;
    border-color: rgba(255,255,255,0.07);
    box-shadow: none;
}

/* Panel alias */
.panel { @extend .card; }

/* ═══════════════════════════════════════
   BUTTONS  (min 44px tap target)
═══════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 10px;
    padding: 0.625rem 1.25rem;
    min-height: 2.75rem;
    transition: all 0.15s ease;
    white-space: nowrap;
    cursor: pointer;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: #7c3aed;
    color: #fff;
    box-shadow: 0 2px 8px rgba(124,58,237,0.35);
}
.btn-primary:hover {
    background: #6d28d9;
    box-shadow: 0 4px 16px rgba(124,58,237,0.45);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: #7c3aed;
    border: 1.5px solid #c4b5fd;
}
.btn-outline:hover {
    background: #ede9fe;
    border-color: #7c3aed;
}

.btn-ghost {
    background: transparent;
    color: #374151;
}
.btn-ghost:hover { background: #f3f4f6; color: #111827; }
.dark .btn-ghost { color: #d1d5db; }
.dark .btn-ghost:hover { background: rgba(255,255,255,0.06); color: #fff; }

/* ═══════════════════════════════════════
   FORM INPUTS
═══════════════════════════════════════ */
.input-field {
    display: block;
    width: 100%;
    background: #f9fafb;
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    font-weight: 500;
    color: #111827;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    min-height: 3rem;
}
.input-field::placeholder { color: #9ca3af; font-weight: 400; }
.input-field:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
    background: #fff;
}
.dark .input-field {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.1);
    color: #f9fafb;
}
.dark .input-field:focus {
    border-color: #7c3aed;
    background: rgba(255,255,255,0.07);
}

/* ═══════════════════════════════════════
   SIDEBAR NAV LINKS  (set in sidebar.blade.php via Tailwind inline)
   These classes used as fallback only.
═══════════════════════════════════════ */
.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #9ca3af;
    min-height: 2.75rem;
    transition: all 0.15s;
    margin-bottom: 2px;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,0.07); }
.nav-link-active {
    background: #7c3aed;
    color: #fff !important;
    font-weight: 600;
}

/* ═══════════════════════════════════════
   STAT CARDS
═══════════════════════════════════════ */
.stat-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.25rem;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(124,58,237,0.12);
    border-color: #c4b5fd;
}
.dark .stat-card { background: #111827; border-color: rgba(255,255,255,0.07); }

/* ═══════════════════════════════════════
   BADGE
═══════════════════════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}
.badge-violet  { background: #ede9fe; color: #5b21b6; }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-gray    { background: #f3f4f6; color: #374151; }

.dark .badge-violet  { background: rgba(124,58,237,0.2); color: #c4b5fd; }
.dark .badge-success { background: rgba(21,128,61,0.2);  color: #86efac; }
.dark .badge-warning { background: rgba(146,64,14,0.2);  color: #fcd34d; }
.dark .badge-danger  { background: rgba(185,28,28,0.2);  color: #fca5a5; }
.dark .badge-gray    { background: rgba(255,255,255,0.08); color: #d1d5db; }

/* ═══════════════════════════════════════
   PAGE TITLE
═══════════════════════════════════════ */
.page-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: #111827;
    letter-spacing: -0.02em;
    line-height: 1.25;
}
@media (max-width: 640px) { .page-title { font-size: 1.25rem; } }
.dark .page-title { color: #f9fafb; }

.page-subtitle {
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    margin-top: 0.25rem;
}
.dark .page-subtitle { color: #9ca3af; }

/* ═══════════════════════════════════════
   PANEL HEADER
═══════════════════════════════════════ */
.panel-hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #f3f4f6;
}
.dark .panel-hd { border-color: rgba(255,255,255,0.06); }

.panel-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #111827;
}
.dark .panel-title { color: #f9fafb; }

.panel-subtitle {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #6b7280;
    margin-top: 0.125rem;
}
.dark .panel-subtitle { color: #9ca3af; }

/* ═══════════════════════════════════════
   DATA TABLE  (desktop)
═══════════════════════════════════════ */
.data-table { width: 100%; border-collapse: collapse; }

.data-table th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b7280;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid #f3f4f6;
    background: #fafafa;
    white-space: nowrap;
}
.dark .data-table th {
    background: rgba(255,255,255,0.02);
    color: #9ca3af;
    border-color: rgba(255,255,255,0.06);
}

.data-table td {
    padding: 0.875rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    border-bottom: 1px solid #f9fafb;
    vertical-align: middle;
}
.dark .data-table td { color: #d1d5db; border-color: rgba(255,255,255,0.04); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(124,58,237,0.03); }

/* ═══════════════════════════════════════
   MOBILE CARD (replaces table rows on sm)
═══════════════════════════════════════ */
.mobile-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid #f3f4f6;
}
.dark .mobile-row { border-color: rgba(255,255,255,0.05); }
.mobile-row:last-child { border-bottom: none; }

/* ═══════════════════════════════════════
   VITAL TILE
═══════════════════════════════════════ */
.vital-tile {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 0.75rem 0.5rem;
    text-align: center;
}
.dark .vital-tile { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.07); }

.vital-label {
    font-size: 0.6875rem;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}
.dark .vital-label { color: #9ca3af; }

.vital-value {
    font-size: 1rem;
    font-weight: 800;
    color: #111827;
    margin-top: 0.2rem;
}
.dark .vital-value { color: #f9fafb; }

/* ═══════════════════════════════════════
   KV ROW (key-value pair in profile)
═══════════════════════════════════════ */
.kv-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0;
    border-bottom: 1px solid #f3f4f6;
    gap: 0.5rem;
}
.dark .kv-row { border-color: rgba(255,255,255,0.05); }
.kv-row:last-child { border-bottom: none; }

.kv-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    flex-shrink: 0;
}
.dark .kv-label { color: #9ca3af; }

.kv-value {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #111827;
    text-align: right;
}
.dark .kv-value { color: #f9fafb; }

/* ═══════════════════════════════════════
   STAT BOX
═══════════════════════════════════════ */
.stat-box {
    border-radius: 10px;
    padding: 0.875rem 0.75rem;
    text-align: center;
}
.stat-box-num {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1;
}
.stat-box-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    margin-top: 0.3rem;
}
.dark .stat-box-label { color: #9ca3af; }

/* ═══════════════════════════════════════
   TIMELINE
═══════════════════════════════════════ */
.tl-wrap { position: relative; }
.tl-item { position: relative; padding-left: 2rem; padding-bottom: 1.5rem; }
.tl-item:last-child { padding-bottom: 0; }
.tl-line {
    position: absolute;
    left: 0.6875rem; top: 1.5rem; bottom: 0;
    width: 1px; background: #e5e7eb;
}
.dark .tl-line { background: rgba(255,255,255,0.08); }
.tl-dot {
    position: absolute;
    left: 0; top: 0.3rem;
    width: 1.375rem; height: 1.375rem;
    border-radius: 50%;
    border: 2px solid #7c3aed;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
}
.dark .tl-dot { background: #111827; }

/* ═══════════════════════════════════════
   EMPTY STATE
═══════════════════════════════════════ */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3rem 1.5rem;
    text-align: center;
}
.empty-icon {
    width: 3rem; height: 3rem;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: #ede9fe;
    margin-bottom: 1rem;
}
.dark .empty-icon { background: rgba(124,58,237,0.15); }
.empty-title { font-size: 0.9375rem; font-weight: 700; color: #374151; }
.dark .empty-title { color: #d1d5db; }
.empty-text { font-size: 0.8125rem; font-weight: 500; color: #6b7280; margin-top: 0.25rem; }
.dark .empty-text { color: #9ca3af; }

/* ═══════════════════════════════════════
   ACCENT STRIP
═══════════════════════════════════════ */
.accent-strip { background: linear-gradient(90deg, #7c3aed, #a78bfa); }

/* ═══════════════════════════════════════
   PROGRESS BAR
═══════════════════════════════════════ */
.progress-track { height: 6px; background: #e5e7eb; border-radius: 99px; overflow: hidden; }
.dark .progress-track { background: rgba(255,255,255,0.08); }
.progress-fill { height: 100%; background: #7c3aed; border-radius: 99px; transition: width 0.7s ease; }

/* ═══════════════════════════════════════
   SCROLLBAR
═══════════════════════════════════════ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(124,58,237,0.25); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(124,58,237,0.5); }

/* ═══════════════════════════════════════
   GLASS CARD (login / auth)
═══════════════════════════════════════ */
.glass-card {
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.6);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.08);
}

/* ═══════════════════════════════════════
   SECTION LABEL
═══════════════════════════════════════ */
.section-lbl {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #6b7280;
    margin-bottom: 0.625rem;
    display: block;
}
.dark .section-lbl { color: #9ca3af; }

/* ═══════════════════════════════════════
   MOBILE UTILITY
═══════════════════════════════════════ */
@media (max-width: 640px) {
    /* Reduce padding on small screens */
    .px-6 { padding-left: 1rem !important; padding-right: 1rem !important; }
    .p-6  { padding: 1rem !important; }
    .p-5  { padding: 0.875rem !important; }
}

/* Safe area for notched phones */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .pb-safe { padding-bottom: env(safe-area-inset-bottom); }
}

/* Hover: white/8 helper (since Tailwind arbitrary opacity isn't always available) */
.hover\:bg-white\/8:hover { background-color: rgba(255,255,255,0.08); }
