/* ============================================================
   Widget Mode Styles - Mobile-first, lightweight
   No map, chat-based interface
   ============================================================ */

.widget-container {
    max-width: 480px;
    width: 100%;
    margin: 0 auto;
    background: var(--white);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Header */
.widget-header {
    background: var(--church-primary);
    color: var(--white);
    padding: 20px;
    text-align: center;
}

.widget-logo img {
    height: 40px;
    width: auto;
    margin-bottom: 10px;
}

.widget-header h1 {
    font-size: 1.4em;
    font-weight: normal;
    margin-bottom: 4px;
}

.widget-subtitle {
    font-size: 0.85em;
    opacity: 0.9;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-green);
    margin-right: 4px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Language Picker */
.language-picker {
    padding: 8px 16px;
    background: var(--white);
}

.language-picker-main {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    align-items: center;
}

.dynamic-pill-slot {
    display: contents;
}

.language-picker-expanded {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
    margin-top: 8px;
}

.language-picker-expanded.open {
    display: flex;
}

.lang-pill {
    background: var(--white);
    border: 1.5px solid var(--church-primary);
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 0.78em;
    font-weight: 600;
    font-family: Arial, sans-serif;
    color: var(--church-primary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.lang-pill:hover {
    background: var(--church-primary);
    color: var(--white);
}

.lang-pill.active {
    background: var(--church-primary);
    color: var(--white);
}

/* Dynamic pill (AI-detected language) — subtle entrance */
.lang-pill-dynamic {
    animation: pillSlideIn 0.3s ease-out;
}

@keyframes pillSlideIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* "More" / "Less" button */
.lang-more-btn {
    border-style: dashed;
    font-weight: 500;
    opacity: 0.7;
}

.lang-more-btn:hover {
    opacity: 1;
    background: var(--church-primary);
    color: var(--white);
}

.lang-more-btn.expanded {
    opacity: 1;
}

/* Detection Card */
.detection-card {
    margin: 16px;
    padding: 16px;
    background: var(--info-blue-bg);
    border-radius: 8px;
    border-left: 4px solid var(--church-primary);
}

.detection-spinner {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--church-primary);
    font-size: 0.9em;
}

.spinner-small {
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--church-primary);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    flex-shrink: 0;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.detection-result {
    display: flex;
    align-items: center;
    gap: 12px;
}

.detection-icon {
    font-size: 1.5em;
    flex-shrink: 0;
}

.detection-info {
    flex: 1;
}

.detection-label {
    font-size: 0.75em;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detection-value {
    font-size: 1em;
    font-weight: 600;
    color: var(--text-dark);
}

.detection-area {
    font-size: 0.85em;
    color: var(--church-primary);
    font-weight: 600;
}

/* Chat Toolbar */
.chat-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--light-gray);
    border-bottom: 1px solid var(--border-color);
}

.ai-mode-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: auto;
    background: #ccc;
}

.ai-mode-dot.active {
    background: #28a745;
    box-shadow: 0 0 4px rgba(40, 167, 69, 0.5);
}

.copy-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.72em;
    font-family: Arial, sans-serif;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s;
}

.copy-btn:hover {
    color: var(--church-primary);
    border-color: var(--church-primary);
    background: var(--white);
}

.copy-btn.copied {
    color: var(--success-green);
    border-color: var(--success-green);
}

/* Chat Section */
.chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin: 0 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    min-height: 300px;
    max-height: 50vh;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Chat Bubbles */
.chat-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.9em;
    line-height: 1.4;
    animation: fadeIn 0.3s ease-out;
    user-select: text;
    -webkit-user-select: text;
    cursor: text;
}

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

.chat-message.assistant {
    align-self: flex-start;
    background: var(--light-gray);
    color: var(--text-dark);
    border-bottom-left-radius: 4px;
}

.chat-message.user {
    align-self: flex-end;
    background: var(--church-primary);
    color: var(--white);
    border-bottom-right-radius: 4px;
}

.chat-message.system {
    align-self: center;
    background: var(--info-blue-bg);
    color: var(--church-primary);
    font-size: 0.8em;
    text-align: center;
    border-radius: 8px;
}

/* Typing indicator */
.typing-indicator {
    align-self: flex-start;
    padding: 10px 14px;
    background: var(--light-gray);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-light);
    animation: typingBounce 1.4s infinite;
}

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* Chat Input */
.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border-color);
    background: var(--white);
}

.chat-input-area input {
    flex: 1;
    padding: 10px 14px;
    font-size: 0.9em;
    font-family: Arial, sans-serif;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input-area input:focus {
    border-color: var(--church-primary);
}

.chat-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--church-primary);
    color: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.chat-send-btn:hover {
    background: var(--church-primary-hover);
}

.chat-send-btn:disabled {
    background: #CCCCCC;
    cursor: not-allowed;
}

/* Call Section */
.call-section {
    margin: 16px;
}

