/**
 * Klinexia Design System
 * Based on the provided reference image
 * Modern, dark theme, medical SaaS aesthetic
 */

/* ============================================
   CSS Custom Properties (Design Tokens)
   ============================================ */

:root {
    /* Colors - Primary Palette */
    --color-primary: #8B5CF6;
    --color-primary-dark: #7C3AED;
    --color-primary-light: #A78BFA;

    /* Colors - Semantic */
    --color-success: #10B981;
    --color-success-light: rgba(16, 185, 129, 0.15);
    --color-warning: #F59E0B;
    --color-warning-light: rgba(245, 158, 11, 0.15);
    --color-error: #EF4444;
    --color-error-light: rgba(239, 68, 68, 0.15);
    --color-info: #06B6D4;
    --color-info-light: rgba(6, 182, 212, 0.15);

    /* Colors - Background */
    --bg-primary: #0F0F1A;
    --bg-secondary: #1A1A2E;
    --bg-tertiary: #252542;
    --bg-card: rgba(30, 30, 50, 0.8);
    --bg-card-hover: rgba(40, 40, 65, 0.9);
    --bg-input: rgba(255, 255, 255, 0.05);
    --bg-input-focus: rgba(255, 255, 255, 0.08);

    /* Colors - Text */
    --text-primary: #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-tertiary: rgba(255, 255, 255, 0.5);
    --text-muted: rgba(255, 255, 255, 0.3);

    /* Colors - Borders */
    --border-color: rgba(255, 255, 255, 0.1);
    --border-color-light: rgba(255, 255, 255, 0.05);

    /* Colors - Stat Cards */
    --stat-purple: #8B5CF6;
    --stat-orange: #F97316;
    --stat-green: #10B981;
    --stat-cyan: #06B6D4;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #8B5CF6 0%, #6366F1 100%);
    --gradient-success: linear-gradient(135deg, #10B981 0%, #059669 100%);
    --gradient-card: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0) 100%);

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.3);

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-size-xs: 11px;
    --font-size-sm: 13px;
    --font-size-base: 14px;
    --font-size-md: 16px;
    --font-size-lg: 18px;
    --font-size-xl: 24px;
    --font-size-2xl: 32px;
    --font-size-3xl: 40px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;

    /* Z-index */
    --z-dropdown: 100;
    --z-modal: 200;
    --z-toast: 300;
}

/* ============================================
   Base Styles
   ============================================ */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    line-height: 1.5;
    min-height: 100vh;
}

#app {
    min-height: 100vh;
}

/* Screen Management */
.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: flex;
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* SECURITY: Prevent scroll when login active (blocks data leak after logout) */
body.login-active {
    overflow: hidden;
    height: 100vh;
}

body.login-active #login-screen {
    overflow-y: auto;
}

/* ============================================
   Typography
   ============================================ */

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    line-height: 1.3;
}

h1 {
    font-size: var(--font-size-2xl);
}

h2 {
    font-size: var(--font-size-xl);
}

h3 {
    font-size: var(--font-size-lg);
}

a {
    color: var(--color-primary-light);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-primary);
}

/* ============================================
   Buttons
   ============================================ */

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    background: var(--gradient-primary);
    color: white;
    font-size: var(--font-size-base);
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    min-height: 48px;
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

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

.btn-primary.loading .btn-text {
    opacity: 0;
}

.btn-primary.loading .btn-spinner {
    display: block;
    position: absolute;
}

.btn-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   Form Elements
   ============================================ */

.form-group {
    margin-bottom: var(--space-lg);
}

.form-group label {
    display: block;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.form-group input {
    width: 100%;
    padding: var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    transition: all var(--transition-fast);
}

.form-group input::placeholder {
    color: var(--text-muted);
}

.form-group input:focus {
    outline: none;
    background: var(--bg-input-focus);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.error-message {
    padding: var(--space-md);
    background: var(--color-error-light);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    color: #FCA5A5;
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-md);
}

/* ============================================
   Login Screen
   ============================================ */

#login-screen {
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(ellipse at top left, rgba(139, 92, 246, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(99, 102, 241, 0.1) 0%, transparent 50%),
        var(--bg-primary);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: var(--space-lg);
}

.login-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: var(--space-2xl);
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    font-size: var(--font-size-lg);
    font-weight: 700;
    color: white;
}

