/* ==========================================================================
   La Santé Day Close - Medical Theme CSS
   ========================================================================== */

/* CSS Variables - Light Theme */
:root, [data-theme="light"] {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #f59e0b;
    --warning-light: #fef3c7;

    --bg: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #1e293b;
    --bg-input: #ffffff;
    --bg-hover: #f1f5f9;

    --text: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-sidebar: #cbd5e1;
    --text-sidebar-active: #ffffff;

    --border: #e2e8f0;
    --border-focus: #2563eb;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-sm: 6px;

    --sidebar-width: 260px;
}

/* Dark Theme */
[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: #1e3a5f;

    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-sidebar: #0f172a;
    --bg-input: #1e293b;
    --bg-hover: #334155;

    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-sidebar: #94a3b8;

    --border: #334155;
    --border-focus: #3b82f6;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.3);
}

/* ==========================================================================
   Base Styles
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; color: var(--text); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }

/* ==========================================================================
   Layout
   ========================================================================== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.page-content {
    padding: 1.5rem;
    flex: 1;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

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

.logo svg { color: var(--primary); }
.logo-text { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; }

.sidebar-nav {
    flex: 1;
    padding: 0.5rem 0;
    overflow-y: auto;
}

.nav-section {
    padding: 0.5rem 0;
}

.nav-section-title {
    display: block;
    padding: 0.5rem 1.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    color: var(--text-sidebar);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0;
    transition: all 0.15s;
    text-decoration: none;
}

.nav-link:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-sidebar-active);
    text-decoration: none;
}

.nav-link.active {
    background: rgba(37,99,235,0.15);
    color: var(--primary);
    border-right: 3px solid var(--primary);
}

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

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 0.5rem 0;
}

.logout-link { color: #f87171 !important; }
.logout-link:hover { background: rgba(248,113,113,0.1) !important; }

/* ==========================================================================
   Top Bar
   ========================================================================== */
.top-bar {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-title {
    flex: 1;
    font-size: 1.125rem;
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-badge {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-hover);
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 0.25rem;
}

/* ==========================================================================
   Theme Toggle
   ========================================================================== */
[data-theme="light"] .icon-moon { display: none; }
[data-theme="dark"] .icon-sun { display: none; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-outline {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}
.btn-outline:hover { background: var(--bg-hover); }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { background: var(--danger-hover); }

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-icon:hover { background: var(--bg-hover); }

.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-xs { padding: 0.2rem 0.5rem; font-size: 0.75rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ==========================================================================
   Forms
   ========================================================================== */
.form-container { max-width: 700px; }

.form-group {
    margin-bottom: 1rem;
    flex: 1;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.35rem;
}

.required { color: var(--danger); }

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.form-group textarea { resize: vertical; }
.input-disabled { opacity: 0.6; cursor: not-allowed; }

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group { flex: 1; }

.form-group-btn {
    display: flex;
    align-items: flex-end;
    flex: 0 !important;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.inline-form {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

.inline-form .form-group { min-width: 200px; }

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.card-body { padding: 1.25rem; }

.card-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.5rem;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
}

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

.stat-icon.blue   { background: #dbeafe; color: #2563eb; }
.stat-icon.green  { background: #dcfce7; color: #16a34a; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon.gold   { background: #fef3c7; color: #d97706; }

[data-theme="dark"] .stat-icon.blue   { background: #1e3a5f; }
[data-theme="dark"] .stat-icon.green  { background: #14532d; }
[data-theme="dark"] .stat-icon.purple { background: #2e1065; }
[data-theme="dark"] .stat-icon.gold   { background: #451a03; }

.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 0.8rem; color: var(--text-secondary); }

/* ==========================================================================
   Tables
   ========================================================================== */
.table-responsive { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.data-table th,
.data-table td {
    padding: 0.65rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}

.data-table th {
    background: var(--bg-hover);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
}

.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }

.text-right { text-align: right; }
.text-truncate { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions-cell { white-space: nowrap; display: flex; gap: 0.35rem; }

/* ==========================================================================
   Alerts
   ========================================================================== */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    margin: 0.75rem 1.5rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideDown 0.3s ease;
}

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

.alert-success { background: var(--success-light); color: #166534; border: 1px solid #86efac; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-close { background: none; border: none; font-size: 1.25rem; cursor: pointer; color: inherit; padding: 0 0.25rem; }

[data-theme="dark"] .alert-success { background: #14532d; color: #86efac; border-color: #166534; }
[data-theme="dark"] .alert-error { background: #450a0a; color: #fca5a5; border-color: #991b1b; }

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: scaleIn 0.2s ease;
}

@keyframes scaleIn {
    from { transform: scale(0.95); }
    to { transform: scale(1); }
}

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

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}

.modal-body { padding: 1.25rem; }

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

/* ==========================================================================
   Client Cards
   ========================================================================== */
.client-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
}

.client-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.client-info { flex: 1; min-width: 0; }
.client-info h3 { font-size: 0.95rem; margin-bottom: 0.1rem; }
.client-actions { flex-shrink: 0; }

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 999px;
    background: var(--primary-light);
    color: var(--primary);
}

/* ==========================================================================
   Empty State
   ========================================================================== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state svg { margin-bottom: 1rem; opacity: 0.4; }
.empty-state p { font-size: 0.95rem; }

/* ==========================================================================
   Filters & Search
   ========================================================================== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.dashboard-filters { margin-bottom: 1.5rem; }

.filter-form {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.filter-group input {
    padding: 0.45rem 0.6rem;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font-family: inherit;
}

.search-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.search-input {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    font-family: inherit;
    min-width: 250px;
}

.search-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.quick-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ==========================================================================
   Operator Hero
   ========================================================================== */
.operator-hero {
    text-align: center;
    padding: 2rem;
    margin-bottom: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

/* ==========================================================================
   Service Entry Section
   ========================================================================== */
.service-entry-section {
    background: var(--bg-hover);
    padding: 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.service-entry-section h3 {
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

/* ==========================================================================
   Login Page
   ========================================================================== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

.login-container { width: 100%; max-width: 400px; padding: 1rem; }

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-header h1 {
    font-size: 1.75rem;
    margin: 0.75rem 0 0.25rem;
}

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

.login-form .form-group { margin-bottom: 1.25rem; }

.login-footer-text {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 1.25rem;
}

/* ==========================================================================
   Utilities
   ========================================================================== */
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 0.8rem; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: block;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-form {
        flex-direction: column;
        align-items: stretch;
    }

    .search-input {
        min-width: auto;
        width: 100%;
    }

    .inline-form {
        flex-direction: column;
    }

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

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

    .actions-cell {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .page-content {
        padding: 1rem;
    }
}
