/* 
 * Styles for Q Business Anonymous URL API UI
 * Requirements: 4.1, 8.1, 8.5
 */

/* ===== Reset and Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

/* ===== Floating Chat Button ===== */
/* Requirements: 4.1 - Floating chat button fixed in bottom-right corner */
.chat-button {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    z-index: 999;
    color: white;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

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

.chat-button svg {
    width: 24px;
    height: 24px;
}

/* ===== Modal Overlay ===== */
/* Requirements: 8.1 - Medium-sized overlay aligned to right side, 8.5 - Appropriate z-index */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    animation: fadeIn 0.3s ease;
}

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

/* ===== Modal Container ===== */
/* Requirements: 8.1 - Right-aligned, medium size */
.modal-container {
    position: relative;
    width: 600px;
    height: 80vh;
    max-height: 800px;
    background-color: white;
    border-radius: 12px 0 0 12px;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s ease;
    overflow: hidden;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

/* ===== Close Button ===== */
.close-button {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.05);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
    color: #666;
}

.close-button:hover {
    background-color: rgba(0, 0, 0, 0.1);
    color: #333;
}

.close-button:active {
    transform: scale(0.9);
}

.close-button svg {
    width: 20px;
    height: 20px;
}

/* ===== Loading Indicator ===== */
.loading-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(102, 126, 234, 0.2);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 20px;
}

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

.loading-indicator p {
    color: #666;
    font-size: 16px;
    font-weight: 500;
}

/* ===== Error Message Display ===== */
.error-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
    text-align: center;
}

.error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.error-message {
    color: #d32f2f;
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 24px;
    line-height: 1.5;
    max-width: 400px;
}

.error-close-button {
    padding: 10px 24px;
    background-color: #d32f2f;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.error-close-button:hover {
    background-color: #b71c1c;
}

.error-close-button:active {
    transform: scale(0.95);
}

/* ===== Iframe Container ===== */
/* Requirements: 8.1 - Iframe container with minimum 450px width */
.iframe-container {
    flex: 1;
    width: 100%;
    min-width: 450px;
    height: 100%;
    overflow: hidden;
}

.qbusiness-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* ===== Responsive Design for Mobile ===== */
/* Requirements: 8.5 - Responsive design for mobile */

/* Tablets and smaller desktops */
@media (max-width: 768px) {
    .modal-container {
        width: 90%;
        max-width: 500px;
        height: 85vh;
        border-radius: 12px;
        margin: 0 auto;
    }
    
    .modal-overlay {
        justify-content: center;
    }
    
    .iframe-container {
        min-width: 100%;
    }
}

/* Mobile phones */
@media (max-width: 480px) {
    .chat-button {
        width: 56px;
        height: 56px;
        bottom: 16px;
        right: 16px;
    }
    
    .chat-button svg {
        width: 22px;
        height: 22px;
    }
    
    .modal-container {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    
    .close-button {
        top: 12px;
        right: 12px;
        width: 32px;
        height: 32px;
    }
    
    .close-button svg {
        width: 18px;
        height: 18px;
    }
    
    .loading-indicator,
    .error-display {
        padding: 24px;
    }
    
    .spinner {
        width: 40px;
        height: 40px;
    }
    
    .loading-indicator p,
    .error-message {
        font-size: 14px;
    }
    
    .error-icon {
        font-size: 40px;
    }
}

/* Small mobile phones */
@media (max-width: 360px) {
    .chat-button {
        width: 52px;
        height: 52px;
        bottom: 12px;
        right: 12px;
    }
    
    .iframe-container {
        min-width: 320px;
    }
}

/* Landscape orientation on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .modal-container {
        height: 100%;
        max-height: 100%;
    }
    
    .loading-indicator,
    .error-display {
        padding: 20px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .chat-button {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    }
    
    .modal-container {
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.25);
    }
}

/* Accessibility: Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .chat-button,
    .close-button,
    .error-close-button {
        transition: none;
    }
    
    .modal-overlay,
    .modal-container {
        animation: none;
    }
    
    .spinner {
        animation: none;
        border-top-color: transparent;
    }
}

/* Accessibility: Focus styles */
.chat-button:focus,
.close-button:focus,
.error-close-button:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .chat-button,
    .modal-overlay {
        display: none !important;
    }
}