:root {
    /* Color Palette */
    --primary: #4f46e5;         /* Indigo 600 */
    --primary-hover: #4338ca;   /* Indigo 700 */
    --primary-light: #e0e7ff;   /* Indigo 100 */
    
    --success: #10b981;         /* Emerald 500 */
    --success-light: #d1fae5;   /* Emerald 100 */
    
    --info: #3b82f6;            /* Blue 500 */
    --info-light: #dbeafe;      /* Blue 100 */
    
    --warning: #f59e0b;         /* Amber 500 */
    --warning-light: #fef3c7;   /* Amber 100 */
    
    --danger: #ef4444;          /* Red 500 */
    --danger-light: #fee2e2;    /* Red 100 */
    
    --text-main: #111827;       /* Gray 900 */
    --text-muted: #6b7280;      /* Gray 500 */
    --text-light: #9ca3af;      /* Gray 400 */
    
    --bg-body: #f3f4f6;         /* Gray 100 */
    --bg-surface: #ffffff;      /* White */
    --bg-surface-hover: #f9fafb;/* Gray 50 */
    
    --border-color: #e5e7eb;    /* Gray 200 */
    --border-color-focus: #a5b4fc; /* Indigo 300 */
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    /* Border Radius */
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition: all 0.2s ease;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Typography Utility */
.text-muted { color: var(--text-muted); }
.text-blue { color: var(--info); }
.text-green { color: var(--success); }
.text-right { text-align: right; }
.mr-2 { margin-right: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.p-0 { padding: 0 !important; }
.w-100 { width: 100%; }
.w-50 { width: calc(50% - 0.5rem); }
.w-25 { width: calc(25% - 0.5rem); }

.bg-blue-light { background-color: var(--info-light); }
.bg-green-light { background-color: var(--success-light); }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-align-center { display: flex; align-items: center; }

/* Layout Grid */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-header {
    height: 72px;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.logo-icon {
    width: 32px;
    height: 32px;
    background-color: var(--primary);
    color: white;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-right: 0.75rem;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.5px;
}

.nav-links {
    list-style: none;
    padding: 1.5rem 1rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 500;
    transition: var(--transition);
}

.nav-item i {
    width: 24px;
    font-size: 1.1rem;
    margin-right: 0.75rem;
}

.nav-item:hover {
    background-color: var(--bg-surface-hover);
    color: var(--primary);
}

.nav-item.active {
    background-color: var(--primary-light);
    color: var(--primary);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.top-header {
    height: 72px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 5;
}

.top-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.content-wrapper {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* View Toggling */
.view {
    display: none;
    animation: fadeIn 0.3s ease;
}

.view.active {
    display: block;
}

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

/* Cards & Containers */
.card {
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
}

.card-subtle {
    background-color: var(--bg-body);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    position: relative;
}

/* Stats Container */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.stat-card {
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-right: 1.25rem;
}

.stat-details h3 {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-number {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

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

.data-table th, 
.data-table td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: var(--bg-surface-hover);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

.data-table tbody tr:hover {
    background-color: var(--bg-surface-hover);
}

.data-table td {
    font-size: 0.95rem;
    vertical-align: middle;
}

.data-table td.text-right,
.data-table th.text-right {
    text-align: right;
}

.empty-state {
    padding: 4rem 2rem;
    text-align: center;
    color: var(--text-muted);
    display: none; /* hidden by default */
}

.empty-state .empty-icon {
    font-size: 3rem;
    color: var(--text-light);
    margin-bottom: 1rem;
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 1rem;
}

.form-row {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="tel"],
select,
textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    color: var(--text-main);
    transition: var(--transition);
    background-color: var(--bg-surface);
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.input-with-icon {
    position: relative;
}

.input-with-icon i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.input-with-icon input {
    padding-left: 2.5rem;
}

.hint-text {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-family: inherit;
    gap: 0.5rem;
}

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

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

.btn-secondary {
    background-color: var(--bg-body);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-surface-hover);
}

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

.btn-outline-primary:hover {
    background-color: var(--primary-light);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.btn-text {
    background-color: transparent;
    color: var(--text-muted);
    padding: 0.5rem 0;
}

.btn-text:hover {
    color: var(--primary);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    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 {
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: var(--transition);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.large-modal {
    max-width: 800px;
}

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

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.btn-close {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover {
    background-color: var(--bg-body);
    color: var(--text-main);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Search Box */
.search-box {
    position: relative;
    width: 300px;
}

.search-box i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    padding-left: 2.5rem;
    border-radius: var(--radius-full);
}

/* Patient Profile */
.patient-profile-card .profile-header {
    padding: 2rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.avatar-large {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--primary), var(--info));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
}

.avatar-sm {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background-color: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 600;
}

.profile-info {
    flex: 1;
}

.profile-info h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.profile-meta {
    display: flex;
    gap: 1.5rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.profile-meta .meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Timeline */
.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--border-color);
}

.timeline-item {
    position: relative;
    margin-bottom: 2rem;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-marker {
    position: absolute;
    left: -2rem;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--primary);
    border: 3px solid white;
    box-shadow: 0 0 0 1px var(--border-color);
    top: 4px;
}

.timeline-content {
    background-color: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
}

.timeline-date {
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.25rem;
}

.timeline-diagnosis {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.prescribed-meds {
    background-color: white;
    border-radius: var(--radius-md);
    padding: 1rem;
    border: 1px solid var(--border-color);
}

.med-item {
    display: flex;
    justify-content: space-between;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px dashed var(--border-color);
}

.med-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Autocomplete Utilities */
.position-relative {
    position: relative;
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: white;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    box-shadow: var(--shadow-md);
    max-height: 200px;
    overflow-y: auto;
    z-index: 50;
    display: none;
}

.autocomplete-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-size: 0.95rem;
}

.autocomplete-item:hover {
    background-color: var(--primary-light);
    color: var(--primary);
}

.autocomplete-item.add-new {
    color: var(--primary);
    font-weight: 500;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-surface-hover);
}

/* Prescription Medicines List */
.btn-remove-medicine {
    position: absolute;
    top: -0.75rem;
    right: -0.75rem;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: white;
    color: var(--danger);
    border: 1px solid var(--danger-light);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

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

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

/* Alert Boxes */
.alert {
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-info {
    background-color: var(--info-light);
    color: var(--info);
    border: 1px solid #bfdbfe;
}

/* Simulated SMS Body */
.sms-preview {
    background-color: var(--bg-body);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    font-family: monospace;
    font-size: 0.9rem;
    color: var(--text-main);
    white-space: pre-wrap;
    line-height: 1.6;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-blue { background-color: var(--info-light); color: var(--info); }
.badge-green { background-color: var(--success-light); color: var(--success); }

/* Responsive adjustments */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .sidebar-header {
        height: 60px;
    }
    
    .nav-links {
        display: flex;
        padding: 0.5rem;
    }
    
    .nav-item {
        margin-bottom: 0;
        margin-right: 0.5rem;
    }
    
    .patient-profile-card .profile-header {
        flex-direction: column;
        text-align: center;
    }
    
    .profile-meta {
        justify-content: center;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .form-group.half,
    .w-50, .w-25 {
        width: 100%;
    }
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, var(--bg-body) 0%, var(--primary-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.login-overlay.hidden {
    display: none;
}

.login-box {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    animation: slideUp 0.5s ease;
}

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

.login-box .card-header {
    border-bottom: none;
    padding-bottom: 0;
}

.login-box .logo-icon {
    width: 64px;
    height: 64px;
    font-size: 2rem;
    background: linear-gradient(135deg, var(--primary), var(--info));
    box-shadow: var(--shadow-md);
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: white;
}

.login-box h2 {
    color: var(--text-main);
    font-weight: 700;
}

.login-box .card-body {
    padding-top: 1rem;
}

.login-box .form-group label {
    font-weight: 600;
    color: var(--text-muted);
}

.login-box .input-with-icon input {
    background-color: var(--bg-body);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.login-box .input-with-icon input:focus {
    background-color: var(--bg-surface);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.login-box .btn-primary {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, var(--primary), var(--info));
    border: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.login-box .btn-primary:active {
    transform: translateY(1px);
}

.hidden {
    display: none !important;
}
