/* ==========================================
   SalmasFlix — FAB (Floating Action Button)
   Extracted from components.css in Phase 7.2.

   Self-contained. Owns:
     - `.fab-container` positioning + snap / drag states
     - `.fab-main` button, spinning ring (::before), glow (::after)
     - `.fab-actions` expanded panel + directional variants
       (fab-top / fab-left) so the menu flips around the button
     - `.fab-action-icon` / `.fab-action-label` item chrome
     - Chat + main badges with pulse
     - FAB backdrop dim overlay
     - Phone compaction (≤600px)

   Depends on `@keyframes fadeIn` (defined in components.css) for the
   backdrop. Every accent uses theme tokens; only the "open" state uses
   literal red (#e74c3c / #c0392b) because it's the semantic "close/cancel"
   indicator (same red used by the call-decline button). That's an
   allowed literal per CLAUDE.md's standing rule ("red #ef4444 for
   danger / errors when semantic").
   ========================================== */

/* ==========================================
   @layer components — FAB container + actions + menu chrome.
   ========================================== */
@layer components {

.fab-container {
    position: fixed;
    /* Lift above iOS home indicator (env() is 0 elsewhere). */
    bottom: calc(40px + env(safe-area-inset-bottom, 0px));
    right: calc(24px + env(safe-area-inset-right, 0px));
    z-index: 1000;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    transition: none;
}
/* When the FAB drawer is expanded, raise the entire FAB cluster ABOVE
   the chat panel (which sits at z-index 1500). This way clicking the
   FAB while chat is open shows the Profile / Fit / Mood / Letter
   actions OVER the chat instead of buried behind it. The .fab-backdrop
   below also rises so the dimming applies to the chat panel too,
   reinforcing that the drawer is now the focused layer. */
.fab-container.open {
    z-index: 1600;
}

.fab-container.fab-snapping {
    transition: left 0.3s ease, right 0.3s ease, top 0.3s ease, bottom 0.3s ease;
}

/* Actions positioned absolutely so FAB button never moves */
.fab-actions {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
}

/* Default: right side, actions open upward */
.fab-actions {
    bottom: calc(100% + 12px);
    right: 0;
}

/* When near top, actions open downward with reversed order */
.fab-container.fab-top .fab-actions {
    bottom: auto;
    top: calc(100% + 12px);
    flex-direction: column-reverse;
}

/* Right side: label then icon (default) */
.fab-action {
    flex-direction: row;
}

/* Left side: flip to icon then label, align left */
.fab-container.fab-left .fab-actions {
    align-items: flex-start;
    right: auto;
    left: 0;
}

.fab-container.fab-left .fab-action {
    flex-direction: row-reverse;
}

.fab-container.fab-dragging .fab-main {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(var(--primary-rgb),0.6), 0 6px 28px rgba(var(--secondary-alt-rgb),0.5);
    cursor: grabbing;
}

.fab-container.fab-dragging .fab-main::before {
    animation-duration: 0.6s;
}

.fab-container.hidden {
    display: none;
}

.fab-main {
    /* Phase 8.7 touch target: bumped from 52px → 56px so it clears the
       WCAG 2.1 AA 44px floor + Apple's 44px guidance with the 2px rim
       the button carries. Visually the ring + glow pulse adds ~10px
       bloom so the optical size still reads "medium FAB". */
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 2px solid rgba(var(--primary-rgb),0.6);
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-size: 1.3rem;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(var(--primary-rgb),0.4), 0 0 15px rgba(var(--secondary-alt-rgb),0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease, border-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow: visible;
    z-index: 1;
}

/* Spinning ring (themed secondary) */
.fab-main::before {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    border: 2.5px solid transparent;
    border-top-color: var(--secondary);
    border-right-color: rgba(var(--secondary-rgb),0.3);
    border-bottom-color: rgba(var(--secondary-rgb),0.1);
    animation: fab-ring-spin 2s linear infinite;
    pointer-events: none;
    z-index: -1;
}

/* Pulsing glow */
.fab-main::after {
    content: '';
    position: absolute;
    inset: -10px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(var(--secondary-alt-rgb),0.25) 0%, rgba(var(--primary-rgb),0.1) 40%, transparent 70%);
    animation: fab-glow-pulse 3s ease-in-out infinite;
    pointer-events: none;
    z-index: -2;
}

@keyframes fab-ring-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes fab-glow-pulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.18); }
}

