/* ============================================================
   Mesoflow Contact Popup — self-contained component
   Toast trigger + inquiry modal
   Load on any page; call ContactPopup.init() to activate
   ============================================================ */

.cp-toast,
.cp-modal-backdrop {
    --cp-blue:       #003087;
    --cp-teal:       #00A99D;
    --cp-teal-dark:  #007e77;
    --cp-text:       #333;
    --cp-subtext:    #555;
    --cp-border:     #d0d5dd;
    --cp-bg:         #fff;
    --cp-shadow:     0 4px 20px rgba(0, 0, 0, 0.15);
    --cp-shadow-lg:  0 8px 40px rgba(0, 0, 0, 0.25);
    --cp-ease:       250ms ease;
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* ── TOAST ── */
.cp-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 280px;
    background: var(--cp-bg);
    border-radius: 10px;
    border-top: 4px solid var(--cp-teal);
    box-shadow: var(--cp-shadow);
    z-index: 10000;
    padding: 16px;
    transform: translateX(320px);
    opacity: 0;
    transition: transform var(--cp-ease), opacity var(--cp-ease);
    box-sizing: border-box;
}

.cp-toast.cp-toast--visible {
    transform: translateX(0);
    opacity: 1;
}

.cp-toast__heading {
    font-weight: 700;
    font-size: 14px;
    color: var(--cp-blue);
    margin-bottom: 4px;
    line-height: 1.3;
}

.cp-toast__body {
    font-size: 12px;
    color: var(--cp-subtext);
    margin-bottom: 12px;
    line-height: 1.4;
}

.cp-toast__actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cp-toast__cta {
    flex: 1;
    background: var(--cp-teal);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background var(--cp-ease);
}

.cp-toast__cta:hover {
    background: var(--cp-teal-dark);
}

.cp-toast__dismiss {
    background: none;
    border: none;
    cursor: pointer;
    color: #aaa;
    font-size: 20px;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 4px;
    font-family: inherit;
    transition: color var(--cp-ease);
}

.cp-toast__dismiss:hover {
    color: var(--cp-text);
}

/* ── MODAL BACKDROP ── */
.cp-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10001;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 0 24px 24px 0;
    opacity: 0;
    transition: opacity var(--cp-ease);
    box-sizing: border-box;
}

.cp-modal-backdrop.cp-modal-backdrop--visible {
    opacity: 1;
}

/* ── MODAL CARD ── */
.cp-modal {
    background: var(--cp-bg);
    border-radius: 10px;
    border-top: 4px solid var(--cp-teal);
    box-shadow: var(--cp-shadow-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(16px);
    transition: transform var(--cp-ease);
    box-sizing: border-box;
}

.cp-modal-backdrop--visible .cp-modal {
    transform: translateY(0);
}

.cp-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 20px 20px 0;
    gap: 12px;
}

.cp-modal__title {
    font-size: 18px;
    font-weight: 700;
    color: var(--cp-blue);
    line-height: 1.2;
    margin: 0;
}

.cp-modal__subtitle {
    font-size: 12px;
    color: #777;
    margin-top: 5px;
    line-height: 1.4;
}

.cp-modal__close {
    background: none;
    border: none;
    cursor: pointer;
    color: #aaa;
    font-size: 22px;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 4px;
    flex-shrink: 0;
    font-family: inherit;
    transition: color var(--cp-ease);
    margin-top: -2px;
}

.cp-modal__close:hover {
    color: var(--cp-text);
}

/* ── FORM ── */
.cp-modal__body {
    padding: 16px 20px 20px;
}

.cp-form__field {
    margin-bottom: 12px;
}

.cp-form__label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #444;
    margin-bottom: 4px;
}

.cp-form__required {
    color: var(--cp-teal);
    margin-left: 1px;
}

.cp-form__input,
.cp-form__textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--cp-border);
    border-radius: 6px;
    font-size: 13px;
    color: var(--cp-text);
    background: var(--cp-bg);
    box-sizing: border-box;
    font-family: inherit;
    transition: border-color var(--cp-ease), box-shadow var(--cp-ease);
}

.cp-form__input:focus,
.cp-form__textarea:focus {
    outline: none;
    border-color: var(--cp-teal);
    box-shadow: 0 0 0 3px rgba(0, 169, 157, 0.15);
}

.cp-form__textarea {
    resize: vertical;
    min-height: 72px;
}

.cp-form__error-msg {
    display: none;
    font-size: 12px;
    color: #c0392b;
    background: #fdf2f2;
    border: 1px solid #f5c6c6;
    border-radius: 5px;
    padding: 8px 10px;
    margin-bottom: 10px;
    line-height: 1.4;
}

.cp-form__error-msg.cp-form__error-msg--visible {
    display: block;
}

.cp-form__actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.cp-form__submit,
.cp-form__schedule {
    flex: 1;
    padding: 11px;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background var(--cp-ease), opacity var(--cp-ease);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
}

.cp-form__submit {
    background: var(--cp-blue);
}

.cp-form__schedule {
    background: var(--cp-teal);
}

.cp-form__submit:hover:not(:disabled) {
    background: #004abf;
}

.cp-form__schedule:hover:not(:disabled) {
    background: var(--cp-teal-dark);
}

.cp-form__submit:disabled,
.cp-form__schedule:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* ── SPINNER ── */
.cp-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: cp-spin 0.65s linear infinite;
    flex-shrink: 0;
}

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

/* ── SUCCESS STATE ── */
.cp-success {
    display: none;
    text-align: center;
    padding: 24px 8px 12px;
}

.cp-success--visible {
    display: block;
}

.cp-success__check {
    width: 52px;
    height: 52px;
    background: var(--cp-teal);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    font-size: 24px;
    color: #fff;
}

.cp-success__heading {
    font-size: 17px;
    font-weight: 700;
    color: var(--cp-blue);
    margin-bottom: 6px;
}

.cp-success__body {
    font-size: 13px;
    color: #666;
    line-height: 1.5;
}

/* ── MOBILE ── */
@media (max-width: 480px) {
    .cp-toast {
        width: calc(100vw - 32px);
        right: 16px;
        bottom: 16px;
    }

    .cp-modal {
        max-height: 95vh;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cp-toast,
    .cp-modal-backdrop,
    .cp-modal {
        transition: none;
    }

    .cp-spinner {
        animation: none;
        opacity: 0.6;
    }
}
