/* CSS Variables */
:root {
    --primary-teal: #0D9488; /* Main brand color */
    --primary-teal-dark: #0F766E; /* Darker shade for hover */
    --primary-blue: #0EA5E9; /* Secondary accent */
    --success-green: #10B981; /* Success states */
    --warning-amber: #F59E0B; /* Warning states */
    --error-red: #EF4444; /* Error states */
    --bg-soft: #F1F5F9; /* Softer main background (was #F8FAFC) */
    --bg-card: #F8FAFC; /* Softer card background (was #FFFFFF) */
    --text-primary: #1E293B; /* Primary text (slightly softer than pure black) */
    --text-secondary: #64748B; /* Secondary text */
    --border-color: #E2E8F0; /* Border color */
}

/* Dark Theme Variables */
body[data-theme='dark'] {
    --primary-teal: #2DD4BF;
    --primary-teal-dark: #5EEAD4;
    --bg-soft: #0F172A;
    --bg-card: #1E293B;
    --text-primary: #E2E8F0;
    --text-secondary: #94A3B8;
    --border-color: #334155;
    color-scheme: dark;
}

/* Apply a smooth transition to color changes */
body, .sidebar, .stat-card, .search-card, .action-card, .form-card, .patient-detail-card, .accordion-card, input, select, textarea, button { transition: background-color 0.3s, color 0.3s, border-color 0.3s; }

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

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

html {
    scroll-behavior: smooth;
    /* Reserve scrollbar gutter so it never shifts layout when it appears/disappears */
    scrollbar-gutter: stable;
    overflow-x: hidden;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #F1F5F9;
}

::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-soft);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-teal);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    color: white;
}

.logo-text h2 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

.logo-text p {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
}

.sidebar-nav {
    padding: 0.5rem;
}

.nav-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: 8px;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s;
    margin-bottom: 0.25rem;
    cursor: pointer;
}

.nav-item:hover {
    background: rgba(13, 148, 136, 0.1);
    color: var(--primary-teal-dark);
}

.nav-item.active {
    background: rgba(13, 148, 136, 0.1);
    color: var(--primary-teal-dark);
    font-weight: 600;
}

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

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--primary-teal);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-email {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    color: var(--error-red);
    background: rgba(239, 68, 68, 0.1) !important; /* Ensure hover override */
}

/* ── Invoice Confirm Bar ──────────────────────────────────────────────────── */
#inv-confirm-bar {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 0.85rem 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    z-index: 1500;
    min-width: 340px;
    max-width: 520px;
    animation: slideUpBar 0.25s ease;
}

@keyframes slideUpBar {
    from { opacity: 0; transform: translateX(-50%) translateY(12px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.back-to-clinic-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.45rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--primary-teal);
    background: color-mix(in srgb, var(--primary-teal) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--primary-teal) 25%, transparent);
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.18s, border-color 0.18s;
    margin-bottom: 0.4rem;
}

.back-to-clinic-btn:hover {
    background: color-mix(in srgb, var(--primary-teal) 18%, transparent);
    border-color: color-mix(in srgb, var(--primary-teal) 45%, transparent);
    text-decoration: none;
}

/* Theme Toggle */
.theme-toggle-wrapper {
    display: flex;
    justify-content: flex-end;
}

.theme-toggle {
    cursor: pointer;
    display: block;
}

.theme-toggle-input {
    display: none;
}

.toggle-track {
    width: 50px;
    height: 26px;
    background: var(--bg-soft);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    position: relative;
    transition: background-color 0.2s;
}

.toggle-thumb {
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 3px;
    transition: transform 0.2s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.sun-icon, .moon-icon {
    color: var(--text-secondary);
}

.moon-icon {
    display: none;
}

.theme-toggle-input:checked + .toggle-track .toggle-thumb {
    transform: translateX(23px);
}

.theme-toggle-input:checked + .toggle-track .sun-icon {
    display: none;
}

.theme-toggle-input:checked + .toggle-track .moon-icon {
    display: block;
}

/* Main Content */
.main-content {
    margin-left: 280px;
    flex: 1;
    overflow-y: auto;
}

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

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.page {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.page.active {
    display: block;
}

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

/* Page Header */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-teal);
    color: white;
}
body[data-theme='dark'] .btn-primary {
    color: #0F172A;
    font-weight: 600;
}

