/*
 * Sky Medical Center brand palette — centralized here rather than
 * scattered as hard-coded hex values across PHP files. Adapted into
 * this project's existing --hms-* variable naming (previously a teal
 * theme); every rule below already referenced these tokens, so most of
 * the rebrand is this block plus the few places that had their own
 * hard-coded hex duplicating the old teal.
 */
:root {
    --hms-primary: #6B1F67;       /* Primary Purple */
    --hms-primary-dark: #551950;  /* darker purple, replaces old primary-dark role */
    --hms-primary-light: #8E4A7E; /* Secondary Purple */
    --hms-secondary: #62A9E8;     /* Sky Blue */
    --hms-secondary-light: #DCEEFE; /* Light Background Blue */
    --hms-sidebar-bg: #6B1F67;
    --hms-sidebar-active: #62A9E8;
    --hms-bg: #f4f6f8;
    --hms-border: #e3e7ea;
    --hms-text: #252534;          /* Dark Text */
    --hms-muted: #6b7c85;

    /* Bootstrap 5 reads these for every .btn-primary, focus ring, link,
       etc. — overriding them is what makes brand purple apply app-wide
       without hunting down every Bootstrap component individually. */
    --bs-primary: #6B1F67;
    --bs-primary-rgb: 107, 31, 103;
    --bs-link-color: #6B1F67;
    --bs-link-color-rgb: 107, 31, 103;
    --bs-link-hover-color: #551950;
    --bs-link-hover-color-rgb: 85, 25, 80;
}

* { box-sizing: border-box; }

body {
    background: var(--hms-bg);
    color: var(--hms-text);
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
    width: 250px;
    flex-shrink: 0;
    background: var(--hms-sidebar-bg);
    color: rgba(255,255,255,.82);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1.1rem 1.2rem;
    font-weight: 700;
    font-size: 1.05rem;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.15);
}
.sidebar-brand img { height: 32px; width: 32px; object-fit: contain; border-radius: .3rem; background: #fff; flex-shrink: 0; }
.sidebar-brand .brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.sidebar-brand .brand-tagline { font-size: .68rem; font-weight: 400; color: var(--hms-secondary-light); opacity: .9; }
.sidebar-brand i { font-size: 1.4rem; color: var(--hms-secondary); }
.sidebar-nav { padding: .75rem 0; flex: 1; }
.sidebar-group-label {
    text-transform: uppercase;
    font-size: .7rem;
    letter-spacing: .06em;
    color: rgba(255,255,255,.55);
    padding: 1rem 1.2rem .35rem;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem 1.2rem;
    color: rgba(255,255,255,.82);
    text-decoration: none;
    font-size: .92rem;
    border-left: 3px solid transparent;
}
.sidebar-link i { width: 1.1rem; text-align: center; }
.sidebar-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-link.active {
    background: rgba(98,169,232,.18);
    border-left-color: var(--hms-secondary);
    color: #fff;
    font-weight: 600;
}
.sidebar-note {
    font-size: .72rem;
    color: rgba(255,255,255,.55);
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,.15);
}

/* Main */
.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.app-navbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #fff;
    border-bottom: 1px solid var(--hms-border);
    padding: .65rem 1.25rem;
    position: sticky;
    top: 0;
    z-index: 10;
}
.sidebar-toggle { background: none; border: none; font-size: 1.4rem; color: var(--hms-text); }
.navbar-search { position: relative; flex: 1; max-width: 420px; }
.navbar-search i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--hms-muted); }
.navbar-search input {
    width: 100%;
    padding: .5rem .75rem .5rem 2.2rem;
    border-radius: 999px;
    border: 1px solid var(--hms-border);
    background: var(--hms-bg);
}
.navbar-right { margin-left: auto; display: flex; align-items: center; gap: .85rem; }
.navbar-role-badge {
    background: var(--hms-secondary-light);
    color: var(--hms-primary-dark);
    padding: .3rem .7rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
}
.navbar-user-btn {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: none;
    border: none;
    padding: .3rem .5rem;
    border-radius: 999px;
}
.navbar-user-btn:hover { background: var(--hms-bg); }
.avatar-circle {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--hms-primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}

.app-content { padding: 1.5rem; flex: 1; }
.app-footer {
    padding: 1rem 1.5rem;
    color: var(--hms-muted);
    font-size: .8rem;
    border-top: 1px solid var(--hms-border);
}

/* Shared components */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; flex-wrap: wrap; gap: .75rem; }
.page-header h1 { font-size: 1.4rem; font-weight: 700; margin: 0; }
.page-header .breadcrumb { margin: 0; font-size: .82rem; }

