/**
 * Santa Chat Styles
 * 
 * Stili per la chat interattiva con Babbo Natale
 * Ottimizzato per mobile-first con tema natalizio
 *
 * @package SantaAtHome
 * @since 1.0.0
 */

/* ========================================
   FULLSCREEN MODE (Non-closable)
   ======================================== */

.santa-chat-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999999;
    background: linear-gradient(to bottom, #1a472a 0%, #0d2818 100%);
    display: flex;
    flex-direction: column;
}

.santa-chat-fullscreen-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.santa-chat-fullscreen .santa-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #c41e3a 0%, #8b1a2e 100%);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    position: relative;
}

.santa-chat-fullscreen .santa-chat-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #ffd700, #fff, #ffd700);
}

.santa-chat-fullscreen .santa-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><text x="50%" y="50%" font-size="40" text-anchor="middle" opacity="0.05">❄️</text></svg>') repeat;
    background-size: 100px 100px;
}

.santa-chat-fullscreen .santa-chat-input-area {
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 2px solid rgba(255, 215, 0, 0.3);
}

/* Responsive for fullscreen */
@media (max-width: 768px) {
    .santa-chat-fullscreen .santa-chat-header {
        padding: 12px 16px;
    }
    
    .santa-chat-fullscreen .santa-chat-messages {
        padding: 16px;
    }
    
    .santa-chat-fullscreen .santa-chat-input-area {
        padding: 16px;
    }
}

/* Always Visible Chat Container */
.santa-chat-always-visible {
    max-width: 600px;
    margin: 0 auto;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 600px; /* Altezza fissa, puoi personalizzare */
}

.santa-chat-always-visible .santa-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.santa-chat-always-visible .santa-chat-input-area {
    border-top: 1px solid #eee;
    padding: 15px;
    background: #fff;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .santa-chat-always-visible {
        max-width: 100%;
        height: 500px;
        border-radius: 0;
    }
} 

/* ========================================
   BUTTON TRIGGER
   ======================================== */

   .santa-chat-wrapper {
    display: inline-block;
    margin: 20px 0;
}

.santa-chat-trigger {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 16px 32px;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #c41e3a 0%, #8b1a2e 100%);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(196, 30, 58, 0.4);
    position: relative;
    overflow: hidden;
}

.santa-chat-trigger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(196, 30, 58, 0.6);
}

.santa-chat-trigger:active {
    transform: translateY(0);
}

.santa-chat-trigger::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.santa-chat-trigger:hover::before {
    left: 100%;
}

.santa-chat-icon {
    font-size: 24px;
    animation: santaBounce 2s infinite;
}

@keyframes santaBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* ========================================
   MODAL FULLSCREEN
   ======================================== */

.santa-chat-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999999;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.santa-chat-modal.active {
    opacity: 1;
    visibility: visible;
}

.santa-chat-modal-content {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, #1a472a 0%, #0d2818 100%);
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.santa-chat-modal.active .santa-chat-modal-content {
    transform: translateY(0);
}

/* ========================================
   HEADER
   ======================================== */

.santa-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #c41e3a 0%, #8b1a2e 100%);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    position: relative;
}

.santa-chat-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #ffd700, #fff, #ffd700);
}

.santa-chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.santa-chat-avatar {
    width: 50px;
    height: 50px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.santa-chat-header-info h3 {
    margin: 0;
    font-size: 18px;
    color: #fff;
    font-weight: 700;
}

.santa-chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
}

.santa-status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.santa-chat-close {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.santa-chat-close span {
    font-size: 30px;
    color: #fff;
    line-height: 1;
}

.santa-chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* ========================================
   MESSAGES AREA
   ======================================== */

.santa-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><text x="50%" y="50%" font-size="40" text-anchor="middle" opacity="0.05">❄️</text></svg>') repeat;
    background-size: 100px 100px;
}

.santa-chat-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: rgba(255, 255, 255, 0.7);
}

.santa-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #c41e3a;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

.santa-chat-welcome {
    text-align: center;
    padding: 40px 20px;
    color: #fff;
}

.santa-welcome-icon {
    font-size: 60px;
    margin-bottom: 16px;
    animation: swing 2s ease-in-out infinite;
}

