/* ==========================================================================
   Recordatio - Mobile-first stylesheet
   --------------------------------------------------------------------------
   Design approach (user-centric, mobile-first):
   1. Styles are written for small screens (phones) FIRST. Larger breakpoints
      (tablet >= 700px, desktop >= 1024px) progressively ENHANCE the layout
      using min-width media queries, instead of the old approach of designing
      for desktop and squeezing things down.
   2. Every interactive element (links, buttons, checkboxes, form fields)
      respects a minimum touch target of ~44x44px, per WCAG / mobile HIG
      guidance, so it's comfortable to tap on a phone/tablet.
   3. Form inputs use font-size: 16px (or larger) to prevent iOS Safari from
      automatically zooming in when a field is focused.
   4. Data tables collapse into stacked "cards" on narrow screens (see the
      ".table-responsive" rules) so users don't have to scroll horizontally
      to read appointment/client/reminder data on a phone.
   5. The top navigation collapses into a hamburger-triggered menu below the
      tablet breakpoint, and expands into a normal horizontal bar on larger
      screens (see nav.js for the toggle behaviour).
   ========================================================================== */

/* -------------------------------------------------------------------------
   0. CSS variables - central place to tweak the theme
   ------------------------------------------------------------------------- */
:root {
    --color-brand: #1FA855;        /* WhatsApp-inspired green, slightly deeper for better contrast on white text */
    --color-brand-dark: #178443;
    --color-brand-light: #e8f7ee;  /* tint for subtle highlights/active states */
    --color-text: #1c1e21;
    --color-muted: #6b7280;
    --color-bg: #f6f7f8;
    --color-card-bg: #fff;
    --color-border: #e2e4e8;
    --color-secondary: #6c757d;
    --color-secondary-dark: #565e64;
    --color-danger: #d64545;
    --color-danger-dark: #b53838;
    --radius: 10px;
    --radius-sm: 6px;
    --spacing-1: 0.5rem;
    --spacing-2: 1rem;
    --spacing-3: 1.5rem;
    --spacing-4: 2rem;
    --touch-target: 44px; /* minimum comfortable tap size */
    --shadow-card: 0 1px 3px rgba(20, 20, 30, 0.06), 0 1px 2px rgba(20, 20, 30, 0.04);
}

/* -------------------------------------------------------------------------
   1. Reset & base (mobile-first defaults)
   ------------------------------------------------------------------------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    /* Prevents the classic mobile-browser "text auto-resize" surprise */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-bg);
    /* Fluid base font size: never smaller than 15px, never larger than 16px */
    font-size: clamp(15px, 2.5vw, 16px);
}

a {
    color: var(--color-brand-dark);
}

/* Consistent, visible focus ring for keyboard/assistive-tech users across
   links, buttons and form controls (native outlines vary wildly by browser). */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--color-brand-dark);
    outline-offset: 2px;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    /* Small horizontal padding on phones so content doesn't touch the edges */
    padding: 0 var(--spacing-2);
}

/* -------------------------------------------------------------------------
   2. Header & responsive navigation
   ------------------------------------------------------------------------- */
.header {
    background: var(--color-brand);
    color: #fff;
    padding: var(--spacing-2) 0;
    margin-bottom: var(--spacing-3);
}

.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-2);
}

.header h1 {
    font-size: 1.15rem;
    line-height: 1.3;
    /* Keep long business names from wrapping the header into 3 lines on phones */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header .brand {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.75;
    margin-bottom: 0.1rem;
}

.brand-logo {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    background: #fff;
    padding: 2px;
    vertical-align: -3px;
}

/* Hamburger button: only meaningful/visible on small screens */
.nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--touch-target);
    height: var(--touch-target);
    background: rgba(255, 255, 255, 0.15);
    border: none;
    border-radius: 6px;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    flex-shrink: 0;
}

/* Groups the clock and hamburger together on the right so the layout stays
   a simple two-item flex (title on the left, everything else on the right)
   regardless of viewport width. */
.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-2);
    flex-shrink: 0;
}

/* Running clock (see clock.js): kept compact and secondary in weight/size
   so it stays "large and visible" without competing with the business name
   for attention. font-variant-numeric keeps the digits from jittering the
   layout width as seconds tick over. */
