/* ==========================================================================
   KSS CLINIC - HOSPITAL MANAGEMENT SYSTEM CORE STYLESHEET
   Design: Modern Medical Glassmorphism & High-Contrast Clinical Aesthetics
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary: #0d9488;          /* Medical Teal */
    --primary-dark: #0f766e;
    --primary-light: #ccfbf1;
    --primary-rgb: 13, 148, 136;
    
    --secondary: #0284c7;        /* Medical Cyan / Sky */
    --secondary-light: #e0f2fe;
    
    --dark: #0f172a;             /* Slate 900 */
    --dark-surface: #1e293b;     /* Slate 800 */
    --sidebar-bg: #0b1329;       /* Deep Hospital Navy */
    
    --light-bg: #f8fafc;         /* Crisp Canvas */
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --border-focus: #0d9488;
    
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;
    --purple: #8b5cf6;
    --purple-light: #ede9fe;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.07);
    --shadow-lg: 0 10px 25px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.05);
    --shadow-card: 0 10px 30px -5px rgba(15, 23, 42, 0.06);
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--light-bg);
    color: var(--text-main);
    line-height: 1.5;
    font-size: 14.5px;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------
   APP LAYOUT (Sidebar + Main Content)
   --------------------------------------------------------- */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* Sidebar */
.app-sidebar {
    width: 270px;
    background: var(--sidebar-bg);
    color: #f1f5f9;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
    transition: var(--transition);
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
}

.sidebar-header {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.clinic-logo-badge {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #0d9488 0%, #0284c7 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 20px;
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.clinic-branding h1 {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #ffffff;
    line-height: 1.2;
}

.clinic-branding p {
    font-size: 11px;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 12px 12px 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

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

.nav-link.active {
    color: #ffffff;
    background: linear-gradient(90deg, rgba(13, 148, 136, 0.9) 0%, rgba(15, 118, 110, 0.8) 100%);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(13, 148, 136, 0.25);
}

.nav-link .nav-icon {
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
}

.nav-badge {
    margin-left: auto;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
}

.sidebar-user {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.15);
}

.sidebar-user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #1e293b;
    border: 2px solid var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--primary-light);
}

.sidebar-user-info {
    flex: 1;
    overflow: hidden;
}

.sidebar-user-info .name {
    font-size: 13.5px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-info .role-tag {
    font-size: 11px;
    color: #14b8a6;
    font-weight: 600;
    text-transform: capitalize;
}

/* Main Content Area */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: #f8fafc;
}

/* Topbar */
.app-topbar {
    height: 70px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 0 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 30;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.tv-display-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #f1f5f9;
    color: #334155;
    font-weight: 600;
    font-size: 13px;
    border-radius: var(--radius-md);
    text-decoration: none;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.tv-display-btn:hover {
    background: #e2e8f0;
    color: #0f172a;
}

/* Page Body Container */
.page-body {
    padding: 28px;
    flex: 1;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}

/* ---------------------------------------------------------
   CARDS & GRIDS
   --------------------------------------------------------- */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card);
    margin-bottom: 24px;
    transition: var(--transition);
}

