/*
 * TheraCenter design system: color tokens, typography, and shared
 * component styles (sidebar, tables, cards, badges, forms) layered on
 * top of Bootstrap 5.3's CSS variables.
 *
 * Accent usage rule: the purple/violet brand scale (--brand-500 and
 * nearby steps) is reserved for interactive and key elements only —
 * the active sidebar item, primary buttons/icon actions, chart data,
 * and "key attribute" links that identify a specific record. It is
 * never used as decorative background or text color elsewhere. Plain
 * headings and body text use --brand-900, which is a near-black dark
 * tone (not a vivid accent), so page titles don't read as "accented."
 */
:root {
    --brand-50: #f5f3ff;
    --brand-100: #ede9fe;
    --brand-200: #ddd6fe;
    --brand-300: #c4b5fd;
    --brand-400: #a78bfa;
    --brand-500: #7c3aed;
    --brand-600: #6d28d9;
    --brand-700: #5b21b6;
    --brand-800: #4c1d95;
    --brand-900: #211a35;

    --bs-primary: var(--brand-500);
    --bs-primary-rgb: 124, 58, 237;
    --bs-primary-text-emphasis: var(--brand-700);
    --bs-primary-bg-subtle: var(--brand-50);
    --bs-primary-border-subtle: var(--brand-200);

    --bs-link-color: var(--brand-600);
    --bs-link-color-rgb: 109, 40, 217;
    --bs-link-hover-color: var(--brand-700);
    --bs-link-hover-color-rgb: 91, 33, 182;

    /* Neutral surfaces + borders shared by the app shell, cards, and tables */
    --surface-sidebar: #f7f7f8;
    --surface-content: #ffffff;
    --surface-table-header: #f3f4f6;
    --border-subtle: #e5e7eb;

    /* Sidebar text (dark-on-light, replacing the old light-on-dark scheme) */
    --text-sidebar: #374151;
    --text-sidebar-muted: #6b7280;

    /* Table header text */
    --text-table-header: #4b5563;

    /* Status/trend colors, intentionally decoupled from the brand accent
       so status meaning never depends on the current brand hue */
    --status-positive-bg: #dcfce7;
    --status-positive-text: #15803d;
    --status-negative-bg: #fdecea;
    --status-negative-text: #b71c1c;
    --status-warning-bg: #fef3c7;
    --status-warning-text: #b45309;
    --status-neutral-bg: #f3f4f6;
    --status-neutral-text: #4b5563;
    --status-info-bg: #dbeafe;
    --status-info-text: #1d4ed8;
    --trend-up: #16a34a;
    --trend-down: #dc3545;

    /* Sidebar icon accents: one per top-level nav item, deliberately
       outside the brand/status scales (see usage rule above) */
    --nav-icon-resumen: #2563eb;
    --nav-icon-patients: #0d9488;
    --nav-icon-valoraciones: #d97706;
    --nav-icon-appointments: #e11d48;
    --nav-icon-employees: #0891b2;
    --nav-icon-configuration: #64748b;
}

.btn-primary {
    --bs-btn-bg: var(--brand-500);
    --bs-btn-border-color: var(--brand-500);
    --bs-btn-hover-bg: var(--brand-600);
    --bs-btn-hover-border-color: var(--brand-600);
    --bs-btn-active-bg: var(--brand-700);
    --bs-btn-active-border-color: var(--brand-700);
    --bs-btn-focus-shadow-rgb: 124, 58, 237;
}

.bg-brand-50 {
    background-color: var(--brand-50) !important;
}

.text-brand-900 {
    color: var(--brand-900) !important;
}

.text-brand-800 {
    color: var(--brand-800) !important;
}

.text-brand-700 {
    color: var(--brand-700) !important;
}

/*
 * Dashboard shell: light-gray sidebar + white content area.
 */
.app-shell {
    display: flex;
    min-height: 100vh;
    background: var(--surface-content);
}

.app-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--surface-sidebar);
    color: var(--text-sidebar);
    border-right: 1px solid var(--border-subtle);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
}

.app-sidebar .app-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--brand-600);
    text-decoration: none;
    padding: 0 0.5rem;
    margin-bottom: 2rem;
    display: block;
}

.app-sidebar .nav-section-label {
    text-transform: uppercase;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: var(--text-sidebar-muted);
    margin: 1.25rem 0.5rem 0.5rem;
}

.app-sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--text-sidebar);
    border-radius: 0.6rem;
    padding: 0.6rem 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.15rem;
}