.logo-text {
    font-size: var(--font-size-xl);
    font-weight: 700;
    letter-spacing: 1px;
}

.login-subtitle {
    color: var(--text-tertiary);
    font-size: var(--font-size-sm);
}

.login-form {
    position: relative;
}

/* ============================================
   Loading Screen
   ============================================ */

#loading-screen {
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

.loading-container {
    text-align: center;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto var(--space-lg);
}

.loading-container p {
    color: var(--text-secondary);
}

/* ============================================
   Access Denied Screen
   ============================================ */

#access-denied-screen {
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

.access-denied-container {
    text-align: center;
    max-width: 400px;
    padding: var(--space-lg);
}

.access-denied-icon {
    color: var(--color-error);
    margin-bottom: var(--space-lg);
}

.access-denied-container h2 {
    margin-bottom: var(--space-md);
}

.access-denied-container p {
    color: var(--text-secondary);
    margin-bottom: var(--space-xl);
}

.access-denied-container .btn-primary {
    width: auto;
    min-width: 160px;
}

/* ============================================
   Main App Layout
   ============================================ */

#main-app {
    display: flex;
    min-height: 100vh;
}

#main-app.active {
    display: flex;
}

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width var(--transition-base);
}

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

.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-lg) var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    text-decoration: none;
}

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

.nav-item.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-glow);
}

.nav-item svg {
    flex-shrink: 0;
}

.nav-item span {
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.sidebar-footer {
    padding: var(--space-md);
    border-top: 1px solid var(--border-color);
}

/* ============================================
   Main Content
   ============================================ */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow: hidden;
}

/* ============================================
   Sidebar Collapsed State (Mini-Sidebar)
   ============================================ */

/* Mini-sidebar: show icons only */
.sidebar-collapsed .sidebar {
    width: 72px;
    min-width: 72px;
}

/* Hide text labels in collapsed state */
.sidebar-collapsed .logo-text,
.sidebar-collapsed .nav-item span,
.sidebar-collapsed .sidebar-footer {
    opacity: 0;
    width: 0;
    overflow: hidden;
    pointer-events: none;
}

/* Center icons when collapsed */
.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: var(--space-md) var(--space-sm);
}

/* Reduce logo size */
.sidebar-collapsed .logo {
    justify-content: center;
}

/* Keep toggle button visible and centered */
.sidebar-collapsed .sidebar-header {
    justify-content: center;
    padding: var(--space-lg) var(--space-sm);
}

/* Flip arrow when collapsed (points right to expand) */
.sidebar-collapsed #sidebar-toggle svg {
    transform: rotate(180deg);
}

/* Top Bar */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    height: 64px;
}

.search-container {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: var(--space-sm) var(--space-md);
    width: 400px;
    max-width: 50%;
}

.search-container svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-input:focus {
    outline: none;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

.notification-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.notification-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    background: var(--color-success);
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tenant-selector {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.tenant-selector:hover {
    background: var(--bg-card-hover);
}

.tenant-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #F97316, #FB923C);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: 600;
}

.tenant-name {
    font-size: var(--font-size-sm);
    font-weight: 500;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu {
    position: relative;
}

.user-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.user-avatar:hover {
    transform: scale(1.05);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + var(--space-sm));
    right: 0;
    min-width: 220px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: var(--z-dropdown);
    overflow: hidden;
}

.user-info {
    padding: var(--space-md);
}

.user-name {
    display: block;
    font-weight: 600;
    margin-bottom: 2px;
}

.user-email {
    display: block;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.user-role {
    display: inline-block;
    font-size: var(--font-size-xs);
    color: var(--color-primary-light);
    background: rgba(139, 92, 246, 0.15);
    padding: 2px 8px;
    border-radius: var(--radius-full);
}

.user-dropdown hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    width: 100%;
    padding: var(--space-md);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    text-align: left;
}

.dropdown-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Content Area */
.content-area {
    flex: 1;
    padding: var(--space-xl);
    background: var(--bg-primary);
    overflow-y: auto;
}

.dashboard-header {
    margin-bottom: var(--space-xl);
}

.dashboard-header h1 {
    margin-bottom: var(--space-xs);
}

.date-display {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

/* When sidebar is collapsed, show stats in single row */
.sidebar-collapsed .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-md);
}

