/* ============================================
   Auto Post News — Design System
   ============================================ */

/* === CSS Variables === */
:root {
    /* Colors - Dark Theme */
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #1e2130;
    --bg-card-hover: #252840;
    --bg-input: #161825;
    --bg-sidebar: #141620;

    --text-primary: #e8eaf0;
    --text-secondary: #9398ab;
    --text-muted: #5f6478;

    --accent-primary: #6366f1;
    --accent-primary-hover: #818cf8;
    --accent-primary-glow: rgba(99, 102, 241, 0.3);

    --accent-success: #22c55e;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --accent-info: #3b82f6;

    --border-color: #2a2d3d;
    --border-light: #323548;

    /* Score Colors */
    --score-hot: #ef4444;
    --score-warm: #f59e0b;
    --score-cool: #6366f1;

    /* Platform Colors */
    --fb-color: #1877f2;
    --yt-color: #ff0000;

    /* Spacing */
    --sidebar-width: 240px;
    --topbar-height: 60px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 20px var(--accent-primary-glow);
}

/* === Reset === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', 'Noto Sans Thai', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: var(--accent-primary-hover);
    text-decoration: none;
    transition: color var(--transition-fast);
}
a:hover { color: var(--accent-primary); }

/* === Sidebar === */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition-normal);
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar.collapsed ~ .main-content {
    margin-left: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    font-size: 24px;
}

.logo-text {
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-menu {
    list-style: none;
    padding: 12px 8px;
    flex: 1;
}

.nav-item {
    margin-bottom: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.nav-link:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-item.active .nav-link {
    background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(168,85,247,0.1));
    color: var(--accent-primary-hover);
    border: 1px solid rgba(99,102,241,0.2);
}

.nav-link.disabled {
    opacity: 0.4;
    pointer-events: none;
}

.nav-icon { font-size: 18px; }

.badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 99px;
    margin-left: auto;
}

.badge-soon {
    background: rgba(245,158,11,0.2);
    color: var(--accent-warning);
}

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border-color);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-md);
}

.user-icon { font-size: 16px; }

.user-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    flex: 1;
}

.btn-logout {
    font-size: 16px;
    text-decoration: none;
    opacity: 0.5;
    transition: opacity var(--transition-fast);
    cursor: pointer;
}

.btn-logout:hover {
    opacity: 1;
}

.version-info {
    font-size: 11px;
    color: var(--text-muted);
}

/* === Main Content === */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

.top-bar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    height: var(--topbar-height);
    background: rgba(15, 17, 23, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
}

.menu-toggle:hover {
    background: var(--bg-card);
}

.page-title {
    font-size: 16px;
    font-weight: 600;
}

.top-bar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}

.content-area {
    padding: 24px;
    max-width: 1400px;
}

/* === Cards === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    overflow: hidden;
    transition: border-color var(--transition-fast);
}

.card:hover {
    border-color: var(--border-light);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    font-size: 15px;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* === Stats Grid === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition-normal);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-light);
}

.stat-card.highlight {
    background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(168,85,247,0.05));
    border-color: rgba(99,102,241,0.3);
}

.stat-icon {
    font-size: 28px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
}
.btn-primary:hover {
    background: var(--accent-primary-hover);
    color: white;
    box-shadow: var(--shadow-glow);
}

.btn-glow {
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 5px var(--accent-primary-glow); }
    50% { box-shadow: 0 0 20px var(--accent-primary-glow); }
}

.btn-outline {
    background: transparent;
    border-color: var(--border-light);
    color: var(--text-secondary);
}
.btn-outline:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary-hover);
}

.btn-danger {
    background: var(--accent-danger);
    color: white;
}
.btn-danger:hover { background: #dc2626; color: white; }

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* === Forms === */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    transition: border-color var(--transition-fast);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.form-control-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.inline-form { display: inline; }

.filter-bar {
    display: flex;
    gap: 8px;
}

.filter-form {
    display: flex;
    gap: 8px;
}

/* === Tables === */
.news-table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 10px 12px;
    font-size: 13px;
    border-bottom: 1px solid rgba(42, 45, 61, 0.5);
    vertical-align: middle;
}

tr:hover td {
    background: rgba(99, 102, 241, 0.03);
}

.news-row { cursor: pointer; }

/* === Badges === */
.score-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 700;
}

.score-hot {
    background: rgba(239,68,68,0.15);
    color: var(--score-hot);
}

