/**
 * AI Secretary Widget Styles
 * 
 * Premium, mobile-first, RTL-aware styles
 * 
 * @package AI_Secretary
 */

/* Variables */
:root {
    --aisec-color: #14b8a6;
    --aisec-color-hover: #0f9e8e;
    --aisec-color-light: #e6f7f5;
    --aisec-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    --aisec-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
    --aisec-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Widget Container */
.aisec-widget {
    position: fixed;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    direction: ltr;
}

/* Positioning */
.aisec-widget.aisec-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.aisec-widget.aisec-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

.aisec-widget.aisec-position-top-right {
    top: 20px;
    right: 20px;
}

.aisec-widget.aisec-position-top-left {
    top: 20px;
    left: 20px;
}

/* RTL Support */
[dir="rtl"] .aisec-widget.aisec-position-bottom-right {
    right: auto;
    left: 20px;
}

[dir="rtl"] .aisec-widget.aisec-position-bottom-left {
    left: auto;
    right: 20px;
}

/* Widget Button */
.aisec-widget-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--aisec-color);
    border: none;
    cursor: pointer;
    box-shadow: var(--aisec-shadow);
    transition: var(--aisec-transition);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.aisec-widget-button:hover {
    background: var(--aisec-color-hover);
    box-shadow: var(--aisec-shadow-lg);
    transform: scale(1.05);
}

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

/* Button Sizes */
.aisec-widget.aisec-size-small .aisec-widget-button {
    width: 50px;
    height: 50px;
}

.aisec-widget.aisec-size-large .aisec-widget-button {
    width: 70px;
    height: 70px;
}

/* Button Icons */
.aisec-widget-button .aisec-icon {
    width: 28px;
    height: 28px;
    color: white;
    transition: var(--aisec-transition);
}

.aisec-widget-button .aisec-icon-phone {
    opacity: 1;
    transform: scale(1);
}

.aisec-widget-button .aisec-icon-close {
    position: absolute;
    opacity: 0;
    transform: scale(0);
}

.aisec-widget.aisec-open .aisec-widget-button .aisec-icon-phone {
    opacity: 0;
    transform: scale(0);
}

.aisec-widget.aisec-open .aisec-widget-button .aisec-icon-close {
    opacity: 1;
    transform: scale(1);
}

/* Pulse Animation */
.aisec-widget-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--aisec-color);
    opacity: 0.5;
    animation: aisec-pulse 2s infinite;
}

@keyframes aisec-pulse {
    0% {
        transform: scale(1);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.2);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* Modal */
.aisec-widget-modal {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    background: white;
    border-radius: 16px;
    box-shadow: var(--aisec-shadow-lg);
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: var(--aisec-transition);
    overflow: hidden;
}

.aisec-widget.aisec-open .aisec-widget-modal {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Modal Positioning Adjustments */
.aisec-widget.aisec-position-bottom-left .aisec-widget-modal {
    right: auto;
    left: 0;
}

.aisec-widget.aisec-position-top-right .aisec-widget-modal,
.aisec-widget.aisec-position-top-left .aisec-widget-modal {
    bottom: auto;
    top: 80px;
}

/* Modal Header */
.aisec-modal-header {
    padding: 20px;
    background: var(--aisec-color-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.aisec-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
}

.aisec-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: var(--aisec-transition);
}

.aisec-modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
}

.aisec-modal-close svg {
    width: 20px;
    height: 20px;
    color: #6b7280;
}

/* Modal Body */
.aisec-modal-body {
    padding: 40px 20px;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aisec-call-status {
    text-align: center;
}

.aisec-status-icon {
    margin-bottom: 20px;
}

.aisec-status-text {
    font-size: 16px;
    color: #6b7280;
    margin: 0;
}

/* Wave Animation */
.aisec-wave-animation {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 60px;
}

.aisec-wave-animation span {
    width: 4px;
    height: 20px;
    background: var(--aisec-color);
    border-radius: 2px;
    animation: aisec-wave 1.2s ease-in-out infinite;
}

.aisec-wave-animation span:nth-child(1) { animation-delay: 0s; }
.aisec-wave-animation span:nth-child(2) { animation-delay: 0.1s; }
.aisec-wave-animation span:nth-child(3) { animation-delay: 0.2s; }
.aisec-wave-animation span:nth-child(4) { animation-delay: 0.3s; }
.aisec-wave-animation span:nth-child(5) { animation-delay: 0.4s; }

@keyframes aisec-wave {
    0%, 100% {
        height: 20px;
        opacity: 0.5;
    }
    50% {
        height: 50px;
        opacity: 1;
    }
}

.aisec-wave-animation.aisec-active span {
    animation-play-state: running;
}

.aisec-wave-animation:not(.aisec-active) span {
    animation-play-state: paused;
}

/* Modal Footer */
.aisec-modal-footer {
    padding: 20px;
    background: #f9fafb;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    gap: 12px;
    justify-content: center;
}

.aisec-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--aisec-transition);
}

.aisec-btn svg {
    width: 18px;
    height: 18px;
}

.aisec-btn-mute {
    background: #e5e7eb;
    color: #374151;
}

.aisec-btn-mute:hover {
    background: #d1d5db;
}

.aisec-btn-mute.aisec-muted {
    background: #fecaca;
    color: #991b1b;
}

.aisec-btn-mute .aisec-icon-mic-off {
    display: none;
}

.aisec-btn-mute.aisec-muted .aisec-icon-mic {
    display: none;
}

.aisec-btn-mute.aisec-muted .aisec-icon-mic-off {
    display: block;
}

.aisec-btn-end {
    background: #ef4444;
    color: white;
}

.aisec-btn-end:hover {
    background: #dc2626;
}

/* Shortcode Button */
.aisec-shortcode-button {
    padding: 14px 28px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: var(--aisec-transition);
    box-shadow: var(--aisec-shadow);
}

.aisec-shortcode-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--aisec-shadow-lg);
}

.aisec-shortcode-button:active {
    transform: translateY(0);
}

.aisec-shortcode-button.aisec-size-small {
    padding: 10px 20px;
    font-size: 14px;
}

.aisec-shortcode-button.aisec-size-large {
    padding: 18px 36px;
    font-size: 18px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .aisec-widget {
        bottom: 10px !important;
        right: 10px !important;
        left: auto !important;
        top: auto !important;
    }
    
    .aisec-widget-modal {
        width: calc(100vw - 20px);
        max-width: none;
        bottom: 70px;
    }
    
    .aisec-widget.aisec-position-top-right .aisec-widget-modal,
    .aisec-widget.aisec-position-top-left .aisec-widget-modal {
        bottom: 70px;
        top: auto;
    }
}

/* Loading State */
.aisec-widget.aisec-connecting .aisec-wave-animation span {
    animation-play-state: running;
    opacity: 0.5;
}

/* Connected State */
.aisec-widget.aisec-connected .aisec-wave-animation span {
    animation-play-state: running;
}

/* Error State */
.aisec-widget.aisec-error .aisec-status-text {
    color: #ef4444;
}

/* Ended State */
.aisec-widget.aisec-ended .aisec-status-text {
    color: #10b981;
}

/* Accessibility */
.aisec-widget-button:focus,
.aisec-modal-close:focus,
.aisec-btn:focus {
    outline: 2px solid var(--aisec-color);
    outline-offset: 2px;
}

/* Print */
@media print {
    .aisec-widget {
        display: none !important;
    }
}