.stat-card {
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    padding: var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.stat-icon.purple {
    background: rgba(139, 92, 246, 0.15);
    color: var(--stat-purple);
}

.stat-icon.orange {
    background: rgba(249, 115, 22, 0.15);
    color: var(--stat-orange);
}

.stat-icon.green {
    background: rgba(16, 185, 129, 0.15);
    color: var(--stat-green);
}

.stat-icon.cyan {
    background: rgba(6, 182, 212, 0.15);
    color: var(--stat-cyan);
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.stat-value {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    line-height: 1;
    margin-bottom: var(--space-xs);
}

.stat-change {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
}

.stat-change.positive {
    color: var(--color-success);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: var(--space-xl);
}

/* Appointments Today */
.appointments-today {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-lg);
}

.section-header h2 {
    font-size: var(--font-size-lg);
}

.view-all {
    font-size: var(--font-size-sm);
    color: var(--color-primary-light);
}

.appointments-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.empty-state {
    text-align: center;
    color: var(--text-tertiary);
    padding: var(--space-xl);
}

.appointment-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.appointment-item:hover {
    background: var(--bg-card-hover);
}

.appointment-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-input);
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.appointment-info {
    flex: 1;
    min-width: 0;
}

.appointment-name {
    display: block;
    font-weight: 500;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.appointment-service {
    display: block;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.appointment-time {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.appointment-status {
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 500;
}

.appointment-status.confirmed {
    background: rgba(16, 185, 129, 0.15);
    color: var(--color-success);
}

.appointment-status.completed {
    background: rgba(139, 92, 246, 0.15);
    color: var(--color-primary-light);
}

.appointment-status.cancelled {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-error);
}

.appointment-menu {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: var(--text-tertiary);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.appointment-menu:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

/* Quick Actions */
.quick-actions {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.quick-actions h2 {
    font-size: var(--font-size-lg);
    margin-bottom: var(--space-lg);
}

.actions-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.action-card {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    transition: all var(--transition-base);
    text-align: left;
    width: 100%;
}

.action-card:hover {
    background: var(--bg-card-hover);
    transform: translateX(4px);
}

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

.action-icon.purple {
    background: rgba(139, 92, 246, 0.15);
    color: var(--stat-purple);
}

.action-icon.green {
    background: rgba(16, 185, 129, 0.15);
    color: var(--stat-green);
}

.action-content {
    display: flex;
    flex-direction: column;
}

.action-title {
    font-weight: 600;
    margin-bottom: 2px;
}

.action-desc {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        z-index: 100;
        transition: left var(--transition-base);
    }

    .sidebar.open {
        left: 0;
    }

    .top-bar {
        padding: var(--space-md);
    }

    .search-container {
        display: none;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .content-area {
        padding: var(--space-md);
    }
}

/* ============================================
   Data Tables (Services, Boxes)
   ============================================ */

.section-header-page {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-xl);
}

.section-header-page h1 {
    margin-bottom: var(--space-xs);
}

.section-description {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.data-table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

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

.data-table thead {
    background: var(--bg-tertiary);
}

.data-table th {
    padding: var(--space-md) var(--space-lg);
    text-align: left;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-color-light);
    vertical-align: middle;
}

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

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

.table-cell-primary {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 500;
}

.service-key {
    display: inline-block;
    padding: 4px 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: var(--font-size-xs);
    color: var(--color-primary-light);
}

.duration-badge {
    display: inline-block;
    padding: 4px 10px;
    background: var(--color-info-light);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 500;
    color: var(--color-info);
}

.order-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 500;
}

.status-badge.active {
    background: var(--color-success-light);
    color: var(--color-success);
}

.status-badge.inactive {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-tertiary);
}

.box-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(139, 92, 246, 0.15);
    border-radius: var(--radius-sm);
    color: var(--color-primary-light);
}

.text-secondary {
    color: var(--text-secondary);
}

.error-state {
    color: var(--color-error);
    text-align: center;
    padding: var(--space-xl) !important;
}

.section-placeholder {
    text-align: center;
    padding: var(--space-2xl);
}

.section-placeholder h2 {
    margin-bottom: var(--space-md);
}

