/* ===================================================
   Ads Manager -- Refined utilitarian settings panel
   All rules scoped under .contai-ads-manager for specificity
   =================================================== */

/* --- Container --- */
.contai-ads-manager {
    background: #fff;
    border: 1px solid var(--contai-neutral-400);
    border-radius: var(--contai-radius-lg);
    box-shadow: var(--contai-shadow-sm);
    overflow: hidden;
}

/* --- Tab Navigation --- */
.contai-ads-manager .contai-ads-tabs-nav {
    display: flex;
    background: var(--contai-neutral-50);
    border-bottom: 2px solid var(--contai-neutral-300);
    padding: 0 var(--contai-spacing-lg);
    gap: var(--contai-spacing-xs);
}

.contai-ads-manager .contai-ads-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 14px 18px;
    font-size: 13px;
    font-weight: 600;
    color: var(--contai-neutral-600);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: color var(--contai-duration-fast) ease, border-color var(--contai-duration-fast) ease;
    position: relative;
    white-space: nowrap;
    box-shadow: none;
    outline: none;
    border-radius: 0;
    line-height: 1.4;
    min-height: auto;
}

.contai-ads-manager .contai-ads-tab .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    opacity: 0.6;
    transition: opacity var(--contai-duration-fast) ease, color var(--contai-duration-fast) ease;
}

.contai-ads-manager .contai-ads-tab:hover {
    color: var(--contai-neutral-700);
    background: none;
    border-color: transparent;
    border-bottom-color: var(--contai-neutral-400);
}

.contai-ads-manager .contai-ads-tab:hover .dashicons {
    opacity: 0.85;
    color: var(--contai-primary);
}

.contai-ads-manager .contai-ads-tab.active {
    color: var(--contai-primary);
    border-bottom-color: var(--contai-primary);
    background: none;
}

.contai-ads-manager .contai-ads-tab.active .dashicons {
    opacity: 1;
    color: var(--contai-primary);
}

.contai-ads-manager .contai-ads-tab:focus-visible {
    outline: 2px solid var(--contai-primary);
    outline-offset: -2px;
    border-radius: var(--contai-radius-sm);
}

/* --- Tab Content --- */
.contai-ads-manager .contai-ads-tab-content {
    display: none;
}

.contai-ads-manager .contai-ads-tab-content.active {
    display: block;
    animation: contai-ads-reveal var(--contai-duration-fast) ease-out;
}

@keyframes contai-ads-reveal {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- Status Bar --- */
.contai-ads-manager .contai-ads-status-bar {
    display: flex;
    align-items: center;
    gap: var(--contai-spacing-lg);
    padding: 10px var(--contai-spacing-lg);
    background: var(--contai-neutral-50);
    border-bottom: 1px solid var(--contai-neutral-200);
    font-size: 12px;
    font-weight: 500;
    color: var(--contai-neutral-600);
}

.contai-ads-manager .contai-ads-status-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.contai-ads-manager .contai-ads-status-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.contai-ads-manager .contai-ads-status-active {
    background: var(--contai-success);
    box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.15);
}

.contai-ads-manager .contai-ads-status-inactive {
    background: var(--contai-neutral-400);
    box-shadow: 0 0 0 2px rgba(148, 163, 184, 0.15);
}

/* --- Form Body --- */
.contai-ads-manager .contai-ads-form-body {
    padding: var(--contai-spacing-lg);
}

/* --- Field --- */
.contai-ads-manager .contai-ads-field {
    display: flex;
    flex-direction: column;
}

.contai-ads-manager .contai-ads-field-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--contai-neutral-700);
    margin-bottom: 8px;
    letter-spacing: 0.01em;
}

.contai-ads-manager .contai-ads-textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--contai-neutral-400);
    border-radius: var(--contai-radius-md);
    font-family: var(--contai-font-mono);
    font-size: 13px;
    line-height: 1.65;
    color: var(--contai-neutral-700);
    background: #fff;
    resize: vertical;
    transition: border-color var(--contai-duration-fast) ease, box-shadow var(--contai-duration-fast) ease;
    box-sizing: border-box;
}

.contai-ads-manager .contai-ads-textarea::placeholder {
    color: var(--contai-neutral-500);
    font-style: normal;
}

.contai-ads-manager .contai-ads-textarea:focus {
    outline: none;
    border-color: var(--contai-primary);
    box-shadow: 0 0 0 3px var(--contai-primary-glow);
}

