/**
 * ProRank SEO Posts List Columns - Professional Design
 * All styles scoped to avoid WP core conflicts
 */

/* ═══════════════════════════════════════════════════════════════
   Column Widths - Scoped to ProRank columns only
   ═══════════════════════════════════════════════════════════════ */

/* Ensure Title column has proper width */
body.edit-php .wp-list-table .column-title {
    width: 25% !important;
    min-width: 240px !important;
    max-width: 480px !important;
    white-space: normal !important;
    word-break: normal !important;
    overflow-wrap: break-word;
    writing-mode: horizontal-tb !important;
    transform: none !important;
}

/* Keep WP core list table layout; only size our custom columns */

/* Force horizontal text rendering in list tables */
body.edit-php .wp-list-table th,
body.edit-php .wp-list-table td {
    writing-mode: horizontal-tb !important;
    transform: none !important;
}

.wp-list-table .column-prorank_seo_score {
    width: 50px !important;
    min-width: 50px !important;
    text-align: center;
}

.wp-list-table .column-prorank_headline_score {
    width: 50px !important;
    min-width: 50px !important;
    text-align: center;
}

.wp-list-table .column-prorank_focus_keyword {
    width: 120px !important;
    min-width: 120px !important;
    max-width: 140px !important;
}

.wp-list-table .column-prorank_seo_title {
    width: 140px !important;
    min-width: 140px !important;
    max-width: 200px !important;
}

.wp-list-table .column-prorank_seo_desc {
    width: 160px !important;
    min-width: 160px !important;
    max-width: 240px !important;
}

.wp-list-table th.column-prorank_seo_score,
.wp-list-table th.column-prorank_headline_score,
.wp-list-table th.column-prorank_focus_keyword,
.wp-list-table th.column-prorank_seo_title,
.wp-list-table th.column-prorank_seo_desc {
    white-space: nowrap !important;
    overflow: visible !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
    writing-mode: horizontal-tb !important;
    transform: none !important;
}

.wp-list-table td.column-prorank_seo_score,
.wp-list-table td.column-prorank_headline_score,
.wp-list-table td.column-prorank_focus_keyword,
.wp-list-table td.column-prorank_seo_title,
.wp-list-table td.column-prorank_seo_desc {
    vertical-align: middle;
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: normal !important;
    overflow-wrap: normal !important;
    writing-mode: horizontal-tb !important;
    transform: none !important;
}

.wp-list-table td.column-prorank_seo_score,
.wp-list-table td.column-prorank_headline_score {
    padding-left: 0 !important;
    padding-right: 0 !important;
    text-align: center;
}

/* ─────────────────────────────────────────────────────────────────
   SEO Status Badge
   ───────────────────────────────────────────────────────────────── */

.prorank-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 92px;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    cursor: help;
    line-height: 1;
    text-align: center;
    vertical-align: middle;
    margin: 0 auto;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.prorank-status-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    filter: brightness(1.02);
}

.prorank-status-badge.strong {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
}

.prorank-status-badge.solid {
    background: linear-gradient(135deg, #0f766e 0%, #0d9488 100%);
}

.prorank-status-badge.needs-work {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
}

.prorank-status-badge.empty {
    background: #e5e7eb;
    color: #6b7280;
}

/* ─────────────────────────────────────────────────────────────────
   Bulk Edit Layout Tweaks
   ───────────────────────────────────────────────────────────────── */

body.prorank-seo_page_prorank-bulk-edit #wpbody-content,
body.admin_page_prorank-bulk-edit #wpbody-content {
    padding-bottom: 160px;
}

.prorank-bulk-edit-page {
    padding-bottom: 140px;
}

.prorank-bulk-edit-page .submit {
    margin-bottom: 48px;
}

/* ─────────────────────────────────────────────────────────────────
   Focus Keyword Badge
   ───────────────────────────────────────────────────────────────── */

.prorank-keyword-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.4;
}

.prorank-keyword-badge.set {
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #93c5fd;
}

.prorank-keyword-badge.empty {
    background: #f3f4f6;
    color: #9ca3af;
    font-size: 12px;
}

/* ─────────────────────────────────────────────────────────────────
   Meta Columns with Progress Bars
   ───────────────────────────────────────────────────────────────── */

