/* ===== CSS Variables ===== */
:root {
    --primary-color: #F5A623;
    --primary-hover: #E09000;
    --secondary-color: #2E7D32;
    --background-color: #FDF2F8;
    --chat-bg: #FFFFFF;
    --bot-message-bg: #FFFFFF;
    --user-message-bg: #F8F9FA;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-light: #999999;
    --border-color: #E0E0E0;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.15);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Header ===== */
.header {
    background: white;
    padding: 15px 20px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 800px;
    margin: 0 auto;
}

.logo img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-name {
    font-weight: 600;
    font-size: 16px;
    color: var(--text-primary);
}

.logo-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== Chat Container ===== */
.chat-container {
    flex: 1;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 80px);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 20px;
    scroll-behavior: smooth;
}

/* ===== Message Styles ===== */
.message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

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

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4ECDC4, #44A08D);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.message-avatar.user {
    background: var(--primary-color);
}

.message-content {
    max-width: 70%;
    background: var(--bot-message-bg);
    border-radius: var(--radius);
    padding: 15px 18px;
    box-shadow: var(--shadow);
}

.message.user .message-content {
    background: var(--user-message-bg);
    border: 1px solid var(--border-color);
}

.message-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
}

.message-text strong {
    color: var(--secondary-color);
}

.message-image {
    max-width: 200px;
    border-radius: 8px;
    overflow: hidden;
}

.message-image img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}

.message-time {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 8px;
    text-align: right;
}

/* ===== Input Components ===== */
.input-area {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-top: auto;
}

.input-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    display: block;
}

/* Text Input */
.text-input-group {
    display: flex;
    gap: 10px;
}

.text-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.text-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Number Input */
.number-input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.number-input {
    width: 160px;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 16px;
    text-align: center;
    font-family: inherit;
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Hide spinner buttons in Chrome, Safari, Edge */
.number-input::-webkit-outer-spin-button,
.number-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.number-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.number-controls {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.number-controls button {
    width: 30px;
    height: 20px;
    border: 1px solid var(--border-color);
    background: white;
    cursor: pointer;
    font-size: 10px;
    transition: var(--transition);
}

.number-controls button:hover {
    background: var(--background-color);
}

/* Button Options */
.button-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.option-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    background: var(--primary-color);
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.option-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.option-btn.secondary {
    background: #E91E63;
}

.option-btn.secondary:hover {
    background: #C2185B;
}

/* Submit Button */
.submit-btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary-color);
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.submit-btn:hover {
    background: var(--primary-hover);
}

.submit-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* ===== File Upload ===== */
.file-upload-section {
    margin-top: 15px;
}

.file-guide {
    background: #E3F2FD;
    padding: 15px;
    border-radius: var(--radius-sm);
    margin-bottom: 15px;
}

.file-guide h4 {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.file-guide ul {
    font-size: 13px;
    color: var(--text-secondary);
    margin-left: 20px;
}

.file-guide-image {
    width: 100%;
    max-width: 300px;
    border-radius: var(--radius-sm);
    margin-top: 10px;
}

.file-dropzone {
    border: 2px dashed var(--primary-color);
    border-radius: var(--radius);
    padding: 30px;
    text-align: center;
    background: #FFF8E1;
    cursor: pointer;
    transition: var(--transition);
}

.file-dropzone:hover {
    background: #FFECB3;
}

.file-dropzone.dragover {
    background: #FFE082;
    border-color: var(--primary-hover);
}

.file-dropzone-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.file-dropzone-text {
    font-size: 14px;
    color: var(--text-secondary);
}

.file-dropzone-text strong {
    color: var(--primary-color);
}

.file-input {
    display: none;
}

.file-preview {
    margin-top: 15px;
    display: none;
}

.file-preview.show {
    display: block;
}

.file-preview img {
    max-width: 200px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--secondary-color);
}

.file-info {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 10px;
}

/* ===== Back Button ===== */
.back-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    margin-top: 15px;
    padding: 5px 0;
}

