/**
 * SEOCOSTM Admin Styles - Modern & Colorful
 */

.seocostm-admin-wrap {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    max-width: 100%;
    box-sizing: border-box;
}

.seocostm-admin-wrap *,
.seocostm-admin-wrap *::before,
.seocostm-admin-wrap *::after {
    box-sizing: inherit;
}

/* Header & Titles */
.seocostm-header-flex {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.seocostm-admin-wrap h1 {
    font-weight: 700;
    color: #1d2327;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.seocostm-admin-wrap h1 .dashicons {
    color: #2271b1;
    background: #f0f6fc;
    padding: 8px;
    border-radius: 8px;
    width: auto;
    height: auto;
    font-size: 24px;
}

/* Responsive Table Wrapper */
.seocostm-table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 20px;
    border: 1px solid #c3c4c7;
    box-shadow: 0 1px 1px rgba(0, 0, 0, .04);
    background: #fff;
    /* Ensure bg */
}

.seocostm-table-responsive .wp-list-table {
    border: none;
    box-shadow: none;
    margin: 0;
    /* Let wrapper handle margin */
    table-layout: auto !important;
    /* Force auto layout to allow expansion */
}

/* Ensure columns don't shrink too much */
.seocostm-table-responsive th,
.seocostm-table-responsive td {
    white-space: nowrap;
    min-width: 100px;
    /* Increased min-width */
    box-sizing: border-box;
}

/* Specific Article Column Styling */
.seocostm-col-article {
    white-space: normal !important;
    /* Allow wrapping */
    min-width: 140px;
    max-width: 200px;
    /* Constrain width */
}

/* Allow title and some columns to wrap if needed, but usually nowrap is better for data tables on mobile so they scroll */
.seocostm-table-responsive td.column-primary {
    white-space: normal;
    min-width: 200px;
}

/* Stats Cards (Colorful) */
.seocostm-stats-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.seocostm-stat-box {
    background: #fff;
    border: 1px solid #eef0f5;
    border-radius: 12px;
    padding: 20px;
    text-decoration: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.02);
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
    overflow: hidden;
}

.seocostm-stat-box:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08);
}

.seocostm-stat-icon-bg {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.seocostm-stat-icon-bg.warn {
    background: #fee2e2;
    color: #dc2626;
}

.seocostm-stat-icon-bg.alert {
    background: #fef3c7;
    color: #d97706;
}

.seocostm-stat-icon-bg.info {
    background: #e0f2fe;
    color: #0284c7;
}

.seocostm-stat-icon-bg.purple {
    background: #f3e8ff;
    color: #9333ea;
}

.seocostm-stat-icon-bg.blue {
    background: #dbeafe;
    color: #2563eb;
}

.seocostm-stat-icon-bg.violet {
    background: #ede9fe;
    color: #7c3aed;
}

.seocostm-stat-icon-bg.cyan {
    background: #ecfeff;
    color: #0891b2;
}

.seocostm-stat-icon-bg .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
}

.seocostm-stat-content {
    display: flex;
    flex-direction: column;
}

.seocostm-stat-number {
    font-size: 24px;
    font-weight: 800;
    color: #111827;
    line-height: 1.2;
}

.seocostm-stat-label {
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    margin: 0;
}

/* Health Badge Animation */
.critical-pulse {
    border: 1px solid #ef4444 !important;
    animation: seocostm-pulse-border 2s infinite;
}

