/**
 * iDataMaze Enhanced Chat Widget Styles
 * Version: 2.2.0 - UPDATED with Country Selector & Enhanced Validation
 * 
 * DOWNLOAD AS: chatbot-widget-enhanced.css
 * SAVE TO: assets/css/chatbot-widget-enhanced.css
 * 
 * NEW FEATURES:
 * - Country code selector with 40+ countries
 * - Enhanced phone validation
 * - UK default (+44)
 * - Improved email validation
 * - Better user hints
 */

/* ========== CORE WIDGET STYLES ========== */
.idatamaze-chat-widget {
    position: fixed;
    z-index: 999999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #1e293b;
}

.idatamaze-chat-widget * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ========== CHAT PROMPT BUBBLE ========== */
.idatamaze-chat-prompt {
    position: fixed;
    bottom: 180px;
    right: 25px;
    background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
    color: white;
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.25);
    transition: all 0.3s ease;
    transform: scale(0);
    animation: promptIn 0.6s ease 2s forwards;
    z-index: 999998;
    max-width: 200px;
    font-weight: 600;
}

@keyframes promptIn {
    to { transform: scale(1); }
}

.idatamaze-chat-prompt:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 8px 25px rgba(37, 99, 235, 0.35);
}

.idatamaze-prompt-title {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 4px;
}

.idatamaze-prompt-text {
    font-size: 11px;
    opacity: 0.95;
    transition: opacity 0.3s ease;
}

/* ========== CHAT BUBBLE (FALLBACK) ========== */
.idatamaze-chat-bubble {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 24px rgba(37, 99, 235, 0.3);
    transition: all 0.3s ease;
    transform: scale(0);
    animation: bubbleIn 0.5s ease forwards;
    z-index: 999998;
}

@keyframes bubbleIn {
    to { transform: scale(1); }
}

.idatamaze-chat-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 30px rgba(37, 99, 235, 0.4);
}

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

.idatamaze-chat-icon {
    font-size: 26px;
    color: white;
}

.idatamaze-notification-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    background: #ef4444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: bold;
    animation: pulse 2s infinite;
    border: 2px solid white;
}

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

/* ========== INDUSTRY STANDARD RESPONSIVE CHAT WINDOW ========== */
.idatamaze-chat-window {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 40px);
    max-width: calc(100vw - 40px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    transform: translateY(30px) scale(0.9);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999999;
}

.idatamaze-chat-window.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* ========== RESPONSIVE HEADER ========== */
.idatamaze-chat-header {
    background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
    color: white;
    padding: 16px 20px;
    position: relative;
    min-height: 64px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.idatamaze-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    padding-right: 50px;
}

.idatamaze-avatar {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    position: relative;
}

.idatamaze-online-indicator {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    position: absolute;
    top: -2px;
    right: -2px;
    border: 2px solid white;
    animation: pulse 2s infinite;
}

.idatamaze-header-text {
    flex: 1;
    min-width: 0;
}

