/* ===== OneMedForce — Design System ===== */
:root {
    --color-primary: #1893b2;
    --color-primary-dark: #147a94;
    --color-primary-light: #e8f6fa;
    --color-white: #ffffff;
    --color-bg: #f5f7fa;
    --color-surface: #ffffff;
    --color-border: #e5e7eb;
    --color-border-focus: #1893b2;
    --color-text: #111827;
    --color-text-muted: #6b7280;
    --color-text-light: #9ca3af;
    --color-success: #22c55e;
    --color-danger: #ef4444;
    --color-danger-bg: #fef2f2;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow: 0 4px 6px -1px rgba(16, 24, 40, 0.08), 0 2px 4px -2px rgba(16, 24, 40, 0.04);
    --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, 0.12);

    --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html,
body {
    font-family: var(--font);
    font-size: 15px;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

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

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

/* ===== Layout Auth ===== */
.auth-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 100vh;
}

/* ===== Brand panel ===== */
.auth-brand {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #1893b2 0%, #0f6b84 100%);
    color: var(--color-white);
    padding: 56px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.auth-brand__pattern {
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.08) 0, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.06) 0, transparent 40%),
        repeating-linear-gradient(45deg, transparent 0, transparent 60px, rgba(255, 255, 255, 0.025) 60px, rgba(255, 255, 255, 0.025) 61px);
    pointer-events: none;
}

.auth-brand__content {
    position: relative;
    z-index: 1;
    max-width: 460px;
}

.auth-brand__logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 80px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.auth-brand__title {
    font-size: 38px;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.02em;
    margin-bottom: 20px;
}

.auth-brand__subtitle {
    font-size: 16px;
    line-height: 1.6;
    opacity: 0.85;
    margin-bottom: 40px;
}

.auth-brand__features {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.auth-brand__features li {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 15px;
    opacity: 0.95;
}

.auth-brand__check {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.auth-brand__footer {
    position: relative;
    z-index: 1;
    font-size: 13px;
    opacity: 0.7;
}

/* ===== Main / Card ===== */
.auth-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    background: var(--color-bg);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--color-surface);
    padding: 48px 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--color-border);
}

.auth-card__header {
    margin-bottom: 32px;
}

.auth-card__header h2 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 6px;
}

.auth-card__header p {
    color: var(--color-text-muted);
    font-size: 14px;
}

.auth-card__footer {
    margin-top: 28px;
    text-align: center;
    font-size: 14px;
    color: var(--color-text-muted);
}

/* ===== Form ===== */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
}

.form-group__label-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 8px;
}

.form-group__label-row label {
    margin-bottom: 0;
}

.form-group__link {
    font-size: 12px;
    font-weight: 500;
}

.input-wrap {
    position: relative;
}

.input-wrap input {
    width: 100%;
    padding: 12px 14px 12px 42px;
    font-size: 14px;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-white);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.input-wrap input::placeholder {
    color: var(--color-text-light);
}

.input-wrap input:hover {
    border-color: #d1d5db;
}

.input-wrap input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(24, 147, 178, 0.12);
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-light);
    pointer-events: none;
}

.input-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--color-text-light);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: color var(--transition);
}

.input-toggle:hover {
    color: var(--color-primary);
}

/* Checkbox */
.checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: 24px;
    cursor: pointer;
    user-select: none;
}

.checkbox input {
    width: 16px;
    height: 16px;
    accent-color: var(--color-primary);
    cursor: pointer;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.btn--primary {
    background: var(--color-primary);
    color: var(--color-white);
    box-shadow: 0 1px 2px rgba(24, 147, 178, 0.3);
}

.btn--primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
    box-shadow: 0 4px 12px rgba(24, 147, 178, 0.35);
    transform: translateY(-1px);
}

.btn--primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn--block {
    width: 100%;
}

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

.btn__spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--color-white);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.btn.is-loading .btn__label {
    opacity: 0.6;
}

.btn.is-loading .btn__spinner {
    display: inline-block;
}

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

/* ===== Alert ===== */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 20px;
    animation: slideDown 200ms ease-out;
}