@keyframes seocostm-pulse-border {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Health Dashboard Widget */
.seocostm-health-dashboard {
    background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 30px;
    display: flex;
    gap: 40px;
    align-items: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
}

.seocostm-health-score-card {
    flex-shrink: 0;
}

/* Circular Chart */
.seocostm-circular-chart {
    width: 140px;
    height: 140px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.seocostm-circular-chart svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.seocostm-circle-progress {
    transition: stroke-dashoffset 1.5s ease-out;
    stroke-linecap: round;
}

.seocostm-score-text {
    position: absolute;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.seocostm-big-score {
    font-size: 42px;
    font-weight: 900;
    color: #111827;
    line-height: 1;
}

.seocostm-percent {
    font-size: 14px;
    color: #9ca3af;
    margin-top: -5px;
    margin-bottom: 2px;
}

.seocostm-score-label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #f3f4f6;
    color: #4b5563;
}

/* Breakdown Bars */
.seocostm-health-breakdown {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.seocostm-health-item {
    width: 100%;
}

.seocostm-health-label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.seocostm-health-label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.seocostm-health-val {
    font-size: 13px;
    font-weight: 700;
    color: #111827;
}

.seocostm-health-bar {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.seocostm-health-bar div {
    height: 100%;
    border-radius: 4px;
    transition: width 1s ease-out;
}

/* Responsive */
@media (max-width: 782px) {
    .seocostm-health-dashboard {
        flex-direction: column !important;
        text-align: center;
        gap: 25px;
        padding: 15px;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
        margin: 0 0 20px 0;
    }

    .seocostm-health-score-card {
        margin: 0 auto;
    }

    .seocostm-health-breakdown {
        width: 100%;
    }

    .seocostm-header-flex {
        flex-direction: column !important;
        align-items: stretch;
        gap: 15px;
        width: 100%;
        box-sizing: border-box;
    }

    .seocostm-header-flex h1 {
        font-size: 20px;
        text-align: center;
        justify-content: center;
    }

    .seocostm-stats-container {
        grid-template-columns: repeat(2, 1fr) !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
        gap: 10px !important;
    }

    .seocostm-stat-box {
        padding: 12px 8px !important;
        gap: 8px !important;
    }

    .seocostm-stat-number {
        font-size: 18px !important;
    }

    .seocostm-stat-label {
        font-size: 11px !important;
    }

    .seocostm-stat-icon-bg {
        width: 35px !important;
        height: 35px !important;
    }

    .seocostm-stat-icon-bg .dashicons {
        font-size: 18px !important;
        width: 18px !important;
        height: 18px !important;
    }
}

.seocostm-enhanced-table tbody tr:hover {
    background: #f0f6fc;
}

/* Links Icons Styling */
.seocostm-link-icon {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.seocostm-link-int {
    background: #e5f5fa;
    color: #0085ba;
    border: 1px solid #bce0ee;
}

.seocostm-link-ext {
    background: #f0f6fc;
    color: #135e96;
    border: 1px solid #cce5ff;
    margin-left: 5px;
}

.seocostm-link-icon .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    margin-right: 4px;
}

/* Action Buttons */
.seocostm-intent-btn {
    border-color: #2271b1 !important;
    color: #2271b1 !important;
}

.seocostm-intent-btn:hover {
    background: #2271b1 !important;
    color: #fff !important;
}

/* Pillar Card Styles */
.seocostm-pillar-card {
    background: #fff;
    border: 1px solid #e2e4e7;
    border-radius: 8px;
    margin-bottom: 25px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.03);
}

.seocostm-pillar-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 6px;
    background: linear-gradient(180deg, #2271b1 0%, #00a0d2 100%);
}

.seocostm-card-header {
    padding: 20px;
    border-bottom: 1px solid #f0f0f1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fbfbfc;
    flex-wrap: wrap;
    /* Allow wrapping */
    gap: 10px;
}

.seocostm-card-header h3 {
    margin: 0;
    font-size: 18px;
    color: #1d2327;
    display: flex;
    align-items: center;
    gap: 8px;
}

.seocostm-card-header .dashicons {
    font-size: 22px;
    width: 22px;
    height: 22px;
    color: #2271b1;
}

.seocostm-pillar-highlight {
    background: #f0f6fc;
    border: 1px solid #c5d7ed;
    border-radius: 6px;
    padding: 15px;
    margin: 20px;
    display: flex;
    gap: 15px;
    flex-direction: row;
}

@media (max-width: 600px) {
    .seocostm-pillar-highlight {
        flex-direction: column;
    }
}

.seocostm-pillar-icon {
    display: flex;
    align-items: flex-start;
    padding-top: 5px;
}

.seocostm-pillar-icon .dashicons {
    font-size: 36px;
    width: 36px;
    height: 36px;
    color: #dba617;
}

.seocostm-pillar-details h4 {
    margin: 0 0 5px;
    color: #1d2327;
    font-size: 15px;
}

.seocostm-pillar-meta {
    font-size: 13px;
    color: #646970;
}

.seocostm-info-box {
    background: #fff;
    border: 1px dashed #c3c4c7;
    border-radius: 6px;
    padding: 12px;
    margin-top: 10px;
    font-size: 13px;
    color: #50575e;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.seocostm-info-box .dashicons {
    color: #2271b1;
    font-size: 18px;
}

.seocostm-spokes-table {
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
}

.seocostm-spokes-table td {
    border-bottom: 1px solid #f0f0f1;
    padding: 12px 20px;
}

.seocostm-spokes-table tr:last-child td {
    border-bottom: none;
}

.seocostm-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.seocostm-status-pill .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.status-linked {
    background: #edfaef;
    color: #008a20;
}

.status-not-linked {
    background: #fbeaea;
    color: #d63638;
}

/* Tagify Color Override */
.tagify {
    --tags-focus-border-color: #2271b1;
}

/* Search Bar Styles */
.seocostm-search-container {
    background: #fff;
    border: 1px solid #e2e4e7;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.seocostm-search-header {
    margin-bottom: 15px;
}

.seocostm-search-title {
    margin: 0;
    font-size: 18px;
    color: #1d2327;
    display: flex;
    align-items: center;
    gap: 8px;
}

.seocostm-search-title svg {
    width: 20px;
    height: 20px;
    fill: #2271b1;
}

.seocostm-search-desc {
    margin: 5px 0 0;
    color: #646970;
    font-size: 13px;
    margin-left: 28px;
}

.seocostm-input-group {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    flex-wrap: wrap;
    /* Wrap on small screens */
}

.seocostm-input-wrapper {
    flex-grow: 1;
    min-width: 200px;
}

.seocostm-tagify-search {
    width: 100%;
    border-radius: 4px;
    border: 1px solid #8c8f94;
}

.seocostm-search-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 38px;
}

.seocostm-search-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Analysis Widgets Layout */
.seocostm-main-stats-row {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 20px;
    margin-bottom: 30px;
    width: 100%;
    max-width: 100%;
    /* Prevent overflow */
    box-sizing: border-box;
}

.seocostm-col-left,
.seocostm-col-right {
    min-width: 0;
    max-width: 100%;
}

.seocostm-col-right-widgets {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

@media (max-width: 782px) {
    .seocostm-main-stats-row {
        grid-template-columns: 1fr !important;
        display: flex !important;
        flex-direction: column;
        width: 100% !important;
        gap: 20px;
    }

    .seocostm-col-right-widgets {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
        width: 100%;
    }

    .seocostm-col-right-widgets .seocostm-analysis-widget:last-child {
        grid-column: span 2;
    }

    /* Adjust widgets content when in 2-column mode */
    .seocostm-col-right-widgets .seocostm-analysis-widget {
        padding: 12px !important;
    }

    .seocostm-col-right-widgets .seocostm-analysis-widget h2 {
        font-size: 11px !important;
        margin-bottom: 5px !important;
    }

    .seocostm-col-right-widgets .seocostm-analysis-widget>div:not(.seocostm-intent-bar-progress) {
        flex-direction: column !important;
        text-align: center;
        gap: 5px !important;
        padding: 5px !important;
    }

    .seocostm-col-right-widgets .seocostm-analysis-widget .dashicons {
        font-size: 24px !important;
        width: 24px !important;
        height: 24px !important;
    }

    .seocostm-col-right-widgets .seocostm-analysis-widget .seocostm-stat-number {
        font-size: 18px !important;
    }

    .seocostm-col-right-widgets .seocostm-analysis-widget p {
        font-size: 11px !important;
    }

    .seocostm-col-left,
    .seocostm-col-right {
        width: 100% !important;
        max-width: 100% !important;
        flex: none;
    }

    .seocostm-entities-widget {
        max-height: none !important;
        /* Allow it to expand on mobile */
    }
}

.seocostm-analysis-widget {
    background: #fff;
    border: 1px solid #e2e4e7;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.seocostm-analysis-widget h2 {
    margin-top: 0;
    font-size: 16px;
    border-bottom: 1px solid #f0f0f1;
    padding-bottom: 10px;
    margin-bottom: 15px;
    color: #1d2327;
}

/* Intent Progress Bar */
.seocostm-intent-bar-progress {
    display: flex;
    height: 24px;
    border-radius: 12px;
    overflow: hidden;
    background: #f0f0f1;
}

.seocostm-intent-bar-progress div {
    height: 100%;
    transition: width 0.5s ease-in-out;
}

.seocostm-intent-bar-progress div:hover {
    opacity: 0.9;
}

/* Intent Table */
.seocostm-intent-table-simple {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.seocostm-intent-table-simple td {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f1;
    color: #3c434a;
    font-size: 13px;
}

.seocostm-intent-table-simple tr:last-child td {
    border-bottom: none;
}

.seocostm-intent-table-simple strong {
    color: #1d2327;
}

/* Density Score Badges */
.seocostm-score-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    cursor: help;
    margin-top: 4px;
}

.seocostm-score-bad {
    background-color: #d63638;
    border: 1px solid #d63638;
}

.seocostm-score-poor {
    background-color: #dba617;
    border: 1px solid #dba617;
    color: #1d2327;
}

.seocostm-score-good {
    background-color: #008a20;
    border: 1px solid #008a20;
}

.seocostm-score-strong {
    background-color: #2271b1;
    border: 1px solid #2271b1;
}

/* Pulse Animation */
@keyframes seocostm-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(214, 54, 56, 0.7);
    }

    70% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(214, 54, 56, 0);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(214, 54, 56, 0);
    }
}

