/**
 * Contact FAB (Floating Action Button) Styles
 * AWS Quiz Platform - Facebook Messenger Contact System
 */

/* ========================================
   CSS Variables
   ======================================== */
:root {
    /* Z-index layers */
    --fab-z-index: 40;
    --contact-modal-z-backdrop: 45;
    --contact-modal-z-container: 50;

    /* Colors */
    --fab-primary: #ff9900;          /* AWS Orange */
    --fab-secondary: #232f3e;        /* Dark */
    --fab-messenger: #0084FF;        /* Facebook Messenger Blue */
    --fab-success: #28a745;          /* Success green */
    --fab-text-primary: #111827;
    --fab-text-secondary: #374151;
    --fab-border-subtle: #e0e0e0;

    /* Sizing */
    --fab-size-desktop: 56px;
    --fab-size-mobile: 60px;
    --fab-icon-size: 24px;
    --fab-position-offset: 20px;
    --fab-position-offset-mobile: 24px;

    /* Shadows */
    --fab-shadow: 0 4px 12px rgba(255, 153, 0, 0.4);
    --fab-shadow-hover: 0 6px 16px rgba(255, 153, 0, 0.5);
    --fab-shadow-active: 0 2px 8px rgba(255, 153, 0, 0.3);

    /* Transitions */
    --fab-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   Floating Action Button (FAB)
   ======================================== */
.contact-fab {
    /* Positioning */
    position: fixed;
    bottom: var(--fab-position-offset);
    right: var(--fab-position-offset);
    z-index: var(--fab-z-index);

    /* Sizing */
    width: var(--fab-size-desktop);
    height: var(--fab-size-desktop);

    /* Styling */
    background: var(--fab-primary);
    border: none;
    border-radius: 50%;
    box-shadow: var(--fab-shadow);
    cursor: pointer;

    /* Layout */
    display: flex;
    align-items: center;
    justify-content: center;

    /* Text */
    color: white;
    font-size: var(--fab-icon-size);

    /* Performance */
    contain: layout style paint;
    will-change: transform;

    /* Transition */
    transition: var(--fab-transition);
}

/* Hover State */
.contact-fab:hover {
    transform: scale(1.05);
    box-shadow: var(--fab-shadow-hover);
}

/* Active/Pressed State */
.contact-fab:active {
    transform: scale(0.95);
    box-shadow: var(--fab-shadow-active);
}

/* Focus State (Keyboard Navigation) */
.contact-fab:focus {
    outline: 2px solid var(--fab-messenger);
    outline-offset: 2px;
}

.contact-fab:focus:not(:focus-visible) {
    outline: none;
}

.contact-fab:focus-visible {
    outline: 2px solid var(--fab-messenger);
    outline-offset: 2px;
}

/* Disabled State */
.contact-fab:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Icon */
.contact-fab-icon {
    display: block;
    line-height: 1;
    user-select: none;
}

/* ========================================
   Contact Modal Backdrop
   ======================================== */
.contact-modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: var(--contact-modal-z-backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    animation: contactBackdropFadeIn 300ms ease forwards;
}

.contact-modal-backdrop.closing {
    animation: contactBackdropFadeOut 200ms ease forwards;
}

/* ========================================
   Contact Modal Container
   ======================================== */
.contact-modal-container {
    position: relative;
    z-index: var(--contact-modal-z-container);
    background: white;
    border-radius: 16px;
    padding: 32px;
    max-width: 450px;
    width: 100%;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    transform: translateY(20px);
    opacity: 0;
    animation: contactModalSlideUp 300ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.contact-modal-backdrop.closing .contact-modal-container {
    animation: contactModalSlideDown 200ms ease forwards;
}

/* ========================================
   Modal Header
   ======================================== */
.contact-modal-header {
    text-align: center;
    margin-bottom: 24px;
}

.contact-modal-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--fab-secondary);
    margin: 0 0 8px 0;
    line-height: 1.2;
}

.contact-modal-description {
    font-size: 14px;
    color: var(--fab-text-secondary);
    margin: 0;
    line-height: 1.5;
}

/* ========================================
   Modal Close Button
   ======================================== */
.contact-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: #999;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.contact-modal-close:hover {
    color: #333;
    background: rgba(0, 0, 0, 0.05);
}

.contact-modal-close:focus {
    outline: 2px solid var(--fab-messenger);
    outline-offset: 2px;
}

.contact-modal-close svg {
    width: 24px;
    height: 24px;
}

/* ========================================
   Contact Options
   ======================================== */
.contact-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.contact-option {
    display: flex;
    align-items: center;
    padding: 20px 24px;
    border: 2px solid var(--fab-border-subtle);
    border-radius: 12px;
    background: #f8f9fa;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    text-align: left;
    width: 100%;
}