.app-sidebar .nav-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.app-sidebar .nav-link svg.icon-resumen {
    color: var(--nav-icon-resumen);
}

.app-sidebar .nav-link svg.icon-patients {
    color: var(--nav-icon-patients);
}

.app-sidebar .nav-link svg.icon-valoraciones {
    color: var(--nav-icon-valoraciones);
}

.app-sidebar .nav-link svg.icon-appointments {
    color: var(--nav-icon-appointments);
}

.app-sidebar .nav-link svg.icon-employees {
    color: var(--nav-icon-employees);
}

.app-sidebar .nav-link svg.icon-configuration {
    color: var(--nav-icon-configuration);
}

.app-sidebar .nav-link:hover {
    background: var(--surface-table-header);
    color: var(--brand-900);
}

.app-sidebar .nav-link.active {
    background: var(--brand-500);
    color: #fff;
    font-weight: 600;
}

.app-sidebar .nav-link.active svg {
    color: #fff;
}

.app-sidebar .nav-collapse-chevron {
    width: 14px !important;
    height: 14px !important;
    margin-left: auto;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.app-sidebar .nav-link:not(.collapsed) .nav-collapse-chevron {
    transform: rotate(180deg);
}

.app-sidebar .nav-sublink {
    padding-left: 2.6rem;
    font-size: 0.85rem;
}

.app-sidebar .sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle);
}

.app-sidebar .sidebar-credit {
    display: block;
    margin-top: 0.75rem;
    padding: 0 0.75rem;
    font-size: 0.72rem;
    color: var(--text-sidebar-muted);
    text-decoration: none;
}

.app-sidebar .sidebar-credit:hover {
    color: var(--text-sidebar);
    text-decoration: underline;
}

.app-content {
    flex-grow: 1;
    min-width: 0;
    background: var(--surface-content);
}

.app-topbar {
    background: var(--surface-content);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.85rem 1.75rem;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
}

.app-topbar-username {
    font-weight: 600;
    color: var(--brand-700);
    white-space: nowrap;
}

.app-topbar-center-select {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--brand-50);
    border: 1px solid var(--brand-200);
    border-radius: 999px;
    padding: 0.3rem 0.75rem 0.3rem 1rem;
}

.app-topbar-center-select label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--brand-700);
    margin: 0;
    white-space: nowrap;
}

.app-topbar-center-select select {
    appearance: auto;
    border: none;
    background: transparent;
    color: var(--brand-700);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 0.1rem 0.25rem;
}

.app-topbar-center-select select:focus {
    outline: 2px solid var(--brand-400);
    outline-offset: 2px;
}

.app-main {
    padding: 1.75rem;
}

/* Dashboard widgets */
.stat-card {
    background: var(--surface-content);
    border: 1px solid var(--border-subtle);
    border-radius: 0.75rem;
    padding: 1.25rem;
    height: 100%;
}

.stat-card .stat-icon-chip {
    width: 40px;
    height: 40px;
    border-radius: 0.65rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.stat-card .stat-icon-chip svg {
    width: 20px;
    height: 20px;
}

.stat-icon-chip--green {
    background: var(--status-positive-bg);
    color: var(--status-positive-text);
}

.stat-icon-chip--purple {
    background: var(--brand-100);
    color: var(--brand-600);
}

.stat-icon-chip--blue {
    background: #dbeafe;
    color: #2563eb;
}

.stat-icon-chip--amber {
    background: #fef3c7;
    color: #b45309;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: #6c757d;
    font-weight: 500;
}

.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--brand-900);
}

.stat-card .stat-trend {
    font-size: 0.78rem;
    font-weight: 600;
}

.stat-card .stat-trend.up {
    color: var(--trend-up);
}

.stat-card .stat-trend.down {
    color: var(--trend-down);
}

.dashboard-card {
    background: var(--surface-content);
    border: 1px solid var(--border-subtle);
    border-radius: 0.75rem;
    padding: 1.25rem;
    height: 100%;
}

.dashboard-card .dashboard-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--brand-900);
    margin-bottom: 0;
}

.dashboard-card--mock {
    border: 2px solid #dc3545;
}

.mock-data-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.68rem;
    font-weight: 600;
    color: #dc3545;
    background: rgba(220, 53, 69, 0.1);
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge.status-active {
    background: var(--status-positive-bg);
    color: var(--status-positive-text);
}

