/* ========================================
   COMMVIO — Components
   Buttons, cards, forms, tabs, etc.
   ======================================== */

/* ── Buttons ── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    font-family: var(--font-family);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-wide);
    line-height: 1;
    padding: var(--space-4) var(--space-8);
    border-radius: var(--radius-full);
    border: 1.5px solid transparent;
    transition: all var(--duration-normal) var(--ease-out);
    white-space: nowrap;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

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

.btn--primary:hover {
    background-color: var(--color-black);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn--secondary {
    background-color: transparent;
    color: var(--color-heading);
    border-color: var(--color-border);
}

.btn--secondary:hover {
    border-color: var(--color-heading);
    background-color: var(--color-surface);
    transform: translateY(-1px);
}

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

.btn--accent:hover {
    background-color: var(--color-accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn--ghost {
    background-color: transparent;
    color: var(--color-subtle);
    border-color: transparent;
    padding-left: var(--space-4);
    padding-right: var(--space-4);
}

.btn--ghost:hover {
    color: var(--color-heading);
}

.btn--lg {
    font-size: var(--text-base);
    padding: var(--space-5) var(--space-10);
}

.btn--sm {
    font-size: var(--text-xs);
    padding: var(--space-3) var(--space-6);
}

.btn__arrow {
    display: inline-block;
    transition: transform var(--duration-normal) var(--ease-out);
}

.btn:hover .btn__arrow {
    transform: translateX(3px);
}

.btn--loading {
    pointer-events: none;
    opacity: 0.7;
}

.btn--loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.6s linear infinite;
    margin-left: var(--space-2);
}

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

/* Button group */
.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
}

/* ── Language Dropdown ── */

.lang-dropdown {
    position: relative;
    display: inline-block;
}

.lang-dropdown__toggle {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: var(--font-family);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-heading);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    transition: background-color var(--duration-fast) var(--ease-out);
}

.lang-dropdown__toggle:hover, .lang-dropdown.is-open .lang-dropdown__toggle {
    background-color: var(--color-surface);
}

.lang-flag {
    border-radius: 2px;
    object-fit: cover;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.05); /* slightly defines the flag edge */
}

.lang-dropdown__chevron {
    color: var(--color-subtle);
    transition: transform var(--duration-normal) var(--ease-out);
}

.lang-dropdown.is-open .lang-dropdown__chevron {
    transform: rotate(180deg);
}

.lang-dropdown__menu {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    min-width: 140px;
    background-color: var(--color-white);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-2);
    display: flex;
    flex-direction: column;
    gap: 2px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: all var(--duration-normal) var(--ease-out);
    z-index: 100;
}

#mobile-lang-dropdown .lang-dropdown__menu {
    right: auto;
    left: 50%;
    transform: translate(-50%, -4px);
}

#mobile-lang-dropdown.is-open .lang-dropdown__menu {
    transform: translate(-50%, 0);
}

.lang-dropdown.is-open .lang-dropdown__menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-dropdown__item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
    color: var(--color-text);
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: background-color var(--duration-fast) var(--ease-out), color var(--duration-fast);
}

.lang-dropdown__item:hover {
    background-color: var(--color-surface);
    color: var(--color-heading);
}

.lang-dropdown__item.is-active {
    background-color: var(--color-surface);
    font-weight: var(--weight-semibold);
    color: var(--color-heading);
}

/* ── Cards ── */


.card {
    background-color: var(--color-white);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-3xl);
    padding: var(--space-8);
    transition: all 0.5s var(--ease-out);
    position: relative;
    box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

.card:hover {
    border-color: var(--color-border);
    box-shadow: 0 15px 35px rgba(0,0,0,0.07);
    transform: translateY(-4px);
}

.card--flat {
    border: none;
    background-color: var(--color-surface);
}

.card--flat:hover {
    background-color: var(--color-surface-alt);
    box-shadow: none;
}