.seocostm-pulse {
    animation: seocostm-pulse 2s infinite;
    background-color: #d63638 !important;
    border-color: #d63638 !important;
}

#seocostm-action-center-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 30px;
    left: 30px;
    z-index: 9999;
    width: 56px;
    height: 56px;
    padding: 0 !important;
    border-radius: 50%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

@media (max-width: 600px) {
    #seocostm-action-center-btn {
        bottom: 15px;
        left: 15px;
        width: 48px;
        height: 48px;
    }

    #seocostm-action-center-btn .dashicons {
        font-size: 24px;
        width: 24px;
        height: 24px;
    }
}

#seocostm-action-center-btn:hover {
    transform: scale(1.1);
}

#seocostm-action-center-btn .dashicons {
    font-size: 28px;
    width: 28px;
    height: 28px;
    margin: 0;
}

.seocostm-badge-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #d63638;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: bold;
    border: 2px solid #fff;
    margin-left: 0;
}

/* Modal Styles */
.seocostm-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    /* Add padding used as safe margin */
}

.seocostm-modal-content {
    background: #fff;
    width: 800px;
    max-width: 100%;
    /* Ensure it fits in padding */
    margin: auto;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    /* Increase max height */
    position: relative;
    overflow: hidden;
    /* Manage scroll internally */
}

