/* MedSaaS Component Styles - Plain CSS (works with Tailwind CDN) */

:root {
    --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

html { font-family: var(--font-sans); }
body {
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    letter-spacing: -0.011em;
}
h1, h2, h3, h4, .login-title, .sidebar-brand-text, .page-title {
    font-family: var(--font-sans);
    letter-spacing: -0.02em;
}
code, .mono, [style*="font-family:monospace"], .data-table td[style*="monospace"] {
    font-family: var(--font-mono);
}

*, *::before, *::after { box-sizing: border-box; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    line-height: 1.25rem;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #0d9488; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #0f766e; }
.btn-secondary { background: #fff; color: #374151; border: 1px solid #d1d5db; }
.btn-secondary:hover:not(:disabled) { background: #f9fafb; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-ghost { background: transparent; color: #6b7280; }
.btn-ghost:hover:not(:disabled) { background: #f3f4f6; color: #111827; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.75rem; }
.btn-lg { padding: 0.625rem 1.25rem; font-size: 1rem; }
.btn-icon { padding: 0.5rem; }

.input, .select, .textarea {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: #111827;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: #0d9488;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}
.input::placeholder { color: #9ca3af; }
.textarea { min-height: 80px; resize: vertical; }
.select { cursor: pointer; }

.label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.25rem;
}
.label-required::after { content: ' *'; color: #dc2626; }

.card {
    background: #fff;
    border-radius: 0.75rem;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h3 { font-size: 1rem; font-weight: 600; color: #111827; margin: 0; }
.card-body { padding: 1.25rem; }
.card-footer { padding: 1rem 1.25rem; border-top: 1px solid #e5e7eb; background: #f9fafb; border-radius: 0 0 0.75rem 0.75rem; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 16rem;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 40;
}
.sidebar-brand {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.sidebar-brand-logo {
    width: 2.25rem; height: 2.25rem;
    background: #0d9488;
    border-radius: 0.5rem;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 0.75rem;
}
.sidebar-brand-text { font-weight: 600; font-size: 0.875rem; color: #111827; }
.sidebar-brand-sub { font-size: 0.75rem; color: #6b7280; }
.sidebar-nav { flex: 1; padding: 0.75rem; overflow-y: auto; }
.sidebar-section-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #9ca3af;
    padding: 0.85rem 0.75rem 0.35rem;
    margin-top: 0.25rem;
}
.sidebar-section-label:first-child { padding-top: 0.35rem; margin-top: 0; }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #4b5563;
    border-radius: 0.5rem;
    text-decoration: none;
    transition: all 0.15s;
    margin-bottom: 2px;
}
.sidebar-link:hover { background: #f3f4f6; color: #111827; }
.sidebar-link.active { background: #f0fdfa; color: #0f766e; }
.sidebar-link svg { width: 1.25rem; height: 1.25rem; flex-shrink: 0; }
.sidebar-logout-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
    width: auto; min-width: 0; max-width: 100%; align-self: flex-start;
    padding: 0.375rem 0.75rem; font-size: 0.75rem; font-weight: 500;
    background: none; border: 1px solid #e5e7eb; border-radius: 0.5rem;
    color: #6b7280; cursor: pointer; transition: all 0.15s;
    white-space: nowrap; flex: 0 0 auto; box-sizing: border-box;
    font-family: inherit; line-height: 1.25;
}
.sidebar-logout-btn svg {
    width: 0.875rem; height: 0.875rem; min-width: 0.875rem; min-height: 0.875rem;
    max-width: 0.875rem; max-height: 0.875rem;
    flex-shrink: 0; display: block;
}
.sidebar-logout-btn span { flex: 0 0 auto; line-height: 1.25; }
.sidebar-logout-btn:hover { background: #f3f4f6; color: #374151; }
.topbar-logout-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.375rem;
    width: auto; min-width: 0; max-width: 100%;
    padding: 0.375rem 0.75rem; font-size: 0.8125rem; font-weight: 500;
    background: none; border: 1px solid #e5e7eb; border-radius: 0.5rem;
    color: #6b7280; cursor: pointer; transition: all 0.15s;
    white-space: nowrap; flex: 0 0 auto; box-sizing: border-box;
    font-family: inherit; line-height: 1.25;
}
.topbar-logout-btn svg {
    width: 0.875rem; height: 0.875rem; min-width: 0.875rem; min-height: 0.875rem;
    max-width: 0.875rem; max-height: 0.875rem;
    flex-shrink: 0; display: block;
}
.topbar-logout-btn span { flex: 0 0 auto; line-height: 1.25; }
.topbar-logout-btn:hover { background: #f3f4f6; color: #374151; }
.sidebar-footer {
    display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem;
    padding: 0.75rem; border-top: 1px solid #e5e7eb;
}
.sidebar-footer .sidebar-logout-btn { width: auto; flex: 0 0 auto; }
.sidebar-footer .sidebar-user { width: 100%; }
.sidebar-user { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0.75rem; }
.sidebar-user-avatar {
    width: 2rem; height: 2rem;
    border-radius: 9999px;
    background: #ccfbf1;
    color: #0f766e;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 0.875rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 0.75rem; color: #6b7280; text-transform: capitalize; }
.sidebar-user-practice-type {
    font-size: 0.6875rem; color: #0f766e; line-height: 1.3; margin-top: 0.2rem;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.main-content { flex: 1; margin-left: 16rem; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 1rem 1.5rem;
    position: sticky; top: 0; z-index: 30;
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.topbar-title { font-size: 1.25rem; font-weight: 600; color: #111827; margin: 0; }
.topbar-subtitle { font-size: 0.875rem; color: #6b7280; margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }
.page-content { flex: 1; padding: 1.5rem; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 0.75rem; padding: 1.25rem; }
.stat-card-inner { display: flex; align-items: center; justify-content: space-between; }
.stat-label { font-size: 0.875rem; color: #6b7280; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: #111827; margin-top: 0.25rem; }
.stat-icon {
    width: 2.5rem; height: 2.5rem;
    border-radius: 0.5rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.125rem;
}
.stat-icon-teal { background: #ccfbf1; color: #0d9488; }
.stat-icon-blue { background: #dbeafe; color: #2563eb; }
.stat-icon-orange { background: #ffedd5; color: #ea580c; }
.stat-icon-green { background: #dcfce7; color: #16a34a; }
.stat-icon-red { background: #fee2e2; color: #dc2626; }
.stat-icon-purple { background: #f3e8ff; color: #9333ea; }

/* Tables */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead { background: #f9fafb; }
.data-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e5e7eb;
}
.data-table td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: #111827;
    border-bottom: 1px solid #f3f4f6;
}
.data-table tbody tr:hover { background: #f9fafb; }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 9999px;
}
.badge-booked { background: #dbeafe; color: #1e40af; }
.badge-confirmed { background: #e0e7ff; color: #3730a3; }
.badge-arrived { background: #fef9c3; color: #854d0e; }
.badge-waiting { background: #ffedd5; color: #c2410c; }
.badge-in_consultation { background: #ccfbf1; color: #0f766e; }
.badge-completed { background: #dcfce7; color: #166534; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-no_show { background: #f3f4f6; color: #374151; }
.badge-paid { background: #dcfce7; color: #166534; }
.badge-partial { background: #fef9c3; color: #854d0e; }
.badge-sent { background: #dbeafe; color: #1e40af; }
.badge-draft { background: #f3f4f6; color: #374151; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-suspended { background: #fee2e2; color: #991b1b; }
.badge-pending { background: #fef9c3; color: #854d0e; }
.badge-overdue { background: #fee2e2; color: #991b1b; }

/* Login */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0d9488 0%, #0f766e 50%, #115e59 100%);
    padding: 1rem;
}
.login-screen.dark {
    background: linear-gradient(135deg, #111827 0%, #1f2937 50%, #111827 100%);
}
.login-card {
    background: #fff;
    border-radius: 1rem;
    padding: 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
}
.login-card.dark {
    background: #1f2937;
    border: 1px solid #374151;
}
.login-logo {
    width: 4rem; height: 4rem;
    background: #ccfbf1;
    border-radius: 1rem;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1rem;
    color: #0d9488;
}
.login-card.dark .login-logo { background: #374151; color: #2dd4bf; }
.login-title { text-align: center; font-size: 1.5rem; font-weight: 700; color: #111827; }
.login-card.dark .login-title { color: #fff; }
.login-subtitle { text-align: center; color: #6b7280; font-size: 0.875rem; margin-top: 0.25rem; margin-bottom: 2rem; }
.login-card.dark .login-subtitle { color: #9ca3af; }
.login-card.dark .label { color: #d1d5db; }
.login-card.dark .input { background: #374151; border-color: #4b5563; color: #fff; }
.login-error { font-size: 0.875rem; color: #dc2626; background: #fef2f2; padding: 0.75rem; border-radius: 0.5rem; margin-bottom: 1rem; }
.login-card.dark .login-error { background: rgba(220,38,38,0.15); color: #fca5a5; }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center;
    z-index: 9000; padding: 1rem;
}
.modal {
    background: #fff;
    border-radius: 0.75rem;
    width: 100%; max-width: 32rem;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
}
.modal-lg { max-width: 48rem; }
.modal-xl { max-width: 56rem; }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
}
.modal-header h3 { font-size: 1.125rem; font-weight: 600; margin: 0; }
.modal-close { background: none; border: none; color: #9ca3af; cursor: pointer; padding: 0.25rem; }
.modal-close:hover { color: #374151; }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: 1rem 1.25rem; border-top: 1px solid #e5e7eb; display: flex; justify-content: flex-end; gap: 0.75rem; }

/* Toast notifications (shared — practice & admin portals) */
.toast-container {
    pointer-events: none;
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: calc(100vw - 2rem);
}
.toast-modern {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    min-width: min(320px, calc(100vw - 2rem));
    max-width: 420px;
    padding: 0.875rem 1rem 1rem;
    background: #1e293b;
    border: 1px solid #475569;
    border-radius: 0.75rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.45);
    animation: toastSlideIn 0.35s cubic-bezier(0.21, 1.02, 0.47, 1);
    position: relative;
    overflow: hidden;
}
.toast-modern.toast-exit { animation: toastSlideOut 0.3s ease forwards; }
.toast-modern-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 700;
    font-size: 0.875rem;
}
.toast-modern-success .toast-modern-icon { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.toast-modern-error .toast-modern-icon { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.toast-modern-info .toast-modern-icon { background: rgba(59, 130, 246, 0.15); color: #60a5fa; }
.toast-modern-warning .toast-modern-icon { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.toast-modern-body { flex: 1; min-width: 0; }
.toast-modern-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #f8fafc;
    margin-bottom: 0.125rem;
    line-height: 1.3;
}
.toast-modern-message {
    font-size: 0.8125rem;
    color: #94a3b8;
    line-height: 1.45;
    word-break: break-word;
}
.toast-modern-close {
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}
.toast-modern-close:hover { color: #f1f5f9; }
.toast-modern-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.08);
}
.toast-modern-progress-bar { height: 100%; animation: toastProgress 4s linear forwards; }
.toast-modern-success .toast-modern-progress-bar { background: #22c55e; }
.toast-modern-error .toast-modern-progress-bar { background: #ef4444; }
.toast-modern-info .toast-modern-progress-bar { background: #3b82f6; }
.toast-modern-warning .toast-modern-progress-bar { background: #f59e0b; }
@keyframes toastSlideIn { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastSlideOut { to { transform: translateX(110%); opacity: 0; } }
@keyframes toastProgress { from { width: 100%; } to { width: 0%; } }

/* Search */
.search-box { position: relative; }
.search-box input { padding-left: 2.25rem; width: 16rem; }
.search-box svg { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); width: 1rem; height: 1rem; color: #9ca3af; }
.search-dropdown {
    position: absolute; top: 100%; left: 0; right: 0;
    margin-top: 0.25rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    max-height: 16rem;
    overflow-y: auto;
    z-index: 50;
}
.search-result { display: block; padding: 0.625rem 1rem; text-decoration: none; color: inherit; }
.search-result:hover { background: #f9fafb; }
.search-result-name { font-size: 0.875rem; font-weight: 500; }
.search-result-meta { font-size: 0.75rem; color: #6b7280; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.form-group { margin-bottom: 1rem; }
.form-group.full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* Empty state */
.empty-state { text-align: center; padding: 3rem 1.5rem; color: #6b7280; }
.empty-state-icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.5; }
.empty-state-title { font-size: 1rem; font-weight: 500; color: #374151; margin-bottom: 0.25rem; }

/* Loading */
.spinner {
    width: 2rem; height: 2rem;
    border: 3px solid #e5e7eb;
    border-top-color: #0d9488;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.spinner-center { margin: 3rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Appointment list item */
.appt-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    background: #f9fafb;
    margin-bottom: 0.5rem;
}
.appt-time { font-family: monospace; font-size: 0.875rem; color: #6b7280; width: 4rem; }
.appt-color { width: 4px; height: 2.5rem; border-radius: 2px; flex-shrink: 0; }
.appt-info { flex: 1; min-width: 0; }
.appt-patient { font-weight: 500; font-size: 0.875rem; }
.appt-meta { font-size: 0.75rem; color: #6b7280; }

/* Waiting room */
.queue-item {
    display: flex; align-items: center; gap: 1rem;
    padding: 1rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    margin-bottom: 0.75rem;
}
.queue-item.waiting { border-left: 4px solid #ea580c; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.85; } }

/* Quick actions */
.quick-actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
.quick-action {
    padding: 1.25rem;
    border: 2px dashed #e5e7eb;
    border-radius: 0.75rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    background: #fff;
}
.quick-action:hover { border-color: #99f6e4; background: #f0fdfa; }
.quick-action-icon { font-size: 1.5rem; margin-bottom: 0.5rem; }
.quick-action-label { font-size: 0.875rem; font-weight: 500; }

/* Admin dark theme overrides */
.admin-layout { background: #111827; min-height: 100vh; }
.admin-layout .sidebar { background: #1f2937; border-color: #374151; }
.admin-layout .sidebar-brand-text { color: #fff; }
.admin-layout .sidebar-brand-sub { color: #9ca3af; }
.admin-layout .sidebar-link { color: #9ca3af; }
.admin-layout .sidebar-link:hover { background: #374151; color: #fff; }
.admin-layout .sidebar-link.active { background: rgba(13,148,136,0.15); color: #2dd4bf; }
.admin-layout .sidebar-section-label {
    color: #6b7280;
    padding-left: 0.85rem;
    padding-right: 0.85rem;
}
.admin-layout .sidebar-footer { border-color: #374151; }
.admin-layout .sidebar-user-name { color: #fff; }
.admin-layout .main-content { background: #111827; }
.admin-layout .topbar { background: #1f2937; border-color: #374151; }
.admin-layout .topbar-title { color: #fff; }
.admin-layout .topbar-subtitle { color: #9ca3af; }
.admin-layout .card { background: #1f2937; border-color: #374151; }
.admin-layout .card-header { border-color: #374151; }
.admin-layout .card-header h3 { color: #fff; }
.admin-layout .stat-card { background: #1f2937; border-color: #374151; }
.admin-layout .stat-label { color: #9ca3af; }
.admin-layout .stat-value { color: #fff; }
.admin-layout .data-table thead { background: #374151; }
.admin-layout .data-table th { color: #9ca3af; border-color: #4b5563; }
.admin-layout .data-table td { color: #e5e7eb; border-color: #374151; }
.admin-layout .data-table tbody tr:hover { background: #374151; }
.admin-layout .input, .admin-layout .select { background: #374151; border-color: #4b5563; color: #fff; }
.admin-layout .label { color: #d1d5db; }
.admin-layout .empty-state { color: #9ca3af; }
.admin-layout .empty-state-title { color: #e5e7eb; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .search-box input { width: 100%; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

.hidden { display: none !important; }
