/* ===========================
   KovaLeads Mobile UI Fixes
   =========================== */

/* 1) Buttons, make them behave consistently (override Hello Elementor reset) */
.KovaLeads-button,
.KovaLeads-button-primary,
.KovaLeads-button-secondary,
button.KovaLeads-tier-upgrade-btn,
button.KovaLeads-button,
button.KovaLeads-button-primary,
button.KovaLeads-button-secondary {
    box-sizing: border-box;
    max-width: 100%;
    white-space: normal !important; /* allow wrap on small screens */
    overflow-wrap: anywhere;
    word-break: normal;
    line-height: 1.3 !important;
    height: auto;
    min-height: 0;              /* prevents theme min-height forcing tall buttons */
    padding-top: 0.75rem;       /* override global button padding */
    padding-bottom: 0.75rem;
}

/* Upgrade tier buttons need extra specificity against theme button rules */
button.KovaLeads-tier-upgrade-btn,
.KovaLeads-tier-upgrade-btn {
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: normal !important;
    line-height: 1.3 !important;
    height: auto !important;
    min-height: 0 !important;
    max-width: 100% !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-wrap: wrap !important;
    text-align: center !important;
}

/* Ensure billing + my groups buttons inherit the same sizing rules */
.KovaLeads-billing-upgrade .KovaLeads-button,
.KovaLeads-billing-upgrade .KovaLeads-button-primary,
.KovaLeads-billing-upgrade .KovaLeads-button-secondary,
.KovaLeads-billing-upgrade button,
.KovaLeads-my-groups .KovaLeads-button,
.KovaLeads-my-groups .KovaLeads-button-primary,
.KovaLeads-my-groups .KovaLeads-button-secondary,
.KovaLeads-my-groups button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.3 !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
}

/* Center text and avoid weird vertical alignment issues on iOS */
.KovaLeads-button,
.KovaLeads-button-primary,
.KovaLeads-button-secondary,
button.KovaLeads-tier-upgrade-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

/* 2) Mobile sizing, reduce padding so buttons don't get "double height" for no reason */
@media (max-width: 768px) {
    .KovaLeads-button,
    .KovaLeads-button-primary,
    .KovaLeads-button-secondary,
    button.KovaLeads-tier-upgrade-btn,
    button.KovaLeads-button,
    button.KovaLeads-button-primary,
    button.KovaLeads-button-secondary {
        padding: 10px 14px;
    }

    /* Make primary action buttons full-width in tier selector (fixes the giant pill + centering issues) */
    .KovaLeads-tier-selector .KovaLeads-button,
    .KovaLeads-tier-selector .KovaLeads-button-primary,
    .KovaLeads-tier-selector .KovaLeads-button-secondary {
        width: 100%;
    }

    /* Keep labels centered like I was hoping to do */
    .KovaLeads-tier-selector .KovaLeads-current-tier-info,
    .KovaLeads-tier-selector .KovaLeads-form-field label {
        text-align: center;
    }

    .KovaLeads-tier-selector select {
        width: 100%;
        max-width: 100%;
    }
}

/* 3) Tables on mobile, keep scroll, but make them readable and less chunky */
.KovaLeads-projects-manage {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .KovaLeads-owner-controls {
        padding: 20px;
        overflow: hidden;
    }

    .KovaLeads-manage-table {
        width: 100%;
    }

    /* convert table to stacked cards */
    .KovaLeads-manage-table,
    .KovaLeads-manage-table thead,
    .KovaLeads-manage-table tbody,
    .KovaLeads-manage-table th,
    .KovaLeads-manage-table td,
    .KovaLeads-manage-table tr {
        display: block;
    }

    .KovaLeads-manage-table thead {
        position: absolute;
        left: -9999px;
        top: -9999px;
    }

    .KovaLeads-manage-table tr {
        border: 1px solid #e1e1e1;
        border-radius: 8px;
        margin-bottom: 12px;
        background: #fff;
        padding: 8px 0;
    }

    .KovaLeads-manage-table th,
    .KovaLeads-manage-table td {
        padding: 8px 12px 8px 44%;
        white-space: normal;
        font-size: 14px;
        word-break: break-word;
        position: relative;
    }

    .KovaLeads-manage-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 12px;
        top: 8px;
        width: 40%;
        font-weight: 600;
        color: #1c244b;
    }

    /* make action buttons less huge inside tables */
    .KovaLeads-manage-table .KovaLeads-button,
    .KovaLeads-manage-table .KovaLeads-button-primary,
    .KovaLeads-manage-table .KovaLeads-button-secondary {
        padding: 8px 12px;
        white-space: normal;
    }
}