.card__icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-accent-light);
    color: var(--color-accent);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-6);
    font-size: var(--text-xl);
}

.card__title {
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    color: var(--color-heading);
    margin-bottom: var(--space-3);
    line-height: var(--leading-snug);
}

.card__desc {
    font-size: var(--text-sm);
    color: var(--color-subtle);
    line-height: var(--leading-relaxed);
}

.card__link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-6);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-accent);
    transition: gap var(--duration-fast) var(--ease-out);
}

.card__link:hover {
    gap: var(--space-3);
}

/* Featured card (larger in bento grid) */
.card--featured {
    padding: var(--space-10);
}

.card--featured .card__title {
    font-size: var(--text-xl);
}

/* ── Process Step Card ── */

.process-step {
    position: relative;
    padding: var(--space-8);
    padding-left: var(--space-16);
}

.process-step__number {
    position: absolute;
    left: 0;
    top: var(--space-8);
    font-size: var(--text-4xl);
    font-weight: var(--weight-bold);
    color: var(--color-border-light);
    line-height: 1;
    letter-spacing: var(--tracking-tight);
}

.process-step__title {
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    color: var(--color-heading);
    margin-bottom: var(--space-3);
}

.process-step__desc {
    font-size: var(--text-sm);
    color: var(--color-subtle);
    line-height: var(--leading-relaxed);
}

/* ── Use Case Card ── */

.use-case {
    background-color: var(--color-white);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    padding: var(--space-8);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    transition: all var(--duration-normal) var(--ease-out);
}

.use-case:hover {
    border-color: var(--color-accent-muted);
    box-shadow: var(--shadow-sm);
}

.use-case__tag {
    display: inline-block;
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
    color: var(--color-accent);
    background-color: var(--color-accent-light);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    width: fit-content;
}

.use-case__title {
    font-size: var(--text-lg);
    font-weight: var(--weight-semibold);
    color: var(--color-heading);
}

.use-case__desc {
    font-size: var(--text-sm);
    color: var(--color-subtle);
    line-height: var(--leading-relaxed);
}

/* ── Form Elements ── */

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.form-label {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-heading);
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: var(--space-4) var(--space-5);
    font-size: var(--text-base);
    color: var(--color-heading);
    background-color: var(--color-white);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: border-color var(--duration-fast) var(--ease-out),
        box-shadow var(--duration-fast) var(--ease-out);
    appearance: none;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-light);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--color-muted);
}

.form-textarea {
    min-height: 140px;
    resize: vertical;
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236e6e73' d='M6 8.825L.475 3.3l.85-.85L6 7.125l4.675-4.675.85.85z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-4) center;
    padding-right: var(--space-10);
}

/* Error state */
.form-group--error .form-input,
.form-group--error .form-textarea,
.form-group--error .form-select {
    border-color: var(--color-error);
}

.form-group--error .form-input:focus,
.form-group--error .form-textarea:focus {
    box-shadow: 0 0 0 3px var(--color-error-bg);
}

.form-error {
    font-size: var(--text-xs);
    color: var(--color-error);
    display: none;
}

.form-group--error .form-error {
    display: block;
}

/* Checkbox */
.form-checkbox {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 2px;
    accent-color: var(--color-accent);
}

.form-checkbox__label {
    font-size: var(--text-sm);
    color: var(--color-subtle);
    line-height: var(--leading-normal);
}

/* Form success / error messages */
.form-message {
    padding: var(--space-4) var(--space-6);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    display: none;
}

.form-message--success {
    background-color: var(--color-success-bg);
    color: var(--color-success);
    display: block;
}

.form-message--error {
    background-color: var(--color-error-bg);
    color: var(--color-error);
    display: block;
}

/* ── Tabs ── */

.tabs {
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
    display: none;
}

.tab-btn {
    padding: var(--space-4) var(--space-6);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-muted);
    border-bottom: 2px solid transparent;
    transition: all var(--duration-fast) var(--ease-out);
    white-space: nowrap;
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.tab-btn:hover {
    color: var(--color-heading);
}