.idatamaze-chat-header h3 {
    font-size: 15px;
    margin: 0;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.idatamaze-chat-header p {
    opacity: 0.9;
    font-size: 11px;
    margin: 2px 0 0 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.idatamaze-close-chat {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    font-size: 18px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

/* ========== RESPONSIVE CHAT INPUT ========== */
.idatamaze-chat-input-container {
    padding: 16px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
    min-height: 60px;
}

.idatamaze-chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
    font-family: inherit;
    line-height: 1.4;
    max-height: 80px;
    resize: none;
    min-height: 36px;
}

.idatamaze-send-btn {
    background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 18px;
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    min-width: 60px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ========== MOBILE RESPONSIVE (Industry Standard) ========== */
@media (max-width: 768px) {
    .idatamaze-chat-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        right: 10px;
        bottom: 10px;
        border-radius: 12px;
    }
}

@media (max-width: 480px) {
    .idatamaze-chat-window {
        width: 100vw;
        height: 100vh;
        right: 0;
        bottom: 0;
        border-radius: 0;
        max-width: none;
        max-height: none;
    }
    
    .idatamaze-chat-header {
        padding: 12px 16px;
        min-height: 56px;
    }
    
    .idatamaze-chat-input-container {
        padding: 12px;
    }
}

/* ========== TABLET (iPad) ========== */
@media (min-width: 481px) and (max-width: 1024px) {
    .idatamaze-chat-window {
        width: 400px;
        height: 650px;
    }
}

/* ========== LARGE SCREENS ========== */
@media (min-width: 1400px) {
    .idatamaze-chat-window {
        width: 420px;
        height: 680px;
    }
}
/* ========== FORM STYLES ========== */
.idatamaze-chat-form {
    padding: 28px;
    flex: 1;
    overflow-y: auto;
    background: #fafbfc;
}

.idatamaze-welcome-message {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 24px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.idatamaze-welcome-message strong {
    color: #1e293b;
    display: block;
    margin-bottom: 8px;
    font-size: 16px;
}

.idatamaze-form-group {
    margin-bottom: 20px;
}

.idatamaze-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #374151;
    font-size: 14px;
}

.idatamaze-form-control {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: white;
    font-family: inherit;
}

.idatamaze-form-control:focus {
    outline: none;
    border-color: #2563EB;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
    transform: translateY(-1px);
}

.idatamaze-form-control.error {
    border-color: #ef4444;
    background: #fef2f2;
}

.idatamaze-error-message {
    color: #ef4444;
    font-size: 12px;
    margin-top: 6px;
    display: none;
    font-weight: 500;
}

.idatamaze-form-control.error ~ .idatamaze-error-message {
    display: block;
}

textarea.idatamaze-form-control {
    resize: vertical;
    min-height: 100px;
    max-height: 150px;
    line-height: 1.5;
}

/* ========== COUNTRY CODE SELECTOR ========== */
.idatamaze-phone-container {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.idatamaze-country-selector {
    position: relative;
    min-width: 120px;
    flex-shrink: 0;
}

.idatamaze-country-dropdown {
    width: 100%;
    padding: 14px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.idatamaze-country-dropdown:focus {
    outline: none;
    border-color: #2563EB;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.idatamaze-country-dropdown.error {
    border-color: #ef4444;
    background: #fef2f2;
}

.idatamaze-selected-country {
    display: flex;
    align-items: center;
    gap: 6px;
}

.idatamaze-selected-code {
    font-weight: 500;
    color: #374151;
}

.idatamaze-dropdown-content {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    margin-top: 4px;
}

.idatamaze-dropdown-content.show {
    display: block;
}

.idatamaze-country-option {
    padding: 12px;
    cursor: pointer;
    transition: background 0.2s ease;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.idatamaze-country-option:hover {
    background: #f8fafc;
}

.idatamaze-country-option.selected {
    background: #2563EB;
    color: white;
}

.idatamaze-country-flag {
    font-size: 16px;
}

.idatamaze-country-info {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.idatamaze-country-name {
    font-weight: 500;
}

.idatamaze-country-code {
    color: #6b7280;
    font-size: 13px;
}

.idatamaze-country-option.selected .idatamaze-country-code {
    color: rgba(255, 255, 255, 0.8);
}

.idatamaze-phone-input-wrapper {
    flex: 1;
}

.idatamaze-phone-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: white;
    font-family: inherit;
}

.idatamaze-phone-input:focus {
    outline: none;
    border-color: #2563EB;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
    transform: translateY(-1px);
}

.idatamaze-phone-input.error {
    border-color: #ef4444;
    background: #fef2f2;
}

/* Dropdown scrollbar styling */
.idatamaze-dropdown-content::-webkit-scrollbar {
    width: 6px;
}

.idatamaze-dropdown-content::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.idatamaze-dropdown-content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.idatamaze-dropdown-arrow {
    margin-left: 8px;
    transition: transform 0.3s ease;
    font-size: 12px;
    color: #6b7280;
}

.idatamaze-country-dropdown.open .idatamaze-dropdown-arrow {
    transform: rotate(180deg);
}

/* ========== SUBMIT BUTTON ========== */
.idatamaze-submit-btn {
    width: 100%;
    background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.idatamaze-submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

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

.idatamaze-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.idatamaze-submit-btn.loading .idatamaze-loading-spinner {
    display: inline-block;
}

.idatamaze-loading-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.idatamaze-security-badge {
    text-align: center;
    font-size: 12px;
    color: #6b7280;
    margin-top: 12px;
    padding: 8px;
    background: rgba(37, 99, 235, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(37, 99, 235, 0.1);
}

/* ========== SUCCESS MESSAGE ========== */
.idatamaze-success-message {
    display: none;
    text-align: center;
    padding: 40px 28px;
    color: #1e293b;
    background: white;
    border-radius: 12px;
    margin: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.idatamaze-success-message h3 {
    color: #10b981;
    margin-bottom: 12px;
    font-size: 18px;
}

/* ========== CHAT INTERFACE ========== */
.idatamaze-chat-interface {
    display: none;
    flex-direction: column;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.idatamaze-chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background: #f8fafc;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
    min-height: 0;
    max-height: calc(100% - 140px); /* Reserve space for input */
}

.idatamaze-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.idatamaze-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.idatamaze-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.idatamaze-message {
    margin-bottom: 16px;
    animation: messageSlideIn 0.4s ease;
}

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

.idatamaze-user-message {
    text-align: right;
}

.idatamaze-user-message .idatamaze-message-content {
    background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
    color: white;
    padding: 14px 18px;
    border-radius: 18px 18px 6px 18px;
    display: inline-block;
    max-width: 85%;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.4;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.idatamaze-bot-message .idatamaze-message-content {
    background: white;
    border: 1px solid #e2e8f0;
    padding: 14px 18px;
    border-radius: 18px 18px 18px 6px;
    display: inline-block;
    max-width: 85%;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    font-size: 14px;
    line-height: 1.4;
    color: #1e293b;
}

.idatamaze-message-time {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 6px;
    font-weight: 500;
}

.idatamaze-user-message .idatamaze-message-time {
    text-align: right;
}

.idatamaze-typing-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px 18px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 18px 18px 18px 6px;
    max-width: 85%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.idatamaze-typing-dots {
    display: flex;
    gap: 4px;
}

.idatamaze-typing-dot {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typingPulse 1.4s infinite;
}

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

@keyframes typingPulse {
    0%, 60%, 100% { opacity: 0.3; }
    30% { opacity: 1; }
}

/* ========== CHAT INPUT ========== */
.idatamaze-chat-input-container {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
    align-items: flex-end;
  	min-height: 70px;
}

.idatamaze-chat-input {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid #e5e7eb;
    border-radius: 22px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s ease;
    font-family: inherit;
    line-height: 1.4;
    max-height: 120px;
    resize: none;
}

.idatamaze-chat-input:focus {
    border-color: #2563EB;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.idatamaze-send-btn {
    background: linear-gradient(135deg, #2563EB 0%, #1D4ED8 100%);
    color: white;
    border: none;
    padding: 12px 18px;
    border-radius: 22px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.idatamaze-send-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.idatamaze-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ========== RESPONSIVE DESIGN ========== */
@media (max-width: 768px) {
    .idatamaze-chat-window {
        width: calc(100vw - 30px);
        height: calc(100vh - 120px);
        right: 15px;
        bottom: 90px;
    }

    .idatamaze-chat-bubble,
    .idatamaze-chat-prompt {
        right: 20px;
        bottom: 20px;
    }

    .idatamaze-chat-prompt {
        bottom: 100px;
        max-width: 180px;
    }
}

@media (max-width: 480px) {
    .idatamaze-chat-window {
        width: 100vw;
        height: 100vh;
        right: 0;
        bottom: 0;
        border-radius: 0;
        max-width: none;
        max-height: none;
    }

    .idatamaze-chat-bubble {
        right: 20px;
        bottom: 20px;
        width: 60px;
        height: 60px;
    }

    .idatamaze-chat-prompt {
        right: 20px;
        bottom: 90px;
        max-width: 160px;
        padding: 10px 14px;
    }

    .idatamaze-chat-form {
        padding: 20px;
    }

    .idatamaze-chat-messages {
        padding: 16px;
    }

    .idatamaze-chat-input-container {
        padding: 16px 20px;
    }

    /* Mobile responsive adjustments for country selector */
    .idatamaze-phone-container {
        flex-direction: column;
        gap: 12px;
    }
    
    .idatamaze-country-selector {
        min-width: auto;
    }
    
    .idatamaze-dropdown-content {
        max-height: 150px;
    }
}

/* ========== THEME VARIATIONS ========== */
.scheme-dark .idatamaze-chat-window {
    background: #1f2937;
    color: #f3f4f6;
}

.scheme-dark .idatamaze-chat-form {
    background: #1f2937;
}

.scheme-dark .idatamaze-form-control,
.scheme-dark .idatamaze-phone-input,
.scheme-dark .idatamaze-country-dropdown {
    background: #374151;
    border-color: #4b5563;
    color: #f3f4f6;
}

.scheme-dark .idatamaze-chat-messages {
    background: #111827;
}

.scheme-dark .idatamaze-bot-message .idatamaze-message-content {
    background: #374151;
    border-color: #4b5563;
    color: #f3f4f6;
}

.scheme-dark .idatamaze-dropdown-content {
    background: #374151;
    border-color: #4b5563;
}

.scheme-dark .idatamaze-country-option:hover {
    background: #4b5563;
}

/* ========== ACCESSIBILITY ========== */
@media (prefers-reduced-motion: reduce) {
    .idatamaze-chat-widget *,
    .idatamaze-chat-widget *::before,
    .idatamaze-chat-widget *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.idatamaze-chat-widget button:focus-visible,
.idatamaze-chat-widget .idatamaze-country-dropdown:focus-visible {
    outline: 2px solid #2563EB;
    outline-offset: 2px;
}

.idatamaze-chat-widget input:focus-visible,
.idatamaze-chat-widget textarea:focus-visible {
    outline: 2px solid #2563EB;
    outline-offset: 2px;
}
 /* ========== FORCE OPTIONAL PHONE FIELD ========== */
/* Force optional styling for phone field */
#idatamazePhone:invalid,
.idatamaze-phone-input:invalid {
    border-color: #e5e7eb !important;
    background: white !important;
}

#idatamazePhone:placeholder-shown,
.idatamaze-phone-input:placeholder-shown {
    border-color: #e5e7eb !important;
}

/* Remove red error styling from empty phone field */
#idatamazePhone:not(:focus):placeholder-shown {
    border-color: #e5e7eb !important;
    background: white !important;
}

.idatamaze-phone-input:not(:focus):placeholder-shown {
    border-color: #e5e7eb !important;
    background: white !important;
}