.btn-primary:hover {
    background: var(--primary-teal-dark);
}

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

.btn-outline:hover {
    background: var(--bg-soft) !important;
    color: var(--text-primary);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.07);
    transition: all 0.3s;
}

/* Make clickable stat cards have a pointer cursor */
.stat-card[onclick] {
    cursor: pointer;
}

.stat-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.stat-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.stat-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
} 

.stat-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    font-size: 24px;
    font-weight: 700;
}

.stat-icon.users {
    background: var(--primary-teal);
}

.stat-icon.calendar {
    background: var(--primary-blue);
}

.stat-icon.revenue {
    background: var(--success-green);
}

.stat-icon.pending {
    background: var(--warning-amber);
}

body[data-theme='dark'] .stat-icon {
    color: var(--bg-card);
    font-weight: 600;
}

/* Revenue combined card */
.revenue-card {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.revenue-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.revenue-card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

.revenue-filter-select {
    padding: 0.25rem 0.625rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-soft);
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
}

.revenue-filter-select:focus {
    outline: none;
    border-color: var(--primary-teal);
}

.revenue-date-range {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.625rem 0.75rem;
    background: var(--bg-soft);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.revenue-date-range .date-range-field label {
    font-size: 0.7rem;
}

.revenue-date-range .date-range-input {
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
}

.revenue-sub-tiles {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.revenue-sub-tile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    border-radius: 10px;
    padding: 0.5rem;
    transition: background 0.2s;
}

.revenue-sub-tile:hover {
    background: var(--bg-soft);
}

.revenue-sub-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
}

.revenue-sub-icon.revenue { background: var(--success-green); }
.revenue-sub-icon.pending  { background: var(--warning-amber); }

.revenue-sub-divider {
    width: 1px;
    height: 40px;
    background: var(--border-color);
    flex-shrink: 0;
}

.sub-tile-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.2rem;
}

.sub-tile-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.amount-blurred {
    filter: blur(6px);
    user-select: none;
    transition: filter 0.25s ease;
}

.amount-blurred.revealed {
    filter: none;
}

.amount-toggle-btn {
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    line-height: 1;
    border-radius: 4px;
    transition: color 0.15s;
}

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

/* Filter Tabs */
.filter-tabs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.patients-filter-select {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    min-width: 240px;
    transition: border-color 0.2s;
}

.patients-filter-select:focus {
    outline: none;
    border-color: var(--primary-teal);
}

.patients-date-range {
    margin-bottom: 1rem;
}

.date-range-inner {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem 1.25rem;
}

.date-range-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.date-range-field label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.date-range-input {
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-soft);
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: border-color 0.2s;
}

.date-range-input:focus {
    outline: none;
    border-color: var(--primary-teal);
}

.filter-tab {
    padding: 0.375rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-tab:hover {
    background: var(--bg-soft);
    color: var(--text-primary);
}

.filter-tab.active {
    background: var(--primary-teal);
    color: white;
    border-color: var(--primary-teal);
}

/* Search Card */
.search-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.search-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.search-icon-wrapper {
    width: 48px;
    height: 48px;
    background: var(--primary-teal);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.search-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.search-header p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.search-form {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.search-input-wrapper {
    flex: 1;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.2s;
    background-color: var(--bg-card);
    color: var(--text-primary);
}

body[data-theme='dark'] .search-input {
    background-color: var(--bg-soft);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-teal);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.search-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.phone-placeholder {
    color: var(--border-color);
    transition: color 0.3s;
}

.phone-entered {
    color: var(--text-primary);
    transition: color 0.3s;
}

.search-input-container {
    position: relative;
}

.clear-search-btn {
    position: absolute;
    top: 50%;
    right: 1rem;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.clear-search-btn:hover {
    color: var(--error-red);
}
/* Search Results */
.search-results {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.search-results h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.patient-card {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
    cursor: pointer;
}

.patient-card:hover {
    border-color: var(--primary-teal);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.patient-info h4 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.patient-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}

.action-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s;
    cursor: pointer;
}

.action-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.action-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.action-icon.add-patient {
    background: var(--success-green);
}

.action-icon.recent-activity {
    background: #A855F7;
}

body[data-theme='dark'] .action-icon {
    color: var(--bg-card);
    font-weight: 600;
}

.action-card h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.action-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Form Styles */
.patient-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-card {
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.form-card-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary-teal);
}

.form-card-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.form-content {
    padding: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color); 
    border-radius: 8px;
    transition: all 0.2s;
    background-color: var(--bg-card);
    color: var(--text-primary);
    font-family: inherit;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-teal);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.1);
}

