/* =============================================================================
   AQ Journey: shared UX components for the admin/partner journey
   - Top progress bar (page navigation feedback)
   - Toast notifications (success / error / warning / info)
   - Confirmation modal (destructive action gate)
   - Full-page loading overlay
   ============================================================================= */

:root {
    --aq-journey-primary: var(--Primary-500, #6A5D8B);
    --aq-journey-primary-dark: #5a4e7a;
    --aq-journey-success: #10B981;
    --aq-journey-success-bg: #ECFDF5;
    --aq-journey-error: #DB3A34;
    --aq-journey-error-bg: #FEF2F2;
    --aq-journey-warning: #F59E0B;
    --aq-journey-warning-bg: #FFFBEB;
    --aq-journey-info: #3B82F6;
    --aq-journey-info-bg: #EFF6FF;
    --aq-journey-z-progress: 9998;
    --aq-journey-z-toast: 9999;
    --aq-journey-z-overlay: 10000;
    --aq-journey-z-modal: 10001;
}

/* ─────────────────────────────────────────────────────────
   1) Top Progress Bar — slim coloured bar across page top
   ───────────────────────────────────────────────────────── */
.aq-progress-bar {
    position: fixed;
    top: 0;
    inset-inline-start: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--aq-journey-primary) 0%, #9A8BB7 50%, var(--aq-journey-primary) 100%);
    background-size: 200% 100%;
    z-index: var(--aq-journey-z-progress);
    pointer-events: none;
    transition: width 0.18s ease-out, opacity 0.3s ease;
    box-shadow: 0 0 8px rgba(106, 93, 139, 0.45);
    opacity: 0;
}

.aq-progress-bar.is-active {
    opacity: 1;
    animation: aq-progress-shimmer 1.4s linear infinite;
}

.aq-progress-bar.is-finishing {
    width: 100% !important;
    opacity: 0;
    transition: width 0.2s ease-out, opacity 0.4s ease 0.15s;
}

@keyframes aq-progress-shimmer {
    0%   { background-position: 100% 50%; }
    100% { background-position: -100% 50%; }
}

/* Make the progress bar a touch more visible (was 3px) so users notice navigation. */
.aq-progress-bar {
    height: 4px;
}

/* ─────────────────────────────────────────────────────────
   1.b) Side-menu navigation feedback — instant in-place spinner
   When a sidebar item is clicked, JS adds `.aq-nav-loading` so the
   user gets immediate visual confirmation that the click registered,
   even before the next page begins to render.
   ───────────────────────────────────────────────────────── */
.aq-nav-loading {
    position: relative;
    pointer-events: none;
}

.aq-nav-loading::after {
    content: "";
    position: absolute;
    inset-inline-end: 12px;
    top: 50%;
    width: 14px;
    height: 14px;
    margin-top: -7px;
    border: 2px solid rgba(106, 93, 139, 0.25);
    border-top-color: var(--aq-journey-primary);
    border-radius: 50%;
    animation: aq-nav-spin 0.7s linear infinite;
    z-index: 2;
}

/* While loading, give the tile the active visual (purple wash + bold accent) so the
   user sees their selection take effect immediately. */
.aq-nav-loading {
    background: var(--Primary-50, #F3F2F6) !important;
    border-inline-start: 3px solid var(--aq-journey-primary) !important;
    box-shadow: 0 1px 2px rgba(106, 93, 139, 0.08) !important;
}

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

/* Simple full-page loader — same visual as header account switching. */
.aqr-switch-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
}

.aqr-switch-overlay__spinner {
    width: 44px;
    height: 44px;
    border: 4px solid #e0d9f0;
    border-top-color: #6A5D8B;
    border-radius: 50%;
    animation: aqr-switch-spin 0.7s linear infinite;
}

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

/* ─────────────────────────────────────────────────────────
   2) Toast Notifications — top-end of viewport, stack vertically
   ───────────────────────────────────────────────────────── */
.aq-toast-container {
    position: fixed;
    top: 24px;
    inset-inline-end: 24px;
    z-index: var(--aq-journey-z-toast);
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
    width: calc(100vw - 48px);
    pointer-events: none;
}