.tab-btn[aria-selected="true"],
.tab-btn.is-active {
    color: var(--color-heading);
    border-bottom-color: var(--color-heading);
}

.tab-panel {
    display: none;
    padding-top: var(--space-10);
}

.tab-panel.is-active {
    display: block;
    animation: fadeIn var(--duration-normal) var(--ease-out);
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Accordion ── */

.accordion {
    border-top: 1px solid var(--color-border-light);
}

.accordion-item {
    border-bottom: 1px solid var(--color-border-light);
}

.accordion-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-6) 0;
    font-size: var(--text-md);
    font-weight: var(--weight-medium);
    color: var(--color-heading);
    cursor: pointer;
    text-align: left;
    background: none;
    border: none;
    transition: color var(--duration-fast) var(--ease-out);
}

.accordion-trigger:hover {
    color: var(--color-accent);
}

.accordion-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    position: relative;
    transition: transform var(--duration-normal) var(--ease-out);
}

.accordion-icon::before,
.accordion-icon::after {
    content: '';
    position: absolute;
    background-color: currentColor;
    transition: transform var(--duration-normal) var(--ease-out);
}

.accordion-icon::before {
    width: 14px;
    height: 1.5px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.accordion-icon::after {
    width: 1.5px;
    height: 14px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.accordion-item.is-open .accordion-icon::after {
    transform: translate(-50%, -50%) rotate(90deg);
    opacity: 0;
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--duration-slow) var(--ease-out);
}

.accordion-content__inner {
    padding-bottom: var(--space-8);
    font-size: var(--text-sm);
    color: var(--color-subtle);
    line-height: var(--leading-relaxed);
    max-width: 64ch;
}

/* ── Modal ── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: var(--z-overlay);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration-normal) var(--ease-out),
        visibility var(--duration-normal);
}

.modal-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background-color: var(--color-white);
    border-radius: var(--radius-xl);
    padding: var(--space-10);
    max-width: 560px;
    width: calc(100% - var(--space-8));
    max-height: 90vh;
    overflow-y: auto;
    z-index: var(--z-modal);
    opacity: 0;
    visibility: hidden;
    transition: all var(--duration-normal) var(--ease-out);
}

.modal.is-active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.modal__close {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    color: var(--color-muted);
    transition: all var(--duration-fast) var(--ease-out);
}

.modal__close:hover {
    background-color: var(--color-surface);
    color: var(--color-heading);
}

/* ── Ecosystem Node ── */

.eco-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-8);
    background-color: var(--color-white);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-lg);
    transition: all var(--duration-normal) var(--ease-out);
    position: relative;
}

.eco-node:hover {
    border-color: var(--color-accent-muted);
    box-shadow: var(--shadow-sm);
    transform: translateY(-3px);
}

.eco-node__icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--color-accent-light), var(--color-violet-light));
    border-radius: var(--radius-md);
    margin-bottom: var(--space-5);
    font-size: var(--text-xl);
}

.eco-node__title {
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    color: var(--color-heading);
    margin-bottom: var(--space-2);
}

.eco-node__desc {
    font-size: var(--text-xs);
    color: var(--color-muted);
    line-height: var(--leading-normal);
}

/* Ecosystem connector lines (CSS-only) */
.eco-connector {
    display: none;
}

@media (min-width: 768px) {
    .eco-connector {
        display: block;
        position: absolute;
        border-top: 1px dashed var(--color-border);
        width: 40px;
    }
}

/* ── Multistep Form ── */

.multistep-progress {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-8);
    position: relative;
}

.multistep-progress::before {
    content: '';
    position: absolute;
    top: 14px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--color-border-light);
    z-index: 0;
}

.multistep-step {
    position: relative;
    z-index: 1;
    background-color: var(--color-white); /* Changed from surface to match card background */
    padding: 0 var(--space-3);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-muted);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    transition: color var(--duration-normal) var(--ease-out);
}