.form-group .file-input {
    padding: 0;
    border: none;
}

.form-group .file-input::file-selector-button {
    font-family: inherit;
    font-weight: 500;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-soft);
    cursor: pointer;
    transition: all 0.2s;
    margin-right: 1rem;
}

.form-group .file-input::file-selector-button:hover {
    background-color: var(--border-color);
    border-color: #cbd5e1;
}

.form-group textarea {
    resize: vertical;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 1rem;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.time-select-group {
    display: flex;
    gap: 0.5rem;
}

.time-select-group select {
    flex: 1;
}

/* File Uploader */
.file-uploader {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary-teal);
    background-color: rgba(13, 148, 136, 0.05);
}

.hidden-file-input {
    display: none;
}

.upload-icon {
    width: 32px;
    height: 32px;
    margin: 0 auto 0.5rem;
    color: var(--primary-teal);
}

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

.upload-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.file-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    padding: 0.5rem;
    background-color: var(--bg-soft);
    border-radius: 8px;
}

.file-item span {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Patient Detail Page */
.patient-detail-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1.5rem;
}

.patient-avatar {
    width: 80px;
    height: 80px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary-teal), var(--primary-blue));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.patient-detail-content {
    flex: 1;
}

.patient-detail-content h1 {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.patient-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.detail-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.detail-value {
    font-weight: 500;
    color: var(--text-primary);
}

/* Accordion */
.accordion-card {
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.accordion-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

.accordion-header:hover {
    background: var(--bg-soft);
}

.accordion-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary-teal);
    font-size: 1.125rem;
    font-weight: 600;
}

.accordion-text-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.accordion-icon {
    transition: transform 0.3s;
    color: var(--text-secondary);
}

.accordion-card.open .accordion-icon {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.accordion-card.open .accordion-content {
    max-height: 5000px;
}

.accordion-inner {
    padding: 0 1.5rem 1.5rem;
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
    background: var(--bg-soft);
    color: var(--text-primary);
}

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

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-green);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-amber);
}

.badge-info {
    background: rgba(14, 165, 233, 0.1); /* --primary-blue with opacity */
    color: var(--primary-blue);
}

/* Visit Item */
.visit-item {
    border: 2px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 0.75rem;
    transition: all 0.2s;
}

.visit-item:hover {
    border-color: rgba(13, 148, 136, 0.3);
}

.visit-header {
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.visit-header:hover {
    background: var(--bg-soft);
}

.visit-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: rgba(13, 148, 136, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-teal);
    flex-shrink: 0;
}

.visit-date {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.visit-badges {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.visit-amount {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.visit-chevron {
    margin-left: auto;
    color: var(--text-secondary);
    transition: transform 0.3s;
    flex-shrink: 0;
}

.visit-item.open .visit-chevron {
    transform: rotate(180deg);
}

.visit-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
    background: var(--bg-soft);
    border-top: 1px solid var(--border-color);
}

.visit-item.open .visit-details {
    max-height: 3000px;
    padding: 1rem;
}

/* SOAP Notes */
.soap-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.soap-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.75rem;
}

.soap-label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.soap-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
}

.soap-icon.subjective {
    background: #3B82F6;
}

.soap-icon.objective {
    background: #10B981;
}

.soap-icon.assessment {
    background: #A855F7;
}

.soap-icon.plan {
    background: #F97316;
}

body[data-theme='dark'] .soap-icon {
    color: var(--bg-card);
}

.soap-content {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Payment History */
.payment-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.summary-item {
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}

.summary-item.paid {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-green);
}

.summary-item.pending {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-amber);
}

.summary-item.total {
    background: rgba(13, 148, 136, 0.1);
    color: var(--primary-teal);
}

.summary-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.summary-value {
    font-size: 1.5rem;
    font-weight: 700;
}

body[data-theme='dark'] .summary-value {
    color: var(--text-primary);
}

/* Table */
.table-wrapper {
    overflow-x: auto;
    padding: 1rem;
}

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