.header-clock {
    text-align: right;
    line-height: 1.15;
}

.header-clock__time {
    display: block;
    font-size: 1.05rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.header-clock__date {
    display: block;
    font-size: 0.65rem;
    font-weight: 500;
    text-transform: capitalize;
    opacity: 0.8;
    white-space: nowrap;
}

.header-clock__tier {
    display: inline-block;
    margin-top: 0.2rem;
    padding: 0.1rem 0.5rem;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
    color: #fff;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 999px;
}

.support-banner {
    padding: 0.4rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #664d03;
    background: #fff3cd;
    border-bottom: 1px solid #ffe69c;
}

.support-banner a {
    color: #664d03;
    text-decoration: underline;
}

.usage-banner {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    margin-bottom: var(--spacing-3);
    font-size: 0.9rem;
    font-weight: 600;
    border-bottom: 1px solid transparent;
}

/* The banner sits flush against the header (no gray body background
   showing through the gap) - move .header's normal bottom margin onto
   the banner itself instead, only when a banner is actually present. */
.header:has(+ .usage-banner) {
    margin-bottom: 0;
}

.usage-banner__icon {
    font-size: 1.1rem;
    line-height: 1;
}

.usage-banner--yellow {
    color: #664d03;
    background: #fff3cd;
    border-bottom-color: #ffe69c;
}

.usage-banner--orange {
    color: #7a3b00;
    background: #ffe1b3;
    border-bottom-color: #ffc266;
}

.usage-banner--red {
    color: #ffffff;
    background: #c0392b;
    border-bottom-color: #922b21;
}

.usage-banner--red a {
    color: #ffffff;
    text-decoration: underline;
    font-weight: 700;
}

.header-employee-badge {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.1rem 0.5rem;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #fff;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    vertical-align: middle;
}

.nav-toggle:hover,
.nav-toggle:focus-visible {
    background: rgba(255, 255, 255, 0.3);
}

/* Mobile nav: hidden by default, expands as a full-width dropdown */
.nav {
    display: none;
    flex-direction: column;
    gap: var(--spacing-1);
    margin-top: var(--spacing-2);
    width: 100%;
}

.nav.is-open {
    display: flex;
}

.nav a {
    color: #fff;
    text-decoration: none;
    padding: var(--spacing-1) var(--spacing-2);
    background: rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    min-height: var(--touch-target);
    display: flex;
    align-items: center;
}

.nav a:hover,
.nav a:focus-visible {
    background: rgba(255, 255, 255, 0.3);
}

/* Highlights the current section so users always know where they are */
.nav a.is-active {
    background: #fff;
    color: var(--color-brand-dark);
    font-weight: 600;
}

.nav a.is-active:hover,
.nav a.is-active:focus-visible {
    background: #fff;
}

/* Tablet and up: show the nav inline and hide the hamburger */
@media (min-width: 700px) {
    .nav-toggle {
        display: none;
    }

    .header-bar {
        flex-wrap: wrap;
    }

    .nav {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        width: auto;
        margin-top: 0;
    }

    .nav a {
        min-height: auto;
    }

    .header h1 {
        font-size: 1.5rem;
        white-space: normal;
    }

    /* More breathing room on tablet/desktop, so the clock can be genuinely
       "large and visible" without crowding the business name or nav. */
    .header-clock__time {
        font-size: 1.75rem;
    }

    .header-clock__date {
        font-size: 0.85rem;
    }
}

/* -------------------------------------------------------------------------
   3. Cards, messages, generic layout helpers
   ------------------------------------------------------------------------- */
.card {
    background: var(--color-card-bg);
    padding: var(--spacing-2);
    margin-bottom: var(--spacing-3);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--color-border);
}

@media (min-width: 700px) {
    .card {
        padding: var(--spacing-4);
    }
}

.card-narrow {
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.messages {
    margin-bottom: var(--spacing-2);
}

.message {
    padding: var(--spacing-2);
    margin-bottom: var(--spacing-1);
    border-radius: 6px;
}

.message.success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.message.error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.message.warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }

.text-muted { color: var(--color-muted); }
.text-center { text-align: center; }

.empty-state {
    color: var(--color-muted);
    text-align: center;
    padding: var(--spacing-4) var(--spacing-2);
}