.score-warm {
    background: rgba(245,158,11,0.15);
    color: var(--score-warm);
}

.score-cool {
    background: rgba(99,102,241,0.15);
    color: var(--score-cool);
}

.platform-badge {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 99px;
}

.platform-facebook {
    background: rgba(24,119,242,0.15);
    color: var(--fb-color);
}

.platform-youtube {
    background: rgba(255,0,0,0.12);
    color: var(--yt-color);
}

.status-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 99px;
    font-weight: 500;
}

.status-new {
    background: rgba(99,102,241,0.15);
    color: var(--accent-primary-hover);
}

.status-processing {
    background: rgba(245,158,11,0.15);
    color: var(--accent-warning);
}

.status-processed, .status-success {
    background: rgba(34,197,94,0.15);
    color: var(--accent-success);
}

.status-skipped {
    background: rgba(107,114,128,0.2);
    color: #9ca3af;
}

.status-error {
    background: rgba(239,68,68,0.15);
    color: var(--accent-danger);
}

.type-badge {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.05);
}

.method-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 99px;
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
}

.category-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 99px;
    background: rgba(168,85,247,0.15);
    color: #c084fc;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}

.status-active { background: var(--accent-success); }
.status-inactive { background: var(--text-muted); }

/* === Content Cells === */
.content-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 300px;
}

.thumb-mini {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.engagement-cell {
    display: flex;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.source-name { font-weight: 500; }
.time-cell { font-size: 12px; color: var(--text-muted); }

.row-inactive { opacity: 0.45; }

.actions-cell {
    display: flex;
    gap: 4px;
}

.source-id-cell code {
    font-size: 11px;
    background: var(--bg-primary);
    padding: 2px 6px;
    border-radius: 4px;
}

/* === News Grid (Card View) === */
.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.news-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition-normal);
    text-decoration: none;
    color: inherit;
    position: relative;
}

.news-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-primary);
    color: inherit;
}

.news-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.news-card-image {
    width: 100%;
    height: 160px;
    overflow: hidden;
}

.news-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--transition-slow);
}

.news-card:hover .news-card-image img {
    transform: scale(1.05);
}

.news-card-body {
    padding: 14px;
    flex: 1;
}

.news-card-body h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    line-height: 1.4;
}

.news-card-body p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.news-card-footer {
    padding: 10px 14px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.engagement-mini {
    display: flex;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

/* === News Detail === */
.detail-layout { max-width: 800px; }

.detail-meta {
    display: flex;
    gap: 10px;
    align-items: center;
}

.detail-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
    line-height: 1.4;
}

.detail-source {
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.detail-image {
    margin: 16px 0;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.detail-image img {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
}

.detail-text { margin: 20px 0; }
.detail-text h3 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.original-text {
    background: var(--bg-primary);
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.7;
    max-height: 400px;
    overflow-y: auto;
}

.engagement-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 12px 0;
}

.eng-item {
    text-align: center;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.eng-icon { font-size: 20px; display: block; margin-bottom: 4px; }
.eng-value { font-size: 18px; font-weight: 700; display: block; }
.eng-label { font-size: 11px; color: var(--text-muted); }

.detail-actions {
    display: flex;
    gap: 10px;
    margin: 20px 0;
}

.detail-meta-info {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-muted);
}

.detail-meta-info p { margin-bottom: 4px; }

.detail-meta-info code {
    background: var(--bg-primary);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 11px;
}

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
}
.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* === Pagination === */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.page-info {
    font-size: 13px;
    color: var(--text-secondary);
}

/* === Utilities === */
.text-muted { color: var(--text-muted); }

/* === Manual Input Layout === */
.manual-input-layout {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 20px;
    align-items: start;
}

.manual-detail-layout {
    max-width: 900px;
}

/* === Form Enhancements === */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.textarea-large {
    min-height: 160px;
    resize: vertical;
    line-height: 1.7;
}

.form-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-actions {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.btn-lg {
    padding: 12px 28px;
    font-size: 15px;
    font-weight: 600;
}

/* === Radio Group (Post Type) === */
.radio-group {
    display: flex;
    gap: 12px;
}

.radio-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
}

.radio-card:hover {
    border-color: var(--border-light);
}

.radio-card input[type="radio"] {
    display: none;
}

.radio-card:has(input:checked) {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.08);
}

.radio-label {
    font-size: 14px;
    font-weight: 600;
}

.radio-desc {
    font-size: 11px;
    color: var(--text-muted);
}