@keyframes swing {
    0%, 100% { transform: rotate(-5deg); }
    50% { transform: rotate(5deg); }
}

.santa-chat-welcome h4 {
    font-size: 24px;
    margin: 0 0 12px 0;
    color: #ffd700;
}

.santa-chat-welcome p {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
}

/* Message Bubbles */
.santa-message {
    margin-bottom: 20px;
    animation: messageSlide 0.3s ease;
}

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

.santa-message-user {
    display: flex;
    justify-content: flex-end;
}

.santa-message-assistant {
    display: flex;
    justify-content: flex-start;
}

.santa-message-bubble {
    max-width: 80%;
    padding: 14px 18px;
    border-radius: 20px;
    position: relative;
    word-wrap: break-word;
    min-width: 250px;
}

.santa-message-user .santa-message-bubble {
    background: linear-gradient(135deg, #f3f3f3 0%, #ffffff 100%);
    color: #212121;
    border-bottom-right-radius: 4px;
}

.santa-message-assistant .santa-message-bubble {
    background: linear-gradient(135deg, #c41e3a 0%, #8b1a2e 100%);
    color: #fff;
    border-bottom-left-radius: 4px;
}

.santa-message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 6px;
}

.santa-message-user .santa-message-meta {
    color: #212121;
}

.santa-message-assistant .santa-message-meta {
    color: #fff;
}

.santa-message-time {
    font-size: 11px;
    opacity: 0.7;
}

/* Audio Player in Message - NEW ADVANCED PLAYER */
.santa-message-audio {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
}

.santa-audio-play-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.3s ease;
}

.santa-audio-play-btn:hover {
    background: #fff;
    transform: scale(1.1);
}

.santa-audio-play-btn.playing {
    background: #ffd700;
}

.santa-audio-controls {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.santa-audio-progress {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.santa-audio-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffd700 0%, #ffed4e 100%);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s linear;
}

.santa-audio-time {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    font-family: monospace;
}

.santa-audio-current-time,
.santa-audio-total-time {
    font-weight: 600;
}

/* Text Collapse Button */
.santa-message-text-collapse {
    margin-top: 8px;
}

.santa-text-toggle {
    width: 100%;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.santa-text-toggle:hover {
    background: rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.3);
}

.santa-message-text-collapse .santa-message-text {
    margin-top: 10px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border-left: 3px solid #ffd700;
    line-height: 1.6;
}

/* OLD Waveform (keep for backwards compatibility) */
.santa-audio-waveform {
    flex: 1;
    height: 30px;
    display: flex;
    align-items: center;
    gap: 2px;
}

.santa-audio-bar {
    flex: 1;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    animation: audioWave 1s ease-in-out infinite;
}

@keyframes audioWave {
    0%, 100% { height: 30%; }
    50% { height: 100%; }
}

/* Typing Indicator */
.santa-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 14px 18px;
    background: linear-gradient(135deg, #c41e3a 0%, #8b1a2e 100%);
    border-radius: 20px;
    border-bottom-left-radius: 4px;
    max-width: fit-content;
}

.santa-typing-dot {
    width: 8px;
    height: 8px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    animation: typingDot 1.4s infinite;
}

.santa-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.santa-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.7; }
    30% { transform: translateY(-10px); opacity: 1; }
}

/* Generating Audio Message */
.santa-generating-message {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 18px;
    background: linear-gradient(135deg, #c41e3a 0%, #8b1a2e 100%);
    border-radius: 20px;
    border-bottom-left-radius: 4px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    max-width: fit-content;
    animation: pulse 1.5s infinite;
}

/* ========================================
   INPUT AREA
   ======================================== */

.santa-chat-input-area {
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-top: 2px solid rgba(255, 215, 0, 0.3);
}

.santa-chat-limit-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    margin-bottom: 12px;
    background: rgba(255, 193, 7, 0.2);
    border-left: 4px solid #ffc107;
    border-radius: 8px;
    color: #ffd700;
    font-size: 14px;
}

.santa-warning-icon {
    font-size: 20px;
}

.santa-chat-recording-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin-bottom: 12px;
    background: rgba(220, 38, 38, 0.2);
    border-left: 4px solid #dc2626;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
}