.empty-state .empty-state-icon {
    display: block;
    font-size: 2rem;
    margin-bottom: var(--spacing-1);
    opacity: 0.8;
}

/* -------------------------------------------------------------------------
   3b. Quick-glance stat cards (dashboard)
   ------------------------------------------------------------------------- */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-2);
    margin-bottom: var(--spacing-3);
}

@media (min-width: 480px) {
    .stat-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.stat-card {
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--spacing-2);
    box-shadow: var(--shadow-card);
    border-left: 4px solid var(--color-brand);
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--color-text);
}

.stat-card .stat-label {
    color: var(--color-muted);
    font-size: 0.85rem;
}

/* Generic flex helpers, replacing scattered inline styles */
.stack {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-2);
}

.cluster {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--spacing-1);
}

.toolbar {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-2);
    margin-bottom: var(--spacing-2);
}

@media (min-width: 700px) {
    .toolbar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.form-actions {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-2);
    margin-top: var(--spacing-2);
}

@media (min-width: 480px) {
    .form-actions {
        flex-direction: row;
    }
}

.note-box {
    padding: var(--spacing-2);
    border-radius: 6px;
    margin-bottom: var(--spacing-3);
}

.note-box--info { background: #e7f3ff; }
.note-box--warning { background: #fff3cd; border: 1px solid #ffeeba; color: #856404; }
.note-box--muted { background: #f8f9fa; border: 1px solid #dee2e6; }

/* -------------------------------------------------------------------------
   4. Forms - touch-friendly, full-width on phones
   ------------------------------------------------------------------------- */
.form-group {
    margin-bottom: var(--spacing-2);
    position: relative; /* anchors the client-search dropdown, see forms.js */
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-1);
    font-weight: bold;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: var(--spacing-1) 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    /* 16px stops iOS Safari from zooming the page in on focus */
    font-size: 16px;
    min-height: var(--touch-target);
    font-family: inherit;
}

.form-group input[type="checkbox"] {
    width: auto;
    min-height: auto;
    /* Larger checkbox hit-area for touch, without changing the visual size much */
    width: 1.25rem;
    height: 1.25rem;
    margin-right: var(--spacing-1);
}

/* Same look as .form-group input/select/textarea (rounded, comfortable
   padding, touch-target height) for inputs that live outside a .form-group
   wrapper - e.g. inline edit-in-place controls in a table cell - without
   forcing width: 100% (which would fight a fixed/flex-driven width). */
.text-input {
    padding: var(--spacing-1) 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 16px;
    min-height: var(--touch-target);
    font-family: inherit;
}

/* Opening/closing-time hour+minute picker (reminder_policy.html) - overrides
   the generic full-width .form-group select above so the 4 selects (hour,
   minute, hour, minute) sit on a single row instead of each wrapping onto
   its own line. */
.form-group select.time-select {
    width: auto;
    min-width: 3.5rem;
    flex: 0 1 auto;
}

.checkbox-row {
    display: flex;
    align-items: center;
    font-weight: normal;
    /* Ensures the whole row (not just the tiny checkbox) is tappable */
    min-height: var(--touch-target);
    padding: var(--spacing-1) 0;
}

/* Time picker: pre-defined slot chips, used on every screen size (the
   native <input type="time"> picker is inconvenient on many mobile
   browsers, so we use one consistent widget everywhere instead of
   switching between desktop/mobile pickers). Kept in sync with a hidden
   field via appointment_form.html's inline script. */
.time-picker-chips {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(4.5rem, 1fr));
    gap: var(--spacing-1);
    max-height: 14rem;
    overflow-y: auto;
    padding: var(--spacing-1);
    border: 1px solid var(--color-border);
    border-radius: 6px;
}

.time-chip {
    padding: 0.6rem 0.25rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: #fff;
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
    text-align: center;
    cursor: pointer;
    min-height: var(--touch-target);
}

.time-chip.is-selected {
    background: var(--color-brand);
    border-color: var(--color-brand);
    color: #fff;
    font-weight: 700;
}

@media (min-width: 700px) {
    .time-picker-chips {
        grid-template-columns: repeat(auto-fill, minmax(5rem, 1fr));
        max-height: 18rem;
    }
}

/* Slot-count hint: fades/slides in beneath the time-slot chips when there
   are already appointments at the selected date/time. Reuses the app's
   existing warning color language (see .note-box--warning) so it reads as
   an attention-worthy notice rather than plain muted text, without
   introducing a new visual style. Stays visible until the date or time
   selection changes. */
.slot-count-hint {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.6rem;
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    background: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
    font-size: 0.9rem;
    font-weight: 600;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.slot-count-hint.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Channel selector: WhatsApp vs SMS radio chips for appointment
   create/edit forms. */
.channel-selector {
    display: flex;
    gap: var(--spacing-2);
    flex-wrap: nowrap;
}

.channel-option {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    cursor: pointer;
    min-height: var(--touch-target);
    flex: 1 1 0;
    min-width: 0;
}

.channel-option:has(input:checked) {
    border-color: var(--color-brand);
    background: color-mix(in srgb, var(--color-brand) 10%, #fff);
    font-weight: 700;
}

/* -------------------------------------------------------------------------
   5. Buttons
   ------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    background: var(--color-brand);
    color: #fff;
    text-decoration: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1rem;
    min-height: var(--touch-target);
    text-align: center;
    transition: background-color 0.15s ease;
}

.btn:hover,
.btn:focus-visible {
    background: var(--color-brand-dark);
}

.btn-secondary { background: var(--color-secondary); }
.btn-secondary:hover,
.btn-secondary:focus-visible { background: var(--color-secondary-dark); }

.btn-danger { background: var(--color-danger); }
.btn-danger:hover,
.btn-danger:focus-visible { background: var(--color-danger-dark); }

.btn-sm {
    padding: var(--spacing-1) 0.75rem;
    font-size: 0.875rem;
    min-height: 36px;
}

.btn-block {
    width: 100%;
}

/* On very small phones, stack full-width primary actions for easy tapping */
@media (max-width: 479px) {
    .form-actions .btn {
        width: 100%;
    }
}

/* -------------------------------------------------------------------------
   6. Status badges
   ------------------------------------------------------------------------- */
.status {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    white-space: nowrap;
    text-decoration: none;
}

.status-scheduled { background: #d1ecf1; color: #0c5460; }
.status-sent { background: #d4edda; color: #155724; }
.status-delivered { background: #d6d8db; color: #383d41; }
.status-read { background: #cce5ff; color: #004085; }
.status-failed { background: #f8d7da; color: #721c24; }
.status-skipped { background: #ffc107; color: #856404; }
.status-cancelled { background: #6c757d; color: #fff; }
.status-no-show { background: #4a1418; color: #fff; }

/* Clickable pill linking to an appointment's reminders (appointment_list.html) -
   same pill shape as .status, but interactive (hover/focus), so it reads as
   a button rather than a static label. */
.reminder-count-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
    background: var(--color-brand-light);
    color: var(--color-brand-dark);
    border: 1px solid transparent;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.reminder-count-badge:hover,
.reminder-count-badge:focus-visible {
    background: var(--color-brand);
    color: #fff;
}

/* -------------------------------------------------------------------------
   6b. Pagination (clients/appointments list pages)
   ------------------------------------------------------------------------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.pagination .is-disabled {
    opacity: 0.5;
    pointer-events: none;
}

.pagination__status {
    color: var(--color-text-muted, #6c757d);
    font-size: 0.875rem;
}

/* -------------------------------------------------------------------------
   7. Responsive tables -> stacked cards on narrow screens
   --------------------------------------------------------------------------
   Usage: wrap the <table> in <div class="table-responsive"> and add a
   data-label="Column name" attribute to each <td>. Below 700px, the table
   loses its tabular layout and each <tr> becomes a small card where every
   cell shows its own label, so nothing needs to scroll horizontally.
   ------------------------------------------------------------------------- */
.table-responsive table {
    width: 100%;
    border-collapse: collapse;
}

.table-responsive th,
.table-responsive td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.table-responsive th { background: #f8f9fa; font-weight: bold; }

/* Appointment notes are already truncated server-side, but guard against
   long unbroken strings (no spaces) overflowing the cell/card on narrow
   screens. */
.notes-cell {
    max-width: 220px;
    overflow-wrap: break-word;
}

/* Employees table (employee_list.html): without this, the Teléfono column
   (2nd column - an inline input+button edit form) gets stretched by the
   table's own width: 100% and ends up wider than its content, leaving a
   visible gap before the Estado column. Shrinking it to its content's
   natural width (the classic "width: 1%" table trick) fixes that; only
   applied above the stacked-card breakpoint, where column widths stop
   mattering anyway. */
@media (min-width: 700px) {
    .employee-table td:nth-child(2),
    .employee-table th:nth-child(2) {
        width: 1%;
        white-space: nowrap;
    }

    /* .cluster normally allows wrapping (mobile-friendly), but that lets
       the table's width: 1% column-shrinking above consider the input+
       button wrappable and shrink the column down to just the button's
       width, pushing the input onto its own row. Force them to stay on
       one line only at this breakpoint, where the column-width fix above
       is also active - the mobile stacked-card view keeps wrapping. */
    .employee-table .phone-edit-form {
        flex-wrap: nowrap;
    }
}


@media (max-width: 699px) {
    .table-responsive thead {
        display: none; /* headers are replaced by per-cell data-label text */
    }

    .table-responsive table,
    .table-responsive tbody,
    .table-responsive tr,
    .table-responsive td {
        display: block;
        width: 100%;
    }

    .table-responsive tr {
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
        margin-bottom: var(--spacing-2);
        padding: var(--spacing-1) var(--spacing-2);
        background: var(--color-card-bg);
    }

    .table-responsive td {
        border-bottom: none;
        padding: 0.5rem 0;
        display: flex;
        flex-direction: column;
        gap: 0.15rem;
    }

    /* The label is injected via the data-label attribute set in the template */
    .table-responsive td[data-label]::before {
        content: attr(data-label);
        font-size: 0.75rem;
        font-weight: bold;
        text-transform: uppercase;
        color: var(--color-muted);
    }

    .table-responsive td:empty {
        display: none;
    }
}

/* -------------------------------------------------------------------------
   8. Client search dropdown (used on the appointment form)
   ------------------------------------------------------------------------- */
.client-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--color-border);
    border-top: none;
    max-height: 60vh; /* keeps the list usable on short mobile viewports */
    overflow-y: auto;
    display: none;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-radius: 0 0 6px 6px;
}

.client-search-results.active {
    display: block;
}

.client-result {
    padding: var(--spacing-2);
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-1);
    min-height: var(--touch-target);
}

.client-result:hover,
.client-result:focus-visible {
    background: #f8f9fa;
}

.client-result:last-child {
    border-bottom: none;
}

.no-results {
    padding: var(--spacing-2);
    color: var(--color-muted);
    text-align: center;
}

#client_search.has-selection {
    background-color: #d4edda;
    border-color: var(--color-brand);
}

/* -------------------------------------------------------------------------
   9. Login page
   ------------------------------------------------------------------------- */
.login-card {
    max-width: 400px;
    margin: var(--spacing-3) auto;
}

@media (min-width: 700px) {
    .login-card {
        margin: 4rem auto;
    }
}

/* -------------------------------------------------------------------------
   9. Support business switcher
   ------------------------------------------------------------------------- */
.support-business-search {
    position: relative;
    margin-bottom: 1.25rem;
}

.support-business-search-icon {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.5;
    pointer-events: none;
}

.support-business-search input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
}

.support-business-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-height: 3rem;
    transition: opacity 0.15s ease;
}

.support-business-list.is-loading {
    opacity: 0.5;
}

.support-business-row {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-card-bg);
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.support-business-row:hover {
    box-shadow: var(--shadow-card);
    border-color: var(--color-brand);
}

.support-business-avatar {
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background: var(--color-brand-light);
    color: var(--color-brand-dark);
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.support-business-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.support-business-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.15rem;
    font-size: 0.8rem;
    color: var(--color-muted);
}

.support-business-id {
    font-family: monospace;
}

.support-business-tier {
    padding: 0.05rem 0.5rem;
    border-radius: 999px;
    background: var(--color-brand-light);
    color: var(--color-brand-dark);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.7rem;
}

.support-business-action {
    flex-shrink: 0;
    margin: 0;
}

.support-business-empty {
    padding: var(--spacing-3);
    text-align: center;
    color: var(--color-muted);
}

/* -------------------------------------------------------------------------
   9. Weekly appointment calendar (mobile-first: stacked day cards below
      700px, 7-column grid at/above it - same breakpoint as .stat-grid)
   ------------------------------------------------------------------------- */
.week-nav {
    justify-content: center;
    margin-bottom: var(--spacing-2);
}

.week-range {
    text-align: center;
    margin-bottom: var(--spacing-2);
}

.week-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-2);
}

@media (min-width: 700px) {
    .week-grid {
        grid-template-columns: repeat(7, 1fr);
        gap: var(--spacing-1);
    }
}

.week-day {
    background: var(--color-card-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--spacing-2);
    min-width: 0;
}

.week-day.is-today {
    background: var(--color-brand-light);
    border-color: var(--color-brand);
}

.week-day-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text);
    padding-bottom: var(--spacing-1);
    margin-bottom: var(--spacing-1);
    border-bottom: 1px solid var(--color-border);
}

.week-day-date-bubble {
    display: inline-block;
    background: var(--color-brand-light);
    color: var(--color-brand-dark);
    border-radius: 999px;
    padding: 0.1rem 0.6rem;
    font-weight: 600;
    text-decoration: none;
    font-size: 0.8rem;
}

.week-day-date-bubble:hover,
.week-day-date-bubble:focus-visible {
    background: var(--color-brand);
    color: #fff;
}

.week-day.is-today .week-day-date-bubble {
    background: var(--color-brand);
    color: #fff;
}

.week-appt {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    padding: 0.3rem 0;
    font-size: 0.85rem;
}

.week-appt + .week-appt {
    border-top: 1px dashed var(--color-border);
}

.week-appt a {
    text-decoration: none;
}

.week-appt-time {
    font-weight: 600;
    white-space: nowrap;
}

.week-appt .status {
    padding: 0.1rem 0.45rem;
    font-size: 0.7rem;
    flex-shrink: 0;
}

.week-day-empty {
    color: var(--color-muted);
    font-size: 0.85rem;
    padding: 0.3rem 0;
}

/* -------------------------------------------------------------------------
   10. Row action menu (kebab menu tucking secondary row actions in tables,
       e.g. appointment_list.html, behind a single toggle instead of a
       growing row of buttons)
   ------------------------------------------------------------------------- */
.row-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-1);
    flex-wrap: wrap;
}