.payment-table th {
    text-align: left;
    padding: 0.75rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
}

.payment-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

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

/* Styles for grouped pending payments */
.group-header {
    cursor: pointer;
    transition: background-color 0.2s;
}
.group-header:hover {
    background-color: var(--bg-soft);
}
.group-header .accordion-icon {
    transition: transform 0.3s;
}
.group-header.open .accordion-icon {
    transform: rotate(180deg);
}
.group-details {
    display: none;
}
.nested-table-wrapper {
    background-color: var(--bg-soft);
    padding: 1rem;
}

/* Payment Status Toggle */
.payment-status-toggle {
    position: relative;
    display: inline-block;
    width: 90px;
    height: 28px;
}

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

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--warning-amber);
    transition: .4s;
    border-radius: 28px;
}

.toggle-slider:before {
    position: absolute;
    content: "Pending";
    height: 20px;
    width: 55px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 20px;
    color: var(--warning-amber);
    font-size: 0.7rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

input:checked + .toggle-slider {
    background-color: var(--success-green);
}

input:checked + .toggle-slider:before {
    transform: translateX(27px);
    content: "Paid";
    color: var(--success-green);
}

/* Invoice Summary */
.invoice-summary {
    background: rgba(13, 148, 136, 0.1);
    border: 1px solid rgba(13, 148, 136, 0.2);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    justify-content: space-around;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    min-width: 320px;
    max-width: 400px;
    animation: slideIn 0.3s ease-out;
}

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

.toast.success {
    border-left: 4px solid var(--success-green);
}

.toast.error {
    border-left: 4px solid var(--error-red);
}

.toast.info {
    border-left: 4px solid var(--primary-blue);
}

.toast.info .toast-message {
    font-weight: 700;
    color: var(--primary-blue);
}

.toast.toast-warning {
    border-left: 4px solid #EF4444;
}

.toast.toast-warning .toast-message {
    font-weight: 700;
    color: #EF4444;
}

.toast-icon {
    flex-shrink: 0;
    margin-top: 0.125rem;
}

.toast-message {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 500;
}

.toast-close {
    padding: 0.25rem;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.toast-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .container {
        padding: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .quick-actions {
        grid-template-columns: 1fr;
    }
    
    .search-form {
        flex-direction: column;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }

    /* Patient Detail Page Mobile Adjustments */
    .patient-detail-card {
        flex-direction: column;
        align-items: center;
        padding: 1.5rem;
    }

    .patient-detail-content {
        width: 100%;
    }

    .patient-detail-content h1 {
        text-align: center;
        font-size: 1.5rem;
    }

    .patient-detail-grid {
        grid-template-columns: 1fr; /* Force single column */
    }

    .patient-detail-grid > div {
        text-align: center; /* Center text in all grid items */
    }

    /* Override inline styles for the action buttons container */
    .detail-action-item[style] {
        grid-column: 1 / -1 !important;
        justify-self: stretch !important;
        margin-top: 1.5rem !important;
    }

    .patient-detail-actions[style] {
        flex-direction: column !important;
        gap: 0.75rem !important;
        width: 100%;
    }

    .patient-detail-actions .btn {
        width: 100%;
    }
    
    .main-header {
        padding: 1rem;
    }
    
    .mobile-menu-btn {
        display: block;
    }
    
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 2px 0 8px rgba(0,0,0,0.1);
    }
    
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 90;
        display: none;
    }
    
    .sidebar-overlay.open {
        display: block;
    }
}

/* Main App Wrapper */
#app-wrapper {
    display: flex;
    width: 100%;
    height: 100vh;
}

/* New Login Page Styles */
.login-container-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

.login-showcase {
    background-color: var(--bg-soft);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4rem;
    text-align: left;
}

.showcase-content {
    max-width: 450px;
}

