/* ============================================
   MiniClinic - Complete Stylesheet
   Inspired by Bahmni Open-Source HMS
   ============================================ */

/* CSS Reset & Variables */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Primary Colors */
    --primary: #1976d2;
    --primary-light: #42a5f5;
    --primary-dark: #1565c0;
    
    /* Secondary Colors */
    --secondary: #455a64;
    --secondary-light: #78909c;
    
    /* Status Colors */
    --success: #2e7d32;
    --success-light: #e8f5e9;
    --warning: #f57c00;
    --warning-light: #fff3e0;
    --danger: #c62828;
    --danger-light: #ffebee;
    --info: #0277bd;
    --info-light: #e3f2fd;
    
    /* Neutral Colors */
    --bg-light: #f5f6fa;
    --bg-white: #ffffff;
    --border-color: #e0e0e0;
    --border-light: #f0f0f0;
    --text-primary: #212121;
    --text-secondary: #757575;
    --text-light: #9e9e9e;
    
    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --header-height: 60px;
    --mobile-header-height: 56px;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --shadow-xl: 0 12px 48px rgba(0,0,0,0.15);
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    
    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* Base Styles */
html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-light);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* App Container */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ============================================
   Sidebar Styles
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1a237e 0%, #0d47a1 50%, #1565c0 100%);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000;
    transition: width var(--transition-normal);
    box-shadow: var(--shadow-lg);
}

.logo {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    min-height: 72px;
}

.logo .material-icons {
    font-size: 36px;
    flex-shrink: 0;
}

.logo h2 {
    font-size: 22px;
    font-weight: 600;
    white-space: nowrap;
    letter-spacing: 0.5px;
}

.nav-menu {
    list-style: none;
    padding: 16px 0;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: rgba(255,255,255,0.7);
    border-left: 3px solid transparent;
    margin: 2px 0;
    position: relative;
    white-space: nowrap;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-item.active {
    background: rgba(255,255,255,0.2);
    color: white;
    border-left-color: white;
    font-weight: 500;
}

.nav-item .material-icons {
    font-size: 22px;
    flex-shrink: 0;
}

.connection-status {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 13px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.status-dot.online {
    background: #4caf50;
    box-shadow: 0 0 12px rgba(76,175,80,0.6);
    animation: pulse 2s infinite;
}

.status-dot.offline {
    background: #f44336;
    box-shadow: 0 0 8px rgba(244,67,54,0.3);
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 8px rgba(76,175,80,0.4); }
    50% { box-shadow: 0 0 16px rgba(76,175,80,0.8); }
}

/* ============================================
   Main Content Area
   ============================================ */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 32px;
    min-height: 100vh;
    transition: margin-left var(--transition-normal);
}

.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-content.active {
    display: block;
}

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

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

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

/* ============================================
   Button Styles
   ============================================ */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-fast);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover {
    background: #37474f;
    box-shadow: var(--shadow-sm);
}

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

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

.btn-text {
    background: transparent;
    color: var(--primary);
    padding: 8px 12px;
}

.btn-text:hover {
    background: var(--info-light);
    transform: none;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn .material-icons {
    font-size: 18px;
}

.btn .spinner {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

/* ============================================
   Dashboard Grid
   ============================================ */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-white);
    padding: 24px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
    border: 1px solid var(--border-light);
    cursor: default;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: transparent;
}

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

.stat-icon .material-icons {
    font-size: 28px;
}

.stat-info {
    flex: 1;
}

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

.stat-info p {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   Card Styles
   ============================================ */
.card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    border: 1px solid var(--border-light);
    overflow: hidden;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
    gap: 12px;
}

.card-header h2,
.card-header h3 {
    font-size: 18px;
    font-weight: 600;
}

/* ============================================
   Table Styles
   ============================================ */
.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

thead {
    background: #f8fafc;
}

th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    border-bottom: 2px solid var(--border-color);
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

tbody tr {
    transition: background var(--transition-fast);
}

tbody tr:hover {
    background: #f8fafc;
}

.empty-cell {
    text-align: center;
    color: var(--text-light);
    padding: 32px;
    font-style: italic;
}

/* ============================================
   Search Bar
   ============================================ */
.search-bar {
    display: flex;
    align-items: center;
    background: var(--bg-white);
    padding: 12px 20px;
    border