/* === Image Upload === */
.upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 28px;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.05);
}

.upload-icon { font-size: 32px; }
.upload-text { font-size: 13px; color: var(--text-secondary); }
.upload-hint { font-size: 11px; color: var(--text-muted); }

.image-preview-grid {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.image-preview-item {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-img {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === AI Prompt Box === */
.prompt-box {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
    font-size: 12px;
    line-height: 1.7;
    white-space: pre-wrap;
    color: var(--text-secondary);
    max-height: 400px;
    overflow-y: auto;
}

/* === Source Text Box === */
.source-text-box {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    white-space: pre-wrap;
    line-height: 1.7;
    max-height: 300px;
    overflow-y: auto;
}

/* === Detail Row === */
.detail-row {
    margin-bottom: 16px;
}

.detail-row > label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

/* === Recent Items === */
.recent-item {
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.recent-item:hover {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.03);
}

.recent-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.recent-page-name {
    font-size: 12px;
    font-weight: 600;
}

.recent-item-text {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 4px;
}

.recent-item-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
}

.empty-state-sm {
    text-align: center;
    padding: 24px;
    color: var(--text-muted);
}

/* === Pages Grid === */
.pages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.page-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition-fast);
}

.page-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.page-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: rgba(99, 102, 241, 0.05);
    border-bottom: 1px solid var(--border-color);
}

.page-card-header h3 {
    font-size: 14px;
    font-weight: 600;
}

.page-card-body {
    padding: 14px 16px;
}

.page-info-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid rgba(42, 45, 61, 0.3);
    font-size: 12px;
}

.page-info-row:last-child { border-bottom: none; }
.page-info-row .label { color: var(--text-muted); }
.page-info-row .value { font-weight: 500; }

/* === Page Badge === */
.page-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 99px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary-hover);
    font-weight: 500;
}

/* === Status additions === */
.status-draft {
    background: rgba(107, 114, 128, 0.2);
    color: #9ca3af;
}

.status-ready {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-info);
}

.status-approved {
    background: rgba(34, 197, 94, 0.15);
    color: var(--accent-success);
}

.status-posted {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
}

/* === AI Generate Controls === */
.ai-mode-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mode-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-right: 4px;
}

.generate-controls {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    padding: 16px 0;
}

.generate-status {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 13px;
    margin-top: 12px;
}

.status-processing-text {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: var(--accent-warning);
}

.status-success-text {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--accent-success);
}

.status-error-text {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--accent-danger);
}

.ai-meta {
    display: flex;
    gap: 16px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
    padding: 8px 12px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
}

/* === URL Scraper === */
.url-input-group {
    display: flex;
    gap: 8px;
}

.url-input-group .form-control {
    flex: 1;
}

.url-input-group .btn {
    white-space: nowrap;
    min-width: 120px;
}

.scrape-status {
    margin-top: 8px;
}

.top-comments-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.comment-item {
    background: var(--bg-primary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.5;
    border-left: 3px solid var(--accent-info);
}

.comment-num {
    color: var(--accent-info);
    font-weight: 600;
    margin-right: 6px;
}

/* === Flash Messages === */
.flash-message {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    animation: flashIn 0.3s ease;
}

@keyframes flashIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.flash-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--accent-danger);
}

.flash-success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--accent-success);
}

.flash-info {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--accent-info);
}

/* === Debug Console === */
.debug-layout {
    max-width: 900px;
}

.debug-row {
    display: flex;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(42, 45, 61, 0.3);
    font-size: 13px;
    align-items: center;
}

.debug-row .label {
    color: var(--text-muted);
    min-width: 120px;
}