.alert--error {
    background: var(--color-danger-bg);
    color: var(--color-danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

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

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

/* ===== Responsive ===== */
@media (max-width: 960px) {
    .auth-layout {
        grid-template-columns: 1fr;
    }

    .auth-brand {
        display: none;
    }

    .auth-main {
        padding: 32px 20px;
    }
}

@media (max-width: 480px) {
    .auth-card {
        padding: 32px 24px;
        box-shadow: none;
        border: none;
        background: transparent;
    }
}


/* ===================================================================
   APP LAYOUT — Sidebar + Topbar + Content
=================================================================== */

.app {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    background: var(--color-white);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 24px;
    border-bottom: 1px solid var(--color-border);
    font-size: 17px;
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: -0.02em;
}

.sidebar__brand svg {
    flex-shrink: 0;
}

.sidebar__nav {
    flex: 1;
    padding: 20px 14px;
    overflow-y: auto;
}

.sidebar__section {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-light);
    padding: 16px 12px 8px;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
}

.sidebar__link svg {
    flex-shrink: 0;
}

.sidebar__link:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.sidebar__link.is-active {
    background: var(--color-primary-light);
    color: var(--color-primary);
    font-weight: 600;
}

.sidebar__footer {
    padding: 16px;
    border-top: 1px solid var(--color-border);
}

.sidebar__user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: var(--radius);
    background: var(--color-bg);
}

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

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

.sidebar__user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar__user-role {
    font-size: 11px;
    color: var(--color-text-muted);
}

.sidebar__logout {
    background: none;
    border: none;
    color: var(--color-text-light);
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: all var(--transition);
}

.sidebar__logout:hover {
    color: var(--color-danger);
    background: var(--color-danger-bg);
}

/* ===== Main area ===== */
.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 32px;
    background: var(--color-white);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar__title h1 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.topbar__title p {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.topbar__actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.content {
    padding: 32px;
    flex: 1;
}

/* ===================================================================
   COMPONENTS
=================================================================== */

/* Stat cards */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 22px;
    transition: all var(--transition);
}

.stat-card:hover {
    border-color: #d1d5db;
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.stat-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.stat-card__label {
    font-size: 13px;
    color: var(--color-text-muted);
    font-weight: 500;
}

.stat-card__icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--color-primary-light);
    color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card__icon--success {
    background: #dcfce7;
    color: var(--color-success);
}

.stat-card__icon--danger {
    background: var(--color-danger-bg);
    color: var(--color-danger);
}

.stat-card__icon--warn {
    background: #fef3c7;
    color: #d97706;
}

.stat-card__value {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--color-text);
}

.stat-card__trend {
    font-size: 12px;
    margin-top: 6px;
    color: var(--color-text-muted);
}

.stat-card__trend--up {
    color: var(--color-success);
}

/* Card (generic container) */
.card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

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

.card__title {
    font-size: 16px;
    font-weight: 600;
}

.card__subtitle {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.card__body {
    padding: 24px;
}

/* Toolbar inside card */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--color-border);
    background: #fafbfc;
    flex-wrap: wrap;
}

.toolbar__search {
    flex: 1;
    min-width: 240px;
    position: relative;
}

.toolbar__search input {
    width: 100%;
    padding: 9px 12px 9px 38px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    background: var(--color-white);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.toolbar__search input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(24, 147, 178, 0.1);
}

.toolbar__search svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-light);
}

.select {
    padding: 9px 12px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    background: var(--color-white);
    color: var(--color-text);
    cursor: pointer;
}

.select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(24, 147, 178, 0.1);
}

/* ===== Textarea ===== */
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-white);
    resize: vertical;
    line-height: 1.6;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}

textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(24, 147, 178, 0.1);
}

textarea::placeholder {
    color: #9ca3af;
    font-style: italic;
}

/* ===== Table ===== */
.table-wrap {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table thead th {
    text-align: left;
    padding: 14px 24px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    background: #fafbfc;
    border-bottom: 1px solid var(--color-border);
}

.table tbody td {
    padding: 16px 24px;
    border-bottom: 1px solid #f3f4f6;
    color: var(--color-text);
}

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

.table tbody tr {
    transition: background var(--transition);
}

.table tbody tr:hover {
    background: #fafbfc;
}

.table__empty {
    text-align: center;
    padding: 60px 24px;
    color: var(--color-text-muted);
}

.table__empty svg {
    margin: 0 auto 12px;
    color: var(--color-text-light);
}

/* Cell components */
.cell-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.avatar--lg {
    width: 48px;
    height: 48px;
    font-size: 16px;
}

.cell-user__info {
    min-width: 0;
}

.cell-user__name {
    font-weight: 600;
    color: var(--color-text);
}

.cell-user__email {
    font-size: 12px;
    color: var(--color-text-muted);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge--primary {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.badge--success {
    background: #dcfce7;
    color: #15803d;
}

.badge--danger {
    background: var(--color-danger-bg);
    color: #b91c1c;
}

.badge--warn {
    background: #fef3c7;
    color: #b45309;
}

.badge--neutral {
    background: #f3f4f6;
    color: #4b5563;
}

.badge__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* Action buttons row */
.actions {
    display: flex;
    gap: 6px;
}

.icon-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--color-border);
    background: var(--color-white);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.icon-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-primary-light);
}