.showcase-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 2rem;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.showcase-description {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.login-form-wrapper {
    background-color: var(--bg-card);
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
    text-align: left;
}

/* Responsive adjustments for login page */
@media (max-width: 900px) {
    .login-container-split {
        grid-template-columns: 1fr;
    }
    .login-showcase {
        display: block; /* Show the showcase on smaller screens */
    }
    .login-card {
        text-align: center;
    }
}

/* Pharmacy — filter tabs */
.filter-tab {
    padding: 0.45rem 1rem;
    border: 1.5px solid var(--border-color);
    border-radius: 20px;
    background: none;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.filter-tab.active,
.filter-tab:hover {
    background: var(--primary-teal);
    border-color: var(--primary-teal);
    color: #fff;
}

/* Sidebar badge (pending count) */
.nav-badge {
    margin-left: auto;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: var(--primary-teal);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

.nav-badge.nav-badge-warn {
    background: #ef4444;
}

/* Inventory low-stock row */
.low-stock-row {
    border-left: 3px solid #f59e0b;
}

/* Rx / bill status badge */
.rx-status-badge {
    display: inline-block;
    padding: 0.18rem 0.6rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: capitalize;
}

.rx-status-pending   { background: #fef3c7; color: #92400e; }
.rx-status-dispensed { background: #d1fae5; color: #065f46; }
.rx-status-cancelled { background: #fee2e2; color: #991b1b; }

[data-theme="dark"] .rx-status-pending   { background: #78350f40; color: #fcd34d; }
[data-theme="dark"] .rx-status-dispensed { background: #06402640; color: #6ee7b7; }
[data-theme="dark"] .rx-status-cancelled { background: #7f1d1d40; color: #fca5a5; }

/* Rx item row in new-rx modal */
.rx-item-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

/* ── Inventory search bar ─────────────────────────────────────────────────── */
.inv-search-bar {
    display: flex;
    align-items: stretch;
    flex: 1;
    min-width: 280px;
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    background: var(--bg-card);
    transition: border-color 0.18s, box-shadow 0.18s;
}

.inv-search-bar:focus-within {
    border-color: var(--primary-teal);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-teal) 15%, transparent);
}

/* Also fix other form-input selects across pharmacy in dark mode */
body[data-theme='dark'] select.form-input option {
    background-color: var(--bg-card);
    color: var(--text-primary);
}
body[data-theme='dark'] select.form-input {
    color-scheme: dark;
}

/* ── Custom category dropdown ──────────────────────────────────────────────── */
.inv-search-bar {
    overflow: visible; /* allow custom dropdown list to escape the container */
}

/* ── Today's Queue (doctor dashboard) ────────────────────────────────────── */
.queue-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
    display: inline-block;
    flex-shrink: 0;
    transition: background 0.3s;
}

.queue-live-dot.queue-live-dot-active {
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
    animation: queuePulse 1.8s ease-in-out infinite;
}

@keyframes queuePulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25); }
    50%       { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.08); }
}

.queue-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    background: var(--primary-teal);
    color: white;
    font-size: 0.72rem;
    font-weight: 700;
    border-radius: 99px;
}

/* ── Analytics charts grid ────────────────────────────────────────────────── */
.analytics-charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .analytics-charts-grid {
        grid-template-columns: 1fr;
    }
}

.custom-cat-wrap {
    position: relative;
    flex-shrink: 0;
    align-self: stretch;
    display: flex;
    align-items: center;
}

.custom-cat-btn {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.65rem 0.85rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    min-width: 130px;
    font-family: inherit;
}

.custom-cat-btn:hover {
    color: var(--primary-teal);
}

.custom-cat-list {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 190px;
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
    list-style: none;
    padding: 0.3rem 0;
    margin: 0;
    z-index: 300;
}

.custom-cat-list.open {
    display: block;
    animation: catDropIn 0.15s ease;
}

@keyframes catDropIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.custom-cat-list li {
    padding: 0.55rem 1rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-primary);
    transition: background 0.12s;
}

.custom-cat-list li:hover {
    background: var(--bg-soft);
}

.custom-cat-list li.selected {
    color: var(--primary-teal);
    font-weight: 600;
}

/* ── Patient mode tab buttons (New Bill modal) ───────────────────────────── */
.patient-mode-btn {
    flex: 1;
    padding: 0.5rem 0.75rem;
    font-size: 0.83rem;
    font-weight: 600;
    border: none;
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.patient-mode-btn.active {
    background: var(--primary-teal);
    color: #fff;
}

.patient-mode-btn:not(.active):hover {
    background: var(--bg-soft);
    color: var(--text-primary);
}

/* ── Bill item card (New Bill modal) ──────────────────────────────────────── */
.bill-item-card {
    background: var(--bg-soft);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.85rem;
    margin-bottom: 0.65rem;
    transition: border-color 0.2s;
}

.bill-item-card:hover {
    border-color: var(--primary-teal);
}

.timing-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    font-size: 0.78rem;
    cursor: pointer;
    padding: 0.22rem 0.55rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    user-select: none;
    white-space: nowrap;
}