.debug-row code {
    background: var(--bg-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    word-break: break-all;
}

.debug-log {
    background: #0a0c12;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
    font-size: 12px;
    max-height: 300px;
    overflow-y: auto;
    margin-top: 12px;
}

.log-entry {
    padding: 3px 0;
    border-bottom: 1px solid rgba(42, 45, 61, 0.2);
    line-height: 1.6;
}

.log-info { color: var(--accent-info); }
.log-success { color: var(--accent-success); }
.log-error { color: var(--accent-danger); }
.log-warn { color: var(--accent-warning); }

/* === Responsive === */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar:not(.collapsed) {
        transform: translateX(0);
    }
    .main-content { margin-left: 0; }
    .menu-toggle { display: block; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .news-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .engagement-grid { grid-template-columns: repeat(2, 1fr); }
    .filter-bar { flex-wrap: wrap; }
    .manual-input-layout { grid-template-columns: 1fr; }
    .radio-group { flex-direction: column; }
    .pages-grid { grid-template-columns: 1fr; }
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* === Comment Items === */
.comment-item {
    padding: 8px 12px;
    margin-bottom: 6px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent-primary);
    font-size: 13px;
    line-height: 1.5;
}

.comment-num {
    color: var(--accent-primary);
    font-weight: 700;
    margin-right: 4px;
}

.comment-likes {
    display: inline-block;
    background: rgba(99, 102, 241, 0.2);
    color: var(--accent-primary);
    padding: 1px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
}

/* === Gen Style Toggle === */
.gen-style-toggle {
    display: flex;
    gap: 8px;
}

.gen-style-option {
    cursor: pointer;
}

.gen-style-option input[type="radio"] {
    display: none;
}

.gen-style-btn {
    display: inline-block;
    padding: 8px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 13px;
    transition: all 0.2s ease;
}

.gen-style-btn small {
    color: var(--text-muted);
    font-size: 11px;
}

.gen-style-option input[type="radio"]:checked + .gen-style-btn {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.15);
    color: var(--text-primary);
}

.gen-style-option input[type="radio"]:checked + .gen-style-btn small {
    color: var(--accent-primary);
}

/* === AI Options Section (Manual Input) === */
.ai-options-section {
    margin-top: 16px;
    padding: 16px;
    background: rgba(99, 102, 241, 0.04);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: var(--radius-md);
}

.ai-options-header {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 12px;
}

.ai-options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

.form-group.compact {
    margin-bottom: 0;
}

.form-group.compact label {
    font-size: 11px;
    margin-bottom: 4px;
}

.form-group.compact .form-control {
    padding: 6px 10px;
    font-size: 12px;
}

/* === Radio Pill (inline) === */
.radio-group-inline {
    display: flex;
    gap: 6px;
}

.radio-pill {
    cursor: pointer;
}

.radio-pill input[type="radio"] {
    display: none;
}

.radio-pill span {
    display: inline-block;
    padding: 5px 10px;
    border: 1.5px solid var(--border-color);
    border-radius: 99px;
    font-size: 11px;
    background: var(--bg-input);
    color: var(--text-secondary);
    transition: all 0.15s;
    white-space: nowrap;
}

.radio-pill input:checked + span {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.12);
    color: var(--text-primary);
}

.radio-pill:hover span {
    border-color: var(--border-light);
}

/* === Pipeline Log (One-Click Progress) === */
.pipeline-log {
    margin-top: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.log-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.log-entry {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    margin-bottom: 4px;
    line-height: 1.5;
}

.log-icon {
    margin-right: 4px;
}

.log-working {
    background: rgba(245, 158, 11, 0.08);
    color: var(--accent-warning);
}

.log-success {
    background: rgba(34, 197, 94, 0.08);
    color: var(--accent-success);
}

.log-error {
    background: rgba(239, 68, 68, 0.08);
    color: var(--accent-danger);
}

.log-warning {
    background: rgba(245, 158, 11, 0.08);
    color: #d97706;
}

.log-info {
    background: rgba(99, 102, 241, 0.06);
    color: var(--text-secondary);
}

/* === Button Accent === */
.btn-accent {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    border: none;
}

.btn-accent:hover {
    background: linear-gradient(135deg, #d97706, #dc2626);
    color: white;
}

@media (max-width: 700px) {
    .ai-options-grid {
        grid-template-columns: 1fr;
    }
}

/* === Multi-Page Checkbox Selector === */
.page-select-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.page-select-actions .btn-sm {
    padding: 4px 12px;
    font-size: 0.75rem;
    border-radius: 6px;
}
.page-checkbox-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.page-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-card);
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}
.page-checkbox-item:hover {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.06);
}
.page-checkbox-item:has(input:checked) {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.12);
    box-shadow: 0 0 0 1px var(--accent-primary);
}
.page-checkbox-item input[type="checkbox"] {
    accent-color: var(--accent-primary);
    width: 16px;
    height: 16px;
}
.page-checkbox-name {
    font-size: 0.9rem;
    color: var(--text-primary);
}
.order-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    font-size: 11px;
    font-weight: 700;
    margin-left: auto;
    flex-shrink: 0;
}

