/* =========================================
   Admin UI Rebuild - Variable Definitions
   ========================================= */
:root {
    --atsp-primary: #2271b1;
    --atsp-primary-hover: #135e96;
    --atsp-secondary: #f0f0f1;
    --atsp-text: #3c434a;
    --atsp-bg: #fff;
    --atsp-border: #dcdcde;
    --atsp-success: #00a32a;
    --atsp-danger: #d63638;
    --atsp-youtube: #ff0000;
    --atsp-twitter: #1da1f2;
    /* Old X blue, or use black for X spec */
    --atsp-google: #4285f4;
    --atsp-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --atsp-radius: 6px;
    --atsp-spacing: 15px;
}

/* =========================================
   Root Wrapper & Layout
   ========================================= */
.atsp-admin-wrapper {
    background: #f6f7f7;
    /* WP Admin Gray */
    padding: 20px;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    max-width: 100%;
}

.atsp-admin-wrapper * {
    box-sizing: border-box;
}

/* =========================================
   1. Header & Stats Grid
   ========================================= */
.atsp-header {
    margin-bottom: 20px;
}

.atsp-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.atsp-stat-item {
    background: var(--atsp-bg);
    border: 1px solid var(--atsp-border);
    border-radius: var(--atsp-radius);
    padding: 15px;
    text-align: center;
    box-shadow: var(--atsp-shadow);
}

.atsp-stat-item.highlight {
    border-color: var(--atsp-primary);
    background: #f0f6fc;
}

.atsp-stat-number {
    font-size: 24px;
    font-weight: 700;
    color: var(--atsp-primary);
    margin-bottom: 5px;
    line-height: 1;
}

.atsp-stat-label {
    font-size: 13px;
    color: #646970;
}

/* =========================================
   2. Sticky Toolbar
   ========================================= */
.atsp-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--atsp-bg);
    border: 1px solid var(--atsp-border);
    padding: 10px 15px;
    border-radius: var(--atsp-radius);
    margin-bottom: 20px;
    box-shadow: var(--atsp-shadow);
    flex-wrap: wrap;
    gap: 10px;
}

.atsp-toolbar.sticky-toolbar {
    position: sticky;
    top: 32px;
    /* WP Admin Bar offset */
    z-index: 99;
}

.atsp-toolbar-group {
    display: flex;
    gap: 10px;
}

.atsp-toolbar .button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 36px;
    padding: 0 15px;
    font-size: 14px;
}

.atsp-toolbar .button .dashicons {
    margin-top: 3px;
    /* visual alignment */
}

/* =========================================
   3. Trend Grid Architecture
   ========================================= */
.atsp-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding-bottom: 50px;
    /* Space for scroll */
}

/* =========================================
   4. Trend Card Styling
   ========================================= */
.atsp-card {
    background: var(--atsp-bg);
    border: 1px solid var(--atsp-border);
    border-radius: var(--atsp-radius);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    position: relative;
    /* Selection State */
}

.atsp-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    border-color: #aaa;
}

.atsp-card.selected {
    border-color: var(--atsp-primary);
    background-color: #f0f6fc;
    box-shadow: 0 0 0 1px var(--atsp-primary);
}

/* Card Header */
.atsp-card-header {
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fafafa;
    border-bottom: 1px solid #f0f0f1;
}

.atsp-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #ddd;
    color: #555;
}

/* Platform Colors */
.atsp-card.platform-google .atsp-badge {
    color: var(--atsp-google);
    border-color: rgba(66, 133, 244, 0.3);
    background: rgba(66, 133, 244, 0.05);
}

.atsp-card.platform-youtube .atsp-badge {
    color: var(--atsp-youtube);
    border-color: rgba(255, 0, 0, 0.3);
    background: rgba(255, 0, 0, 0.05);
}

.atsp-card.platform-x .atsp-badge {
    color: var(--atsp-text);
    border-color: rgba(0, 0, 0, 0.3);
    background: rgba(0, 0, 0, 0.05);
}

/* X is black/dark */

.atsp-checkbox {
    transform: scale(1.2);
    cursor: pointer;
}

/* Card Body */
.atsp-card-body {
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.atsp-card-body h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
    color: #1d2327;
    /* Line Clamp */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 42px;
    /* 2 lines approx */
}

.atsp-thumb {
    width: 100%;
    height: 140px;
    background: #eee;
    border-radius: 4px;
    overflow: hidden;
    margin-top: auto;
    /* Push to bottom if text is short */
}

.atsp-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.atsp-card:hover .atsp-thumb img {
    transform: scale(1.05);
}

.atsp-meta {
    font-size: 12px;
    color: #888;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* =========================================
   5. Loading & Empty States
   ========================================= */
.atsp-no-data {
    grid-column: 1 / -1;
    text-align: center;
    padding: 50px;
    background: #fff;
    border-radius: 8px;
    color: #666;
    font-size: 16px;
}

.atsp-no-data .dashicons {
    font-size: 40px;
    width: 40px;
    height: 40px;
    color: #ccc;
    margin-bottom: 10px;
}

/* Loading Overlay for Toolbar actions */
.atsp-loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

/* =========================================
   6. RTL Support (Native in Wrapper)
   ========================================= */
/* Wrapper has dir="rtl", so flex/grid should behave.
   Just ensuring margin flips */
.atsp-admin-wrapper[dir="rtl"] .atsp-toolbar-group {
    /* No special overrides usually needed for flex gap */
}

/* Responsive */
@media (max-width: 782px) {
    .atsp-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .atsp-toolbar-group {
        justify-content: center;
    }
}