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

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg-main: #fcfdfe;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #f1f5f9;
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: rgba(255, 255, 255, 0.2);
}

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

h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
}

/* Sidebar Styling */
.sidebar {
    width: 280px;
    height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    left: 0;
    top: 0;
    box-shadow: 10px 0 30px rgba(0,0,0,0.02);
    z-index: 1050;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid var(--border-color);
}

.sidebar-header {
    padding: 2.5rem 1.5rem;
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-link {
    padding: 0.9rem 1.5rem;
    color: var(--text-muted);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 12px;
    margin: 0.3rem 1.25rem;
    transition: all 0.3s;
}

.nav-link:hover {
    background-color: #f8fafc;
    color: var(--primary);
    transform: translateX(5px);
}

.nav-link.active {
    background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
    color: #fff;
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.3);
}

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

/* Main Content Area */
.main-content {
    margin-left: 280px;
    padding: 2rem 3rem;
    min-height: 100vh;
    transition: all 0.4s ease;
}

/* Navbar/Header */
.top-navbar {
    margin-bottom: 2.5rem;
    padding: 0.5rem 0;
}

/* Mobile Toggle */
.sidebar-toggler {
    display: none;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

/* Cards & Components */
.card {
    border: none;
    border-radius: 20px;
    background: var(--card-bg);
    box-shadow: 0 4px 20px rgba(0,0,0,0.02);
    border: 1px solid rgba(0,0,0,0.03);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem;
    font-weight: 600;
}

.stats-card {
    padding: 2rem;
    display: flex;
    align-items: center;
    gap: 24px;
    position: relative;
    overflow: hidden;
}

.stats-card::after {
    content: '';
    position: absolute;
    right: -20px;
    top: -20px;
    width: 100px;
    height: 100px;
    background: currentColor;
    opacity: 0.05;
    border-radius: 50%;
}

.stats-icon {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    flex-shrink: 0;
}

/* Medical Preloader */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease-out;
}

.loader-pulse {
    width: 80px;
    height: 80px;
    background-color: #fff;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    animation: medicalPulse 1.2s infinite ease-in-out;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
}

@keyframes medicalPulse {
    0% { transform: scale(0.8); opacity: 0.7; }
    50% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(0.8); opacity: 0.7; }
}

.loader-text {
    margin-top: 20px;
    font-family: 'Outfit', sans-serif;
    color: var(--primary);
    font-weight: 600;
    letter-spacing: 1px;
}

/* Medical List System (The Real Solution for Scroll issues) */
.medical-list {
    background: transparent;
}

@media (min-width: 992px) {
    .medical-list-mobile {
        display: none !important;
    }
    .medical-list table {
        width: 100%;
        border-collapse: separate;
        border-spacing: 0;
    }
}

@media (max-width: 991px) {
    .medical-list table, .table-responsive {
        display: none !important; /* Hide the table entirely */
    }
    .medical-list-mobile {
        display: block !important;
    }
    .medical-card {
        background: #fff;
        border: 1px solid var(--border-color);
        border-radius: 24px;
        padding: 1.5rem;
        margin-bottom: 1.25rem;
        box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    }
    .medical-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 1.25rem;
        border-bottom: 1px solid #f1f5f9;
        padding-bottom: 1.25rem;
    }
    .medical-card-body {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }
    .medical-card-item {
        display: flex;
        flex-direction: column;
    }
    .medical-card-label {
        font-size: 0.7rem;
        font-weight: 700;
        text-transform: uppercase;
        color: var(--secondary);
        margin-bottom: 2px;
    }
    .medical-card-value {
        font-size: 0.95rem;
        font-weight: 600;
        color: var(--text-main);
    }
    .medical-card-footer {
        margin-top: 1.5rem;
        padding-top: 1rem;
        border-top: 1px dashed #e2e8f0;
        display: flex;
        gap: 10px;
    }
    .medical-card-footer .btn {
        flex: 1;
        padding: 0.7rem;
    }
    .medical-card-alert {
        grid-column: span 2;
        background: #fef2f2;
        border: 1px solid #fee2e2;
        padding: 1rem;
        border-radius: 15px;
        margin-top: 5px;
    }
    
    /* Sidebar adjustments */
    .sidebar { transform: translateX(-100%); }
    .sidebar.active { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 1.5rem; }
    .sidebar-toggler { display: block; }
    .top-navbar { display: flex; align-items: center; gap: 15px; }
}

/* Form Controls */
.form-control, .form-select {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background-color: #fff;
    transition: all 0.2s;
}

.form-control:focus {
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
    border-color: var(--primary);
}

/* Buttons */
.btn {
    border-radius: 12px;
    font-weight: 600;
    padding: 0.7rem 1.5rem;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
    border: none;
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(79, 70, 229, 0.3);
}

/* Badges */
.badge {
    padding: 0.6em 1em;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.75rem;
}

.bg-primary-soft { background-color: #eef2ff; color: var(--primary); }
.bg-success-soft { background-color: #ecfdf5; color: var(--success); }
.bg-danger-soft { background-color: #fef2f2; color: var(--danger); }
.bg-warning-soft { background-color: #fffbeb; color: var(--warning); }

/* Login Page Premium */
.login-wrapper {
    min-height: 100vh;
    background: radial-gradient(circle at top left, #eef2ff 0%, #fcfdfe 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.login-card {
    max-width: 440px;
    padding: 3rem;
    border-radius: 30px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.05);
}

/* Action Buttons Premium */
.action-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-action {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none !important;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    border: 1px solid #f1f5f9;
    padding: 0;
}

.btn-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.btn-action-view { color: var(--primary) !important; background: #eef2ff; border-color: #e0e7ff; }
.btn-action-view:hover { background: var(--primary) !important; color: #fff !important; }

.btn-action-edit { color: var(--warning) !important; background: #fffbeb; border-color: #fef3c7; }
.btn-action-edit:hover { background: var(--warning) !important; color: #fff !important; }

.btn-action-delete { color: var(--danger) !important; background: #fef2f2; border-color: #fee2e2; }
.btn-action-delete:hover { background: var(--danger) !important; color: #fff !important; }

.btn-action i { font-size: 1.1rem; line-height: 1; }

/* PWA Custom Modal */
.pwa-install-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.pwa-install-card {
    background: #fff;
    width: 100%;
    max-width: 400px;
    border-radius: 30px;
    padding: 2rem;
    text-align: center;
    position: relative;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    animation: pwaSlideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.pwa-close-btn {
    position: absolute;
    right: 20px;
    top: 20px;
    background: #f1f5f9;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    cursor: pointer;
}

.pwa-logo-box {
    width: 90px;
    height: 90px;
    background: #fff;
    border: 1px solid #f1f5f9;
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    box-shadow: 0 10px 20px rgba(0,0,0,0.02);
}

.pwa-install-btn {
    width: 100%;
    padding: 1rem;
    border-radius: 18px;
    background: var(--primary);
    color: #fff;
    border: none;
    font-weight: 700;
    margin-top: 1.5rem;
    box-shadow: 0 10px 20px rgba(79, 70, 229, 0.2);
    transition: all 0.3s;
}

.pwa-install-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(79, 70, 229, 0.3);
}