.timing-chip:has(input:checked) {
    border-color: var(--primary-teal);
    background: color-mix(in srgb, var(--primary-teal) 12%, transparent);
    color: var(--primary-teal);
    font-weight: 600;
}

.timing-chip:has(input[type="radio"]:checked) {
    border-color: #8b5cf6;
    background: color-mix(in srgb, #8b5cf6 12%, transparent);
    color: #8b5cf6;
}

.timing-chip input {
    width: 13px;
    height: 13px;
    cursor: pointer;
    accent-color: var(--primary-teal);
}

.timing-chip input[type="radio"] {
    accent-color: #8b5cf6;
}


/* Role Selection */
.role-cards {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.role-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.1rem;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-card);
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    width: 100%;
}

.role-card:hover {
    border-color: var(--primary-teal);
    background: var(--bg-soft);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.07);
}

.role-card-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.role-card-text {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    flex: 1;
}

.role-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.role-card-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.role-card-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.role-card-disabled:hover {
    border-color: var(--border-color);
    background: var(--bg-card);
    box-shadow: none;
}

.role-card-badge {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-soft);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 0.2rem 0.65rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.role-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0;
    margin-bottom: 1.5rem;
    transition: color 0.15s;
}

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

.login-role-badge {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin: 0 auto 0.75rem;
}