.card:hover {
    border-color: #cbd5e1;
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #ffffff;
    border-top-left-radius: var(--radius-md);
    border-top-right-radius: var(--radius-md);
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.card-body {
    padding: 24px;
}

/* Metric Stats Cards */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.metric-card {
    background: #ffffff;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 20px 22px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: #cbd5e1;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
}

.metric-card.teal::before { background: var(--primary); }
.metric-card.blue::before { background: var(--secondary); }
.metric-card.amber::before { background: var(--warning); }
.metric-card.purple::before { background: var(--purple); }
.metric-card.emerald::before { background: var(--success); }

.metric-icon-box {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.metric-icon-box.teal { background: var(--primary-light); color: var(--primary-dark); }
.metric-icon-box.blue { background: var(--secondary-light); color: var(--secondary); }
.metric-icon-box.amber { background: var(--warning-light); color: #b45309; }
.metric-icon-box.purple { background: var(--purple-light); color: var(--purple); }
.metric-icon-box.emerald { background: var(--success-light); color: #047857; }

.metric-details {
    flex: 1;
}

.metric-value {
    font-size: 26px;
    font-weight: 800;
    color: var(--dark);
    line-height: 1.2;
}

.metric-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.metric-sub {
    font-size: 11.5px;
    color: #94a3b8;
    margin-top: 3px;
}

/* ---------------------------------------------------------
   BUTTONS & CONTROLS
   --------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #ffffff;
    box-shadow: 0 4px 10px rgba(13, 148, 136, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #115e59 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(13, 148, 136, 0.35);
    color: #ffffff;
}

.btn-secondary {
    background: #f1f5f9;
    color: #334155;
    border-color: var(--border-color);
}

.btn-secondary:hover {
    background: #e2e8f0;
    color: var(--dark);
}

.btn-success {
    background: var(--success);
    color: #ffffff;
}

.btn-success:hover {
    background: #059669;
    color: #ffffff;
}

.btn-warning {
    background: #f59e0b;
    color: #ffffff;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-outline {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12.5px;
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: 13px 26px;
    font-size: 16px;
    font-weight: 700;
}

/* ---------------------------------------------------------
   FORMS & INPUTS
   --------------------------------------------------------- */
.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 6px;
}

.form-label .required {
    color: var(--danger);
}

.form-control, .form-select {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text-main);
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition);
    outline: none;
    font-family: inherit;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.form-control::placeholder {
    color: #94a3b8;
}

textarea.form-control {
    min-height: 80px;
    resize: vertical;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.input-group {
    display: flex;
}

.input-group .form-control {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group .btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* ---------------------------------------------------------
   TABLES
   --------------------------------------------------------- */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.table th {
    background-color: #f8fafc;
    color: #475569;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
    vertical-align: middle;
}

.table tbody tr {
    transition: var(--transition);
}

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

.table tbody tr:last-child td {
    border-bottom: none;
}

/* ---------------------------------------------------------
   BADGES & PILLS
   --------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
}

.badge-teal { background: var(--primary-light); color: var(--primary-dark); }
.badge-blue { background: var(--secondary-light); color: var(--secondary); }
.badge-success { background: var(--success-light); color: #065f46; }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-danger { background: var(--danger-light); color: #991b1b; }
.badge-purple { background: var(--purple-light); color: #5b21b6; }
.badge-gray { background: #e2e8f0; color: #334155; }

/* Pulse Indicator */
.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.pulse-dot.green { background: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2); }
.pulse-dot.amber { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2); }
.pulse-dot.red { background: #ef4444; box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2); }

/* ---------------------------------------------------------
   TOKEN CARDS & QUEUE COMPONENTS
   --------------------------------------------------------- */
.token-badge {
    font-size: 16px;
    font-weight: 800;
    padding: 6px 14px;
    border-radius: var(--radius-md);
    background: #0f172a;
    color: #38bdf8;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    letter-spacing: 0.05em;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.vitals-pill-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.vital-pill {
    background: #f1f5f9;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    color: #334155;
    border: 1px solid #e2e8f0;
}

.vital-pill.alert {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
    font-weight: 700;
}

/* ---------------------------------------------------------
   DOCTOR CONSULTATION WORKSPACE
   --------------------------------------------------------- */
.consultation-layout {
    display: grid;
    grid-template-columns: 330px 1fr;
    gap: 24px;
}

.template-highlight-box {
    background: linear-gradient(135deg, #f0fdfa 0%, #e0f2fe 100%);
    border: 1px solid #99f6e4;
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 20px;
}

.template-select-bar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rx-table-container {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 18px;
}

.rx-table {
    width: 100%;
    border-collapse: collapse;
}

.rx-table th {
    background: #f8fafc;
    padding: 12px 14px;
    font-size: 12px;
    font-weight: 700;
    color: #475569;
    border-bottom: 1px solid var(--border-color);
}

.rx-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.rx-input {
    width: 100%;
    padding: 6px 10px;
    font-size: 13px;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-sm);
}

.rx-input:focus {
    border-color: var(--primary);
    outline: none;
}

/* ---------------------------------------------------------
   MODALS & TOASTS
   --------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: #ffffff;
    width: 90%;
    max-width: 650px;
    max-height: 90vh;
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px);
    transition: var(--transition);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--dark);
}

.modal-close-btn {
    background: transparent;
    border: none;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    border-radius: 4px;
}

.modal-close-btn:hover {
    color: var(--dark);
    background: #f1f5f9;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    background: #f8fafc;
}

/* Toast Container */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: #0f172a;
    color: #ffffff;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 500;
    animation: slideIn 0.3s ease-out;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.danger { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--info); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .consultation-layout {
        grid-template-columns: 1fr;
    }
    .app-sidebar {
        position: fixed;
        left: -270px;
    }
    .app-sidebar.show {
        left: 0;
    }
}