.icon-btn--danger:hover {
    border-color: var(--color-danger);
    color: var(--color-danger);
    background: var(--color-danger-bg);
}

/* Secondary button */
.btn--secondary {
    background: var(--color-white);
    color: var(--color-text);
    border: 1.5px solid var(--color-border);
}

.btn--secondary:hover:not(:disabled) {
    border-color: #9ca3af;
    background: #fafbfc;
}

.btn--danger {
    background: var(--color-danger);
    color: var(--color-white);
}

.btn--danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn--sm {
    padding: 8px 14px;
    font-size: 13px;
}

/* ===== Modal ===== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    animation: fadeIn 200ms ease-out;
}

.modal-backdrop.is-open {
    display: flex;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal {
    background: var(--color-white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    animation: slideUp 250ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

.modal__title {
    font-size: 17px;
    font-weight: 600;
}

.modal__close {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all var(--transition);
}

.modal__close:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.modal__body {
    padding: 24px;
}

.modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--color-border);
    background: #fafbfc;
}

/* Form rows for modals */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form-group--plain input,
.form-group--plain select {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: var(--color-white);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group--plain input:focus,
.form-group--plain select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(24, 147, 178, 0.12);
}

.form-error {
    font-size: 12px;
    color: var(--color-danger);
    margin-top: 6px;
}

/* ===== Toasts ===== */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 420px;
    pointer-events: auto;
    animation: toastIn 300ms cubic-bezier(0.16, 1, 0.3, 1);
    border-left: 4px solid var(--color-primary);
}

.toast--success {
    border-left-color: var(--color-success);
}

.toast--error {
    border-left-color: var(--color-danger);
}

.toast__icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-white);
    flex-shrink: 0;
}

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

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

.toast__text {
    flex: 1;
    font-size: 13px;
    color: var(--color-text);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

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

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-top: 1px solid var(--color-border);
    font-size: 13px;
    color: var(--color-text-muted);
}

.pagination__controls {
    display: flex;
    gap: 6px;
}

.pagination__btn {
    padding: 6px 12px;
    border: 1px solid var(--color-border);
    background: var(--color-white);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    transition: all var(--transition);
}

.pagination__btn:hover:not(:disabled) {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.pagination__btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 1024px) {
    .app {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 260px;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.25s cubic-bezier(.4,0,.2,1);
        will-change: transform;
    }

    .sidebar.is-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,.15);
    }

    .content {
        padding: 20px;
    }

    .topbar {
        padding: 14px 20px;
    }
}

@media (max-width: 640px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .modal {
        max-width: 100%;
        margin: 0;
        border-radius: 0;
        max-height: 100vh;
    }
}

.pagination__btn {
    display: inline-block;
    text-decoration: none;
    color: var(--color-text);
}

.pagination__btn:hover:not(:disabled) {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* ===================================================================
   CALENDAR
=================================================================== */

.calendar {
    display: grid;
    grid-template-columns: 80px repeat(6, 1fr);
    background: var(--color-border);
    gap: 1px;
    font-size: 13px;
}

.calendar__corner {
    background: #fafbfc;
}

.calendar__day-header {
    background: #fafbfc;
    padding: 14px 8px;
    text-align: center;
    border-bottom: 2px solid var(--color-border);
}

.calendar__day-header.is-today {
    background: var(--color-primary-light);
}

.calendar__day-name {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--color-text-muted);
    font-weight: 600;
    letter-spacing: 0.05em;
}

.calendar__day-header.is-today .calendar__day-name {
    color: var(--color-primary);
}

.calendar__day-num {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
    margin-top: 2px;
}

.calendar__day-header.is-today .calendar__day-num {
    color: var(--color-primary);
}

