/**
 * Coach4Life Chat Widget Styles
 * Version: 1.0.0
 * Fallback styles for browsers without Shadow DOM support
 */

/* Login Required Message */
.ascoltus-login-required {
    max-width: 600px;
    padding: 40px;
    text-align: center;
    border: 2px solid #BFDBFE;
    border-radius: 12px;
    background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
    margin: 40px auto;
}

.ascoltus-login-required h3 {
    font-size: 24px;
    color: #1E40AF;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.ascoltus-login-required p {
    font-size: 16px;
    color: #1f2937;
    margin-bottom: 24px;
    line-height: 1.6;
}

.ascoltus-login-required .button {
    display: inline-block;
    padding: 12px 32px;
    background: #2563EB;
    color: white !important;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    transition: background 0.2s;
    font-size: 16px;
}

.ascoltus-login-required .button:hover {
    background: #1E40AF;
}

/* Error Message */
.ascoltus-error {
    padding: 16px 20px;
    background: #FEE2E2;
    border: 1px solid #FCA5A5;
    border-radius: 8px;
    color: #991B1B;
    margin: 20px 0;
    font-weight: 500;
}

/* Loading State */
.ascoltus-loading {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(37, 99, 235, 0.3);
    border-radius: 50%;
    border-top-color: #2563EB;
    animation: ascoltus-spin 0.8s linear infinite;
}

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

/* Chat Root Container */
#ascoltus-chat-root {
    display: block;
    margin: 20px auto;
    width: 95%;
    max-width: 1200px;
}

/* Accessibility */
.ascoltus-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;
}

/* Focus states for keyboard navigation */
.ascoltus-btn-icon:focus,
.ascoltus-input:focus,
.ascoltus-btn-send:focus {
    outline: 2px solid #2563EB;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .ascoltus-wrapper {
        border-width: 2px;
    }
    
    .ascoltus-message-content {
        border-width: 2px;
    }

    .ascoltus-login-required,
    .ascoltus-coach-card {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .ascoltus-message,
    .ascoltus-typing-dot,
    .ascoltus-loading {
        animation: none;
    }

    .ascoltus-coach-card {
        transition: none;
    }

    .ascoltus-coach-card:hover {
        transform: none;
    }
}

/* Print styles */
@media print {
    .ascoltus-input-area,
    .ascoltus-header-actions {
        display: none;
    }
    
    .ascoltus-wrapper {
        border: none;
        box-shadow: none;
        height: auto;
    }
    
    .ascoltus-messages {
        overflow: visible;
    }

    .ascoltus-coach-card .button {
        display: none;
    }
}

/* Mobile optimization */
@media (max-width: 768px) {
    .ascoltus-coaches-grid {
        grid-template-columns: 1fr;
    }

    .ascoltus-login-required {
        margin: 20px;
        padding: 30px 20px;
    }
}

/* Dark mode support (if theme supports it) */
@media (prefers-color-scheme: dark) {
    .ascoltus-login-required {
        background: linear-gradient(135deg, #1E3A8A 0%, #1E40AF 100%);
        border-color: #3B82F6;
    }

    .ascoltus-login-required h3,
    .ascoltus-login-required p {
        color: white;
    }

    .ascoltus-coach-card {
        background: #1f2937;
        border-color: #374151;
    }

    .ascoltus-coach-card h3 {
        color: white;
    }

    .ascoltus-coach-card p {
        color: #d1d5db;
    }
}


/* ---------- Upgrade Banner (fallback) ---------- */
#ascoltus-upgrade-banner { display:none; padding: 12px 14px; border-bottom: 1px solid #e5e7eb; background: #ffffff; }
.ascoltus-upgrade-banner { border:1px solid #e5e7eb; background:#f9fafb; border-radius:12px; padding:12px 14px; font-size:14px; line-height:1.35; color:#111827; }
.ascoltus-hint { margin-top:6px; color:#4b5563; font-size:13px; }
#ascoltus-upgrade-modal { display:none; position:fixed; inset:0; z-index:9999; }
.ascoltus-modal-backdrop { position:absolute; inset:0; background: rgba(0,0,0,0.35); }
.ascoltus-modal { position:relative; width:calc(100% - 24px); max-width:480px; margin:12vh auto; background:#fff; padding:18px; border-radius:14px; box-shadow:0 20px 40px rgba(0,0,0,0.15); }
.ascoltus-modal-actions { display:flex; gap:10px; margin-top:14px; flex-wrap:wrap; }
.ascoltus-modal button { padding:10px 14px; border-radius:10px; border:none; cursor:pointer; flex:1; min-width:130px; }
.ascoltus-modal .primary { background:#111827; color:#fff; }
.ascoltus-modal .secondary { background:#f3f4f6; color:#111827; }
@media (max-height: 650px) { .ascoltus-modal { margin: 6vh auto; } }

/* ===== C4L_VOICE_BUTTON_COLORS_V1 ===== */
.ascoltus-voice-on  { background: #22c55e !important; border-color: #22c55e !important; color: #fff !important; }
.ascoltus-voice-off { background: #ef4444 !important; border-color: #ef4444 !important; color: #fff !important; }
/* ===== /C4L_VOICE_BUTTON_COLORS_V1 ===== */

/* ===== C4L_VOICE_BUTTON_COLORS_V2 ===== */
.ascoltus-voice-on  { background: #22c55e !important; border-color: #22c55e !important; color: #fff !important; }
.ascoltus-voice-off { background: #ef4444 !important; border-color: #ef4444 !important; color: #fff !important; }
/* ===== /C4L_VOICE_BUTTON_COLORS_V2 ===== */

/* =========================================
 * ASCOLTUS_LAYOUT_FIX
 * Make chat height follow the parent container (so left/right panels can match height).
 * Also disables fixed aspect-ratio / max-height constraints if present.
 * =======================================*/

#ascoltus-chat-root {
    height: 100%;
}

#ascoltus-chat-root .ascoltus-wrapper,
#ascoltus-chat-root .c41-wrapper,
.ascoltus-wrapper,
.c41-wrapper {
    height: 100% !important;
    max-height: none !important;
    aspect-ratio: auto !important;
    display: flex;
    flex-direction: column;
}

/* Ensure message area grows and scrolls (input stays visible) */
#ascoltus-chat-root .ascoltus-messages,
#ascoltus-chat-root .c41-messages,
.ascoltus-messages,
.c41-messages {
    flex: 1 1 auto;
    overflow: auto;
    min-height: 0;
}

/* Mobile: keep chat usable by limiting to viewport height (optional app-like behavior) */
@media (max-width: 768px) {
    #ascoltus-chat-root .ascoltus-wrapper,
    #ascoltus-chat-root .c41-wrapper,
    .ascoltus-wrapper,
    .c41-wrapper {
        height: calc(100vh - 120px) !important;
    }
}
