:root {
    /* Premium Indigo-Blue Palette */
    --primary: #4f46e5;
    --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --primary-light: #818cf8;
    --primary-dark: #3730a3;
    --primary-bg: #f5f3ff;

    /* Semantic Colors */
    --success: #059669;
    --success-bg: #ecfdf5;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --info: #0284c7;

    /* Neutrals */
    --background: #f8fafc;
    --surface: #ffffff;
    --text: #0f172a;
    --text-muted: #475569;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    /* Design Tokens */
    --radius-sm: 10px;
    --radius: 18px;
    --radius-lg: 28px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-premium: 0 25px 50px -12px rgba(79, 70, 229, 0.12);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.2s, border-color 0.2s;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    font-size: 15px;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 2.5rem;
}

/* UI Elements */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
}

.glass-premium {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: var(--shadow-premium);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.8rem 1.75rem;
    border-radius: 14px;
    font-weight: 650;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    gap: 0.75rem;
    text-decoration: none;
    font-size: 0.95rem;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 12px 20px rgba(79, 70, 229, 0.4);
    transform: translateY(-2px) scale(1.02);
}

.btn-outline {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-bg);
}

/* Animation */
.fade-in {
    animation: fadeIn 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.blink-badge {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }

    100% {
        opacity: 1;
    }
}

/* Modal Responsive Fix */
.modal .card {
    width: 90%;
    max-width: 500px;
}

/* Form Styles */
input,
select,
textarea {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.badge {
    padding: 0.4rem 1rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Global Layout */
.app-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    background: #fff;
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    height: 100vh;
    z-index: 10;
}

.sidebar-brand {
    padding: 2rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 1rem;
}

.sidebar-brand i {
    font-size: 1.75rem;
    color: var(--primary);
}

.sidebar-brand span {
    font-size: 1.25rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.01em;
}

.nav-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 0.75rem;
}

.nav-section {
    margin-bottom: 2rem;
}

.nav-label {
    padding: 0 1rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.nav-menu {
    list-style: none;
    display: grid;
    gap: 0.4rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1rem;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    border-radius: 12px;
    transition: all 0.25s;
    font-size: 0.95rem;
}

.nav-link i {
    width: 20px;
    font-size: 1.1rem;
    text-align: center;
    color: var(--text-light);
    transition: color 0.25s;
}

.nav-link:hover {
    background: var(--primary-bg);
    color: var(--primary);
}

.nav-link:hover i {
    color: var(--primary);
}

.nav-link.active {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.nav-link.active i {
    color: #fff;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-light);
}

/* Top Bar Refinements */
.search-box input {
    width: 400px;
    max-width: 100%;
    padding: 0.85rem 1rem 0.85rem 3rem;
    border-radius: 14px;
    background: #fff;
    border: 1px solid var(--border-light);
    font-size: 0.9rem;
}

.search-box i {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 0.9rem;
}

.main-content {
    padding: 2.5rem;
    overflow-y: auto;
    background: #fdfdfd;
    height: 100vh;
    width: 100%;
}

.top-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    gap: 1rem;
}

/* Sidebar Toggle (Mobile) */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text);
    cursor: pointer;
}

@media (max-width: 1024px) {
    .app-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 280px;
        transition: left 0.3s ease;
        z-index: 1000;
        box-shadow: var(--shadow-premium);
    }

    .sidebar.active {
        left: 0;
    }

    .menu-toggle {
        display: block;
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

/* Tables */
.table-container {
    background: var(--surface);
    border-radius: var(--radius);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* smooth scrolling on iOS */
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    margin-bottom: 1.5rem;
    /* Ensure space for scrollbar */
}

.clinical-table {
    width: 100%;
    min-width: 600px;
    /* Force scroll */
    border-collapse: collapse;
}

.data-table {
    width: 100%;
    min-width: 800px;
    /* Force scroll on mobile */
    border-collapse: collapse;
    text-align: left;
}

.data-table thead {
    background: var(--background);
}

.clinical-table th {
    text-align: left;
    padding: 1rem;
    background: #f8fafc;
    color: var(--text-light);
    font-size: 0.8rem;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table th {
    padding: 1rem 1.5rem;
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    /* Prevent headers from wrapping awkwardly */
}

.data-table td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover {
    background: #fcfcfd;
}

/* Avatars & Badges */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--primary-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
}

.badge {
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-weight: 800;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.badge-success {
    background: #ecfdf5;
    color: #059669;
}

.badge-warning {
    background: #fffbeb;
    color: #d97706;
}

.badge-danger {
    background: #fef2f2;
    color: #dc2626;
}

.badge-primary {
    background: #eff6ff;
    color: #2563eb;
}

/* Grid Helpers */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

/* Responsive Overrides */
@media (max-width: 768px) {
    .main-content {
        padding: 1.5rem;
    }

    .top-bar-header {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
    }

    .top-bar-header div:last-child {
        text-align: left !important;
        margin-top: 0.5rem;
    }

    .search-box input {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 1.75rem !important;
    }

    .card {
        padding: 1rem;
    }
}

/* Landing Page Specific Styles */
.landing-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border);
}

.hero-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5rem 0;
    gap: 4rem;
}

.hero-content {
    flex: 1;
}

.hero-image {
    flex: 1;
}

.hero-section h1 {
    font-size: 3.5rem;
    line-height: 1.1;
    margin-bottom: 1.5rem;
}

.hero-section p {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 2.5rem;
    max-width: 500px;
}

.appt-container {
    display: flex;
    gap: 4rem;
    align-items: flex-start;
    flex-wrap: wrap;
}

.location-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 4rem;
    align-items: center;
}

@media (max-width: 1024px) {
    .hero-section {
        flex-direction: column;
        text-align: center;
        gap: 2rem;
        padding: 3rem 0;
    }

    .hero-section p {
        margin-left: auto;
        margin-right: auto;
    }

    .hero-section h1 {
        font-size: 2.8rem;
    }

    .hero-image {
        width: 100%;
        max-width: 600px;
    }

    .location-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

@media (max-width: 768px) {
    .landing-nav {
        flex-direction: row;
        justify-content: space-between;
        padding: 1rem 0;
        gap: 0.5rem;
    }

    .logo-text {
        font-size: 1.1rem;
        max-width: 120px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .landing-nav .nav-links {
        justify-content: flex-end;
        width: auto;
        gap: 0.75rem;
        margin-left: auto;
    }

    .landing-nav .nav-links a:not(.btn) {
        display: inline-block;
        font-size: 0.8rem;
        white-space: nowrap;
    }

    .hero-section h1 {
        font-size: 2.2rem;
    }

    .appt-container {
        flex-direction: column;
        gap: 2rem;
    }

    .appt-container>div {
        width: 100% !important;
    }
}

@media (max-width: 480px) {
    .hero-section h1 {
        font-size: 1.8rem;
    }

    .grid-2 {
        grid-template-columns: 1fr !important;
    }
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}