/* ============================================
   DHB Billing System - Dhir Hospital Theme
   Colors match counselling project style
   ============================================ */

:root {
    --primary: #1a5276;
    --primary-dark: #0e3a55;
    --primary-light: #2980b9;
    --secondary: #2c3e50;
    --accent: #e67e22;
    --success: #27ae60;
    --danger: #e74c3c;
    --warning: #f39c12;
    --info: #3498db;
    --bg-body: #ecf0f1;
    --bg-card: #ffffff;
    --bg-header: #1a5276;
    --bg-sidebar: #1c2833;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --text-light: #bdc3c7;
    --border: #dce1e5;
    --shadow: rgba(0,0,0,0.08);
    --yellow-highlight: #ffff00;
    --yellow-soft: #fffde7;
    --sidebar-width: 220px;
    --header-height: 56px;
    --radius: 4px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-body);
    line-height: 1.5;
}

/* ============================================
   TOP HEADER
   ============================================ */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-header);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
    box-shadow: 0 2px 8px var(--shadow);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius);
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.1); }

.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { height: 36px; width: auto; }
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: 0.5px; }
.brand-sub { font-size: 10px; opacity: 0.7; font-weight: 300; }

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-date {
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-menu { position: relative; cursor: pointer; }
.user-name {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    padding: 4px 10px;
    border-radius: var(--radius);
    transition: background 0.2s;
}
.user-name:hover { background: rgba(255,255,255,0.1); }

.user-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: #fff;
    color: var(--text-primary);
    min-width: 160px;
    border-radius: var(--radius);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    padding: 8px 0;
    margin-top: 4px;
}
.user-menu:hover .user-dropdown { display: block; }
.user-dropdown .user-role {
    display: block;
    padding: 6px 16px;
    font-size: 11px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}
.user-dropdown a {
    display: block;
    padding: 8px 16px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 13px;
}
.user-dropdown a:hover { background: var(--bg-body); }

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    z-index: 900;
    overflow-y: auto;
    transition: transform 0.25s ease;
}
.sidebar.collapsed { transform: translateX(-100%); }

.sidebar-nav {
    padding: 12px 0;
    display: flex;
    flex-direction: column;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-light);
    text-decoration: none;
    font-size: 13px;
    font-weight: 400;
    transition: all 0.15s;
    border-left: 3px solid transparent;
}
.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}
.nav-item.active {
    background: rgba(255,255,255,0.08);
    color: #fff;
    border-left-color: var(--accent);
    font-weight: 500;
}
.nav-item i { width: 20px; text-align: center; font-size: 15px; }

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: 20px;
    min-height: calc(100vh - var(--header-height));
    transition: margin-left 0.25s ease;
}
.sidebar.collapsed ~ .main-content { margin-left: 0; }

/* ============================================
   ALERTS
   ============================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    animation: slideDown 0.3s ease;
}
.alert-success { background: #d4edda; color: #155724; border-left: 4px solid var(--success); }
.alert-danger { background: #f8d7da; color: #721c24; border-left: 4px solid var(--danger); }
.alert-warning { background: #fff3cd; color: #856404; border-left: 4px solid var(--warning); }
.alert-info { background: #d1ecf1; color: #0c5460; border-left: 4px solid var(--info); }
.alert-close { background: none; border: none; font-size: 18px; cursor: pointer; color: inherit; }

@keyframes slideDown {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ============================================
   PAGE HEADER
   ============================================ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-dark);
}

.page-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: 0 1px 4px var(--shadow);
    margin-bottom: 16px;
}

.card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 13px;
    color: var(--primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-body { padding: 16px; }

/* ============================================
   BILLING FORM - Yellow Header Style
   ============================================ */