/* === Batch Progress Page === */
.batch-progress-grid {
    display: grid;
    gap: 16px;
    margin-top: 16px;
}
.batch-page-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    transition: border-color 0.3s;
}
.batch-page-card.status-running {
    border-color: #f59e0b;
}
.batch-page-card.status-done {
    border-color: #10b981;
}
.batch-page-card.status-error {
    border-color: #ef4444;
}
.batch-page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.batch-page-name {
    font-weight: 600;
    font-size: 1.05rem;
}
.batch-page-status {
    font-size: 0.85rem;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 500;
}
.batch-page-status.waiting { background: rgba(107,114,128,0.15); color: #9ca3af; }
.batch-page-status.running { background: rgba(245,158,11,0.15); color: #f59e0b; }
.batch-page-status.done { background: rgba(16,185,129,0.15); color: #10b981; }
.batch-page-status.error { background: rgba(239,68,68,0.15); color: #ef4444; }
.batch-page-log {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* === Article Content (from news websites) === */
.article-url-bar {
    padding: 8px 12px;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    font-size: 0.85em;
}
.article-url-bar a {
    color: var(--accent-primary-hover);
    word-break: break-all;
}

.article-method-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 99px;
    font-size: 0.75em;
    font-weight: 600;
    background: rgba(34, 197, 94, 0.15);
    color: var(--accent-success);
    margin-left: 6px;
}

.article-content-preview {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    max-height: 300px;
    overflow-y: auto;
}

.article-title {
    font-size: 1.05em;
    font-weight: 700;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.article-body {
    font-size: 0.9em;
    line-height: 1.7;
    color: var(--text-secondary);
    white-space: pre-wrap;
}

.article-meta {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
    font-size: 0.8em;
    color: var(--text-muted);
    text-align: right;
}

/* === Auto Image Search Toggle === */
.auto-search-toggle {
    margin-top: 14px;
    padding: 12px 16px;
    background: rgba(245, 158, 11, 0.06);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--radius-md);
}

.toggle-switch-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.toggle-switch-label input[type="checkbox"] {
    display: none;
}

.toggle-switch-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--border-color);
    border-radius: 12px;
    transition: background 0.3s;
    flex-shrink: 0;
}

.toggle-switch-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
}

.toggle-switch-label input:checked + .toggle-switch-slider {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
}

.toggle-switch-label input:checked + .toggle-switch-slider::after {
    transform: translateX(20px);
}

.toggle-switch-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.toggle-hint {
    margin-top: 6px;
    margin-left: 56px;
    font-size: 11px;
    color: var(--text-muted);
}

/* === Google Image Search Debug Panel === */
.search-debug-section {
    margin-bottom: 16px;
}

.search-debug-section label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.keyword-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.keyword-tag {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 99px;
    font-size: 12px;
    color: var(--accent-primary-hover);
    font-weight: 500;
}

.debug-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.debug-image-item {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 2px solid transparent;
    background: var(--bg-primary);
}

.debug-image-item.kept {
    border-color: var(--accent-success);
}

.debug-image-item.rejected {
    border-color: rgba(239, 68, 68, 0.4);
    opacity: 0.6;
}

.debug-image-item img {
    width: 100%;
    height: 90px;
    object-fit: cover;
    display: block;
}

.debug-image-title {
    padding: 4px 6px;
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.debug-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.debug-badge.kept {
    background: rgba(34, 197, 94, 0.9);
    color: white;
}

.debug-badge.rejected {
    background: rgba(239, 68, 68, 0.8);
    color: white;
}

.debug-error {
    padding: 8px 12px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--accent-danger);
}

/* ============================================
   Mobile Responsive
   ============================================ */

/* Sidebar overlay backdrop */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}

@media (max-width: 768px) {
    /* Sidebar: hidden by default on mobile */
    .sidebar {
        transform: translateX(-100%) !important;
    }

    .sidebar.open {
        transform: translateX(0) !important;
    }

    /* Main content: full width */
    .main-content {
        margin-left: 0;
    }

    /* Show hamburger button */
    .menu-toggle {
        display: block;
    }

    /* Content area: less padding */
    .content-area {
        padding: 16px 12px;
    }

    .top-bar {
        padding: 0 12px;
    }

    /* Cards grid adjustments */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .sources-grid,
    .news-grid {
        grid-template-columns: 1fr;
    }

    /* Review queue horizontal scroll */
    .review-scroll {
        gap: 12px;
    }

    .review-card {
        min-width: 240px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .page-title {
        font-size: 14px;
    }

    .content-area {
        padding: 12px 8px;
    }
}