.prorank-meta-column {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.prorank-meta-column.empty {
    justify-content: center;
}

.prorank-meta-column .meta-text {
    font-size: 12px;
    color: #374151;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.prorank-meta-column .meta-text.empty {
    color: #9ca3af;
}

.prorank-progress-bar {
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
}

.prorank-progress-bar .progress-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.prorank-progress-bar.good .progress-fill {
    background: linear-gradient(90deg, #22c55e, #16a34a);
}

.prorank-progress-bar.warning .progress-fill {
    background: linear-gradient(90deg, #f97316, #ea580c);
}

.prorank-progress-bar.over .progress-fill {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

.prorank-progress-bar.empty .progress-fill {
    background: #e5e7eb;
}

.prorank-meta-column .char-count {
    font-size: 10px;
    color: #9ca3af;
    line-height: 1;
}

/* ─────────────────────────────────────────────────────────────────
   Bulk Edit Page Enhancements
   ───────────────────────────────────────────────────────────────── */

.prorank-bulk-edit-page .prorank-bulk-edit-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.prorank-bulk-edit-page .prorank-field-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    font-size: 11px;
    color: #6b7280;
}

.prorank-bulk-edit-page .prorank-progress-bar {
    margin-top: 2px;
}

.prorank-bulk-edit-page {
    padding-bottom: 96px;
}

.prorank-bulk-edit-page .submit {
    margin: 20px 0 40px;
}

/* ─────────────────────────────────────────────────────────────────
   Filter Dropdowns
   ───────────────────────────────────────────────────────────────── */

.prorank-seo-filter,
.prorank-keyword-filter {
    margin-left: 6px;
}

/* ─────────────────────────────────────────────────────────────────
   Quick/Bulk Edit Fields
   ───────────────────────────────────────────────────────────────── */

.prorank-quick-edit-fields,
.prorank-bulk-edit-fields {
    border-left: 3px solid #2271b1;
    padding-left: 12px;
    margin-top: 12px;
}

.prorank-quick-edit-fields h4,
.prorank-bulk-edit-fields h4 {
    margin: 0 0 12px 0;
    color: #1d2327;
    font-size: 13px;
}

.prorank-quick-edit-fields .title,
.prorank-bulk-edit-fields .title {
    width: 7em;
}

.prorank-quick-edit-fields .input-text-wrap,
.prorank-bulk-edit-fields .input-text-wrap {
    display: block;
}

.prorank-quick-edit-fields textarea.pdesc,
.prorank-bulk-edit-fields textarea {
    width: 100%;
}

.prorank-quick-edit-fields input[type="url"],
.prorank-bulk-edit-fields input[type="url"] {
    width: 100%;
}

.prorank-quick-edit-robots,
.prorank-bulk-robots {
    margin-top: 10px;
}

.prorank-robot-options {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    padding-top: 4px;
}

.prorank-robot-option {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 0;
    white-space: nowrap;
}

.prorank-bulk-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0 0;
}

.prorank-robot-select-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
    padding-top: 4px;
}

.prorank-bulk-robot-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.prorank-bulk-robot-label {
    font-size: 11px;
    font-weight: 600;
    color: #374151;
}

/* Character Counter */
.prorank-char-counter {
    display: inline-block;
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
}

.prorank-char-counter.warning {
    color: #f97316;
}

.prorank-char-counter.over {
    color: #ef4444;
    font-weight: 600;
}

/* ─────────────────────────────────────────────────────────────────
   AI Optimization Indicator
   ───────────────────────────────────────────────────────────────── */

.prorank-ai-optimizing {
    position: relative;
}

.prorank-ai-optimizing::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 10px;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    border: 2px solid #e5e7eb;
    border-top-color: #2271b1;
    border-radius: 50%;
    animation: prorank-spin 0.8s linear infinite;
}

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

/* ─────────────────────────────────────────────────────────────────
   Bulk Actions
   ───────────────────────────────────────────────────────────────── */

#bulk-action-selector-top option[value="prorank_ai_optimize_seo"],
#bulk-action-selector-bottom option[value="prorank_ai_optimize_seo"] {
    font-weight: 600;
}

/* ─────────────────────────────────────────────────────────────────
   Column Header
   ───────────────────────────────────────────────────────────────── */

.prorank-seo-column-header {
    cursor: help;
    display: inline-block;
    line-height: 1;
    white-space: nowrap;
}

/* ─────────────────────────────────────────────────────────────────
   Responsive Design
   ───────────────────────────────────────────────────────────────── */

@media screen and (max-width: 1100px) {
    .wp-list-table .column-prorank_focus_keyword {
        display: none;
    }
}

@media screen and (max-width: 900px) {
    .wp-list-table .column-prorank_seo_title,
    .wp-list-table .column-prorank_seo_desc {
        display: none;
    }
}

@media screen and (max-width: 782px) {
    .wp-list-table .column-prorank_seo_score {
        display: none;
    }
    .wp-list-table .column-prorank_headline_score {
        display: none;
    }
}