.santa-recording-pulse {
    width: 12px;
    height: 12px;
    background: #dc2626;
    border-radius: 50%;
    animation: pulse 1s infinite;
}

.santa-recording-timer {
    margin-left: auto;
    font-weight: 600;
    font-family: monospace;
}

.santa-chat-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.santa-chat-record-btn,
.santa-chat-send-btn,
.santa-chat-cancel-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 24px;
    border: none;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.santa-chat-record-btn {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(5, 150, 105, 0.4);
}

.santa-chat-record-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(5, 150, 105, 0.6);
}

.santa-chat-record-btn.recording {
    background: linear-gradient(135deg, #dc2626 0%, #991b1b 100%);
    animation: recordPulse 1.5s infinite;
}

@keyframes recordPulse {
    0%, 100% { box-shadow: 0 4px 15px rgba(220, 38, 38, 0.4); }
    50% { box-shadow: 0 4px 25px rgba(220, 38, 38, 0.8); }
}

.santa-chat-send-btn {
    background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(37, 99, 235, 0.4);
}

.santa-chat-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.6);
}

.santa-chat-cancel-btn {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    color: #fff;
    box-shadow: 0 4px 15px rgba(100, 116, 139, 0.4);
}

.santa-chat-cancel-btn:hover {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.santa-btn-icon {
    font-size: 20px;
}

.santa-chat-record-btn:disabled,
.santa-chat-send-btn:disabled,
.santa-chat-cancel-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ========================================
   ERROR MESSAGE
   ======================================== */

.santa-chat-error {
    padding: 16px;
    background: rgba(239, 68, 68, 0.2);
    border-left: 4px solid #ef4444;
    border-radius: 8px;
    color: #fca5a5;
    font-size: 14px;
}

/* 
 * Stili indicatore "Babbo sta registrando audio"
 */

/* Indicatore generazione audio nella input-area */
.santa-generating-status {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    gap: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    margin-bottom: 10px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.santa-generating-pulse {
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
    animation: santa-pulse-generating 1.5s ease-in-out infinite;
}

.santa-generating-text {
    color: #fff;
    font-size: 15px;
    font-weight: 500;
}

@keyframes santa-pulse-generating {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.7;
    }
}

/* Error Modal - SweetAlert Style */
.santa-error-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.santa-error-modal.active {
    opacity: 1;
}

.santa-error-modal-content {
    background: #fff;
    border-radius: 16px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.santa-error-modal.active .santa-error-modal-content {
    transform: scale(1);
}

.santa-error-icon {
    font-size: 64px;
    margin-bottom: 20px;
    animation: santa-error-bounce 0.5s ease;
}

@keyframes santa-error-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.santa-error-message {
    font-size: 16px;
    color: #333;
    margin-bottom: 25px;
    line-height: 1.5;
}

.santa-error-ok-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    padding: 12px 40px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.santa-error-ok-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.santa-error-ok-btn:active {
    transform: translateY(0);
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .santa-chat-trigger {
        padding: 14px 24px;
        font-size: 16px;
    }
    
    .santa-chat-header {
        padding: 12px 16px;
    }
    
    .santa-chat-avatar {
        width: 40px;
        height: 40px;
        font-size: 24px;
    }
    
    .santa-chat-header-info h3 {
        font-size: 16px;
    }
    
    .santa-chat-messages {
        padding: 16px;
    }
    .santa-message {
        padding: 0!important;
    }

    .santa-message-bubble {
        max-width: 85%;
        font-size: 15px;
    }
    
    .santa-chat-buttons {
        flex-direction: column;
    }
    
    .santa-chat-record-btn,
    .santa-chat-send-btn,
    .santa-chat-cancel-btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .santa-chat-input-area {
        padding: 16px;
    }
    
    .santa-message-bubble {
        max-width: 90%;
        padding: 12px 16px;
        font-size: 14px;
    }
}

/* ========================================
   SCROLLBAR
   ======================================== */

.santa-chat-messages::-webkit-scrollbar {
    width: 8px;
}

.santa-chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.santa-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(196, 30, 58, 0.5);
    border-radius: 10px;
}

.santa-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(196, 30, 58, 0.7);
}
