/* ==========================================================================
   PRABHAKARAN HEALTHCARE CRM — DESIGN SYSTEM (Vanilla CSS)
   Clinical, Modern, High-Contrast Healthcare Interface
   ========================================================================== */

:root {
    /* Healthcare Primary Palette */
    --pkh-primary: #0f4c81;
    --pkh-primary-dark: #092c4d;
    --pkh-primary-light: #e8f1f8;
    --pkh-primary-subtle: #d0e3f2;

    /* Healthcare Accent & Secondary */
    --pkh-teal: #00a896;
    --pkh-teal-dark: #028090;
    --pkh-teal-light: #e6f7f5;

    /* Neutral Backgrounds & Surfaces */
    --pkh-bg: #f8fafc;
    --pkh-surface: #ffffff;
    --pkh-surface-muted: #f1f5f9;
    --pkh-border: #e2e8f0;
    --pkh-border-subtle: #f1f5f9;

    /* Text & Typography */
    --pkh-text-main: #0f172a;
    --pkh-text-muted: #64748b;
    --pkh-text-light: #94a3b8;

    /* Functional Clinical Accents */
    --pkh-success: #059669;
    --pkh-success-bg: #ecfdf5;
    --pkh-warning: #d97706;
    --pkh-warning-bg: #fffbeb;
    --pkh-danger: #dc2626;
    --pkh-danger-bg: #fef2f2;
    --pkh-info: #2563eb;
    --pkh-info-bg: #eff6ff;

    /* Structural Constants */
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.04);
}

/* Base Document Setup */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--pkh-text-main);
    background-color: var(--pkh-bg);
    -webkit-font-smoothing: antialiased;
}

/* Accessibility & Focus States */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--pkh-teal);
    outline-offset: 2px;
}

/* ==========================================================================
   APP LAYOUT (Sidebar + Topbar + Main Content)
   ========================================================================== */

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

/* Sidebar */
.app-sidebar {
    width: var(--sidebar-width);
    background: #092c4d;
    background: linear-gradient(180deg, #0f4c81 0%, #092c4d 100%);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1030;
    transition: transform 0.25s ease-in-out;
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand {
    font-weight: 700;
    font-size: 1.05rem;
    color: #ffffff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.sidebar-brand i {
    font-size: 1.4rem;
    color: var(--pkh-teal);
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.75rem;
}

.sidebar-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255, 255, 255, 0.45);
    padding: 0.75rem 0.75rem 0.35rem 0.75rem;
    font-weight: 600;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.15s ease, color 0.15s ease;
    margin-bottom: 0.2rem;
}

.sidebar-nav-link:hover {
    background-color: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.sidebar-nav-link.active {
    background-color: var(--pkh-teal);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 168, 150, 0.3);
}

.sidebar-nav-link i {
    font-size: 1.15rem;
}

.sidebar-footer {
    padding: 0.85rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background-color: rgba(0, 0, 0, 0.15);
}

/* Main Container Area */
.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Top Navbar */
.app-topbar {
    height: var(--topbar-height);
    background-color: var(--pkh-surface);
    border-bottom: 1px solid var(--pkh-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 1020;
    backdrop-filter: blur(8px);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.branch-selector-pill {
    background-color: var(--pkh-primary-light);
    border: 1px solid var(--pkh-primary-subtle);
    border-radius: 20px;
    padding: 0.35rem 0.85rem;
    font-size: 0.825rem;
    color: var(--pkh-primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* Content Area */
.app-content {
    flex: 1;
    padding: 1.75rem;
}

/* ==========================================================================
   REUSABLE UI COMPONENTS
   ========================================================================== */

/* Cards */
.card-clinical {
    background-color: var(--pkh-surface);
    border: 1px solid var(--pkh-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease;
}

.card-clinical:hover {
    box-shadow: var(--shadow-md);
}

.card-clinical .card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--pkh-border);
    padding: 1rem 1.25rem;
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-clinical .card-body {
    padding: 1.25rem;
}

/* Stat Cards */
.stat-card {
    background-color: var(--pkh-surface);
    border: 1px solid var(--pkh-border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-icon.primary { background: var(--pkh-primary-light); color: var(--pkh-primary); }
.stat-icon.teal { background: var(--pkh-teal-light); color: var(--pkh-teal); }
.stat-icon.success { background: var(--pkh-success-bg); color: var(--pkh-success); }
.stat-icon.warning { background: var(--pkh-warning-bg); color: var(--pkh-warning); }
.stat-icon.danger { background: var(--pkh-danger-bg); color: var(--pkh-danger); }

.stat-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--pkh-text-muted);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--pkh-text-main);
    line-height: 1.1;
}

/* Tables */
.table-clinical {
    width: 100%;
    margin-bottom: 0;
    color: var(--pkh-text-main);
    border-collapse: separate;
    border-spacing: 0;
}

.table-clinical th {
    background-color: var(--pkh-surface-muted);
    color: var(--pkh-text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--pkh-border);
    white-space: nowrap;
}

.table-clinical td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--pkh-border-subtle);
    font-size: 0.875rem;
    vertical-align: middle;
}

.table-clinical tbody tr:hover {
    background-color: #f8fafc;
}

/* Badges */
.badge-clinical {
    padding: 0.35em 0.75em;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.badge-clinical.active, .badge-clinical.confirmed, .badge-clinical.completed, .badge-clinical.paid {
    background-color: var(--pkh-success-bg);
    color: var(--pkh-success);
    border: 1px solid rgba(5, 150, 105, 0.2);
}

.badge-clinical.pending, .badge-clinical.partially_paid {
    background-color: var(--pkh-warning-bg);
    color: var(--pkh-warning);
    border: 1px solid rgba(217, 119, 6, 0.2);
}

.badge-clinical.inactive, .badge-clinical.cancelled, .badge-clinical.unpaid, .badge-clinical.danger {
    background-color: var(--pkh-danger-bg);
    color: var(--pkh-danger);
    border: 1px solid rgba(220, 38, 38, 0.2);
}

.badge-clinical.draft, .badge-clinical.info {
    background-color: var(--pkh-info-bg);
    color: var(--pkh-info);
    border: 1px solid rgba(37, 99, 235, 0.2);
}

/* Primary Button Styles */
.btn-pkh-primary {
    background-color: var(--pkh-primary);
    border-color: var(--pkh-primary);
    color: #ffffff;
    font-weight: 500;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
    transition: all 0.15s ease;
}

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

.btn-pkh-teal {
    background-color: var(--pkh-teal);
    border-color: var(--pkh-teal);
    color: #ffffff;
    font-weight: 500;
    border-radius: var(--radius-sm);
    padding: 0.5rem 1rem;
}

.btn-pkh-teal:hover {
    background-color: var(--pkh-teal-dark);
    border-color: var(--pkh-teal-dark);
    color: #ffffff;
}

/* Responsive adjustments */
@media (max-width: 991.98px) {
    .app-sidebar {
        transform: translateX(-100%);
    }
    .app-sidebar.show {
        transform: translateX(0);
    }
    .app-main {
        margin-left: 0;
    }
}