.multistep-step span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background-color: var(--color-border-light);
    color: var(--color-text);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    transition: all var(--duration-normal) var(--ease-out);
}

.multistep-step.is-active,
.multistep-step.is-completed {
    color: var(--color-heading);
}

.multistep-step.is-active span {
    background-color: var(--color-accent);
    color: var(--color-white);
}

.multistep-step.is-completed span {
    background-color: var(--color-heading);
    color: var(--color-white);
}

.form-step {
    display: none;
    animation: fadeIn var(--duration-normal) var(--ease-out);
}

.form-step.is-active {
    display: block;
}

/* ── Popups & Modals ── */

.popup-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration-normal) var(--ease-out), visibility var(--duration-normal);
    /* Needed on iOS so taps outside the box register to close */
    -webkit-tap-highlight-color: transparent;
}

.popup-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

.popup-box {
    background-color: var(--color-white);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    width: 90%;
    max-width: 600px;
    /* Use dvh so iOS Safari address bar doesn't clip content */
    max-height: 90dvh;
    /* scroll — not auto — is more reliable on iOS Safari */
    overflow-y: scroll;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    /* Allow vertical touch scrolling inside the box */
    touch-action: pan-y;
    position: relative;
    transform: translateY(20px) scale(0.98);
    transition: transform var(--duration-normal) var(--ease-out);
}

.popup-overlay.is-active .popup-box {
    transform: translateY(0) scale(1);
}

.popup-box--details {
    max-width: 500px;
}

/* ── Mobile: full-height bottom sheet ── */
@media (max-width: 640px) {
    .popup-overlay {
        align-items: flex-end;
        /* Allow overlay itself to not trap touches needed for inner scroll */
        overflow: hidden;
    }

    .popup-box {
        width: 100%;
        max-width: 100%;
        /* Leave small gap at top so user knows they can close */
        max-height: calc(100dvh - 52px);
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
        /* Ensure the box itself grows to fill content height */
        display: flex;
        flex-direction: column;
    }

    .popup-overlay.is-active .popup-box {
        transform: translateY(0);
        transition: transform 0.38s cubic-bezier(0.34, 1.1, 0.64, 1);
    }

    .popup-box--details {
        max-width: 100%;
    }

    /* Drag handle at top */
    .popup-box::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        background: rgba(0, 0, 0, 0.14);
        border-radius: 2px;
        margin: 14px auto 0;
        flex-shrink: 0;
    }

    /* Scrollable inner content area */
    .popup-content,
    .popup-box--details {
        flex: 1;
        overflow-y: scroll;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        touch-action: pan-y;
    }
}

.popup-close {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background-color: transparent;
    color: var(--color-heading);
    border: none;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all var(--duration-fast) var(--ease-out);
}

.popup-close:hover {
    background-color: var(--color-surface);
}

.popup-content {
    padding: var(--space-10);
}

@media (max-width: 640px) {
    .popup-content {
        padding: var(--space-6) var(--space-5) var(--space-8);
    }
}

/* Details Popup Specific */
.details-hero {
    text-align: center;
    margin-bottom: var(--space-6);
}

.details-title {
    font-size: var(--text-3xl);
    font-weight: var(--weight-semibold);
    color: var(--color-heading);
    margin: var(--space-2) 0;
    letter-spacing: var(--tracking-tight);
}

.details-price {
    font-size: var(--text-lg);
    color: var(--color-muted);
}

.details-body {
    margin-bottom: var(--space-8);
}

.details-body .separator {
    height: 1px;
    background-color: var(--color-border-light);
    margin: var(--space-6) 0;
}

.details-feature-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.details-feature-list li {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--color-subtle);
}

.details-feature-list li svg {
    flex-shrink: 0;
    margin-top: 2px;
    color: var(--color-muted);
}

.details-footer {
    text-align: center;
}

.details-footer .btn {
    width: 100%;
}