.calendar__hour {
    background: #fafbfc;
    padding: 12px 10px;
    font-size: 11px;
    color: var(--color-text-muted);
    font-weight: 600;
    text-align: right;
    min-height: 80px;
}

.calendar__cell {
    background: var(--color-white);
    min-height: 80px;
    padding: 4px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.calendar-event {
    display: block;
    padding: 6px 8px;
    border-radius: 6px;
    text-decoration: none;
    border-left: 3px solid;
    font-size: 11px;
    line-height: 1.3;
    transition: all 150ms;
    overflow: hidden;
}

.calendar-event:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

.calendar-event__time {
    font-weight: 700;
    font-size: 11px;
}

.calendar-event__patient {
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.calendar-event__doctor {
    font-size: 10px;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Couleurs par statut */
.calendar-event--planifie {
    background: #e0f2fe;
    border-left-color: #0284c7;
}

.calendar-event--planifie .calendar-event__time {
    color: #0284c7;
}

.calendar-event--confirme {
    background: #dcfce7;
    border-left-color: #16a34a;
}

.calendar-event--confirme .calendar-event__time {
    color: #16a34a;
}

.calendar-event--en_cours {
    background: #fef3c7;
    border-left-color: #d97706;
}

.calendar-event--en_cours .calendar-event__time {
    color: #d97706;
}

.calendar-event--termine {
    background: #f3f4f6;
    border-left-color: #6b7280;
    opacity: 0.85;
}

.calendar-event--termine .calendar-event__time {
    color: #6b7280;
}

.calendar-event--absent {
    background: #fee2e2;
    border-left-color: #dc2626;
}

.calendar-event--absent .calendar-event__time {
    color: #dc2626;
}

@media (max-width: 1024px) {
    .calendar {
        font-size: 11px;
    }

    .calendar__hour,
    .calendar__cell {
        min-height: 60px;
    }

    .calendar-event__doctor {
        display: none;
    }
}

/* ===================================================================
   DOCTORS
=================================================================== */

.doctor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 24px;
}

.doctor-card {
    display: flex;
    flex-direction: column;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-decoration: none;
    color: inherit;
    transition: all var(--transition);
}

.doctor-card:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.doctor-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
}

.doctor-card__avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
}

.doctor-card__body {
    flex: 1;
}

.doctor-card__name {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 4px;
}

.doctor-card__speciality {
    font-size: 13px;
    color: var(--color-primary);
    font-weight: 500;
    margin-bottom: 10px;
}

.doctor-card__meta {
    font-size: 12px;
    color: var(--color-text-muted);
}

.doctor-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid var(--color-border);
}

/* ===== Schedule table (form) ===== */
.schedule-table {
    width: 100%;
    border-collapse: collapse;
}

.schedule-table thead th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    background: #fafbfc;
    border-bottom: 1px solid var(--color-border);
}

.schedule-row td {
    padding: 14px 12px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}

.schedule-row:last-child td {
    border-bottom: none;
}

.schedule-row.is-disabled {
    opacity: 0.4;
}

.schedule-row.is-disabled input[type="time"] {
    pointer-events: none;
}

.schedule-time-pair {
    display: flex;
    align-items: center;
    gap: 8px;
}

.schedule-time-pair input[type="time"] {
    padding: 7px 10px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    width: 105px;
}

.schedule-time-pair input[type="time"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(24, 147, 178, 0.1);
}

.schedule-time-pair span {
    color: var(--color-text-light);
}

/* Toggle switch */
.schedule-toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    cursor: pointer;
}

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

.schedule-toggle__slider {
    position: absolute;
    inset: 0;
    background: #d1d5db;
    border-radius: 22px;
    transition: background var(--transition);
}

.schedule-toggle__slider:before {
    content: '';
    position: absolute;
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform var(--transition);
}

.schedule-toggle input:checked+.schedule-toggle__slider {
    background: var(--color-primary);
}

.schedule-toggle input:checked+.schedule-toggle__slider:before {
    transform: translateX(18px);
}

/* ===== Schedule day row (visualisation) ===== */
.schedule-day-row {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    border-bottom: 1px solid #f3f4f6;
}

.schedule-day-row:last-child {
    border-bottom: none;
}

.schedule-day-row.is-off {
    opacity: 0.5;
}

.schedule-day-row__name {
    width: 100px;
    font-weight: 600;
    font-size: 14px;
}