.contai-ads-manager .contai-ads-textarea-code {
    background: var(--contai-neutral-50);
    border-color: var(--contai-neutral-300);
    tab-size: 2;
    font-size: 12.5px;
    line-height: 1.7;
}

.contai-ads-manager .contai-ads-textarea-code:focus {
    background: #fff;
}

.contai-ads-manager .contai-ads-field-hint {
    margin: 8px 0 0;
    font-size: 12px;
    line-height: 1.5;
    color: var(--contai-neutral-500);
}

/* --- Callout Boxes --- */
.contai-ads-manager .contai-ads-callout {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px var(--contai-spacing-lg);
    border-top: 1px solid var(--contai-neutral-200);
    font-size: 13px;
    line-height: 1.5;
}

.contai-ads-manager .contai-ads-callout > .dashicons {
    flex-shrink: 0;
    font-size: 20px;
    width: 20px;
    height: 20px;
    margin-top: 1px;
}

.contai-ads-manager .contai-ads-callout strong {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    margin-bottom: 2px;
    letter-spacing: 0.01em;
}

.contai-ads-manager .contai-ads-callout p {
    margin: 0;
    font-size: 12.5px;
    color: var(--contai-neutral-600);
    line-height: 1.55;
}

.contai-ads-manager .contai-ads-callout-info {
    background: var(--contai-info-bg);
}

.contai-ads-manager .contai-ads-callout-info > .dashicons {
    color: var(--contai-primary);
}

.contai-ads-manager .contai-ads-callout-info strong {
    color: var(--contai-primary-dark);
}

.contai-ads-manager .contai-ads-callout-warning {
    background: var(--contai-warning-bg);
}

.contai-ads-manager .contai-ads-callout-warning > .dashicons {
    color: var(--contai-warning);
}

.contai-ads-manager .contai-ads-callout-warning strong {
    color: var(--contai-warning-text);
}

/* --- Form Footer --- */
.contai-ads-manager .contai-ads-form-footer {
    padding: 14px var(--contai-spacing-lg);
    background: var(--contai-neutral-50);
    border-top: 1px solid var(--contai-neutral-200);
}

/* --- Advanced Tab -- Action Cards --- */
.contai-ads-manager .contai-ads-advanced-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--contai-spacing-lg);
    padding: var(--contai-spacing-lg);
}

.contai-ads-manager .contai-ads-action-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--contai-neutral-300);
    border-radius: var(--contai-radius-lg);
    overflow: hidden;
    transition: box-shadow var(--contai-duration-fast) ease;
}

.contai-ads-manager .contai-ads-action-card:hover {
    box-shadow: var(--contai-shadow-sm);
}

.contai-ads-manager .contai-ads-action-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--contai-radius-md);
    background: var(--contai-neutral-100);
    margin: 20px 20px 0;
    flex-shrink: 0;
}

.contai-ads-manager .contai-ads-action-icon .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
    color: var(--contai-neutral-600);
}

.contai-ads-manager .contai-ads-action-icon-danger {
    background: var(--contai-error-bg);
}

.contai-ads-manager .contai-ads-action-icon-danger .dashicons {
    color: var(--contai-error);
}

.contai-ads-manager .contai-ads-action-body {
    flex: 1;
    padding: 14px 20px 16px;
}

.contai-ads-manager .contai-ads-action-body h3 {
    margin: 0 0 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--contai-neutral-700);
}

.contai-ads-manager .contai-ads-action-body > p {
    margin: 0 0 12px;
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--contai-neutral-600);
}

.contai-ads-manager .contai-ads-action-meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--contai-neutral-500);
    padding: 4px 10px;
    background: var(--contai-neutral-50);
    border-radius: 20px;
    border: 1px solid var(--contai-neutral-200);
}

.contai-ads-manager .contai-ads-action-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--contai-neutral-200);
    background: var(--contai-neutral-50);
}

.contai-ads-manager .contai-ads-action-footer form {
    margin: 0;
}

/* Danger card accent */
.contai-ads-manager .contai-ads-action-card-danger {
    border-color: var(--contai-error-border);
}

.contai-ads-manager .contai-ads-action-card-danger:hover {
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.08);
}

.contai-ads-manager .contai-ads-action-card-danger .contai-ads-action-footer {
    background: var(--contai-error-bg);
    border-top-color: var(--contai-error-border);
}