.back-btn:hover {
    color: var(--text-primary);
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(253, 242, 248, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.show {
    display: flex;
}

.loading-content {
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.loading-content p {
    font-size: 16px;
    color: var(--text-secondary);
}

/* ===== Result Modal ===== */
.result-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.result-modal.show {
    display: flex;
}

.result-content {
    background: white;
    border-radius: var(--radius);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.result-header {
    background: linear-gradient(135deg, var(--secondary-color), #4CAF50);
    color: white;
    padding: 25px;
    text-align: center;
}

.result-header h2 {
    font-size: 22px;
    margin-bottom: 10px;
}

.result-note {
    font-size: 12px;
    opacity: 0.9;
}

.result-body {
    padding: 25px;
}

.result-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--background-color);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}

.result-icon {
    font-size: 24px;
}

.result-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.result-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--secondary-color);
}

.result-actions {
    padding: 20px 25px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.btn {
    flex: 1;
    min-width: 140px;
    padding: 14px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

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

.btn-calendly {
    background: #006BFF;
    color: white;
}

.btn-calendly:hover {
    background: #0052CC;
}

.btn-secondary {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #D0D0D0;
}

/* ===== Contact Form ===== */
.contact-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 13px;
    color: var(--text-secondary);
}

.form-group input {
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ===== Country Code Phone Input ===== */
.phone-input-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.country-code-selector {
    position: relative;
    flex-shrink: 0;
}

.cc-selected-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: white;
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    height: 100%;
    white-space: nowrap;
    transition: var(--transition);
}

.cc-selected-btn:hover {
    border-color: var(--primary-color);
}

.cc-flag {
    font-size: 20px;
    line-height: 1;
}

.cc-code {
    font-weight: 500;
    color: var(--text-primary);
}

.cc-arrow {
    font-size: 11px;
    color: var(--text-secondary);
    margin-left: 2px;
}

.cc-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 280px;
    max-height: 300px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    overflow: hidden;
    flex-direction: column;
}

.cc-dropdown.open {
    display: flex;
}

.cc-search-box {
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.cc-search-box input {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: var(--transition);
}

.cc-search-box input:focus {
    border-color: var(--primary-color);
}

.cc-list {
    overflow-y: auto;
    max-height: 240px;
    overscroll-behavior: contain;
}

.cc-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.15s ease;
    font-size: 13px;
}

.cc-item:hover {
    background: #FFF8E1;
}

.cc-item.active {
    background: #FFF3E0;
    font-weight: 500;
}

.cc-item-flag {
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
}

.cc-item-country {
    flex: 1;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cc-item-code {
    color: var(--text-secondary);
    font-weight: 500;
    flex-shrink: 0;
}

.cc-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-light);
    font-size: 13px;
}

.phone-number-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    min-width: 0;
}

.phone-number-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    .chat-container {
        padding: 10px;
    }

    .message-content {
        max-width: 85%;
    }

    .button-options {
        flex-direction: column;
    }

    .option-btn {
        width: 100%;
    }

    .result-actions {
        flex-direction: column;
    }

    .cc-dropdown {
        width: 260px;
    }

    .phone-input-row {
        gap: 6px;
    }

    .cc-selected-btn {
        padding: 10px 8px;
    }
}

/* ===== Mobile Wizard ===== */
#mobileWizard {
    display: none;
    flex-direction: column;
    min-height: 100dvh;
    background: #FDF2F8;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mw-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: white;
    border-bottom: 1px solid #f0e0ea;
    position: sticky;
    top: 0;
    z-index: 10;
}

.mw-back-btn {
    background: none;
    border: 1.5px solid #F5A623;
    border-radius: 20px;
    color: #F5A623;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 14px;
    font-family: inherit;
    transition: background 0.2s, color 0.2s;
}

.mw-back-btn:hover {
    background: #F5A623;
    color: white;
}

.mw-back-placeholder {
    width: 80px;
}

.mw-logo-img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
}

.mw-phase-counter {
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 2.5px;
    color: #aaa;
    padding: 18px 20px 8px;
}

.mw-stepper {
    display: flex;
    gap: 5px;
    padding: 0 20px;
    margin-bottom: 10px;
}

.mw-step-bar {
    flex: 1;
    height: 5px;
    border-radius: 3px;
    background: #E8D8E0;
    transition: background 0.35s ease;
}

.mw-step-bar.done {
    background: #2E7D32;
}

.mw-step-bar.active {
    background: #F5A623;
}

.mw-phase-name {
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 3px;
    color: #F5A623;
    padding: 2px 20px 4px;
}

.mw-dashes {
    text-align: center;
    color: #CCC;
    font-size: 12px;
    letter-spacing: 5px;
    padding: 2px 20px 14px;
}

.mw-card {
    margin: 0 16px 16px;
    background: white;
    border-radius: 20px;
    padding: 22px 20px 24px;
    box-shadow: 0 4px 24px rgba(245, 166, 35, 0.13);
    flex: 1;
}

.mw-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #FFF3E0;
    color: #E08C00;
    font-size: 11px;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 20px;
    margin-bottom: 16px;
    letter-spacing: 0.3px;
}

.mw-badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #F5A623;
    display: inline-block;
    flex-shrink: 0;
}

.mw-question {
    font-size: 17px;
    font-weight: 600;
    color: #222;
    line-height: 1.55;
    margin-bottom: 22px;
}

/* Override desktop input styles inside wizard card */
.mw-input-area .button-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mw-input-area .option-btn {
    width: 100%;
    padding: 14px 18px;
    font-size: 15px;
    border-radius: 12px;
    text-align: left;
}

.mw-input-area .text-input-group {
    flex-direction: column;
    gap: 10px;
}