.schedule-day-row__blocks {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.schedule-block {
    display: inline-block;
    padding: 4px 10px;
    background: var(--color-primary-light);
    color: var(--color-primary);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    font-family: 'SFMono-Regular', Menlo, monospace;
}

/* ===== Slots list ===== */
.slots-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 500px;
    overflow-y: auto;
}

.slots-day {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 16px;
    align-items: flex-start;
}

.slots-day__header {
    text-align: right;
    padding-right: 12px;
    border-right: 2px solid var(--color-border);
}

.slots-day__header.is-today {
    border-right-color: var(--color-primary);
}

.slots-day__name {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    font-weight: 600;
}

.slots-day__header.is-today .slots-day__name {
    color: var(--color-primary);
}

.slots-day__date {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
    margin-top: 2px;
}

.slots-day__items {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.slot-chip {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    font-family: 'SFMono-Regular', Menlo, monospace;
    cursor: default;
}

.slot-chip--available {
    background: #dcfce7;
    color: #15803d;
}

.slot-chip--booked {
    background: #fee2e2;
    color: #b91c1c;
    text-decoration: line-through;
}

.slot-chip--blocked {
    background: #f3f4f6;
    color: #6b7280;
}

@media (max-width: 1200px) {
    .doctor-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    }
}

/* ===== Slot selector (modale RDV) ===== */
.slot-selector {
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    background: #fafbfc;
    min-height: 120px;
    max-height: 280px;
    overflow: hidden;
}

.slot-selector__scroll {
    max-height: 280px;
    overflow-y: auto;
    padding: 12px;
}

.slot-selector__empty {
    padding: 30px 20px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 13px;
    line-height: 1.6;
}

.slot-selector__day {
    margin-bottom: 14px;
}
.slot-selector__day:last-child { margin-bottom: 0; }

.slot-selector__date {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    font-weight: 700;
    margin-bottom: 6px;
    padding-left: 2px;
}

.slot-selector__times {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.slot-pill {
    padding: 7px 12px;
    background: var(--color-white);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    font-family: 'SFMono-Regular', Menlo, monospace;
    color: var(--color-text);
    cursor: pointer;
    transition: all var(--transition);
}
.slot-pill:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-primary-light);
}
.slot-pill.is-selected {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-white);
}


#portal-unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-width: 18px;
    height: 18px;
    padding: 0 6px;

    font-size: 11px;
    font-weight: 600;
    color: #fff;

    background: #ef4444; /* rouge moderne */
    border-radius: 999px;

    line-height: 1;
    white-space: nowrap;

    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

/* ===================================================================
   HAMBURGER / SIDEBAR TOGGLE
=================================================================== */
.sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    background: none;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all var(--transition);
    padding: 0;
}
.sidebar-toggle:hover {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    z-index: 49;
    animation: fadeIn 200ms ease-out;
}
.sidebar-backdrop.is-open { display: block; }

/* Portal: mini header visible only on mobile */
.portal-mobile-header {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 13px 16px;
    background: var(--color-white);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.portal-mobile-header__brand {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-primary);
    letter-spacing: -0.02em;
    flex: 1;
}

/* ===================================================================
   RESPONSIVE — Tablet (≤ 1024px)
=================================================================== */
@media (max-width: 1024px) {
    .sidebar-toggle { display: flex; }
    .portal-mobile-header { display: flex; }

    /* Topbar */
    .topbar { gap: 12px; padding: 13px 20px; }
    .topbar__title h1 { font-size: 18px; }

    /* Topbar actions: horizontal scroll instead of wrap */
    .topbar__actions {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        max-width: 60vw;
    }
    .topbar__actions::-webkit-scrollbar { display: none; }

    /* Content */
    .content { padding: 20px 16px; }

    /* Cards */
    .card__header { padding: 14px 18px; }
    .card__body { padding: 16px 18px; }

    /* Stats */
    .stats { gap: 14px; }

    /* Calendar: horizontal scroll on tablet */
    .calendar-scroll-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .calendar { min-width: 700px; }
}

