/* ============================================================
   rxhub — brand theme v2
   Navy + Blue palette, Inter typeface
   ============================================================ */

/* ---- Design Tokens ---- */
:root {
    --navy:       #0F1C3F;
    --navy-light: #1E3A6E;
    --blue:       #2563EB;
    --blue-hover: #1d4ed8;
    --blue-pale:  #EFF6FF;
    --white:      #FFFFFF;
    --bg:         #F7F9FC;
    --border:     #E4E9F0;
    --text:       #0F1C3F;
    --text-2:     #4B5870;
    --text-3:     #6B7A99;
    --green:      #10B981;
    --green-bg:   #ECFDF5;
    --amber:      #F59E0B;
    --amber-bg:   #FFFBEB;
    --red:        #EF4444;
    --red-bg:     #FEF2F2;
    --purple:     #8B5CF6;
    --purple-bg:  #F5F3FF;
}

/* ---- Global ---- */
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text);
    background: var(--bg);
    font-feature-settings: "kern", "liga";
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .font-serif {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    letter-spacing: -0.025em;
    color: var(--navy);
    font-weight: 700;
}
h1 { font-weight: 800; letter-spacing: -0.035em; }
h2 { font-weight: 700; }
h3 { font-weight: 700; }

[x-cloak] { display: none !important; }

/* ---- Links ---- */
:where(a) { color: var(--blue); }
:where(a):hover { color: var(--blue-hover); }