/* ============================================
   Modal Styles
   ============================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    padding: var(--space-lg);
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h3 {
    font-size: var(--font-size-lg);
    font-weight: 600;
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal form {
    padding: var(--space-lg);
}

.modal-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: flex-end;
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-color);
}

/* ============================================
   Additional Button Styles
   ============================================ */

.btn-compact {
    width: auto;
    min-height: 40px;
    padding: var(--space-sm) var(--space-md);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    transition: all var(--transition-fast);
    min-height: 40px;
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    border-color: var(--text-tertiary);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background: var(--color-primary-light);
    background: rgba(139, 92, 246, 0.15);
    color: var(--color-primary-light);
}

/* ============================================
   Checkbox Styles
   ============================================ */

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    font-size: var(--font-size-base);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

.checkbox-label span {
    color: var(--text-primary);
}

/* ============================================
   Form Row (Multiple inputs in one row)
   ============================================ */

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

.form-hint {
    display: block;
    margin-top: var(--space-xs);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* ============================================
   Price Display
   ============================================ */

.price-display {
    font-weight: 500;
    color: var(--text-primary);
}

.price-display:empty::before {
    content: '—';
    color: var(--text-muted);
}

/* ============================================
   Box Services Section
   ============================================ */

.box-services-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-lg);
}

.box-services-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.box-services-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.box-services-header .box-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(139, 92, 246, 0.15);
    border-radius: var(--radius-sm);
    color: var(--color-primary-light);
}

.box-services-header h3 {
    font-size: var(--font-size-md);
    font-weight: 600;
    margin: 0;
}

.box-services-list {
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.box-service-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.box-service-item:hover {
    background: var(--bg-input-focus);
}

.box-service-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--color-primary);
    cursor: pointer;
    flex-shrink: 0;
}

.box-service-checkbox:disabled {
    opacity: 0.5;
    cursor: wait;
}

.box-service-name {
    flex: 1;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
}