.fab-main:hover {
    box-shadow: 0 6px 28px rgba(var(--primary-rgb),0.5), 0 0 20px rgba(var(--secondary-alt-rgb),0.4);
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
}

.fab-main:active {
    transform: scale(0.95);
}

.fab-icon {
    transition: transform 0.3s ease;
    display: inline-block;
}

.fab-container.open .fab-icon {
    transform: rotate(45deg);
}

.fab-container.open .fab-main {
    background: linear-gradient(135deg, #c0392b, #e74c3c);
    border-color: rgba(231, 76, 60, 0.6);
    box-shadow: 0 4px 20px rgba(231, 76, 60, 0.4);
    color: #1a1a2e;
}

.fab-container.open .fab-main::before {
    border-top-color: #e74c3c;
    border-right-color: rgba(231, 76, 60, 0.3);
    border-bottom-color: transparent;
}

.fab-container.open .fab-main::after {
    background: radial-gradient(circle, rgba(231, 76, 60, 0.2) 0%, transparent 70%);
}

.fab-actions.hidden {
    display: none;
}

.fab-action {
    display: flex;
    align-items: center;
    gap: 10px;
    border: none;
    background: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    animation: fabPopIn 0.25s ease-out both;
}

.fab-action:nth-child(1) { animation-delay: 0.05s; }
.fab-action:nth-child(2) { animation-delay: 0.1s; }
.fab-action:nth-child(3) { animation-delay: 0.15s; }
.fab-action:nth-child(4) { animation-delay: 0.2s; }
.fab-action:nth-child(5) { animation-delay: 0.25s; }

.fab-action-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(25, 20, 50, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.55);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.fab-action-icon svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}
.fab-action:hover .fab-action-icon {
    color: rgba(255, 255, 255, 0.95);
    border-color: rgba(255, 255, 255, 0.25);
}

.fab-action-label {
    padding: 4px 12px;
    background: rgba(25, 20, 50, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 8px;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(var(--secondary-rgb),0.15);
    max-width: 60vw;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fab-action {
    position: relative;
}

.fab-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #e74c3c;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.5);
}

.fab-chat-badge.hidden {
    display: none;
}

/* Badge on the outer FAB main button */
.fab-main-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: #e74c3c;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.5);
    pointer-events: none;
    animation: fabBadgePulse 2s ease-in-out infinite;
}

.fab-main-badge.hidden {
    display: none;
}

@keyframes fabBadgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

@keyframes fabPopIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* FAB backdrop when open. z-index 1599 sits between the chat panel
   (1500) and the FAB drawer (1600), so when both are open the dim
   covers the chat too — reinforces that the FAB drawer is now the
   focused layer. Tap on the backdrop closes the drawer (handled in
   fab.ts) and brings chat back to front. */
.fab-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1599;
    background: rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.2s ease;
}

/* fadeIn keyframe shared with components.css. Local fallback so this file
   stands alone if components.css fails to load. */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* breakpoint snap 600px -> 768px (Phase 7.6 ladder) */
@media (max-width: 768px) {
    .fab-container {
        bottom: 32px;
        right: 16px;
    }
    /* Phase 8.7: keep the phone FAB ≥ 44px tap target. 52px clears that
       comfortably (was 50px — close enough to be nominally compliant,
       but the extra pair of pixels reduces mis-taps when the FAB is
       near the home-indicator safe-area band). */
    .fab-main {
        width: 52px;
        height: 52px;
        font-size: 1.2rem;
    }
    .fab-action-icon {
        /* 44px matches the WCAG 2.1 AA + Apple minimum. */
        width: 44px;
        height: 44px;
        font-size: 1rem;
    }
}

} /* end @layer components */