/* --- Danger Button --- */
.contai-ads-manager .button-danger,
.contai-ads-manager button.button-danger {
    background: linear-gradient(135deg, var(--contai-error) 0%, #c02225 100%);
    border: 1px solid var(--contai-error);
    color: #fff;
    box-shadow: var(--contai-shadow-sm);
}

.contai-ads-manager .button-danger:hover,
.contai-ads-manager button.button-danger:hover {
    background: linear-gradient(135deg, #c02225 0%, #a71d27 100%);
    border-color: #a71d27;
    color: #fff;
    box-shadow: var(--contai-shadow-md);
    transform: translateY(-1px);
}

.contai-ads-manager .button-danger:active,
.contai-ads-manager button.button-danger:active {
    background: #a71d27;
    border-color: #a71d27;
    color: #fff;
    transform: translateY(0);
}

/* ===================================================
   AdSense Account Tab -- Empty & Connected States
   Mirrors Google Analytics panel UX
   =================================================== */

/* --- Empty State --- */
.contai-ads-manager .contai-adsense-empty {
    text-align: center;
    padding: var(--contai-spacing-xl) var(--contai-spacing-lg);
    max-width: 560px;
    margin: 0 auto;
}

.contai-ads-manager .contai-adsense-empty__icon {
    width: 64px;
    height: 64px;
    border-radius: var(--contai-radius-lg);
    background: var(--contai-primary-glow);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--contai-spacing-md);
}

.contai-ads-manager .contai-adsense-empty__icon .dashicons {
    font-size: 32px;
    width: 32px;
    height: 32px;
    color: var(--contai-primary);
}

.contai-ads-manager .contai-adsense-empty h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--contai-neutral-700);
    margin: 0 0 var(--contai-spacing-xs);
}

.contai-ads-manager .contai-adsense-empty p {
    color: var(--contai-neutral-500);
    font-size: 14px;
    line-height: 1.6;
    margin: 0 0 var(--contai-spacing-lg);
}

/* --- Steps --- */
.contai-ads-manager .contai-adsense-steps {
    display: flex;
    flex-direction: column;
    gap: var(--contai-spacing-md);
    max-width: 460px;
    margin: 0 auto var(--contai-spacing-lg);
    text-align: left;
}

.contai-ads-manager .contai-adsense-step {
    display: flex;
    align-items: flex-start;
    gap: var(--contai-spacing-sm);
    padding: var(--contai-spacing-sm) var(--contai-spacing-md);
    border-radius: var(--contai-radius-md);
    background: var(--contai-neutral-50);
    border: 1px solid var(--contai-neutral-200);
    transition: border-color 0.2s, background 0.2s;
}

.contai-ads-manager .contai-adsense-step.active {
    border-color: var(--contai-primary-border);
    background: var(--contai-primary-glow);
}

.contai-ads-manager .contai-adsense-step.done {
    border-color: var(--contai-success-border);
    background: var(--contai-success-bg);
}

.contai-ads-manager .contai-adsense-step__num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--contai-neutral-200);
    color: var(--contai-neutral-600);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.contai-ads-manager .contai-adsense-step.active .contai-adsense-step__num {
    background: var(--contai-primary);
    color: #fff;
}

.contai-ads-manager .contai-adsense-step.done .contai-adsense-step__num {
    background: var(--contai-success);
    color: #fff;
}

.contai-ads-manager .contai-adsense-step h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--contai-neutral-700);
    margin: 0 0 2px;
}

.contai-ads-manager .contai-adsense-step p {
    font-size: 12px;
    color: var(--contai-neutral-500);
    margin: 0;
    line-height: 1.4;
}

/* --- OAuth Button --- */
.contai-ads-manager .contai-btn-oauth {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--contai-primary);
    color: #fff;
    border: none;
    border-radius: var(--contai-radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
}

.contai-ads-manager .contai-btn-oauth:hover {
    background: var(--contai-primary-dark);
    box-shadow: var(--contai-shadow-md);
    color: #fff;
}

.contai-ads-manager .contai-btn-oauth:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.contai-ads-manager .contai-btn-oauth .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* --- Connected State --- */
.contai-ads-manager .contai-adsense-connected {
    display: flex;
    flex-direction: column;
    gap: var(--contai-spacing-lg);
    padding: var(--contai-spacing-lg);
}

.contai-ads-manager .contai-adsense-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: var(--contai-spacing-md);
    border-bottom: 1px solid var(--contai-neutral-200);
}

.contai-ads-manager .contai-adsense-header__left {
    display: flex;
    align-items: center;
    gap: var(--contai-spacing-sm);
}

.contai-ads-manager .contai-adsense-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: var(--contai-radius-pill);
    font-size: 13px;
    font-weight: 600;
    background: var(--contai-success-bg);
    color: var(--contai-success-text);
    border: 1px solid var(--contai-success-border);
}

