/* ========================================================================
   WP Hook Injector - Pro Editor Styles
   ======================================================================== */

/* ---- Popup sizing for wide editor ---- */
.wphi-popup-wide {
    width: 640px;
    max-width: calc(100vw - 40px);
    max-height: 90vh;
    overflow-y: auto;
}

/* ========================================================================
   Tabs
   ======================================================================== */
.wphi-tabs-nav {
    list-style: none;
    padding: 0;
    margin: 0 0 0;
    display: flex;
    border-bottom: 1px solid #ccd0d4;
    gap: 0;
}

.wphi-tab {
    padding: 8px 14px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #50575e;
    background: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    margin-bottom: -1px;
    user-select: none;
    transition: all .15s ease;
}

.wphi-tab:hover {
    color: #2271b1;
    background: #f6f7f7;
}

.wphi-tab.active {
    background: #fff;
    color: #2271b1;
    border-color: #ccd0d4;
    border-bottom-color: #fff;
}

.wphi-tab-panes {
    border: 1px solid #ccd0d4;
    border-top: none;
    padding: 16px;
    background: #fff;
}

.wphi-tab-pane {
    display: none;
}

.wphi-tab-pane.active {
    display: block;
}

.wphi-tab-pane textarea,
.wphi-tab-pane input[type="text"],
.wphi-tab-pane input[type="url"],
.wphi-tab-pane input[type="number"],
.wphi-tab-pane select {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.wphi-code-input {
    font-family: Consolas, Monaco, monospace;
    font-size: 13px;
    tab-size: 4;
}

/* ========================================================================
   Widget K-V rows
   ======================================================================== */
.wphi-kv-row {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
    align-items: center;
}

.wphi-kv-key {
    flex: 0 0 180px;
}

.wphi-kv-value {
    flex: 1 1 auto;
}

.wphi-kv-remove {
    flex: 0 0 auto;
    color: #b32d2e !important;
    border-color: #b32d2e !important;
}

.wphi-checkbox-label {
    display: inline-flex !important;
    align-items: center;
    gap: 6px;
    font-weight: 400;
}

/* ========================================================================
   Shortcode preview
   ======================================================================== */
.wphi-shortcode-preview {
    margin-top: 12px;
    border: 1px dashed #ccd0d4;
    padding: 12px;
    background: #f6f7f7;
    border-radius: 3px;
    min-height: 40px;
}

.wphi-preview-label {
    font-size: 11px;
    text-transform: uppercase;
    color: #646970;
    letter-spacing: .05em;
    margin-bottom: 8px;
}

.wphi-preview-body {
    font-size: 13px;
}

/* ========================================================================
   Conditions builder
   ======================================================================== */
#wphi-conditions {
    margin-top: 16px;
    border-top: 1px solid #f0f0f1;
    padding-top: 12px;
}

.wphi-conditions-wrap {
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 12px;
}