.contact-option:hover {
    border-color: var(--fab-messenger);
    box-shadow: 0 4px 12px rgba(0, 132, 255, 0.15);
    transform: translateY(-2px);
}

.contact-option:active {
    transform: translateY(0) scale(0.98);
}

.contact-option:focus {
    outline: 2px solid var(--fab-messenger);
    outline-offset: 2px;
}

/* Messenger Option (Primary) */
.contact-option.messenger {
    border-color: var(--fab-messenger);
    background: linear-gradient(135deg, #f7fbff 0%, #e8f4ff 100%);
}

.contact-option.messenger:hover {
    background: linear-gradient(135deg, #e8f4ff 0%, #d9edff 100%);
}

/* Email Option (Secondary) */
.contact-option.email .option-icon {
    background: var(--fab-primary);
}

/* Option Icon */
.option-icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: 50%;
    background: var(--fab-messenger);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
}

.option-icon svg,
.option-icon img {
    width: 24px;
    height: 24px;
    color: white;
}

/* Option Content */
.option-content {
    flex: 1;
}

.option-label {
    font-size: 16px;
    font-weight: 600;
    color: var(--fab-text-primary);
    margin: 0 0 4px 0;
    line-height: 1.3;
}

.option-sublabel {
    font-size: 14px;
    color: var(--fab-text-secondary);
    margin: 0;
    line-height: 1.4;
}

.option-meta {
    font-size: 12px;
    color: #999;
    margin: 4px 0 0 0;
    line-height: 1.3;
}

/* Option Badge */
.option-badge {
    position: absolute;
    top: -8px;
    right: 16px;
    background: var(--fab-success);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

/* Loading State */
.contact-option.loading {
    opacity: 0.6;
    pointer-events: none;
}

.contact-option.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    border: 3px solid var(--fab-border-subtle);
    border-top-color: var(--fab-messenger);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ========================================
   Loading Overlay
   ======================================== */
.contact-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 10;
}

.contact-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--fab-border-subtle);
    border-top-color: var(--fab-messenger);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.contact-loading-text {
    font-size: 14px;
    color: var(--fab-text-secondary);
}

/* ========================================
   Responsive Design
   ======================================== */

/* Mobile: Bottom Sheet Style */
@media (max-width: 767px) {
    /* FAB */
    .contact-fab {
        width: var(--fab-size-mobile);
        height: var(--fab-size-mobile);
        bottom: var(--fab-position-offset-mobile);
        right: var(--fab-position-offset-mobile);
    }

    /* Modal Container */
    .contact-modal-container {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-width: 100%;
        border-radius: 24px 24px 0 0;
        padding: 24px;
        max-height: 85vh;
        overflow-y: auto;
        animation: contactModalSlideUpMobile 300ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
    }

    .contact-modal-backdrop.closing .contact-modal-container {
        animation: contactModalSlideDownMobile 200ms ease forwards;
    }

    /* Backdrop alignment */
    .contact-modal-backdrop {
        align-items: flex-end;
        padding: 0;
    }

    /* Options */
    .contact-option {
        min-height: 48px;
    }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1023px) {
    .contact-modal-container {
        padding: 28px;
    }
}

/* Desktop Large */
@media (min-width: 1024px) {
    .contact-fab:hover {
        /* Enhanced hover effects on desktop */
    }
}

/* ========================================
   Animations
   ======================================== */

/* Backdrop Animations */
@keyframes contactBackdropFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes contactBackdropFadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Modal Animations - Desktop */
@keyframes contactModalSlideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes contactModalSlideDown {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(20px);
        opacity: 0;
    }
}

/* Modal Animations - Mobile (Bottom Sheet) */
@keyframes contactModalSlideUpMobile {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes contactModalSlideDownMobile {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(100%);
        opacity: 0;
    }
}

/* Spinner Animation */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Pulse Animation (Optional - for first load) */
@keyframes fabPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: var(--fab-shadow);
    }
    50% {
        transform: scale(1.05);
        box-shadow: var(--fab-shadow-hover);
    }
}

.contact-fab.pulse {
    animation: fabPulse 2s ease-in-out 3;
}

/* ========================================
   Accessibility
   ======================================== */

/* Screen Reader Only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Reduce Motion */
@media (prefers-reduced-motion: reduce) {
    .contact-fab,
    .contact-option,
    .contact-modal-container,
    .contact-modal-backdrop {
        animation: none !important;
        transition: none !important;
    }

    .contact-fab:hover {
        transform: none;
    }

    .contact-option:hover {
        transform: none;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .contact-fab {
        border: 2px solid currentColor;
    }

    .contact-option {
        border-width: 3px;
    }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    .contact-fab,
    .contact-modal-backdrop {
        display: none !important;
    }
}
