/* ============================================
   FAB (FLOATING ACTION BUTTON) COMPONENT SYSTEM
   Unified mobile floating action menu
   No base class variants - single unified structure
   ============================================ */

/* ============================================
   Z-INDEX HIERARCHY (CRITICAL!)
   ============================================
   fab-backdrop:      1049  (lowest - behind everything)
   fab-container:     1050  (base container level)
   fab-main-button:   2     (relative to container)
   fab-menu-items:    1051  (above backdrop!)
   fab-badge/tooltip: 3     (relative - above main button)
   Bootstrap modals:  1055  (highest - above all FAB elements)
   ============================================ */

/* ============================================
   FAB CONTAINER
   Fixed position, mobile-only, animates on enter
   ============================================ */

.fab-container {
    position: fixed;
    bottom: var(--fab-position-bottom);
    right: var(--fab-position-right);
    z-index: var(--fab-z-container);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--fab-gap);
    animation: fabEnter 0.3s ease-out;
}

/* Hide on desktop (≥768px) - Mobile only */
@media (min-width: 768px) {
    .fab-container.d-md-none {
        display: none !important;
    }
}

/* Smaller screens adjustment */
@media (max-width: 380px) {
    .fab-container {
        bottom: var(--fab-position-bottom-sm);
        right: var(--fab-position-right-sm);
    }
}

/* FAB Enter Animation */
@keyframes fabEnter {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ============================================
   MAIN FAB BUTTON
   Circular button with icon, always visible
   ============================================ */

.fab-main-button {
    position: relative;
    width: var(--fab-main-size);
    height: var(--fab-main-size);
    border: var(--fab-border-width) solid var(--fab-border);
    border-radius: 50%;
    background: var(--fab-bg);
    backdrop-filter: blur(8px);
    color: var(--fab-color);
    font-size: var(--fab-main-font-size);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--fab-transition);
    box-shadow: var(--fab-shadow);
    z-index: 2; /* Relative to container */
    padding: 0;
}

.fab-main-button:hover {
    transform: scale(1.05);
    box-shadow: var(--fab-shadow-hover);
    background: rgba(255, 255, 255, 1);
}

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

/* Rotate icon when menu is active */
.fab-main-button.active i {
    transform: rotate(45deg);
}

.fab-main-button i {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Smaller main button on small screens */
@media (max-width: 380px) {
    .fab-main-button {
        width: 52px;
        height: 52px;
        font-size: 1.35rem;
    }
}

/* ============================================
   BACKDROP
   Covers screen when menu is open, clickable to close
   ============================================ */

.fab-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    z-index: var(--fab-z-backdrop);
    display: none;
    cursor: pointer;
}

.fab-backdrop.active {
    display: block;
}

/* ============================================
   MENU ITEMS CONTAINER
   Positions menu items above main button
   ============================================ */

.fab-menu-items {
    position: absolute;
    bottom: var(--fab-menu-bottom);
    left: 50%;
    transform: translateX(-50%); /* Center the menu items container */
    display: flex;
    flex-direction: column;
    align-items: center; /* Center items horizontally */
    gap: var(--fab-menu-gap);
    pointer-events: none; /* Prevent clicks when closed */
    z-index: var(--fab-z-menu); /* CRITICAL: Above backdrop! */
}

/* Enable pointer events when menu is active */
.fab-container.active .fab-menu-items {
    pointer-events: auto !important;
}

/* Adjust menu position on small screens */
@media (max-width: 380px) {
    .fab-menu-items {
        bottom: 64px;
    }
}

/* ============================================
   INDIVIDUAL MENU ITEM WRAPPER
   Contains label + button, hidden by default
   ============================================ */

.fab-menu-item {
    opacity: 0;
    transform: translateY(10px) scale(0.8);
    transition: var(--fab-transition);
    pointer-events: none;
    position: relative; /* For absolute positioning of label */
    display: flex;
    flex-direction: column; /* Stack vertically (but we'll position label absolutely) */
    align-items: center; /* Center the button */
}

/* Show menu items when active */
.fab-container.active .fab-menu-item {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto !important;
}

/* Staggered animation delays for cascade effect */
.fab-container.active .fab-menu-item:nth-child(1) {
    transition-delay: 0.05s;
}

