/* ============================================================
   UI/UX Pro Max improvements for clinic app
   Addresses: focus states, reduced-motion, status badge
   accessibility (color-not-only), empty states, loading
   buttons. Loaded after style.css so it wins on equal ties.
   ============================================================ */

/* --- 1. Focus states (CRITICAL: keyboard nav) --------------
   The old sheet only styled .form-control:focus. Buttons,
   links, nav items and table rows had no visible focus ring,
   so keyboard users could not tell where they were.        */
:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
    border-radius: 6px;
}

/* Bootstrap's own .btn uses box-shadow for focus; give it a
   ring instead so it works on dark sidebar items too.        */
.btn:focus-visible,
.sidebar-link:focus-visible,
.nav-link:focus-visible,
.page-link:focus-visible,
.dropdown-item:focus-visible {
    outline: 3px solid var(--primary-light);
    outline-offset: 2px;
    box-shadow: none;
}

/* Dark sidebar: light ring shows up against #0f172a. The saturated shop nav is the
   same problem: --primary-light on --primary is ~1.5:1, so cover both dark surfaces
   and saturated brand fills with one light ring.                            */
.sidebar .sidebar-link:focus-visible,
.sidebar a:focus-visible,
.sidebar button:focus-visible,
.shop-nav :focus-visible {
    outline-color: #7dd3fc;
}

/* Skip link for keyboard users — hidden until focused.       */
.skip-link {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 2000;
    background: var(--primary);
    color: #fff;
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    box-shadow: var(--shadow);
}
.skip-link:not(:focus) {
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* --- 2. Reduced motion --------------------------------------
   The hover transforms and entrance animations must respect
   the user's OS-level reduced-motion setting.                */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    .stat-card:hover,
    .product-card:hover,
    .btn:hover,
    .btn-primary-custom:hover,
    .captcha-img:hover { box-shadow: none; border-color: var(--border-strong); }
}

/* --- 3. Status badges: color + text, not color alone --------
   Statuses in dashboard tables were colored backgrounds only.
   Add a leading dot/icon so meaning survives without color
   (colorblind users, grayscale printing).                    */
.badge.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4em 0.75em;
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-size: 0.72rem;
    white-space: nowrap;
}
.badge.status-badge::before {
    content: "";
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: currentColor;
    flex: 0 0 auto;
}
/* Keep Bootstrap's bg-* colors but make the dot inherit the
   badge's own text color so it tracks the semantic state.     */
.badge.status-badge.bg-warning { color: #92400e; }
.badge.status-badge.bg-info    { color: #075985; }
.badge.status-badge.bg-success { color: #065f46; }
.badge.status-badge.bg-danger  { color: #991b1b; }
.badge.status-badge.bg-primary { color: #fff; }
.badge.status-badge.bg-secondary { color: #475569; }

/* --- 4. Loading state on submit buttons ---------------------
   Prevents double-submits and gives immediate feedback per
   the skill's submit-feedback rule. Usage in PHP:
   <button class="btn btn-primary" data-loading>
   ... then JS in main.js toggles .is-loading on submit.       */
.btn.is-loading,
.btn-hero.is-loading,
.btn-primary-custom.is-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}
.btn.is-loading::after,
.btn-hero.is-loading::after,
.btn-primary-custom.is-loading::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 1.1rem;
    height: 1.1rem;
    border: 2.5px solid rgba(255,255,255,0.45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
}
@keyframes btn-spin {
    to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
    .btn.is-loading::after { animation-duration: 1.6s; }
}

/* --- 5. Empty states -----------------------------------------
   List pages show a bare table when there is no data.
   A friendly empty state with an action is better.          */
.empty-state {
    text-align: center;
    padding: 2.75rem 1.5rem;
    color: var(--secondary);
}
.empty-state .empty-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 0.9rem;
    border-radius: 16px;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}
.empty-state .empty-title {
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 0.3rem;
}
.empty-state .empty-text {
    font-size: 0.9rem;
    margin-bottom: 1.15rem;
}

/* --- 6. Table header accessibility --------------------------
   Data tables need column scope so screen readers announce
   headers when moving through cells.                         */
.table thead th {
    font-weight: 700;
    color: var(--secondary);
    white-space: nowrap;
}

/* --- 7. Cursor + touch affordances -------------------------- */
.btn,
.page-link,
.captcha-img,
[role="button"] { cursor: pointer; }

/* Password show/hide toggle for the auth pages. The field is a
   .form-floating, so the button sits inside it, pinned to the
   far (left, in RTL) edge of the input and clear of the label.  */
.password-toggle {
    position: absolute;
    top: 50%;
    left: 0.6rem;
    transform: translateY(-50%);
    z-index: 5;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--secondary);
    border-radius: var(--radius-sm);
}
.password-toggle:hover { color: var(--primary); }
/* The toggle has to sit outside the padding the typed characters
   run into, or a long password disappears behind the eye. The
   button is 44px wide at a 0.6rem inset, so it intrudes to 53.6px;
   3rem (48px) was not enough and clipped the tail of a long value.
   The label spans the full width in both its floated and unfloated
   states, so it gets the same inset.                            */
.form-floating:has(> .password-toggle) .form-control,
.form-floating:has(> .password-toggle) > label {
    padding-left: 3.75rem;
}

/* Small screens: keep row-hover off (it implies pointer), and
   make sure the table doesn't shrink below readable size.     */
@media (max-width: 767px) {
    .table { min-width: 560px; }
}