.status-badge.status-inactive {
    background: var(--status-negative-bg);
    color: var(--status-negative-text);
}

.text-status-positive {
    color: var(--status-positive-text);
    font-weight: 600;
}

.text-status-info {
    color: var(--status-info-text);
    font-weight: 600;
}

.alert-readonly-positive {
    color: var(--status-positive-text);
    background: #fff;
    border: 1px solid var(--status-positive-text);
}

/* Compact status indicator: a colored dot + label, used where a full
   pill badge would be too heavy (e.g. next to an inline form control). */
.status-dot-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-table-header);
    white-space: nowrap;
}

.status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    flex: 0 0 auto;
}

.status-dot--pendiente {
    background: var(--status-warning-text);
}

.status-dot--realizada {
    background: var(--status-positive-text);
}

.status-dot--cancelada {
    background: var(--status-negative-text);
}

.status-dot--neutral {
    background: var(--status-neutral-text);
}

/* Reusable data-table styling: light-gray header row, white body rows,
   hairline dividers only (no zebra striping). */
.table-theracenter {
    --bs-border-color: var(--border-subtle);
}

/* Rounded container: overflow:hidden clips the table's square corners to
   match the border-radius, since border-radius on <table> alone doesn't
   clip cell backgrounds. */
.table-responsive:has(> .table-theracenter) {
    border: 1px solid var(--border-subtle);
    border-radius: 0.75rem;
    overflow-x: auto;
    overflow-y: hidden;
}

.table-responsive:has(> .table-theracenter) > .table-theracenter {
    margin-bottom: 0;
}

.table-theracenter thead th {
    background-color: var(--surface-table-header);
    color: var(--text-table-header);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.table-theracenter thead th a {
    color: inherit;
}

.table-theracenter tbody td {
    font-size: 0.9rem;
    padding: 0.7rem 1rem;
}

.table-theracenter.table-hover tbody tr:hover {
    background-color: var(--brand-50) !important;
}

/* Pagination nav below a catalog list table: a compact, floating pill
   group (page numbers + chevron prev/next) instead of Bootstrap's default
   bordered, full-width pagination component. */
.list-pagination {
    margin-top: 1.25rem;
}

.pagination-pill-group {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background-color: var(--surface-content);
    border-radius: 0.9rem;
    padding: 0.35rem;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 10px rgba(16, 24, 40, 0.06);
}

.pagination-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.4rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-table-header);
    background-color: transparent;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

a.pagination-pill:hover {
    background-color: var(--brand-50);
    color: var(--brand-700);
}

.pagination-pill--active {
    background-color: var(--brand-500);
    color: #fff;
}

a.pagination-pill--active:hover {
    background-color: var(--brand-500);
    color: #fff;
}

.pagination-pill--ellipsis {
    color: #9ca3af;
    cursor: default;
}

.pagination-pill--nav {
    color: var(--text-table-header);
}

.pagination-pill--disabled {
    background-color: var(--surface-table-header);
    color: #c1c5cc;
    cursor: not-allowed;
}

/* List pages: title + search/autocomplete + "register new" header row */
.list-page-title {
    min-width: 12rem;
    flex-shrink: 0;
}

.list-page-subtitle {
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: 0.15rem;
}

.list-page-register-btn {
    font-size: 0.85rem;
}

.list-search-bar {
    width: 100%;
    border: 1px solid var(--border-subtle);
    border-radius: 0.75rem;
    background: #fff;
    padding: 0.6rem 1rem;
}

.list-search-form {
    position: relative;
    width: 100%;
    max-width: 620px;
}

.list-search-box {
    position: relative;
    display: flex;
    align-items: center;
    border: 1px solid var(--border-subtle);
    border-radius: 0.5rem;
    background: #fff;
}

.list-search-box:focus-within {
    border-color: var(--brand-300);
    box-shadow: 0 0 0 0.2rem var(--brand-50);
}

.list-search-icon {
    position: absolute;
    left: 0.9rem;
    color: #8a93a3;
    pointer-events: none;
}

.list-search-box input[type="text"] {
    border: none;
    background: transparent;
    font-size: 0.75rem;
    padding-left: 2.25rem;
    padding-right: 2.25rem;
}

.list-search-box input[type="text"]:focus {
    box-shadow: none;
}

.list-search-clear {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #6c757d;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.list-search-clear:hover {
    color: #212529;
}

.list-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 20;
    max-height: 14rem;
    overflow-y: auto;
    border: 1px solid var(--border-subtle);
    border-radius: 0.375rem;
    background: #fff;
}