.box-service-status {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.box-service-status[data-status="loading"]::after {
    content: '';
    display: block;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border-color);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.box-service-status[data-status="success"]::after {
    content: '✓';
    display: block;
    color: var(--color-success);
    font-size: 14px;
    font-weight: bold;
}

.box-service-status[data-status="error"]::after {
    content: '✗';
    display: block;
    color: var(--color-error);
    font-size: 14px;
    font-weight: bold;
}

/* ============================================
   Agenda Section
   ============================================ */

.agenda-controls {
    display: flex;
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.control-group label {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    font-weight: 500;
}

.agenda-date-input,
.agenda-box-select {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    min-width: 180px;
    transition: all var(--transition-fast);
}

.agenda-date-input:focus,
.agenda-box-select:focus {
    outline: none;
    background: var(--bg-input-focus);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.agenda-box-select {
    min-width: 200px;
    cursor: pointer;
}

.agenda-container {
    min-height: 200px;
}

.agenda-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    padding: var(--space-2xl);
    color: var(--text-muted);
    text-align: center;
}

.agenda-empty svg {
    opacity: 0.5;
}

.agenda-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.agenda-appointment {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.agenda-appointment:hover {
    background: var(--bg-card-hover);
}

.appointment-time {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    min-width: 120px;
    font-family: 'SF Mono', 'Consolas', monospace;
}

.time-start {
    font-weight: 600;
    font-size: var(--font-size-md);
    color: var(--text-primary);
}

.time-separator {
    color: var(--text-muted);
}

.time-end {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.appointment-details {
    flex: 1;
}

.appointment-service {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.appointment-patient {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.appointment-status {
    flex-shrink: 0;
}

/* Appointment Status Badges */
.status-badge.confirmed {
    background: rgba(16, 185, 129, 0.15);
    color: var(--color-success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.completed {
    background: rgba(99, 102, 241, 0.15);
    color: #818CF8;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.status-badge.cancelled {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-error);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-badge.no-show {
    background: rgba(245, 158, 11, 0.15);
    color: var(--color-warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-badge.pending {
    background: rgba(107, 114, 128, 0.15);
    color: var(--text-secondary);
    border: 1px solid rgba(107, 114, 128, 0.3);
}

/* ============================================
   Monthly Calendar Layout
   ============================================ */

.agenda-month-input {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    min-width: 180px;
    transition: all var(--transition-fast);
}

.agenda-month-input:focus {
    outline: none;
    background: var(--bg-input-focus);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.agenda-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: var(--space-xl);
}

@media (max-width: 1024px) {
    .agenda-layout {
        grid-template-columns: 1fr;
    }
}

/* Calendar Container */
.calendar-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
}

.calendar-grid {
    display: flex;
    flex-direction: column;
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-bottom: var(--space-sm);
}

.calendar-day-name {
    text-align: center;
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-secondary);
    padding: var(--space-sm);
    text-transform: uppercase;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: var(--space-sm);
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.calendar-day.empty {
    background: transparent;
    cursor: default;
}

.calendar-day:not(.empty):hover {
    background: var(--bg-card-hover);
    border-color: var(--border-color);
}

.calendar-day.today {
    background: rgba(139, 92, 246, 0.1);
    border-color: var(--color-primary);
}

.calendar-day.today .day-number {
    color: var(--color-primary-light);
    font-weight: 700;
}

.calendar-day.selected {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.calendar-day.selected .day-number {
    color: white;
}

.calendar-day.selected .appointment-count {
    background: white;
    color: var(--color-primary);
}

.calendar-day.has-appointments {
    background: rgba(16, 185, 129, 0.1);
}

.calendar-day.has-appointments:not(.selected) .day-number {
    color: var(--color-success);
}

.day-number {
    font-size: var(--font-size-md);
    font-weight: 500;
    color: var(--text-primary);
}

.appointment-count {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--color-success);
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-full);
}

/* Day Detail Panel */
.day-detail-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 600px;
}

.day-detail-header {
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.day-detail-header h3 {
    font-size: var(--font-size-md);
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.day-appointments {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* Appointment Actions */
.appointment-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-shrink: 0;
}

.btn-cancel-apt {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    color: var(--color-error);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-cancel-apt:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--color-error);
}

/* ============================================
   Dashboard Enhancements
   ============================================ */

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    z-index: 1001;
    animation: slideIn 0.3s ease;
}

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

.toast.error {
    background: var(--color-error);
    color: white;
}

.toast.hidden {
    display: none;
}

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

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Disabled Action Card */
.action-card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.action-card.disabled:hover {
    background: var(--bg-card);
    transform: none;
}

/* Dashboard Cancel Button */
.btn-cancel-dashboard {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    color: var(--color-error);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.btn-cancel-dashboard:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--color-error);
}

/* Appointment Phone */
.appointment-phone {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* Appointment Item Enhancement */
.appointment-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.appointment-item:hover {
    background: var(--bg-tertiary);
}

/* ============================================
   Slots Grid for Appointment Modal
   ============================================ */

.slots-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: var(--space-xs);
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    min-height: 60px;
    max-height: 280px;
    overflow-y: auto;
}

.slots-placeholder {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    font-size: var(--font-size-sm);
    padding: var(--space-md);
    margin: 0;
}

.slots-placeholder.slots-error {
    color: var(--color-error);
}

/* Slot Button */
.slot-btn {
    padding: var(--space-sm) var(--space-xs);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
    border: 1px solid transparent;
}

/* Available slot */
.slot-btn.available {
    background: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.slot-btn.available:hover {
    background: rgba(139, 92, 246, 0.1);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* Selected slot */
.slot-btn.selected {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.3);
}

/* Occupied slot */
.slot-btn.occupied {
    background: var(--bg-tertiary);
    border-color: transparent;
    color: var(--text-muted);
    cursor: not-allowed;
    opacity: 0.5;
    text-decoration: line-through;
}

/* ============================================
   Select Contrast Fix
   ============================================ */

.agenda-box-select,
.agenda-box-select option {
    background-color: var(--bg-input);
    color: var(--text-primary);
}

.agenda-box-select option {
    background-color: #1e1e2e;
    color: #e0e0e0;
    padding: var(--space-sm);
}

.agenda-box-select option:checked,
.agenda-box-select option:hover {
    background-color: var(--color-primary);
    color: white;
}

/* ============================================
   Users Section Styles
   ============================================ */

.user-avatar-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.role-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 500;
}

.role-badge.admin {
    background: rgba(139, 92, 246, 0.15);
    color: var(--color-primary-light);
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.role-badge.staff {
    background: rgba(6, 182, 212, 0.15);
    color: var(--color-info);
    border: 1px solid rgba(6, 182, 212, 0.3);
}

.status-badge.active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--color-success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.inactive {
    background: rgba(107, 114, 128, 0.15);
    color: var(--text-muted);
    border: 1px solid rgba(107, 114, 128, 0.3);
}

.text-muted {
    color: var(--text-muted);
}

/* Disabled select styling (for staff users) */
.agenda-box-select:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    background: var(--bg-tertiary);
}

/* ============================================
   Global Search Dropdown
   ============================================ */

.search-container {
    position: relative;
}

.search-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: var(--space-xs);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
}

.search-results-dropdown.hidden {
    display: none;
}

.search-loading,
.search-error,
.search-empty {
    padding: var(--space-lg);
    text-align: center;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.search-error {
    color: var(--color-error);
}

.search-result-item {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-color-light);
    cursor: pointer;
    transition: background-color var(--transition-fast);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--bg-tertiary);
}

.search-result-item.readonly {
    opacity: 0.7;
    cursor: default;
}

.search-result-item.readonly:hover {
    background: transparent;
}

.search-result-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-md);
}

.search-result-name {
    font-weight: 600;
    color: var(--text-primary);
}

.search-result-phone {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.search-result-details {
    display: flex;
    gap: var(--space-md);
    font-size: var(--font-size-sm);
}

.search-result-service {
    color: var(--color-primary-light);
}

.search-result-box {
    color: var(--text-tertiary);
}

.search-result-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--font-size-xs);
}

.search-result-date {
    color: var(--text-muted);
}

.search-result-action {
    font-size: var(--font-size-xs);
    color: var(--color-primary);
    font-weight: 500;
}

.search-result-readonly {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    font-style: italic;
}

/* ============================================
   Clinic Configuration Section
   ============================================ */

.config-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-lg);
    overflow: hidden;
}

