/**
 * Chat Styles - Nordersun v6.2
 * Mobile-first responsive design for the eSIM sales chat
 */

/* ==========================================
   RESET & BASE
   ========================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --chat-primary: #1e3a5f;
    --chat-primary-light: #2d5f8a;
    --chat-accent: #3498db;
    --chat-bg: #f0f4f8;
    --chat-white: #ffffff;
    --chat-text: #2c3e50;
    --chat-text-light: #7f8c8d;
    --chat-border: #e1e8ed;
    --chat-user-bg: #1e3a5f;
    --chat-user-text: #ffffff;
    --chat-assistant-bg: #ffffff;
    --chat-success: #27ae60;
    --chat-error: #e74c3c;
    --chat-radius: 16px;
    --chat-radius-sm: 10px;
    --chat-shadow: 0 2px 12px rgba(0,0,0,0.08);
    --chat-max-width: 520px;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 15px;
    color: var(--chat-text);
    background: var(--chat-bg);
    -webkit-font-smoothing: antialiased;
}

/* ==========================================
   LAYOUT
   ========================================== */
#chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: var(--chat-max-width);
    margin: 0 auto;
    background: var(--chat-bg);
}

/* ==========================================
   HEADER
   ========================================== */
#chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--chat-primary);
    color: white;
    flex-shrink: 0;
}

.chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.chat-header-info h1 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.chat-header-info p {
    font-size: 12px;
    opacity: 0.8;
    margin: 0;
}

/* ==========================================
   MESSAGES AREA
   ========================================== */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* ==========================================
   MESSAGE BUBBLES
   ========================================== */
.chat-msg {
    display: flex;
    max-width: 88%;
}

.chat-msg-user {
    align-self: flex-end;
}

.chat-msg-assistant {
    align-self: flex-start;
}

.chat-bubble {
    padding: 10px 14px;
    border-radius: var(--chat-radius);
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: var(--chat-shadow);
}

.chat-msg-user .chat-bubble {
    background: var(--chat-user-bg);
    color: var(--chat-user-text);
    border-bottom-right-radius: 4px;
}

.chat-msg-assistant .chat-bubble {
    background: var(--chat-assistant-bg);
    color: var(--chat-text);
    border-bottom-left-radius: 4px;
}

.chat-bubble-wide {
    width: 100%;
}

/* Animation */
.chat-msg-animate {
    animation: chatSlideIn 0.3s ease-out;
}

@keyframes chatSlideIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================
   TYPING INDICATOR
   ========================================== */
.chat-typing .chat-bubble {
    display: flex;
    gap: 4px;
    padding: 14px 18px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chat-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); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ==========================================
   COUNTRY GRID
   ========================================== */
.chat-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--chat-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.chat-country-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chat-country-btn {
    padding: 8px 12px;
    border: 1px solid var(--chat-border);
    border-radius: 20px;
    background: var(--chat-white);
    color: var(--chat-text);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.chat-country-btn:hover {
    background: var(--chat-primary);
    color: white;
    border-color: var(--chat-primary);
}

.chat-regional-btn {
    background: #f8f9fa;
    border-style: dashed;
}

.chat-search-wrap {
    margin-top: 10px;
}

.chat-search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--chat-border);
    border-radius: var(--chat-radius-sm);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-search-input:focus {
    border-color: var(--chat-accent);
}

/* ==========================================
   OPTIONS (DATA / DURATION)
   ========================================== */
.chat-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
}

.chat-option-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    border: 2px solid var(--chat-border);
    border-radius: var(--chat-radius-sm);
    background: var(--chat-white);
    cursor: pointer;
    transition: all 0.2s;
}

.chat-option-btn:hover {
    border-color: var(--chat-accent);
    background: #f0f7ff;
}

.chat-option-selected {
    border-color: var(--chat-primary) !important;
    background: #e8f0fe !important;
}

.chat-option-main {
    font-size: 16px;
    font-weight: 700;
    color: var(--chat-primary);
}

.chat-option-sub {
    font-size: 12px;
    color: var(--chat-text-light);
    margin-top: 2px;
}

/* ==========================================
   PLAN SUMMARY
   ========================================== */
.chat-plan-summary {
    padding: 4px 0;
}

.chat-plan-header {
    font-size: 18px;
    font-weight: 700;
    color: var(--chat-primary);
    margin-bottom: 12px;
    text-align: center;
}

