/* =====================================================
   Floating Action Button (FAB) Enhancements
   Additional visibility and interaction features
   ===================================================== */

/* Ensure FAB is always visible above content */
.theme-toggle-fab {
    z-index: 99990 !important;
    position: fixed !important;
    bottom: 30px !important;
    right: 30px !important;
}

/* Add a subtle background glow circle - Orange & Gray */
.theme-toggle-fab::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    background: radial-gradient(circle, rgba(55, 65, 81, 0.2) 0%, transparent 70%);
    border-radius: 50%;
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s;
}

.theme-toggle-fab:hover::before {
    opacity: 1;
}

.theme-toggle-fab.dark-mode::before {
    background: radial-gradient(circle, rgba(249, 115, 22, 0.3) 0%, transparent 70%);
}

/* Tooltip on hover */
.theme-toggle-fab .tooltip {
    position: absolute;
    right: 75px;
    top: 50%;
    transform: translateY(-50%) translateX(10px);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    border: 1px solid var(--border-color);
}

.theme-toggle-fab:hover .tooltip {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* Add tooltip arrow */
.theme-toggle-fab .tooltip::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid var(--bg-card);
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

/* Breathing animation for dark mode - Orange Glow */
@keyframes breathe {

    0%,
    100% {
        box-shadow: 0 8px 32px rgba(249, 115, 22, 0.4);
    }

    50% {
        box-shadow: 0 8px 48px rgba(249, 115, 22, 0.6);
    }
}

.theme-toggle-fab.dark-mode {
    animation: breathe 3s ease-in-out infinite;
}

/* Add keyboard focus indicator - Orange Glow */
.theme-toggle-fab:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(55, 65, 81, 0.3), var(--shadow-xl);
}

.theme-toggle-fab.dark-mode:focus {
    box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.4), var(--shadow-xl);
}

/* Rotate icon on theme change */
@keyframes icon-spin {
    from {
        transform: rotate(0deg) scale(1);
    }

    50% {
        transform: rotate(180deg) scale(1.2);
    }

    to {
        transform: rotate(360deg) scale(1);
    }
}

.theme-toggle-fab.transitioning .theme-icon {
    animation: icon-spin 0.6s ease;
}

/* Add a subtle border for better definition */
.theme-toggle-fab {
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.theme-toggle-fab.dark-mode {
    border: 2px solid rgba(255, 255, 255, 0.1);
}

/* Badge for new feature (optional) */
.theme-toggle-fab .new-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(214, 48, 49, 0.4);
    animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .theme-toggle-fab {
        border: 3px solid currentColor;
    }
}

/* Ensure visibility on all backgrounds */
.theme-toggle-fab {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Print: hide the toggle */
@media print {
    .theme-toggle-fab {
        display: none !important;
    }
}

/* Accessibility: Increase size for users who need it */
@media (prefers-reduced-motion: no-preference) {
    .theme-toggle-fab {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
}

/* Landscape mode adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .theme-toggle-fab {
        bottom: 10px;
        right: 15px;
        width: 50px;
        height: 50px;
    }

    .theme-icon {
        font-size: 18px;
    }

    .toggle-hint {
        display: none;
    }
}

/* Tablet specific */
@media (min-width: 768px) and (max-width: 1024px) {
    .theme-toggle-fab {
        width: 70px;
        height: 70px;
        bottom: 25px;
        right: 25px;
    }
}

/* Large desktop - slightly larger and more prominent */
@media (min-width: 1920px) {
    .theme-toggle-fab {
        width: 75px;
        height: 75px;
        bottom: 40px;
        right: 40px;
    }

    .theme-icon {
        font-size: 26px;
    }
}

/* Prevent FAB from overlapping with sticky footer or other elements */
.theme-toggle-fab {
    margin-bottom: env(safe-area-inset-bottom);
}

/* iOS specific safe area */
@supports (-webkit-touch-callout: none) {
    .theme-toggle-fab {
        bottom: max(30px, env(safe-area-inset-bottom) + 10px);
        right: max(30px, env(safe-area-inset-right) + 10px);
    }
}