.wphi-cond-top {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.wphi-cond-toggle {
    font-weight: 400 !important;
    margin: 0 !important;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.wphi-cond-body {
    margin-top: 10px;
}

.wphi-top-relation-wrap {
    margin-bottom: 10px;
    font-size: 12px;
}

.wphi-cond-groups {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wphi-cond-group {
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 10px;
    background: #fff;
}

.wphi-cond-group-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px dashed #eee;
}

.wphi-cond-group-head .wphi-group-relation {
    width: auto;
}

.wphi-cond-rules {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wphi-rule {
    display: grid;
    grid-template-columns: 1fr 110px 1fr auto;
    gap: 6px;
    align-items: center;
}

.wphi-rule select,
.wphi-rule input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.wphi-rule-remove {
    color: #b32d2e !important;
    border-color: #b32d2e !important;
    min-height: 30px;
    padding: 0 8px !important;
}

.wphi-date-range {
    display: flex;
    align-items: center;
    gap: 6px;
}

.wphi-date-range span {
    color: #646970;
}

.wphi-add-group {
    margin-top: 10px !important;
}

/* ---- AJAX search for post/page/category conditions ---- */
.wphi-cond-ajaxsearch {
    position: relative;
}
.wphi-cond-ajaxsearch .wphi-cond-search-input {
    width: 100%;
}
.wphi-cond-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ccd0d4;
    border-top: none;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(0,0,0,.1);
}
.wphi-cond-search-item {
    padding: 6px 10px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid #f0f0f1;
}
.wphi-cond-search-item:hover {
    background: #f0f6fc;
}
.wphi-cond-search-item:last-child {
    border-bottom: none;
}
.wphi-cond-search-empty {
    padding: 8px 10px;
    color: #646970;
    font-style: italic;
    font-size: 12px;
}
.wphi-top-relation-label {
    margin-right: 4px;
    color: #50575e;
}

/* ========================================================================
   Frontend rendered template styles
   (These are lightweight defaults — themes can override.)
   ======================================================================== */

/* AdSense wrapper */
.wphi-adsense {
    margin: 10px 0;
}

/* Affiliate banner */
.wphi-affiliate-banner {
    text-align: center;
    margin: 15px 0;
}
.wphi-affiliate-banner img {
    max-width: 100%;
    height: auto;
}

/* Image ad */
.wphi-image-ad-wrap {
    text-align: center;
    margin: 15px 0;
}
.wphi-image-ad-wrap img {
    max-width: 100%;
    height: auto;
}

/* CTA Box */
.wphi-cta {
    background: #f6f7f7;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 24px;
    text-align: center;
    margin: 16px 0;
}
.wphi-cta-primary {
    background: #2271b1;
    border-color: #135e96;
    color: #fff;
}
.wphi-cta-primary .wphi-cta-heading { color: #fff; }
.wphi-cta-primary .wphi-cta-desc { color: rgba(255,255,255,.85); }
.wphi-cta-primary .wphi-cta-button {
    background: #fff;
    color: #2271b1;
    border-color: #fff;
}
.wphi-cta-dark {
    background: #1d2327;
    border-color: #1d2327;
    color: #fff;
}
.wphi-cta-dark .wphi-cta-heading { color: #fff; }
.wphi-cta-dark .wphi-cta-desc { color: rgba(255,255,255,.75); }
.wphi-cta-dark .wphi-cta-button {
    background: #fff;
    color: #1d2327;
    border-color: #fff;
}
.wphi-cta-light {
    background: #fff;
    border-color: #ddd;
}
.wphi-cta-heading {
    margin: 0 0 8px;
    font-size: 20px;
}
.wphi-cta-desc {
    margin: 0 0 16px;
    color: #50575e;
}
.wphi-cta-desc p { margin: 0 0 8px; }
.wphi-cta-desc p:last-child { margin-bottom: 0; }
.wphi-cta-button {
    display: inline-block;
    padding: 8px 22px;
    background: #2271b1;
    color: #fff;
    border: 1px solid #135e96;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
}
.wphi-cta-button:hover {
    background: #135e96;
    color: #fff;
}

/* Notice Box */
.wphi-notice {
    padding: 12px 16px;
    border-left: 4px solid #72aee6;
    background: #fff;
    margin: 16px 0;
    box-shadow: 0 1px 1px rgba(0,0,0,.04);
    position: relative;
}
.wphi-notice p { margin: 0; }
.wphi-notice-success { border-left-color: #00a32a; background: #edfaef; }
.wphi-notice-warning { border-left-color: #dba617; background: #fcf9e8; }
.wphi-notice-error   { border-left-color: #d63638; background: #fcf0f1; }
.wphi-notice-info    { border-left-color: #72aee6; }
.wphi-notice.is-dismissible { padding-right: 36px; }
.wphi-notice-dismiss {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    color: #787c82;
    padding: 4px;
}
.wphi-notice-dismiss:hover { color: #d63638; }

/* Author Box */
.wphi-author-box {
    display: flex;
    gap: 16px;
    padding: 20px;
    background: #f6f7f7;
    border-radius: 6px;
    margin: 16px 0;
    align-items: flex-start;
}
.wphi-author-avatar img {
    border-radius: 50%;
    display: block;
}
.wphi-author-name {
    margin: 0 0 6px;
    font-size: 16px;
}
.wphi-author-bio {
    color: #50575e;
    font-size: 14px;
}
.wphi-author-bio p { margin: 0 0 6px; }
.wphi-author-bio p:last-child { margin-bottom: 0; }

/* TinyMCE iframe height in popup */
.wphi-tab-pane .wp-editor-wrap {
    min-height: 250px;
}

/* Responsive for conditions */
@media (max-width: 600px) {
    .wphi-rule {
        grid-template-columns: 1fr;
    }
    .wphi-author-box {
        flex-direction: column;
        text-align: center;
        align-items: center;
    }
}