@media (max-width: 768px) {
  button.KovaLeads-button.KovaLeads-button-primary.KovaLeads-tier-upgrade-btn,
  button.KovaLeads-button.KovaLeads-button-secondary.KovaLeads-tier-upgrade-btn,
  button.KovaLeads-button.KovaLeads-tier-upgrade-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;

    /* stop iOS/Elementor "nowrap pill" behavior */
    white-space: normal !important;
    text-wrap: wrap !important;
    overflow-wrap: anywhere !important;

    line-height: 1.2 !important;
    height: auto !important;
    min-height: 0 !important;

    padding: 10px 14px !important;
  }
}

/* ===========================
   .white-form conflict fix
   The Elementor container uses .white-form * { color:#fff !important }
   which overrides all plugin text. We counter with a two-class selector
   (.white-form + plugin wrapper) which has higher specificity and wins.
   =========================== */

.white-form .kovaleads-wrap,
.white-form .kovaleads-wrap *,
.white-form .kl-bp-wrap,
.white-form .kl-bp-wrap *,
.white-form .kovaleads-form-wrap,
.white-form .kovaleads-form-wrap *,
.white-form .kovaleads-sent-leads-list-wrap,
.white-form .kovaleads-sent-leads-list-wrap *,
.white-form .kovaleads-tab-panel,
.white-form .kovaleads-tab-panel *,
.white-form .kovaleads-backend-link-notice,
.white-form .kovaleads-backend-link-notice * {
    color: #1C244B !important;
}

/* Keep business profile fields visible even when theme resets input borders. */
.white-form #kl-business-profile-form .kl-bp-input,
.white-form #kl-business-profile-form .kl-bp-textarea,
.white-form #kl-business-profile-form input.kl-bp-input,
.white-form #kl-business-profile-form textarea.kl-bp-textarea {
    border: 1px solid #cfd5df !important;
    background: #ffffff !important;
}

/* Restore intentional white text inside plugin elements (table headers, buttons, links) */
.white-form .kovaleads-wrap th,
.white-form .kl-bp-wrap th,
.white-form .kovaleads-sent-leads-list-wrap th,
.white-form .kovaleads-tab-panel th {
    color: #ffffff !important;
}

.white-form .kovaleads-wrap a.kovaleads-btn,
.white-form .kl-bp-wrap a.kovaleads-btn,
.white-form .kovaleads-sent-leads-list-wrap a[style*="background:#1e6fa8"],
.white-form .kovaleads-tab-panel a.kovaleads-btn {
    color: #ffffff !important;
}

/* ===========================
   AI Keywords section
   =========================== */

.kl-bp-section--ai {
    border-color: #7c3aed;
    background: #f5f3ff;
}

.kl-managed-keywords-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 4px;
}

.kl-kw-tag {
    display: inline-block;
    background: #ede9fe;
    color: #4c1d95;
    border: 1px solid #c4b5fd;
    border-radius: 20px;
    padding: 3px 12px;
    font-size: 0.82em;
    font-weight: 500;
    white-space: nowrap;
}

.kl-bp-btn--secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 18px;
    font-size: 0.88em;
    font-weight: 600;
    border-radius: var(--kl-radius, 8px);
    border: 1.5px solid #7c3aed;
    background: transparent;
    color: #7c3aed;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.kl-bp-btn--secondary:hover:not(:disabled) {
    background: #7c3aed;
    color: #fff;
}

.kl-bp-btn--secondary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