/* ---- Buttons ---- */
.btn-primary {
    background-color: var(--blue);
    color: #fff;
    padding: 0.55rem 1.25rem;
    border-radius: 9px;
    font-weight: 600;
    font-size: 0.8125rem;
    letter-spacing: -0.01em;
    transition: background-color 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid var(--blue);
}
.btn-primary:hover { background-color: var(--blue-hover); color: #fff; border-color: var(--blue-hover); }

.btn-outline {
    background-color: transparent;
    color: var(--text);
    padding: 0.45rem 1rem;
    border-radius: 9px;
    font-weight: 600;
    font-size: 0.8125rem;
    letter-spacing: -0.01em;
    border: 1px solid var(--border);
    transition: background-color 0.15s ease, color 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}
.btn-outline:hover { background-color: var(--bg); color: var(--navy); border-color: #C8D3E0; }

/* Blue variant for confirmations */
.btn-blue {
    background-color: var(--blue);
    color: #fff;
    padding: 0.55rem 1.25rem;
    border-radius: 9px;
    font-weight: 600;
    font-size: 0.8125rem;
    letter-spacing: -0.01em;
    transition: background-color 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid var(--blue);
}
.btn-blue:hover { background-color: var(--blue-hover); color: #fff; }

/* ---- Stat Cards ---- */
.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}
.stat-card:hover { box-shadow: 0 2px 12px rgba(15,28,63,0.07); }
.stat-card .stat-value {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 2.25rem;
    font-weight: 900;
    line-height: 1;
    color: var(--navy);
    letter-spacing: -0.04em;
}
.stat-card .stat-label {
    font-size: 0.625rem;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
}
.stat-card .stat-icon { font-size: 1.5rem; color: var(--blue); opacity: 0.25; }

/* Dark stat card variant */
.stat-card-dark {
    background: var(--navy);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}
.stat-card-dark .stat-value {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 2.75rem;
    font-weight: 900;
    line-height: 1;
    color: #fff;
    letter-spacing: -0.04em;
}
.stat-card-dark .stat-label {
    font-size: 0.625rem;
    color: rgba(255, 255, 255, 0.45);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 700;
}

/* ---- Status Badges ---- */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0.2rem 0.65rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0em;
}
.status-badge::before {
    content: '●';
    font-size: 0.45rem;
    line-height: 1;
}

.status-pending      { background: var(--amber-bg); color: #D97706; }
.status-confirmed    { background: var(--blue-pale); color: var(--blue); }
.status-in_progress  { background: var(--purple-bg); color: var(--purple); }
.status-completed    { background: var(--green-bg);  color: #059669; }
.status-cancelled    { background: var(--red-bg);    color: #DC2626; }
.status-active       { background: var(--green-bg);  color: #059669; }
.status-dispensed    { background: var(--blue-pale); color: var(--blue); }
.status-expired      { background: var(--bg);        color: var(--text-2); border: 1px solid var(--border); }
.status-under_review { background: var(--amber-bg);  color: #D97706; }

/* ---- Avatar ---- */
.avatar {
    width: 36px; height: 36px; border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.75rem; color: #fff; flex-shrink: 0;
}
.avatar-sm { width: 24px; height: 24px; font-size: 0.6rem; border-radius: 6px; }
.avatar-lg { width: 50px; height: 50px; font-size: 1rem; border-radius: 11px; }
.avatar-xl { width: 72px; height: 72px; font-size: 1.25rem; border-radius: 14px; }
.avatar-primary { background-color: var(--navy); }
.avatar-success { background-color: #059669; }
.avatar-info    { background-color: var(--blue); }
.avatar-warning { background-color: var(--amber); color: #fff; }

/* ---- Tables ---- */
table.uhc-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

table.uhc-table thead th {
    background-color: var(--bg);
    color: var(--text-3);
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.625rem 1.25rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
table.uhc-table tbody td {
    padding: 0.7rem 1.25rem;
    border-bottom: 1px solid #F4F6FA;
    font-size: 0.8125rem;
    color: var(--text);
}
table.uhc-table tbody tr:last-child td { border-bottom: none; }
table.uhc-table tbody tr:hover { background-color: #FAFBFD; }
table.uhc-table tfoot td {
    padding: 0.85rem 1.25rem;
    border-top: 1px solid var(--border);
}

/* ---- Table corner rounding ---- */
/* Top-left / top-right on header */
table.uhc-table thead tr:first-child th:first-child { border-top-left-radius: 10px; }
table.uhc-table thead tr:first-child th:last-child  { border-top-right-radius: 10px; }
/* Bottom-left / bottom-right on last body row */
table.uhc-table tbody tr:last-child td:first-child  { border-bottom-left-radius: 10px; }
table.uhc-table tbody tr:last-child td:last-child   { border-bottom-right-radius: 10px; }
/* Bottom corners via tfoot when present */
table.uhc-table tfoot tr:last-child td:first-child  { border-bottom-left-radius: 10px; }
table.uhc-table tfoot tr:last-child td:last-child   { border-bottom-right-radius: 10px; }

/* ---- Forms ---- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="search"],
select,
textarea {
    border-color: var(--border) !important;
    border-radius: 9px !important;
    background-color: #fff !important;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--blue) !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1) !important;
    outline: none !important;
}
label {
    color: var(--text-3);
    font-weight: 700;
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ---- Empty State ---- */
.empty-state { text-align: center; padding: 5rem 1rem; color: var(--text-3); }
.empty-state .empty-icon {
    width: 4rem; height: 4rem; border-radius: 12px;
    background: var(--blue-pale);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 1.5rem;
    color: var(--blue);
}
.empty-state h3 { color: var(--navy); font-weight: 700; margin-bottom: 0.5rem; letter-spacing: -0.02em; }

/* ---- Chat ---- */
.chat-messages { max-height: 60vh; overflow-y: auto; scroll-behavior: smooth; }
.chat-bubble {
    max-width: 75%; padding: 0.65rem 0.9rem; border-radius: 12px;
    word-wrap: break-word; font-size: 0.85rem;
}
.chat-bubble-mine  { background-color: var(--navy); color: #fff; border-bottom-right-radius: 4px; }
.chat-bubble-other { background-color: var(--white); color: var(--text); border-bottom-left-radius: 4px; border: 1px solid var(--border); }
.chat-time { font-size: 0.65rem; opacity: 0.6; }

/* ---- Vital Signs ---- */
.vital-sign-card {
    text-align: center; padding: 0.9rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background-color: var(--white);
}
.vital-sign-card .vital-value {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 1.5rem; font-weight: 800; color: var(--navy);
    letter-spacing: -0.03em;
}
.vital-sign-card .vital-label {
    font-size: 0.6rem; color: var(--text-3);
    text-transform: uppercase; letter-spacing: 0.1em;
    font-weight: 700;
}

/* ---- Prescription / Medication ---- */
.medication-item {
    border: 1px solid var(--border); border-radius: 12px;
    padding: 1rem; margin-bottom: 0.65rem;
    background-color: var(--white); position: relative;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.medication-item:hover { border-color: #BFDBFE; box-shadow: 0 1px 4px rgba(37,99,235,0.06); }
.medication-item .remove-btn { position: absolute; top: 0.5rem; right: 0.5rem; }

/* ---- Calendar (FullCalendar) ---- */
.fc .fc-toolbar-title {
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 1.1rem !important;
    font-weight: 700 !important;
    color: var(--navy);
    letter-spacing: -0.02em;
}
.fc .fc-button {
    background-color: var(--navy) !important;
    border-color: var(--navy) !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    padding: 0.35rem 0.9rem !important;
}
.fc .fc-button:hover { background-color: var(--navy-light) !important; }
.fc .fc-event {
    cursor: pointer; border: none; padding: 2px 4px;
    font-size: 0.72rem; border-radius: 6px;
    background-color: var(--blue);
}

/* ---- Schedule ---- */
.schedule-row { transition: background-color 0.15s ease; }
.schedule-row:hover { background-color: #FAFBFD; }
.schedule-row.inactive { opacity: 0.5; }

/* ---- Autocomplete ---- */
.autocomplete-dropdown {
    position: absolute; z-index: 50; width: 100%;
    max-height: 200px; overflow-y: auto;
    background: var(--white); border: 1px solid var(--border);
    border-top: none; border-radius: 0 0 9px 9px;
    box-shadow: 0 8px 24px rgba(15,28,63,0.1);
}
.autocomplete-item {
    padding: 0.55rem 0.85rem; cursor: pointer; font-size: 0.8rem;
    transition: background-color 0.1s ease;
}
.autocomplete-item:hover, .autocomplete-item.active { background-color: var(--blue-pale); }
.autocomplete-item .generic { font-size: 0.72rem; color: var(--text-3); }

/* ---- Breadcrumbs ---- */
.breadcrumbs {
    display: flex; align-items: center;
    gap: 0.5rem; font-size: 0.8rem;
    color: var(--text-3); margin-bottom: 1.5rem;
}
.breadcrumbs a { color: var(--blue); }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs .separator { color: var(--border); }

/* ---- Table row action links ---- */
.tbl-action {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0em;
    color: var(--text-3);
    transition: color 0.15s ease;
}
.tbl-action:hover { color: var(--navy); }
.tbl-action-danger { color: #FCA5A5; }
.tbl-action-danger:hover { color: var(--red); }

/* ---- Custom scrollbar ---- */
.table-container::-webkit-scrollbar { height: 6px; }
.table-container::-webkit-scrollbar-track { background: var(--bg); }
.table-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
.table-container::-webkit-scrollbar-thumb:hover { background: #C8D3E0; }

/* ---- Utility ---- */
.text-truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.cursor-pointer { cursor: pointer; }

/* ---- Print ---- */
@media print {
    nav, footer, .no-print, button { display: none !important; }
    main { padding: 0 !important; }
    body { background: #fff; color: #000; }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .stat-card .stat-value { font-size: 1.75rem; }
    .stat-card-dark .stat-value { font-size: 2.25rem; }
    .chat-bubble { max-width: 90%; }
    table.uhc-table thead th,
    table.uhc-table tbody td { padding: 0.5rem 0.75rem; }
}