.config-card-header {
    padding: var(--space-lg);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.config-card-header h2 {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin: 0;
}

.config-card-header h2 svg {
    color: var(--color-primary);
    flex-shrink: 0;
}

.config-card-body {
    padding: var(--space-lg);
}

.config-card-body .form-row {
    display: flex;
    gap: var(--space-md);
    align-items: flex-end;
    flex-wrap: wrap;
}

.config-card-body .form-row .form-group {
    flex: 1;
    min-width: 180px;
    margin-bottom: 0;
}

.config-card-body .form-row .form-group:last-child {
    margin-right: 0;
}

/* Weekday Toggles */
.weekday-toggles {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.weekday-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    cursor: pointer;
}

.weekday-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.weekday-toggle span {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    user-select: none;
}

.weekday-toggle:hover span {
    color: var(--text-primary);
}

/* Checkbox Label */
.config-card-body .btn-sm {
    width: auto;
    min-width: 140px;
    padding: var(--space-sm) var(--space-md);
    min-height: 40px;
    margin-top: var(--space-md);
}

/* Schedule Grid */
.schedule-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.schedule-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    transition: opacity var(--transition-fast);
}

.schedule-row.disabled {
    opacity: 0.5;
}

.schedule-day {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    min-width: 180px;
}

.day-name {
    font-weight: 500;
    font-size: var(--font-size-base);
}

.schedule-times {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.schedule-times input[type="time"] {
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    min-width: 120px;
}

.schedule-times input[type="time"]:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.schedule-times span {
    color: var(--text-tertiary);
    font-size: var(--font-size-sm);
}

/* Toggle Switch */
.toggle-container {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-container input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    transition: var(--transition-fast);
    border-radius: var(--radius-full);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-tertiary);
    transition: var(--transition-fast);
    border-radius: 50%;
}

.toggle-container input:checked+.toggle-slider {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

.toggle-container input:checked+.toggle-slider:before {
    transform: translateX(20px);
    background-color: white;
}

/* Holiday Form and List */
.holiday-form {
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--border-color);
}

.holiday-form .form-row {
    align-items: flex-end;
}

.holiday-form .btn-sm {
    margin-top: 0;
    align-self: flex-end;
}

.holidays-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.holiday-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.holiday-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.holiday-date {
    font-weight: 500;
    text-transform: capitalize;
}