.aq-toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid #E5E7EB;
    border-inline-start: 4px solid var(--aq-journey-primary);
    border-radius: 10px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 4px 8px -2px rgba(0, 0, 0, 0.06);
    animation: aq-toast-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.aq-toast.is-leaving {
    animation: aq-toast-out 0.25s ease-in forwards;
}

[dir="rtl"] .aq-toast {
    animation-name: aq-toast-in-rtl;
}

[dir="rtl"] .aq-toast.is-leaving {
    animation-name: aq-toast-out-rtl;
}

@keyframes aq-toast-in {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes aq-toast-out {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(20px); }
}
@keyframes aq-toast-in-rtl {
    from { opacity: 0; transform: translateX(-20px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes aq-toast-out-rtl {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(-20px); }
}

/* Type-specific accents */
.aq-toast--success { border-inline-start-color: var(--aq-journey-success); }
.aq-toast--error   { border-inline-start-color: var(--aq-journey-error); }
.aq-toast--warning { border-inline-start-color: var(--aq-journey-warning); }
.aq-toast--info    { border-inline-start-color: var(--aq-journey-info); }

.aq-toast__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 1px;
}

.aq-toast--success .aq-toast__icon { background: var(--aq-journey-success-bg); color: var(--aq-journey-success); }
.aq-toast--error   .aq-toast__icon { background: var(--aq-journey-error-bg);   color: var(--aq-journey-error); }
.aq-toast--warning .aq-toast__icon { background: var(--aq-journey-warning-bg); color: var(--aq-journey-warning); }
.aq-toast--info    .aq-toast__icon { background: var(--aq-journey-info-bg);    color: var(--aq-journey-info); }

.aq-toast__icon svg { width: 14px; height: 14px; }

.aq-toast__body {
    flex: 1 1 auto;
    min-width: 0;
}

.aq-toast__title {
    font-size: 13.5px;
    font-weight: 700;
    color: #111827;
    line-height: 1.3;
    margin: 0 0 2px 0;
}

.aq-toast__message {
    font-size: 12.5px;
    color: #4B5563;
    line-height: 1.45;
    margin: 0;
    word-break: break-word;
}

.aq-toast__close {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    background: transparent;
    border: none;
    color: #9CA3AF;
    cursor: pointer;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s ease, color 0.15s ease;
}

.aq-toast__close:hover {
    background: #F3F4F6;
    color: #111827;
}

.aq-toast__close svg { width: 14px; height: 14px; }

/* Auto-dismiss progress strip */
.aq-toast__progress {
    position: absolute;
    bottom: 0;
    inset-inline-start: 0;
    height: 2px;
    background: currentColor;
    opacity: 0.35;
    width: 100%;
    transform-origin: left;
    animation: aq-toast-progress linear forwards;
}

[dir="rtl"] .aq-toast__progress {
    transform-origin: right;
}

.aq-toast--success .aq-toast__progress { color: var(--aq-journey-success); }
.aq-toast--error   .aq-toast__progress { color: var(--aq-journey-error); }
.aq-toast--warning .aq-toast__progress { color: var(--aq-journey-warning); }
.aq-toast--info    .aq-toast__progress { color: var(--aq-journey-info); }

@keyframes aq-toast-progress {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

/* ─────────────────────────────────────────────────────────
   3) Confirmation Modal — centered dialog with backdrop
   ───────────────────────────────────────────────────────── */
.aq-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: var(--aq-journey-z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: aq-fade-in 0.2s ease-out;
}

.aq-modal-backdrop.is-leaving {
    animation: aq-fade-out 0.18s ease-in forwards;
}

@keyframes aq-fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes aq-fade-out { from { opacity: 1; } to { opacity: 0; } }

.aq-modal {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 440px;
    overflow: hidden;
    animation: aq-modal-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.aq-modal-backdrop.is-leaving .aq-modal {
    animation: aq-modal-out 0.18s ease-in forwards;
}

@keyframes aq-modal-in  {
    from { opacity: 0; transform: scale(0.94) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes aq-modal-out {
    from { opacity: 1; transform: scale(1) translateY(0); }
    to   { opacity: 0; transform: scale(0.96) translateY(4px); }
}

.aq-modal__header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 22px 24px 14px;
}

.aq-modal__icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--aq-journey-warning-bg);
    color: var(--aq-journey-warning);
}

.aq-modal--danger .aq-modal__icon  { background: var(--aq-journey-error-bg);   color: var(--aq-journey-error); }
.aq-modal--success .aq-modal__icon { background: var(--aq-journey-success-bg); color: var(--aq-journey-success); }
.aq-modal--info .aq-modal__icon    { background: var(--aq-journey-info-bg);    color: var(--aq-journey-info); }

.aq-modal__icon svg { width: 22px; height: 22px; }

.aq-modal__title {
    font-size: 17px;
    font-weight: 700;
    color: #111827;
    margin: 0;
    line-height: 1.3;
}

.aq-modal__body {
    padding: 0 24px 22px;
    font-size: 14px;
    color: #4B5563;
    line-height: 1.55;
}

.aq-modal__footer {
    display: flex;
    gap: 10px;
    padding: 16px 24px;
    background: #F9FAFB;
    border-top: 1px solid #F0F0F2;
    justify-content: flex-end;
}

[dir="rtl"] .aq-modal__footer {
    flex-direction: row-reverse;
}

.aq-modal__btn {
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    font-family: inherit;
    min-width: 92px;
}

.aq-modal__btn--cancel {
    background: #fff;
    color: #374151;
    border-color: #D1D5DB;
}
.aq-modal__btn--cancel:hover {
    background: #F3F4F6;
    border-color: #9CA3AF;
}

.aq-modal__btn--confirm {
    background: var(--aq-journey-primary);
    color: #fff;
    border-color: var(--aq-journey-primary);
}
.aq-modal__btn--confirm:hover {
    background: var(--aq-journey-primary-dark);
    border-color: var(--aq-journey-primary-dark);
}

.aq-modal--danger .aq-modal__btn--confirm {
    background: var(--aq-journey-error);
    border-color: var(--aq-journey-error);
}
.aq-modal--danger .aq-modal__btn--confirm:hover {
    background: #B82E29;
    border-color: #B82E29;
}

/* ─────────────────────────────────────────────────────────
   4) Full-page Loading Overlay
   ───────────────────────────────────────────────────────── */
.aq-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.78);
    backdrop-filter: blur(1.5px);
    -webkit-backdrop-filter: blur(1.5px);
    z-index: var(--aq-journey-z-overlay);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    animation: aq-fade-in 0.18s ease-out;
}