.fab-container.active .fab-menu-item:nth-child(2) {
    transition-delay: 0.1s;
}

.fab-container.active .fab-menu-item:nth-child(3) {
    transition-delay: 0.15s;
}

.fab-container.active .fab-menu-item:nth-child(4) {
    transition-delay: 0.2s;
}

/* ============================================
   MENU BUTTON
   Individual action button in the menu
   ============================================ */

.fab-menu-button {
    position: relative;
    width: var(--fab-menu-size);
    height: var(--fab-menu-size);
    border: var(--fab-border-width) solid var(--fab-menu-border);
    border-radius: 50%;
    background: var(--fab-bg);
    backdrop-filter: blur(8px);
    color: var(--fab-menu-border);
    font-size: var(--fab-menu-font-size);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--fab-shadow);
    pointer-events: auto !important;
    padding: 0;
}

.fab-menu-button:hover {
    transform: scale(1.1);
    box-shadow: var(--fab-shadow-hover);
    background: rgba(255, 255, 255, 1);
    border-color: var(--fab-border);
    color: var(--fab-border);
}

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

.fab-menu-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Smaller menu buttons on small screens */
@media (max-width: 380px) {
    .fab-menu-button {
        width: 44px;
        height: 44px;
        font-size: 1.15rem;
    }
}

/* ============================================
   MENU LABEL
   Text label displayed next to menu button
   ============================================ */

.fab-menu-label {
    position: absolute;
    right: calc(100% + var(--spacing-3)); /* Position to left of button with gap */
    top: 50%; /* Vertically center */
    transform: translateY(-50%); /* Vertically center */
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: var(--spacing-2) var(--spacing-3);
    border-radius: var(--radius-md);
    font-size: var(--fab-label-font-size);
    font-weight: 500;
    white-space: nowrap;
    box-shadow: var(--fab-tooltip-shadow);
}

/* ============================================
   BADGES
   Notification badges on buttons
   ============================================ */

/* Badge on main button */
.fab-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: var(--red-600);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 3; /* Above main button */
}

/* Badge on menu button */
.fab-menu-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    background: var(--red-600);
    color: white;
    font-size: 0.625rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ============================================
   COUNTER
   Display counter below main button (e.g., "2/2")
   ============================================ */

.fab-counter {
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    font-size: var(--fab-counter-font-size);
    font-weight: 600;
    color: var(--slate-600);
    white-space: nowrap;
    pointer-events: none;
}

/* Counter at limit (red theme) */
.fab-counter-limit {
    color: var(--red-600);
}

/* ============================================
   TOOLTIP
   Shown on hover for disabled state or info
   ============================================ */

.fab-tooltip {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    padding: var(--spacing-2) var(--spacing-3);
    background: var(--slate-900);
    color: white;
    font-size: var(--fab-label-font-size);
    font-weight: 500;
    border-radius: var(--radius-md);
    white-space: nowrap;
    box-shadow: var(--fab-tooltip-shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 4;
}

/* Show tooltip on container hover */
.fab-container:hover .fab-tooltip {
    opacity: 1;
}

/* Tooltip arrow */
.fab-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--slate-900);
}

/* ============================================
   DISABLED STATE
   Red theme for disabled FAB
   ============================================ */

.fab-main-button:disabled,
.fab-main-button.fab-disabled {
    background: var(--fab-disabled-bg);
    border-color: var(--fab-disabled-border);
    color: var(--fab-disabled-color);
    cursor: not-allowed;
}

.fab-main-button:disabled:hover,
.fab-main-button.fab-disabled:hover {
    transform: none;
    background: var(--fab-disabled-bg);
    color: var(--fab-disabled-color);
}

/* ============================================
   ACCESSIBILITY
   Focus styles for keyboard navigation
   ============================================ */

.fab-main-button:focus-visible,
.fab-menu-button:focus-visible {
    outline: 3px solid var(--slate-400);
    outline-offset: 2px;
}

/* ============================================
   SMOOTH TRANSITIONS
   Disable tap highlight on mobile
   ============================================ */

.fab-container *,
.fab-main-button,
.fab-menu-button {
    -webkit-tap-highlight-color: transparent;
}