/* Modal Styles */
.pay-status-toggle {
    display: flex;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.pay-status-btn {
    flex: 1;
    padding: 0.52rem 0;
    background: var(--bg-card);
    color: var(--text-secondary);
    border: none;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.pay-status-btn:first-child {
    border-right: 1.5px solid var(--border-color);
}

.pay-status-btn:hover:not(.active) {
    background: var(--bg-soft);
    color: var(--text-primary);
}

.pay-status-btn.active[data-value="Pending"] {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.pay-status-btn.active[data-value="Paid"] {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.reg-section-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    margin-bottom: 0.6rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-inline-error {
    margin: 0 1.5rem 0.25rem;
    padding: 0.65rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.35);
    border-radius: 8px;
    color: var(--error-red, #ef4444);
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-inline-error::before {
    content: '⚠';
    font-size: 0.95rem;
    flex-shrink: 0;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
    padding: 2rem;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.25), 0 8px 20px rgba(0, 0, 0, 0.12);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
    border-radius: 16px 16px 0 0;
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

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

.modal-body {
    padding: 1.5rem;
}

.review-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.review-item {
    background-color: var(--bg-soft);
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.review-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    display: block;
}

.review-value {
    font-size: 0.875rem;
    color: var(--text-primary);
    line-height: 1.4;
    word-break: break-word;
}

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

/* Fix for browser autofill styles in dark mode */
body[data-theme='dark'] input:-webkit-autofill,
body[data-theme='dark'] input:-webkit-autofill:hover,
body[data-theme='dark'] input:-webkit-autofill:focus,
body[data-theme='dark'] input:-webkit-autofill:active,
body[data-theme='dark'] select:-webkit-autofill,
body[data-theme='dark'] select:-webkit-autofill:hover,
body[data-theme='dark'] select:-webkit-autofill:focus,
body[data-theme='dark'] select:-webkit-autofill:active {
    -webkit-text-fill-color: var(--text-primary) !important;
    -webkit-box-shadow: 0 0 0 30px var(--bg-card) inset !important;
    box-shadow: 0 0 0 30px var(--bg-card) inset !important;
}

/* Make date and time picker icons visible in dark mode */
body[data-theme='dark'] input[type="date"]::-webkit-calendar-picker-indicator {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' viewBox='0 0 16 16'%3e%3cpath d='M3.5 0a.5.5 0 0 1 .5.5V1h8V.5a.5.5 0 0 1 1 0V1h1a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V3a2 2 0 0 1 2-2h1V.5a.5.5 0 0 1 .5-.5zM1 4v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V4H1z'/%3e%3c/svg%3e");
}

body[data-theme='dark'] input[type="time"]::-webkit-calendar-picker-indicator {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' viewBox='0 0 16 16'%3e%3cpath d='M8 3.5a.5.5 0 0 0-1 0V9a.5.5 0 0 0 .252.434l3.5 2a.5.5 0 0 0 .496-.868L8 8.71V3.5z'/%3e%3cpath d='M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16zm7-8A7 7 0 1 1 1 8a7 7 0 0 1 14 0z'/%3e%3c/svg%3e");
}

/* Fix for disabled dropdowns in dark mode to match the theme */
body[data-theme='dark'] select:disabled {
    background-color: var(--bg-card);
    opacity: 0.6;
    color: var(--text-secondary);
}

/* Fix for dropdown menu background in dark mode */
body[data-theme='dark'] select option {
    background: var(--bg-card);
    color: var(--text-primary);
}
body[data-theme='dark'] select {
    color-scheme: dark;
}

/* Loading Placeholder */
.loading-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.loading-placeholder .spinner {
    width: 24px;
    height: 24px;
    border-width: 3px;
    border-top-color: var(--primary-teal);
    border-right-color: transparent;
    border-bottom-color: transparent;
    border-left-color: transparent;
    margin-bottom: 1rem;
    display: block; /* Override inline-block */
}

.loading-placeholder p {
    font-weight: 500;
}

.attachments-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.attachments-section h4 {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.attachments-section ul {
    list-style-position: inside;
    padding-left: 0.5rem;
}

.attachments-section ul li a {
    color: var(--primary-teal);
    text-decoration: none;
}

.attachments-section ul li a:hover {
    text-decoration: underline;
}

/* AI Assistant Floating Action Button */
.fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    background-color: var(--primary-teal);
    color: white;
    border-radius: 50%;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    transition: box-shadow 0.3s ease;
    z-index: 999;
    user-select: none;
}

.fab:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.fab.dragging {
    cursor: grabbing;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* AI Assistant Chat Window (Floating) */
.ai-chat-window {
    position: fixed;
    bottom: 2rem; /* Align with FAB */
    right: 2rem; /* Align with FAB */
    z-index: 1000; /* Above FAB and other content */
    display: flex; /* To center the chat box if needed, though it's fixed */
    justify-content: flex-end; /* Keep it to the right */
    align-items: flex-end; /* Keep it to the bottom */
    pointer-events: none; /* Allow clicks through when hidden */
}

.ai-chat-window[style*="display: flex"] {
    pointer-events: auto; /* Enable clicks when visible */
}

/* Window controls styling */
.ai-chat-header-controls {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}
.ai-chat-header .ai-window-controls {
    display: flex;
    gap: 0.25rem;
}

.ai-chat-header .ai-window-controls button {
    padding: 0.3rem 0.5rem;
    min-width: unset;
    height: 28px;
    border-radius: 6px;
}

/* Minimized state */
.ai-chat-window.minimized .ai-chat-box {
    height: auto;
    width: 350px; /* Keep width */
    border-bottom-right-radius: 16px; /* Ensure corners are rounded */
    border-bottom-left-radius: 16px;
}
.ai-chat-window.minimized .ai-chat-body,
.ai-chat-window.minimized .ai-chat-footer {
    display: none;
}

/* Maximized state */
.ai-chat-window.maximized {
    top: 1rem; left: 1rem; bottom: 1rem; right: 1rem; width: auto; height: auto;
}
.ai-chat-window.maximized .ai-chat-box {
    width: 100%; height: 100%;
}
.ai-chat-box {
    width: 350px; /* Smaller width for chat box */
    height: 500px; /* Fixed height for chat box */
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
}

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

.ai-chat-header h3 {
    margin: 0;
    font-size: 1.125rem;
    color: var(--text-primary);
}

.ai-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ai-chat-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

.ai-chat-footer form {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

#ai-question-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    background-color: var(--bg-soft);
    color: var(--text-primary);
}

.user-message, .ai-message {
    display: flex;
    max-width: 85%;
}

.user-message {
    align-self: flex-end;
}

.ai-message {
    align-self: flex-start;
}

.message-bubble {
    padding: 0.75rem 1rem;
    border-radius: 18px;
    line-height: 1.5;
}

.user-message .message-bubble {
    background-color: var(--primary-teal);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message .message-bubble {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}