/* ===================================================================
   RESPONSIVE — Mobile large (≤ 768px)
=================================================================== */
@media (max-width: 768px) {
    /* Topbar */
    .topbar { padding: 11px 14px; }
    .topbar__title h1 { font-size: 16px; }
    .topbar__title p { display: none; }
    .topbar__actions { max-width: 58vw; gap: 6px; }
    .topbar__actions .btn--sm { padding: 7px 10px; font-size: 12px; gap: 4px; }
    .topbar__actions .btn--sm svg { width: 12px; height: 12px; }

    /* Content */
    .content { padding: 16px 12px; }

    /* Stats: 2 columns */
    .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
    .stat-card { padding: 14px; }
    .stat-card__value { font-size: 24px; }

    /* Card */
    .card__header { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
    .card__body { padding: 12px 14px; }
    .card__title { font-size: 14px; }

    /* Toolbar */
    .toolbar { padding: 10px 12px; gap: 8px; }
    .toolbar__search { min-width: 0; flex: 1; }

    /* Table */
    .table { font-size: 13px; }
    .table thead th { padding: 9px 12px; font-size: 10px; }
    .table tbody td { padding: 10px 12px; }
    .table__empty { padding: 40px 16px; }

    /* Pagination */
    .pagination { flex-direction: column; gap: 6px; padding: 10px 12px; font-size: 12px; }

    /* Doctor grid */
    .doctor-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); padding: 14px; gap: 14px; }

    /* Slots */
    .slots-day { grid-template-columns: 60px 1fr; gap: 10px; }
}

/* ===================================================================
   RESPONSIVE — Mobile small (≤ 480px)
=================================================================== */
@media (max-width: 480px) {
    /* Topbar */
    .topbar { padding: 10px 12px; }
    .topbar__title h1 { font-size: 15px; }
    .topbar__actions { max-width: 56vw; }

    /* Content */
    .content { padding: 12px 10px; }

    /* Stats: single column */
    .stats { grid-template-columns: 1fr; gap: 8px; }
    .stat-card { padding: 12px 14px; }
    .stat-card__value { font-size: 22px; }
    .stat-card__trend { display: none; }

    /* Form rows: always single col */
    .form-row { grid-template-columns: 1fr; }

    /* Doctor grid: single column */
    .doctor-grid { grid-template-columns: 1fr; padding: 12px; gap: 12px; }

    /* Toast */
    .toast-container { right: 10px; left: 10px; top: 16px; }
    .toast { min-width: unset; width: 100%; }

    /* Modal: slide from bottom on very small */
    .modal {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        max-height: 92vh;
        max-width: 100%;
        margin: 0;
    }
    .modal-backdrop { align-items: flex-end; padding: 0; }

    /* Calendar */
    .calendar { min-width: 560px; }
}

/* Utility: hide column on mobile */
@media (max-width: 640px) {
    .col-hide-mobile { display: none !important; }
}

/* ===================================================================
   RESPONSIVE GRID UTILITIES
=================================================================== */

/* 2-column grid that collapses to 1 on mobile */
.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
@media (max-width: 768px) {
    .grid-2col {
        grid-template-columns: 1fr;
        gap: 14px;
    }
}

/* 3-column grid that collapses to 2 then 1 */
.grid-3col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}
@media (max-width: 960px) {
    .grid-3col { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
    .grid-3col { grid-template-columns: 1fr; gap: 12px; }
}

/* ===================================================================
   RESPONSIVE — Dashboard improvements
=================================================================== */

/* Stat cards: always 2 columns on small mobile (never 1) */
@media (max-width: 480px) {
    .stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    .stat-card {
        padding: 12px;
    }
    .stat-card__value {
        font-size: 20px;
        word-break: break-all;
    }
    .stat-card__label {
        font-size: 11px;
    }
}

/* Table inside a card: always scrollable, never squeezed */
.card .table-wrap {
    -webkit-overflow-scrolling: touch;
}
.card .table {
    min-width: 420px;
}

/* Topbar title: prevent subtitle from pushing actions on small screens */
@media (max-width: 480px) {
    .topbar__title p {
        display: none;
    }
    .topbar__title h1 {
        font-size: 14px;
    }
    .topbar {
        padding: 10px 10px;
        gap: 8px;
    }
    .topbar__actions {
        max-width: 52vw;
        gap: 5px;
    }
    .topbar__actions .btn--sm {
        padding: 6px 8px;
        font-size: 11px;
    }
    .content {
        padding: 10px 8px;
    }
}

/* Card header: wrap nicely on small screens */
@media (max-width: 480px) {
    .card__header {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px 12px;
    }
    .card__title {
        font-size: 13px;
    }
}