.aq-loading-overlay.is-leaving {
    animation: aq-fade-out 0.18s ease-in forwards;
}

.aq-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid #E5E7EB;
    border-top-color: var(--aq-journey-primary);
    border-radius: 50%;
    animation: aq-spin 0.8s linear infinite;
}

.aq-spinner--sm {
    width: 22px;
    height: 22px;
    border-width: 3px;
}

.aq-loading-overlay__text {
    font-size: 14px;
    color: #374151;
    font-weight: 500;
    letter-spacing: 0.2px;
}

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

/* ─────────────────────────────────────────────────────────
   5) Inline section skeletons (when content is loading inside a card)
   ───────────────────────────────────────────────────────── */
.aq-skeleton {
    display: block;
    background: linear-gradient(90deg, #F3F4F6 25%, #E5E7EB 50%, #F3F4F6 75%);
    background-size: 200% 100%;
    border-radius: 6px;
    animation: aq-skeleton-pulse 1.4s ease-in-out infinite;
}

.aq-skeleton--text  { height: 14px; width: 100%; margin: 4px 0; }
.aq-skeleton--title { height: 20px; width: 60%; }
.aq-skeleton--card  { height: 80px; width: 100%; }

@keyframes aq-skeleton-pulse {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ─────────────────────────────────────────────────────────
   Responsive tweaks
   ───────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .aq-toast-container {
        top: 12px;
        inset-inline-end: 12px;
        max-width: calc(100vw - 24px);
    }
    .aq-modal {
        max-width: 100%;
    }
    .aq-modal__footer {
        flex-direction: column-reverse;
    }
    [dir="rtl"] .aq-modal__footer {
        flex-direction: column-reverse;
    }
    .aq-modal__btn {
        width: 100%;
    }
}