.seocostm-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
    flex-shrink: 0;
}

.seocostm-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
}

/* Task Cards */
.seocostm-tasks-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.seocostm-task-card {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    border-left-width: 4px;
    background: #fff;
    transition: transform 0.2s;
    flex-direction: row;
}

@media (max-width: 500px) {
    .seocostm-task-card {
        flex-direction: column;
    }

    .seocostm-task-actions {
        width: 100%;
        text-align: left;
        margin-top: 10px;
    }
}

.seocostm-task-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.seocostm-task-critical {
    border-left-color: #d63638;
}

.seocostm-task-structural {
    border-left-color: #dba617;
}

.seocostm-task-optimization {
    border-left-color: #0073aa;
}

.seocostm-task-icon .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
    padding-top: 2px;
}

.seocostm-task-critical .seocostm-task-icon {
    color: #d63638;
}

.seocostm-task-structural .seocostm-task-icon {
    color: #dba617;
}

.seocostm-task-optimization .seocostm-task-icon {
    color: #0073aa;
}

.seocostm-task-info {
    flex-grow: 1;
}

.seocostm-task-title {
    margin: 0 0 5px 0;
    font-size: 14px;
    font-weight: 700;
}

.seocostm-task-desc {
    margin: 0;
    color: #555;
    font-size: 13px;
    line-height: 1.4;
}

.seocostm-task-actions {
    min-width: 80px;
    text-align: right;
}