.contai-ads-manager .contai-adsense-badge .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    color: var(--contai-success);
}

.contai-ads-manager .contai-adsense-mid {
    font-family: monospace;
    font-size: 14px;
    color: var(--contai-neutral-600);
    background: var(--contai-neutral-100);
    padding: 4px 10px;
    border-radius: var(--contai-radius-sm);
}

.contai-ads-manager .contai-adsense-loading {
    display: flex;
    align-items: center;
    gap: var(--contai-spacing-xs);
    font-size: 13px;
    color: var(--contai-neutral-500);
}

.contai-ads-manager .contai-adsense-loading .spinner {
    float: none;
    margin: 0;
}

/* --- Feature Grid --- */
.contai-ads-manager .contai-adsense-features {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--contai-spacing-md);
}

.contai-ads-manager .contai-adsense-feature {
    background: var(--contai-neutral-50);
    border: 1px solid var(--contai-neutral-200);
    border-radius: var(--contai-radius-md);
    padding: var(--contai-spacing-md);
    display: flex;
    align-items: flex-start;
    gap: var(--contai-spacing-sm);
}

.contai-ads-manager .contai-adsense-feature__icon {
    width: 36px;
    height: 36px;
    border-radius: var(--contai-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.contai-ads-manager .contai-adsense-feature__icon--blue {
    background: var(--contai-info-bg);
    color: var(--contai-primary);
}

.contai-ads-manager .contai-adsense-feature__icon--green {
    background: var(--contai-success-bg);
    color: var(--contai-success);
}

.contai-ads-manager .contai-adsense-feature__icon--amber {
    background: var(--contai-warning-bg);
    color: var(--contai-warning);
}

.contai-ads-manager .contai-adsense-feature__icon--purple {
    background: #f3e8ff;
    color: #7c3aed;
}

.contai-ads-manager .contai-adsense-feature__icon .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.contai-ads-manager .contai-adsense-feature h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--contai-neutral-700);
    margin: 0 0 2px;
}

.contai-ads-manager .contai-adsense-feature p {
    font-size: 12px;
    color: var(--contai-neutral-500);
    margin: 0;
    line-height: 1.4;
}

/* --- Earnings Summary --- */
.contai-ads-manager .contai-adsense-earnings-summary {
    padding-top: var(--contai-spacing-md);
    border-top: 1px solid var(--contai-neutral-200);
}

.contai-ads-manager .contai-adsense-earnings-summary h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--contai-neutral-700);
    margin: 0 0 var(--contai-spacing-md);
}

.contai-ads-manager .contai-adsense-earnings-val {
    font-weight: 700;
    color: var(--contai-success) !important;
}

/* --- Disconnect / Actions --- */
.contai-ads-manager .contai-adsense-disconnect {
    display: flex;
    align-items: center;
    gap: var(--contai-spacing-sm);
    padding-top: var(--contai-spacing-md);
    border-top: 1px solid var(--contai-neutral-200);
}

.contai-ads-manager .contai-btn-disconnect {
    padding: 6px 16px;
    background: #fff;
    color: var(--contai-error);
    border: 1px solid var(--contai-error-border);
    border-radius: var(--contai-radius-md);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.contai-ads-manager .contai-btn-disconnect:hover {
    background: var(--contai-error-bg);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .contai-ads-manager .contai-ads-tabs-nav {
        padding: 0 var(--contai-spacing-md);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .contai-ads-manager .contai-ads-tab {
        padding: 12px 14px;
        font-size: 12px;
    }

    .contai-ads-manager .contai-ads-form-body,
    .contai-ads-manager .contai-ads-form-footer,
    .contai-ads-manager .contai-ads-callout {
        padding-left: var(--contai-spacing-md);
        padding-right: var(--contai-spacing-md);
    }

    .contai-ads-manager .contai-ads-status-bar {
        flex-direction: column;
        gap: var(--contai-spacing-xs);
        align-items: flex-start;
        padding-left: var(--contai-spacing-md);
        padding-right: var(--contai-spacing-md);
    }

    .contai-ads-manager .contai-ads-advanced-grid {
        grid-template-columns: 1fr;
        padding: var(--contai-spacing-md);
    }

    .contai-ads-manager .contai-adsense-features {
        grid-template-columns: 1fr;
    }

    .contai-ads-manager .contai-adsense-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--contai-spacing-xs);
    }

    .contai-ads-manager .contai-adsense-connected {
        padding: var(--contai-spacing-md);
    }
}