.call-summary {
    background: var(--light-gray);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 0.85em;
    color: var(--text-dark);
}

.call-summary .summary-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}

.call-summary .summary-label {
    color: var(--text-light);
}

.call-summary .summary-value {
    font-weight: 600;
}

.widget-call-button {
    width: 100%;
    padding: 16px;
    font-size: 1.1em;
    font-weight: 600;
    font-family: Arial, sans-serif;
    background: var(--church-primary);
    color: var(--white);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s, transform 0.1s;
}

.widget-call-button:hover {
    background: var(--church-primary-hover);
}

.widget-call-button:active {
    transform: scale(0.98);
}

.call-icon {
    font-size: 1.2em;
}

/* Footer */
.widget-footer {
    padding: 16px;
    text-align: center;
    color: var(--text-light);
    font-size: 0.75em;
    border-top: 1px solid var(--border-color);
}

.widget-footer p {
    margin: 0;
}

/* ============================================================
   Inline Channel Selection Buttons (in chat)
   ============================================================ */

.chat-channel-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
    margin: 4px 0 8px 0;
}

.channel-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    padding: 12px 16px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.1s, opacity 0.2s;
    text-align: left;
    font-family: inherit;
}

.channel-btn:hover {
    transform: translateY(-1px);
    text-decoration: none;
}

.channel-btn:active {
    transform: translateY(0);
}

.channel-btn-main {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95em;
    font-weight: 600;
}

.channel-btn-sub {
    font-size: 0.76em;
    opacity: 0.85;
    padding-left: 26px;
}

.channel-btn-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Phone Call — church primary blue */
.channel-btn-phone {
    background: var(--church-primary);
    color: white;
}

.channel-btn-phone:hover {
    background: var(--church-primary-hover);
    color: white;
}

/* WhatsApp Chat — WhatsApp green */
.channel-btn-wa-chat {
    background: #25D366;
    color: white;
}

.channel-btn-wa-chat:hover {
    background: #20b858;
    color: white;
}

/* WhatsApp Voice — dark WhatsApp teal */
.channel-btn-wa-voice {
    background: #075E54;
    color: white;
}

.channel-btn-wa-voice:hover {
    background: #064e45;
    color: white;
}

/* Facebook Messenger */
.channel-btn-facebook {
    background: #1877F2;
    color: white;
}

.channel-btn-facebook:hover {
    background: #166fe5;
    color: white;
}

/* LINE */
.channel-btn-line {
    background: #06C755;
    color: white;
}

.channel-btn-line:hover {
    background: #05b34c;
    color: white;
}

/* Connecting state */
.connecting-message {
    display: flex;
    align-items: center;
    gap: 10px;
    font-style: italic;
    opacity: 0.8;
}

.connecting-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
}

.connecting-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--church-primary);
    animation: connectPulse 1.2s ease-in-out infinite;
}

.connecting-dot:nth-child(2) { animation-delay: 0.2s; }
.connecting-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes connectPulse {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1.2); opacity: 1; }
}

/* ============================================================
   WhatsApp Channel Offer (legacy — kept as fallback)
   ============================================================ */

.whatsapp-offer {
    padding: 14px 16px;
    background: #f0faf0;
    border: 1px solid #d4edda;
    border-radius: 8px;
    margin-bottom: 12px;
}

.whatsapp-offer-label {
    font-size: 0.9em;
    font-weight: 600;
    color: #1a5c2e;
    margin-bottom: 10px;
    text-align: center;
}

.whatsapp-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.whatsapp-btn {
    flex: 1;
    min-width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.2s, transform 0.1s;
}

.whatsapp-btn:hover {
    transform: translateY(-1px);
    text-decoration: none;
}

.whatsapp-btn:active {
    transform: translateY(0);
}

.whatsapp-chat-btn {
    background: #25D366;
    color: white;
}

.whatsapp-chat-btn:hover {
    background: #20b858;
    color: white;
}

.whatsapp-voice-btn {
    background: #075E54;
    color: white;
}

.whatsapp-voice-btn:hover {
    background: #064e45;
    color: white;
}

.wa-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.whatsapp-skip-btn {
    width: 100%;
    background: none;
    border: none;
    color: #666;
    font-size: 0.8em;
    cursor: pointer;
    padding: 4px 0;
    text-decoration: underline;
    text-align: center;
}

.whatsapp-skip-btn:hover {
    color: #333;
}

/* Area unavailable message */
.area-unavailable-message {
    background: #fff3cd;
    border-left: 3px solid #ffc107;
    color: #856404;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 0.9em;
    line-height: 1.5;
}

/* Responsive - larger screens get centered card layout */
@media (min-width: 481px) {
    body {
        display: flex;
        align-items: flex-start;
        justify-content: center;
        padding: 20px;
    }

    .widget-container {
        min-height: auto;
        border-radius: 12px;
        overflow: hidden;
        margin-top: 20px;
    }
}