.seocostm-task-details {
    margin-top: -5px;
    margin-bottom: 15px;
    border-radius: 0 0 6px 6px;
    border: 1px solid #ddd;
    border-top: none;
    margin-left: 4px;
    max-height: 200px;
    overflow-y: auto;
}

/* Smart Links Grid Layout */
.seocostm-smart-links-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    /* Force stack on mobile default */
    gap: 20px;
}

@media (max-width: 782px) {
    .seocostm-smart-links-grid {
        grid-template-columns: 1fr !important;
        width: 100% !important;
    }
}

@media (min-width: 783px) and (max-width: 1100px) {
    .seocostm-smart-links-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.seocostm-link-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-wrap: wrap;
    /* Wrap content */
    gap: 15px;
}

.seocostm-link-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    border-color: #2271b1;
}

.seocostm-link-col {
    flex: 1;
    min-width: 0;
    /* Ensure flex item can shrink */
}

/* Source Side */
.seocostm-link-source {
    padding-right: 15px;
    border-right: 1px solid #f0f0f1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Target Side */
.seocostm-link-target {
    padding-left: 15px;
    border-left: 1px solid #f0f0f1;
    display: flex;
    flex-direction: column;
    gap: 5px;
    text-align: right;
}

@media (max-width: 700px) {
    .seocostm-link-card {
        flex-direction: column;
        align-items: stretch;
    }

    .seocostm-link-source {
        padding-right: 0;
        border-right: none;
        border-bottom: 1px solid #f0f0f1;
        /* Divide vertically */
        padding-bottom: 15px;
    }

    .seocostm-link-target {
        padding-left: 0;
        border-left: none;
        padding-top: 15px;
        text-align: left;
    }

    .seocostm-link-flow {
        display: none;
        /* Hide flow arrow on small screens if vertical */
    }
}

.seocostm-article-label {
    font-size: 10px;
    text-transform: uppercase;
    color: #8c8f94;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.seocostm-article-title {
    font-size: 14px;
    font-weight: 600;
    color: #1d2327;
    text-decoration: none;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.seocostm-article-title:hover {
    color: #2271b1;
}

/* Flow Section */
.seocostm-link-flow {
    flex: 0 0 100px;
    padding: 0 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.seocostm-flow-arrow-container {
    width: 100%;
    position: relative;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.seocostm-arrow-line {
    width: 100%;
    height: 2px;
    background: #e0e0e0;
    position: absolute;
}

.seocostm-arrow-head {
    width: 0;
    height: 0;
    border-top: 5px solid transparent;
    border-bottom: 5px solid transparent;
    border-left: 6px solid #e0e0e0;
    position: absolute;
    right: 0;
}

.seocostm-link-keyword {
    background: #fff8e5;
    color: #dba617;
    border: 1px solid #dba617;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    z-index: 2;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.seocostm-action-btn-wrap {
    margin-top: 5px;
}

/* Graph Responsive Styles */
.seocostm-graph-stats {
    background: #fff;
    padding: 25px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin: 20px 0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    display: grid;
    grid-template-columns: repeat(4, 1fr) auto;
    gap: 30px;
    align-items: center;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.seocostm-stat-item {
    /* Desktop default */
    border-right: 1px solid #f0f0f1;
    padding-right: 20px;
}

.seocostm-stat-item:last-child {
    border-right: none;
    padding-right: 0;
}



/* Specific Logic: Remove border from the last .seocostm-stat-item */
.seocostm-stat-item:nth-last-of-type(1) {
    border-right: none;
    padding-right: 0;
}

/* Heatmap Styles */
.seocostm-heatmap-table {
    width: max-content;
    /* Allow intrinsic width to force scroll */
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 2px;
}

.seocostm-heatmap-table th {
    padding: 15px;
    background: #f0f0f1;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 11px;
    color: #50575e;
    white-space: nowrap;
    /* Prevent wrapping */
}

.seocostm-heatmap-table td {
    padding: 15px;
    text-align: center;
    border-radius: 4px;
    font-weight: bold;
    transition: transform 0.1s;
    cursor: default;
    white-space: nowrap;
    /* Prevent wrapping */
}

.seocostm-heatmap-table td:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.seocostm-heatmap-cat-label {
    background: #fcfcfc;
    text-align: left !important;
    color: #1d2327 !important;
    position: sticky;
    left: 0;
    z-index: 2;
    /* Keep category visible while scrolling if desired, or remove sticky if not */
    border-right: 1px solid #eee;
}


#seocostm-graph-help {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.seocostm-help-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

#seocostm-network-container {
    min-height: 500px;
    width: 100%;
}

@media (max-width: 1000px) {
    .seocostm-graph-stats {
        grid-template-columns: 1fr;
        gap: 15px;
        text-align: center;
        padding: 15px;
    }

    .seocostm-stat-item {
        border-right: none !important;
        padding-right: 0 !important;
        border-bottom: 1px solid #f0f0f1;
        padding-bottom: 15px;
        margin-bottom: 5px;
    }

    .seocostm-stat-item:last-child {
        border-bottom: none;
    }

    .seocostm-help-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .seocostm-smart-links-grid {
        grid-template-columns: 1fr;
    }

    .seocostm-graph-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .seocostm-separator {
        display: none;
    }

    /* Make node panel cover full screen */
    #seocostm-node-panel {
        width: 100% !important;
        right: -100% !important;
        /* Start off screen */
    }
}

.seocostm-funnel-header {
    background: #fff;
    padding: 20px;
    border: 1px solid #ccd0d4;
    border-left: 4px solid #dba617;
    display: flex;
    align-items: center;
    gap: 15px;
}

.seocostm-funnel-header .dashicons {
    font-size: 28px;
    height: 28px;
    width: 28px;
    color: #1d2327;
}

@media (max-width: 600px) {
    .seocostm-funnel-header {
        padding: 15px;
        font-size: 18px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* --- Marketing Funnel Analysis Responsive Styles --- */
.seocostm-funnel-grid {
    display: flex;
    gap: 20px;
    margin-top: 0;
    width: 100%;
}

.seocostm-funnel-main-card {
    flex: 2;
    padding: 20px;
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}

.seocostm-funnel-sidebar {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.seocostm-card-title {
    margin-top: 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    font-size: 18px;
    font-weight: 600;
}

.seocostm-funnel-visual-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 30px 0;
}

.seocostm-detail-card-container {
    border-top: 1px solid #eee;
    margin-top: 20px;
    padding-top: 20px;
    display: none;
}

.seocostm-detail-card-container h3 {
    margin-top: 0;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    color: #1d2327;
    font-size: 16px;
}

.seocostm-score-card {
    padding: 20px;
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    text-align: center;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}

.seocostm-score-card h3 {
    margin: 0;
    font-size: 14px;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.seocostm-score-visual {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 15px auto;
}

.seocostm-insights-card {
    padding: 20px;
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    flex-grow: 1;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
}

.seocostm-insights-card h3 {
    margin-top: 0;
    font-size: 16px;
    font-weight: 600;
}

.seocostm-action-plan {
    margin-top: 20px;
    padding: 20px;
    background: #f0f6fc;
    border-radius: 8px;
    border: 1px solid #c5d9ed;
}

.seocostm-action-plan-title {
    display: block;
    margin-bottom: 15px;
    color: #1d2327;
    font-size: 14px;
    text-transform: uppercase;
    border-bottom: 1px solid #dce6f1;
    padding-bottom: 10px;
}

/* Funnel Layer Responsiveness */
@media (max-width: 782px) {
    .seocostm-funnel-grid {
        flex-direction: column;
        gap: 25px;
        width: 100%;
        box-sizing: border-box;
        padding: 0;
    }

    .seocostm-funnel-main-card,
    .seocostm-funnel-sidebar {
        flex: none;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
        padding: 15px;
    }

    .seocostm-funnel-layer {
        width: 100% !important;
        height: 100px !important;
        border-radius: 8px !important;
        margin-bottom: 10px;
    }

    .seocostm-funnel-layer span:nth-child(3) {
        font-size: 20px !important;
    }

    .seocostm-funnel-layer span:nth-child(1) {
        font-size: 14px !important;
    }
}

.seocostm-tag-simple {
    display: inline-block;
    background: #f0f0f1;
    color: #50575e;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    margin: 2px;
}