.list-search-results .list-group-item {
    cursor: pointer;
    font-size: 0.75rem;
}

/* Patient form (shared by the create modal and the full-page edit view) */
.staff-form-card {
    background: var(--surface-content);
    border: 1px solid var(--border-subtle);
    border-radius: 0.75rem;
    padding: 1.75rem;
}

.form-section {
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

.form-section--last {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.form-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #8a93a3;
    margin-bottom: 0.85rem;
}

.form-section .form-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: #495057;
    margin-bottom: 0.3rem;
}

.form-section .form-control,
.form-section .form-select,
.form-section .btn-outline-secondary {
    font-size: 0.9rem;
}

.patient-photo-preview-box {
    width: 96px;
    height: 96px;
    flex-shrink: 0;
    border-radius: 0.75rem;
    background: #e9ecef;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.patient-photo-preview-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.patient-photo-preview-placeholder {
    color: #adb5bd;
    display: flex;
    align-items: center;
    justify-content: center;
}

.promo-card {
    background: var(--brand-50);
    border: 1px solid var(--border-subtle);
    border-radius: 1rem;
    padding: 1.5rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.75rem;
}

/* Keep the create/registration modals (pacientes, valoraciones, empleados)
   usable on short viewports: cap the dialog to the viewport height so the
   header/footer stay visible and only the body scrolls.

   These modals wrap .modal-body and .modal-footer in a <form>, so that
   <form> -- not modal-body/-footer directly -- is the flex item Bootstrap's
   .modal-content expects. Without turning the form into the flex container,
   the body/footer "flex" rules never apply, the body never shrinks, and it
   just grows past modal-content's max-height (overflow:hidden then hides
   the footer instead of showing a scrollbar). */
.modal-dialog-scrollable {
    max-height: calc(100vh - 3.5rem);
}

.modal-dialog-scrollable .modal-content {
    max-height: calc(100vh - 3.5rem);
}

.modal-dialog-scrollable .modal-content > form {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.modal-dialog-scrollable .modal-body {
    min-height: 0;
}

/* FullCalendar's time-grid view only lays the time + patient name out on
   one line (fc-event-main-frame row layout, smaller title font, "time -
   title" separator) for appointments it judges "short" relative to their
   rendered block height. Taller blocks (e.g. a 45min appointment) get the
   default stacked layout instead: time on its own line, title wrapped
   below. That made appointments of different durations look inconsistent
   within the same day. Force the single-line "short" layout for every
   appointment regardless of duration/block height -- but only in the Día
   view (.fc-timeGridDay-view), since the week view's narrower day columns
   don't have room for a one-line title and need it wrapped onto a 2nd
   line instead. */
.fc-timeGridDay-view .fc-timegrid-event .fc-event-main-frame {
    flex-direction: row;
    overflow: hidden;
}

.fc-timeGridDay-view .fc-timegrid-event .fc-event-time:after {
    content: "\00a0-\00a0";
}

.fc-timeGridDay-view .fc-timegrid-event .fc-event-title {
    font-size: var(--fc-small-font-size, 0.85em);
}

/* Inverse problem in the Semana view: its narrow day columns can't fit
   "time - title" on one line, so FullCalendar's "short event" class
   truncates the patient name (e.g. "Alfredo..." cut off) instead of
   wrapping it. Force the stacked layout -- time on its own line, title
   below -- for every appointment there, undoing the short-event row
   layout regardless of block height. Even stacked, the block often isn't
   tall enough for both the "9:30 - 10:15" time line and a 2-line wrapped
   name, so the name still gets clipped. Drop the time line entirely in
   this view and give that vertical space to the name instead -- the
   appointment's time is still visible via the day view/tooltip. */
.fc-timeGridWeek-view .fc-timegrid-event .fc-event-main-frame {
    flex-direction: column;
}

.fc-timeGridWeek-view .fc-timegrid-event .fc-event-time {
    display: none;
}

/* FullCalendar's short-event class also drives font-size, independently
   of the row/column layout above: short appointments (e.g. a 30min
   Valoracion) get --fc-small-font-size while taller ones (e.g. a 45min
   Terapia) keep the larger default, so the same patient name renders at
   two different sizes depending on appointment type/duration. Force the
   smaller size for every appointment so all names match. */
.fc-timeGridWeek-view .fc-timegrid-event .fc-event-title {
    font-size: var(--fc-small-font-size, 0.85em);
}