.chat-plan-details {
    border: 1px solid var(--chat-border);
    border-radius: var(--chat-radius-sm);
    overflow: hidden;
    margin-bottom: 12px;
}

.chat-plan-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 14px;
    font-size: 14px;
    border-bottom: 1px solid var(--chat-border);
}

.chat-plan-row:last-child { border-bottom: none; }

.chat-plan-row span:first-child {
    color: var(--chat-text-light);
}

.chat-plan-row span:last-child {
    font-weight: 600;
}

.chat-plan-price {
    background: #f0f7ff;
}

.chat-plan-price span:last-child {
    color: var(--chat-primary);
    font-size: 18px;
}

.chat-plan-actions {
    display: flex;
    gap: 8px;
}

/* ==========================================
   BUTTONS
   ========================================== */
.chat-btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--chat-radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    text-align: center;
}

.chat-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-btn-primary {
    background: var(--chat-primary);
    color: white;
    flex: 1;
}

.chat-btn-primary:hover:not(:disabled) {
    background: var(--chat-primary-light);
}

.chat-btn-secondary {
    background: transparent;
    color: var(--chat-text-light);
    border: 1px solid var(--chat-border);
    flex: 1;
}

.chat-btn-secondary:hover:not(:disabled) {
    background: #f8f9fa;
}

.chat-btn-full { width: 100%; }

.chat-btn-link {
    background: none;
    color: var(--chat-accent);
    padding: 6px 12px;
    font-size: 13px;
}

.chat-btn-link:hover { text-decoration: underline; }

/* ==========================================
   FORMS
   ========================================== */
.chat-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--chat-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.chat-form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--chat-border);
    border-radius: var(--chat-radius-sm);
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

.chat-form-group input:focus {
    border-color: var(--chat-accent);
}

/* ==========================================
   VERIFICATION
   ========================================== */
.chat-verify-section {
    text-align: center;
}

.chat-verify-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.chat-otp-wrap {
    margin-bottom: 12px;
}

.chat-otp-input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--chat-border);
    border-radius: var(--chat-radius-sm);
    font-size: 24px;
    text-align: center;
    letter-spacing: 12px;
    font-weight: 700;
    outline: none;
    transition: border-color 0.2s;
}

.chat-otp-input:focus {
    border-color: var(--chat-accent);
}

.chat-verify-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
}

/* ==========================================
   STRIPE
   ========================================== */
.chat-stripe-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#stripe-card-element {
    padding: 12px;
    border: 2px solid var(--chat-border);
    border-radius: var(--chat-radius-sm);
    background: var(--chat-white);
    transition: border-color 0.2s;
}

#stripe-card-element.StripeElement--focus {
    border-color: var(--chat-accent);
}

.chat-error-text {
    color: var(--chat-error);
    font-size: 13px;
    min-height: 18px;
}

/* ==========================================
   SUCCESS
   ========================================== */
.chat-success {
    text-align: center;
    padding: 16px 0;
}

.chat-success-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--chat-success);
    color: white;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    animation: chatSuccessPop 0.5s ease-out;
}

@keyframes chatSuccessPop {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.chat-success-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--chat-primary);
    margin-bottom: 16px;
}

/* ==========================================
   INPUT AREA
   ========================================== */
#chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: var(--chat-white);
    border-top: 1px solid var(--chat-border);
    flex-shrink: 0;
}

#chat-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--chat-border);
    border-radius: 24px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s;
}

#chat-input:focus {
    border-color: var(--chat-accent);
}

#chat-send {
    padding: 10px 18px;
    background: var(--chat-primary);
    color: white;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

#chat-send:hover {
    background: var(--chat-primary-light);
}

/* ==========================================
   FOOTER
   ========================================== */
#chat-footer {
    text-align: center;
    padding: 8px;
    font-size: 11px;
    color: var(--chat-text-light);
    flex-shrink: 0;
}

#chat-footer a {
    color: var(--chat-accent);
    text-decoration: none;
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (min-width: 768px) {
    #chat-container {
        max-width: var(--chat-max-width);
        margin: 20px auto;
        height: calc(100vh - 40px);
        border-radius: 20px;
        overflow: hidden;
        box-shadow: 0 8px 40px rgba(0,0,0,0.12);
    }
}

/* Scrollbar */
#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-track { background: transparent; }
#chat-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