.billing-form { background: #fff; }

.form-section {
    margin-bottom: 2px;
}

.form-section-header {
    background: var(--yellow-highlight);
    padding: 6px 10px;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    color: #000;
    border: 1px solid #ccc;
}

.form-grid {
    display: grid;
    gap: 1px;
    background: #ddd;
    border: 1px solid #ccc;
}

.form-grid > * {
    background: #fff;
    padding: 6px 8px;
}

.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.form-grid-5 { grid-template-columns: 1fr 1fr 1fr 1fr 1fr; }
.form-grid-6 { grid-template-columns: repeat(6, 1fr); }

.form-row {
    display: flex;
    gap: 0;
    border: 1px solid #ddd;
    border-top: none;
}

.form-row:first-child { border-top: 1px solid #ddd; }

.form-cell {
    padding: 4px 8px;
    border-right: 1px solid #ddd;
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 32px;
}
.form-cell:last-child { border-right: none; }

.form-cell label {
    font-size: 11px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    min-width: fit-content;
}

.form-cell.yellow-bg {
    background: var(--yellow-highlight);
}

.form-cell.yellow-soft-bg {
    background: var(--yellow-soft);
}

/* ============================================
   FORM INPUTS
   ============================================ */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.form-group label {
    font-size: 11px;
    font-weight: 600;
    color: #333;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="email"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #ccc;
    border-radius: 2px;
    font-size: 12px;
    font-family: inherit;
    color: var(--text-primary);
    background: #fff;
    outline: none;
    transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 2px rgba(41,128,185,0.15);
}

input:read-only {
    background: #f5f5f5;
    color: #666;
}

.input-sm {
    padding: 3px 6px;
    font-size: 11px;
}

/* ============================================
   SERVICES TABLE
   ============================================ */
.services-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.services-table th {
    background: var(--yellow-highlight);
    padding: 6px 8px;
    text-align: left;
    font-weight: 700;
    font-size: 11px;
    border: 1px solid #ccc;
    color: #000;
}

.services-table td {
    padding: 4px 6px;
    border: 1px solid #ddd;
    vertical-align: middle;
}

.services-table td input,
.services-table td select {
    border: none;
    padding: 3px 4px;
    font-size: 12px;
    background: transparent;
}

.services-table td input:focus {
    background: var(--yellow-soft);
    box-shadow: none;
}

.services-table tr:hover td {
    background: #fafafa;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #219a52; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c0392b; }

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d68910; }

.btn-info { background: var(--info); color: #fff; }
.btn-info:hover { background: #2181b5; }

.btn-secondary { background: #95a5a6; color: #fff; }
.btn-secondary:hover { background: #7f8c8d; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }

.btn-sm { padding: 4px 10px; font-size: 11px; }
.btn-lg { padding: 10px 24px; font-size: 14px; }

.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* ============================================
   REPORT TABLE
   ============================================ */
.report-table-wrap {
    overflow-x: auto;
    border: 1px solid #ddd;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    min-width: 1800px;
}

.report-table th {
    background: var(--primary);
    color: #fff;
    padding: 8px 6px;
    text-align: left;
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border: 1px solid rgba(255,255,255,0.2);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.report-table td {
    padding: 6px;
    border: 1px solid #e0e0e0;
    vertical-align: middle;
    white-space: nowrap;
}

.report-table tbody tr:nth-child(even) { background: #f8f9fa; }
.report-table tbody tr:hover { background: #eef5ff; }

.report-table td select,
.report-table td input {
    font-size: 11px;
    padding: 2px 4px;
    min-width: 80px;
}

.report-table .amount { text-align: right; font-weight: 500; }
.report-table .text-red { color: var(--danger); }
.report-table .text-green { color: var(--success); }

/* ============================================
   DASHBOARD STATS
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: 0 1px 4px var(--shadow);
    border-left: 4px solid var(--primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-card.green { border-left-color: var(--success); }
.stat-card.orange { border-left-color: var(--accent); }
.stat-card.red { border-left-color: var(--danger); }
.stat-card.blue { border-left-color: var(--info); }

.stat-info h3 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-info p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.stat-icon {
    font-size: 32px;
    opacity: 0.2;
}

/* ============================================
   FILTERS BAR
   ============================================ */
.filters-bar {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 1px 4px var(--shadow);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.filter-group label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.filter-group input,
.filter-group select {
    width: auto;
    min-width: 130px;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-light) 100%);
}

.login-box {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    width: 380px;
    max-width: 95%;
    overflow: hidden;
}

.login-header {
    background: var(--primary-dark);
    color: #fff;
    padding: 28px 24px;
    text-align: center;
}

.login-header h1 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.login-header p { font-size: 12px; opacity: 0.7; }

.login-body {
    padding: 28px 24px;
}

.login-body .form-group {
    margin-bottom: 16px;
}

.login-body .form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.login-body input {
    padding: 10px 12px;
    font-size: 14px;
}

.login-body .btn {
    width: 100%;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    justify-content: center;
}

.login-error {
    background: #f8d7da;
    color: #721c24;
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
    text-align: center;
}

/* ============================================
   BILLING LAYOUT - Two Column
   ============================================ */
.billing-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 16px;
    align-items: start;
}

.billing-main { min-width: 0; }
.billing-sidebar {}

.patient-info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: #ddd;
    border: 1px solid #ccc;
}

.patient-info-grid .form-group {
    background: #fff;
    padding: 6px 10px;
}

.patient-info-grid .form-group.yellow-bg {
    background: var(--yellow-highlight);
}

/* ============================================
   SUMMARY PANEL
   ============================================ */
.summary-panel {
    background: #fff;
    border: 2px solid var(--primary);
    border-radius: var(--radius);
}

.summary-panel .summary-header {
    background: var(--primary);
    color: #fff;
    padding: 10px 14px;
    font-weight: 600;
    font-size: 13px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    border-bottom: 1px solid #eee;
}

.summary-row:last-child { border-bottom: none; }
.summary-row label { font-size: 12px; font-weight: 500; }
.summary-row .value { font-weight: 700; font-size: 14px; }
.summary-row.total {
    background: var(--yellow-soft);
    font-size: 14px;
}
.summary-row.total .value {
    font-size: 16px;
    color: var(--primary-dark);
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}
.modal-overlay.show { display: flex; }

.modal {
    background: #fff;
    border-radius: 8px;
    width: 600px;
    max-width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 16px 48px rgba(0,0,0,0.2);
}

.modal-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 15px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #999;
}

.modal-body { padding: 20px; }
.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .top-header, .sidebar, .no-print { display: none !important; }
    .main-content { margin: 0 !important; padding: 0 !important; }
    body { background: #fff; }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
    .billing-layout { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .patient-info-grid { grid-template-columns: 1fr 1fr; }
}

/* ============================================
   UTILITY
   ============================================ */
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-bold { font-weight: 700; }
.text-red { color: var(--danger); }
.text-green { color: var(--success); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.d-flex { display: flex; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.w-100 { width: 100%; }
.hidden { display: none; }

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ccc;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }
