/* ================================================================
   Hospital Information System — Core Stylesheet v1.0
   Based on design language from sample application.
   All buttons: black bg, white text.
   No coloured top bar on sidebar.
   ================================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: #111827;
    background: #f4f5f7;
    overflow-x: hidden;
}

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

/* ================================================================
   SIDEBAR
   ================================================================ */
.his-sidebar {
    width: 240px;
    background: #111827;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 200;
    overflow: hidden;
    transition: transform .25s;
}

/* Brand / logo area */
.his-brand {
    height: 64px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}
.his-brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}
.his-brand-logo {
    width: 36px; height: 36px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 6px;
    background: rgba(255,255,255,.08);
    padding: 4px;
}
.his-brand-text { color: #fff; font-size: .95rem; line-height: 1.25; }
.his-brand-text strong { font-weight: 700; display: block; font-size: .92rem; }
.his-brand-text span   { font-weight: 300; opacity: .5; font-size: .72rem; }

/* User pill */
.his-user-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}
.his-avatar {
    width: 32px; height: 32px;
    background: rgba(255,255,255,.12);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: .78rem; font-weight: 700;
    flex-shrink: 0;
}
.his-user-name  { font-size: .82rem; font-weight: 600; color: #e2e8f0; line-height: 1.3; }
.his-user-role  { font-size: .71rem; color: #9ca3af; line-height: 1.3; }
.his-user-station { font-size: .68rem; color: #6b7280; line-height: 1.3; }

/* Nav */
.his-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.his-nav::-webkit-scrollbar { width: 3px; }
.his-nav::-webkit-scrollbar-track { background: transparent; }
.his-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 2px; }

.his-nav-group { margin-bottom: 4px; }
.his-nav-label {
    font-size: .62rem; font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: rgba(255,255,255,.2);
    padding: 14px 16px 4px;
}
.his-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    color: #9ca3af;
    text-decoration: none;
    font-size: .84rem; font-weight: 500;
    transition: background .15s, color .15s;
    position: relative;
}
.his-nav-link i { width: 16px; text-align: center; opacity: .65; flex-shrink: 0; font-size: .85rem; }
.his-nav-link:hover { background: rgba(255,255,255,.06); color: #e5e7eb; }
.his-nav-link:hover i { opacity: 1; }
.his-nav-link.active { background: rgba(255,255,255,.1); color: #fff; font-weight: 600; }
.his-nav-link.active i { opacity: 1; }
.his-nav-link.active::before {
    content: '';
    position: absolute;
    left: 0; top: 4px; bottom: 4px;
    width: 3px;
    background: #fff;
    border-radius: 0 2px 2px 0;
}

/* Badge on nav links (e.g. pending count) */
.his-nav-badge {
    margin-left: auto;
    background: rgba(255,255,255,.15);
    color: #e5e7eb;
    font-size: .65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

/* Sidebar footer */
.his-sidebar-foot {
    padding: 10px 8px;
    border-top: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}
.his-signout {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    color: rgba(255,255,255,.3);
    text-decoration: none;
    font-size: .82rem;
    transition: background .15s, color .15s;
}
.his-signout:hover { background: rgba(220,38,38,.12); color: #fca5a5; }

/* ================================================================
   MAIN AREA
   ================================================================ */
.his-main {
    flex: 1;
    margin-left: 240px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: #f4f5f7;
}

/* ── Topbar ── */
.his-topbar {
    height: 56px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0; z-index: 100;
    gap: 12px;
}
.his-topbar-left  { display: flex; align-items: center; gap: 12px; min-width: 0; }
.his-topbar-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.his-toggle {
    background: none; border: none;
    width: 34px; height: 34px;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    color: #6b7280; cursor: pointer;
}
.his-toggle:hover { background: #f4f5f7; color: #111827; }

.his-breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .82rem;
    overflow: hidden;
}
.his-bc-mod  { color: #9ca3af; text-decoration: none; }
.his-bc-mod:hover { color: #6b7280; }
.his-bc-sep  { font-size: .6rem; color: #d1d5db; }
.his-bc-page { color: #111827; font-weight: 600; white-space: nowrap; }

.his-station-pill {
    display: flex; align-items: center; gap: 5px;
    font-size: .76rem; color: #6b7280;
    padding: 4px 10px;
    background: #f4f5f7;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    white-space: nowrap;
}
.his-station-pill i { font-size: .72rem; }

.his-user-btn {
    display: flex; align-items: center; gap: 8px;
    background: none;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    padding: 4px 12px 4px 5px;
    cursor: pointer;
    font-size: .82rem; color: #111827;
}
.his-user-btn:hover { border-color: #d1d5db; background: #f9fafb; }

.his-avatar-sm {
    width: 26px; height: 26px;
    background: #111827;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: .72rem; font-weight: 700;
}

.his-drop {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
    min-width: 210px;
}
.his-drop-user { padding: 10px 16px; border-bottom: 1px solid #f3f4f6; }
.his-drop-user .name { font-size: .85rem; font-weight: 600; color: #111827; }
.his-drop-user .role { font-size: .75rem; color: #9ca3af; }
.his-drop-user .station { font-size: .72rem; color: #6b7280; margin-top: 1px; }
.his-drop .dropdown-item { font-size: .84rem; padding: 8px 16px; color: #374151; }
.his-drop .dropdown-item:hover { background: #f4f5f7; }

/* ── Content area ── */
.his-content { flex: 1; padding: 28px; }

/* ── Footer ── */
.his-footer {
    padding: 12px 28px;
    font-size: .74rem;
    color: #9ca3af;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    background: #fff;
}

/* ================================================================
   FLASH MESSAGES
   ================================================================ */
.his-flash { padding: 12px 24px 0; }

/* ================================================================
   BUTTONS  — all black/white
   ================================================================ */
.btn-his {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: .83rem; font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all .15s;
    white-space: nowrap;
    line-height: 1.4;
}
/* Primary — solid black */
.btn-his-primary {
    background: #111827;
    color: #fff;
    border-color: #111827;
}
.btn-his-primary:hover { background: #1f2937; color: #fff; border-color: #1f2937; }

/* Outline — white with dark border */
.btn-his-outline {
    background: #fff;
    color: #111827;
    border-color: #d1d5db;
}
.btn-his-outline:hover { background: #f9fafb; border-color: #9ca3af; color: #111827; }

/* Danger */
.btn-his-danger {
    background: #fff;
    color: #dc2626;
    border-color: #fca5a5;
}
.btn-his-danger:hover { background: #fef2f2; }

/* Sizes */
.btn-his-sm  { padding: 5px 11px; font-size: .78rem; }
.btn-his-xs  { padding: 3px 8px;  font-size: .72rem; }
.btn-his-lg  { padding: 10px 22px; font-size: .9rem; }

/* Icon-only square button */
.btn-his-icon {
    padding: 6px 8px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    color: #6b7280;
    cursor: pointer;
    transition: all .15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-his-icon:hover { background: #f4f5f7; color: #111827; border-color: #d1d5db; }

/* ================================================================
   MODULE HEADER
   ================================================================ */
.mod-header {
    margin-bottom: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.mod-header-left h2 { font-size: 1.12rem; font-weight: 700; color: #111827; margin-bottom: 3px; }
.mod-header-left p  { font-size: .82rem; color: #9ca3af; margin: 0; }
.mod-header-right   { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ================================================================
   STAT BOXES  (dashboard cards)
   ================================================================ */
.stat-box {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px 22px;
    display: block;
    text-decoration: none;
    transition: box-shadow .15s, border-color .15s;
}
.stat-box:hover { border-color: #d1d5db; box-shadow: 0 4px 12px rgba(0,0,0,.07); }
.stat-box-icon  { font-size: 1rem; color: #9ca3af; margin-bottom: 10px; }
.stat-box-value { font-size: 1.85rem; font-weight: 800; color: #111827; line-height: 1; margin-bottom: 4px; }
.stat-box-label { font-size: .7rem; color: #9ca3af; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.stat-box-link  { font-size: .74rem; color: #9ca3af; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; margin-top: 8px; }
.stat-box-link:hover { color: #6b7280; }

/* ================================================================
   MODULE CARDS  (navigation tiles)
   ================================================================ */
.mod-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    text-decoration: none;
    color: #111827;
    transition: border-color .15s, box-shadow .15s, transform .15s;
}
.mod-card:hover {
    border-color: #d1d5db;
    box-shadow: 0 4px 12px rgba(0,0,0,.07);
    transform: translateY(-2px);
    color: #111827;
}
.mod-card-icon {
    width: 44px; height: 44px;
    background: #f4f5f7;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: .95rem; color: #4b5563;
    flex-shrink: 0;
}
.mod-card-title { font-size: .87rem; font-weight: 600; color: #111827; margin-bottom: 2px; }
.mod-card-desc  { font-size: .75rem; color: #9ca3af; line-height: 1.4; }
.mod-card-arrow { margin-left: auto; color: #d1d5db; font-size: .8rem; flex-shrink: 0; }

/* ================================================================
   HIS CARD
   ================================================================ */
.his-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
}
.his-card-header {
    padding: 14px 18px;
    border-bottom: 1px solid #f3f4f6;
    font-size: .87rem;
    font-weight: 600;
    color: #111827;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.his-card-header i { color: #9ca3af; margin-right: 6px; }
.his-card-body { padding: 20px; }

/* ================================================================
   TAB NAV
   ================================================================ */
.his-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 8px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
}
.his-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: .82rem; font-weight: 500;
    color: #4b5563;
    text-decoration: none;
    transition: background .15s, color .15s;
    border: 1px solid transparent;
}
.his-tab:hover  { background: #f4f5f7; color: #111827; }
.his-tab.active { background: #111827; color: #fff; }
.his-tab i { font-size: .77rem; }

/* ================================================================
   TABLES
   ================================================================ */
.his-table { width: 100%; border-collapse: collapse; }
.his-table th {
    font-size: .68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .6px;
    color: #9ca3af;
    padding: 10px 16px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    text-align: left;
    white-space: nowrap;
}
.his-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    font-size: .85rem;
    color: #111827;
    vertical-align: middle;
}
.his-table tbody tr:last-child td { border-bottom: none; }
.his-table tbody tr:hover { background: #fafafa; }

/* DataTables overrides */
table.dataTable thead th {
    background: #f9fafb !important;
    font-size: .68rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: .6px !important;
    color: #9ca3af !important;
    border-bottom: 1px solid #e5e7eb !important;
}
.dataTables_wrapper .dataTables_filter input {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: .82rem;
}
.dataTables_wrapper .dataTables_filter input:focus {
    outline: none;
    border-color: #111827;
    box-shadow: 0 0 0 3px rgba(17,24,39,.08);
}
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length { font-size: .78rem; color: #9ca3af; }
.dataTables_wrapper .dataTables_length select {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 3px 6px;
    font-size: .82rem;
}

/* ================================================================
   FORMS
   ================================================================ */
.form-label { font-size: .82rem; font-weight: 600; color: #374151; margin-bottom: 5px; }
.form-label .req { color: #dc2626; margin-left: 2px; }
.form-control, .form-select {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: .88rem;
    padding: 8px 12px;
    color: #111827;
}
.form-control:focus, .form-select:focus {
    border-color: #111827;
    box-shadow: 0 0 0 3px rgba(17,24,39,.08);
    outline: none;
}
.form-text { font-size: .75rem; color: #9ca3af; }
.form-section { margin-bottom: 28px; }
.form-section-title {
    font-size: .72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .8px;
    color: #9ca3af;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f3f4f6;
}

/* ================================================================
   PATIENT / INFO GRID
   ================================================================ */
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px 20px; }
.info-item {}
.info-label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: #9ca3af; }
.info-value { font-size: .88rem; color: #111827; font-weight: 500; }

/* ================================================================
   BADGES
   ================================================================ */
.badge { font-size: .7rem; padding: 3px 8px; border-radius: 4px; font-weight: 600; }

/* ================================================================
   ALERT
   ================================================================ */
.alert { font-size: .85rem; border-radius: 8px; }

/* ================================================================
   SIDEBAR COLLAPSE
   ================================================================ */
.sidebar-collapsed .his-sidebar { transform: translateX(-240px); }
.sidebar-collapsed .his-main    { margin-left: 0; }

/* ================================================================
   MOBILE
   ================================================================ */
@media (max-width: 768px) {
    .his-sidebar { transform: translateX(-240px); }
    .his-main    { margin-left: 0; }
    .sidebar-open .his-sidebar { transform: translateX(0); }
    .his-content { padding: 16px; }
    .his-topbar  { padding: 0 16px; }
    .his-station-pill { display: none; }
}

/* ================================================================
   PRINT
   ================================================================ */
@media print {
    .his-sidebar, .his-topbar, .his-footer, .no-print { display: none !important; }
    .his-main    { margin-left: 0 !important; }
    .his-content { padding: 0 !important; }
    body         { background: #fff !important; }
    .his-card    { border: none !important; box-shadow: none !important; }
}