.mw-input-area .text-input {
    font-size: 16px;
    padding: 14px 16px;
    border-radius: 12px;
}

.mw-input-area .number-input-group {
    gap: 12px;
}

.mw-input-area .number-input {
    width: 130px;
    font-size: 24px;
    padding: 14px;
    border-radius: 12px;
}

.mw-input-area .submit-btn {
    padding: 14px 24px;
    font-size: 15px;
    border-radius: 12px;
    width: 100%;
    justify-content: center;
    margin-top: 6px;
}

/* Hide the desktop back button inside wizard (wizard has its own) */
.mw-input-area .back-btn {
    display: none;
}

.mw-input-area .file-upload-section {
    margin-top: 0;
}

.mw-input-area .file-dropzone {
    padding: 22px 16px;
    border-radius: 14px;
}

.mw-input-area .contact-form {
    gap: 14px;
}

.mw-input-area .form-group input {
    font-size: 16px;
    padding: 13px 14px;
    border-radius: 10px;
}

.mw-footer-brand {
    text-align: center;
    font-size: 12px;
    color: #C0A8C0;
    padding: 12px 20px 28px;
}

@media (max-width: 767px) {
    .header,
    main.chat-container {
        display: none !important;
    }

    #mobileWizard {
        display: flex;
    }
}

@media (max-width: 767px) {
    body {
        background:
            radial-gradient(circle at top left, rgba(245, 166, 35, 0.16), transparent 260px),
            var(--background-color);
    }

    #mobileWizard {
        min-height: 100svh;
    }

    .mw-header {
        padding: 12px 16px;
        padding-top: max(12px, env(safe-area-inset-top));
        box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
    }

    .mw-back-placeholder {
        width: 70px;
    }

    .mw-back-btn {
        min-height: 36px;
        padding: 7px 12px;
    }

    .mw-logo-img {
        width: 40px;
        height: 40px;
    }

    .mw-phase-counter {
        padding: 16px 16px 8px;
        letter-spacing: 2px;
    }

    .mw-stepper {
        padding: 0 16px;
    }

    .mw-phase-name,
    .mw-dashes {
        padding-left: 16px;
        padding-right: 16px;
    }

    .mw-card {
        margin: 0 12px 14px;
        padding: 20px 18px 22px;
        border: 1px solid rgba(245, 166, 35, 0.12);
        border-radius: 24px;
        box-shadow: 0 8px 30px rgba(245, 166, 35, 0.14);
    }

    .mw-question {
        font-size: clamp(17px, 4.8vw, 20px);
        line-height: 1.5;
        margin-bottom: 20px;
    }

    .mw-input-area .option-btn,
    .mw-input-area .submit-btn,
    .mw-input-area .text-input,
    .mw-input-area .form-group input,
    .mw-input-area .phone-number-input,
    .mw-input-area .cc-selected-btn {
        min-height: 48px;
        border-radius: 14px;
    }

    .mw-input-area .option-btn {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        white-space: normal;
        line-height: 1.35;
    }

    .mw-input-area .number-input-group {
        justify-content: center;
    }

    .mw-input-area .number-input {
        width: min(100%, 160px);
    }

    .mw-input-area .file-guide,
    .mw-input-area .file-dropzone {
        border-radius: 18px;
    }

    .mw-input-area .file-dropzone {
        padding: 26px 16px;
    }

    .mw-input-area .file-preview img {
        max-width: 100%;
    }

    .phone-input-row {
        align-items: stretch;
    }

    .cc-dropdown {
        left: 0;
        width: min(88vw, 320px);
        max-height: 260px;
    }

    .result-modal {
        align-items: flex-end;
        padding: 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .result-content {
        max-height: 88svh;
        border-radius: 24px;
    }

    .result-header,
    .result-body,
    .result-actions {
        padding-left: 18px;
        padding-right: 18px;
    }

    .result-header h2 {
        font-size: 20px;
        line-height: 1.25;
    }

    .result-item {
        align-items: flex-start;
        padding: 14px;
        border-radius: 14px;
    }

    .result-actions {
        flex-direction: column;
    }

    .result-actions .btn {
        width: 100%;
        min-height: 48px;
    }

    .loading-content {
        width: min(100% - 32px, 320px);
        padding: 24px;
        border-radius: 20px;
        background: rgba(255, 255, 255, 0.86);
        box-shadow: var(--shadow-lg);
    }
}

@media (max-width: 374px) {
    .mw-card {
        margin-left: 8px;
        margin-right: 8px;
        padding: 18px 14px 20px;
    }

    .mw-back-placeholder {
        width: 58px;
    }

    .mw-back-btn {
        padding-left: 10px;
        padding-right: 10px;
    }

    .mw-input-area .number-input-group,
    .phone-input-row {
        flex-direction: column;
    }

    .mw-input-area .number-input,
    .phone-number-input,
    .cc-selected-btn {
        width: 100%;
    }
}