.row-menu {
    position: relative;
    display: inline-block;
}

.row-menu__toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--touch-target);
    min-height: var(--touch-target);
    background: var(--color-secondary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1.25rem;
    line-height: 1;
}

.row-menu__toggle:hover,
.row-menu__toggle:focus-visible {
    background: var(--color-secondary-dark);
}

.row-menu__panel {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.25rem;
    min-width: 180px;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    padding: var(--spacing-1) 0;
}

.row-menu.is-open .row-menu__panel {
    display: block;
}

/* Flipped variant: applied via JS (row-menu.js) when there isn't enough
   room below the toggle (e.g. the last row on a mobile screen) so the
   panel opens upward instead of off-screen. */
.row-menu__panel--above {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 0.25rem;
}

.row-menu__panel form {
    margin: 0;
}

.row-menu__item {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: var(--touch-target);
    padding: 0.5rem var(--spacing-2);
    background: none;
    border: none;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}

.row-menu__item:hover,
.row-menu__item:focus-visible {
    background: #f8f9fa;
}

.row-menu__item--danger {
    color: var(--color-danger);
}

/* -------------------------------------------------------------------------
   11. Confirmation dialog (replaces native confirm() popups, see
   confirm-modal.js)
   ------------------------------------------------------------------------- */
.confirm-dialog {
    width: min(90vw, 380px);
    margin: auto; /* keeps <dialog> centered across browsers */
    padding: var(--spacing-3);
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    background: var(--color-card-bg);
    color: var(--color-text);
}

.confirm-dialog::backdrop {
    background: rgba(20, 20, 30, 0.5);
}

.confirm-dialog__message {
    margin-bottom: var(--spacing-3);
}

.confirm-dialog__actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-1);
}

@media (max-width: 479px) {
    .confirm-dialog__actions {
        flex-direction: column;
    }

    .confirm-dialog__actions .btn {
        width: 100%;
    }
}