.holiday-description {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.btn-delete-holiday {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--color-error-light);
    border-radius: var(--radius-sm);
    color: var(--color-error);
    transition: all var(--transition-fast);
}

.btn-delete-holiday:hover {
    background: var(--color-error);
    color: white;
}

/* Success Message */
.success-message {
    padding: var(--space-md);
    background: var(--color-success-light);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-md);
    color: #6EE7B7;
    font-size: var(--font-size-sm);
    margin-top: var(--space-md);
}

/* ============================================
   Messages Section (WhatsApp-style)
   ============================================ */

.messages-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 0;
    height: calc(100vh - 200px);
    min-height: 500px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

/* Left Panel: Conversations */
.conversations-panel {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.conversations-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-color);
}

.conversations-header h3 {
    margin: 0;
    font-size: var(--font-size-lg);
    font-weight: 600;
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-color-light);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.conversation-item:hover {
    background: var(--bg-tertiary);
}

.conversation-item.selected {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--color-primary);
}

.conversation-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    flex-shrink: 0;
}

.conversation-info {
    flex: 1;
    min-width: 0;
}

.conversation-phone {
    font-weight: 500;
    font-size: var(--font-size-base);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-meta {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.conversation-time {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 500;
}

.status-confirmed {
    background: var(--color-success-light);
    color: var(--color-success);
}

.status-expired {
    background: var(--color-error-light);
    color: var(--color-error);
}

.status-pending {
    background: var(--color-warning-light);
    color: var(--color-warning);
}

.status-default {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

/* Right Panel: Conversation Detail */
.conversation-detail {
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

.conversation-detail-header {
    padding: var(--space-lg);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    min-height: 72px;
    display: flex;
    align-items: center;
}

.detail-header-content {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    font-weight: 500;
    font-size: var(--font-size-md);
}

.detail-header-content svg {
    color: var(--text-secondary);
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* Message Bubbles */
.message-bubble {
    max-width: 70%;
    padding: var(--space-md);
    border-radius: var(--radius-lg);
    position: relative;
}

.message-bubble.incoming {
    align-self: flex-start;
    background: var(--bg-tertiary);
    border-bottom-left-radius: var(--radius-sm);
}

.message-bubble.outgoing {
    align-self: flex-end;
    background: var(--color-primary);
    border-bottom-right-radius: var(--radius-sm);
}

.message-content {
    font-size: var(--font-size-sm);
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message-time {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-top: var(--space-xs);
    text-align: right;
}

.message-bubble.outgoing .message-time {
    color: rgba(255, 255, 255, 0.7);
}

/* Responsive: Stack on small screens */
@media (max-width: 768px) {
    .messages-layout {
        grid-template-columns: 1fr;
        grid-template-rows: 40% 60%;
    }

    .conversations-panel {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
}

/* ============================================
   Global Search Dropdown Styles
   ============================================ */

.search-results-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    /* Ensure opaque background */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Force opaque background on dark theme */
.search-results-dropdown::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    z-index: -1;
}

.search-loading,
.search-error,
.search-empty {
    padding: var(--space-lg);
    text-align: center;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.search-error {
    color: var(--color-error);
}

.search-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-color);
    transition: background var(--transition-fast);
    gap: var(--space-md);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: var(--bg-tertiary);
}

.search-result-item.clickable {
    cursor: pointer;
}

.search-result-item.clickable:hover {
    background: var(--bg-card-hover);
}

.search-result-main {
    flex: 1;
    min-width: 0;
}

.search-result-patient {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-xs);
    flex-wrap: wrap;
}

.search-result-patient strong {
    font-size: var(--font-size-base);
    color: var(--text-primary);
}

.search-result-phone {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.search-result-details {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    flex-wrap: wrap;
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.search-result-service,
.search-result-box,
.search-result-date {
    white-space: nowrap;
}

.search-result-separator {
    color: var(--text-tertiary);
}

.search-result-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-shrink: 0;
}

.btn-complete-search {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(16, 185, 129, 0.1);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--color-success);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-complete-search:hover {
    background: rgba(16, 185, 129, 0.2);
    transform: scale(1.05);
}

.btn-complete-search svg {
    flex-shrink: 0;
}