.stat-card {
    background: #fff;
    border: 1px solid var(--hms-border);
    border-radius: .6rem;
    padding: 1.1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.stat-card .stat-icon {
    width: 46px; height: 46px;
    border-radius: .6rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    background: var(--hms-secondary-light);
    color: var(--hms-primary-dark);
}
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { color: var(--hms-muted); font-size: .8rem; margin-top: .2rem; }

.card-panel {
    background: #fff;
    border: 1px solid var(--hms-border);
    border-radius: .6rem;
    padding: 1.25rem;
}

.identity-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: linear-gradient(135deg, var(--hms-primary), var(--hms-primary-light));
    color: #fff;
    border-radius: .6rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}
.identity-banner .identity-photo {
    width: 56px; height: 56px; border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.2rem;
    flex-shrink: 0;
    object-fit: cover;
}
.identity-banner .identity-meta { font-size: .8rem; opacity: .9; }
.identity-banner .identity-alert { background: #dc3545; padding: .2rem .5rem; border-radius: .3rem; font-size: .72rem; font-weight: 700; margin-left: .4rem; }

table.table thead th {
    text-transform: uppercase;
    font-size: .72rem;
    letter-spacing: .04em;
    color: var(--hms-primary-dark);
    border-bottom: 2px solid var(--hms-secondary-light);
}
table.table tbody tr:hover { background-color: var(--hms-secondary-light); }

/* Bootstrap 5.3 compiles each .btn-* variant's colors into its own
   --bs-btn-* custom properties at build time (not a live reference to
   --bs-primary), so redeclaring --bs-primary above does not retint
   .btn-primary on its own — these explicit overrides are required.
   Only primary/outline-primary and outline-secondary are touched (the
   only variants this app actually uses); .btn-danger/.btn-success/
   .btn-warning are deliberately left on Bootstrap's own semantic colors. */
.btn-primary {
    --bs-btn-bg: var(--hms-primary);
    --bs-btn-border-color: var(--hms-primary);
    --bs-btn-hover-bg: var(--hms-primary-dark);
    --bs-btn-hover-border-color: var(--hms-primary-dark);
    --bs-btn-active-bg: var(--hms-primary-dark);
    --bs-btn-active-border-color: var(--hms-primary-dark);
    --bs-btn-disabled-bg: var(--hms-primary);
    --bs-btn-disabled-border-color: var(--hms-primary);
    --bs-btn-focus-shadow-rgb: 107, 31, 103;
}
.btn-outline-primary {
    --bs-btn-color: var(--hms-primary);
    --bs-btn-border-color: var(--hms-primary);
    --bs-btn-hover-bg: var(--hms-primary);
    --bs-btn-hover-border-color: var(--hms-primary);
    --bs-btn-active-bg: var(--hms-primary);
    --bs-btn-active-border-color: var(--hms-primary);
    --bs-btn-disabled-color: var(--hms-primary);
    --bs-btn-disabled-border-color: var(--hms-primary);
    --bs-btn-focus-shadow-rgb: 107, 31, 103;
}
.btn-outline-secondary {
    --bs-btn-color: #4a7aa8;
    --bs-btn-border-color: var(--hms-secondary);
    --bs-btn-hover-bg: var(--hms-secondary);
    --bs-btn-hover-border-color: var(--hms-secondary);
    --bs-btn-active-bg: var(--hms-secondary);
    --bs-btn-active-border-color: var(--hms-secondary);
    --bs-btn-disabled-color: var(--hms-secondary);
    --bs-btn-disabled-border-color: var(--hms-secondary);
}

/* Forms: sky-blue focus ring, purple section headings — validation/warning
   colors are untouched (Bootstrap's own red/yellow classes still apply). */
.form-control:focus, .form-select:focus {
    border-color: var(--hms-secondary);
    box-shadow: 0 0 0 .2rem rgba(98,169,232,.25);
}
/* Section headings default to brand purple, but any element that also
   carries a semantic status class (.text-danger/.text-success/.text-warning)
   keeps that color — clinical/financial severity must never be overridden
   by branding. */
.card-panel h2:not([class*="text-"]), .card-panel .h6:not([class*="text-"]) { color: var(--hms-primary-dark); }

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--hms-secondary-light), #fff);
    padding: 1rem;
}
.auth-card {
    background: #fff;
    border-radius: .75rem;
    padding: 2.25rem 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 50px rgba(107,31,103,.18);
    border-top: 4px solid var(--hms-primary);
}
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand img { max-height: 64px; max-width: 220px; object-fit: contain; margin-bottom: .5rem; }
.auth-brand i { font-size: 2.2rem; color: var(--hms-primary); }
.auth-brand h1 { font-size: 1.15rem; font-weight: 700; margin: .4rem 0 0; color: var(--hms-primary); }
.auth-brand .auth-tagline { font-size: .82rem; color: var(--hms-secondary); font-style: italic; margin-top: .15rem; }

@media print {
    .app-sidebar, .app-navbar, .app-footer, .no-print { display: none !important; }
    .app-content { padding: 0; }
}

@media (max-width: 991.98px) {
    .app-sidebar { position: fixed; left: -260px; z-index: 1050; transition: left .2s ease; }
    .app-sidebar.open { left: 0; }
}
