/* ============================================================
   Vecdis Radar — Web UI Styles
   Color palette from email template: navy gradient, #1a73e8
   ============================================================ */

:root {
    --primary: #1a73e8;
    --primary-dark: #1557b0;
    --navy: #1a237e;
    --navy-light: #0d47a1;
    --bg: #f5f7fa;
    --bg-card: #ffffff;
    --text: #333333;
    --text-light: #666666;
    --text-muted: #999999;
    --border: #e2e8f0;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --info: #3b82f6;
    --info-bg: #eff6ff;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* ---- Navbar ---- */
.navbar {
    background: linear-gradient(135deg, var(--navy), var(--navy-light));
    color: white;
    padding: 0 24px;
    display: flex;
    align-items: center;
    height: 56px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 32px;
}

.nav-logo {
    background: rgba(255,255,255,0.2);
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 1px;
}

.nav-title {
    font-weight: 600;
    font-size: 16px;
    white-space: nowrap;
}

.nav-tabs {
    display: flex;
    gap: 4px;
    height: 100%;
    align-items: stretch;
}

.nav-tab {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    padding: 0 16px;
    display: flex;
    align-items: center;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}

.nav-tab:hover {
    color: white;
    background: rgba(255,255,255,0.08);
}

.nav-tab.active {
    color: white;
    border-bottom-color: white;
    background: rgba(255,255,255,0.1);
}

.badge {
    background: var(--danger);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    margin-left: 6px;
}

/* ---- Container ---- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

/* ---- Flash Messages ---- */
.flash-messages {
    margin-bottom: 20px;
}

.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    animation: slideDown 0.3s ease;
}

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

.flash-success { background: var(--success-bg); color: #065f46; border-left: 4px solid var(--success); }
.flash-error   { background: var(--danger-bg);  color: #991b1b; border-left: 4px solid var(--danger); }
.flash-warning { background: var(--warning-bg); color: #92400e; border-left: 4px solid var(--warning); }
.flash-info    { background: var(--info-bg);    color: #1e40af; border-left: 4px solid var(--info); }

.flash-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.5;
    padding: 0 4px;
}

.flash-close:hover { opacity: 1; }

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

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

.card-header h2 {
    font-size: 16px;
    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-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--navy);
}

.stat-value.accent { color: var(--primary); }
.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-value.danger { color: var(--danger); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover { background: #059669; }

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

.btn-warning {
    background: var(--warning);
    color: white;
}
.btn-warning:hover { background: #d97706; }

.btn-outline {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-outline:hover {
    background: var(--bg);
    border-color: var(--text-muted);
}

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

.btn-lg {
    padding: 12px 24px;
    font-size: 16px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

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

th, td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
    background: var(--bg);
}

td {
    font-size: 14px;
}

tr:hover td {
    background: #f8fafc;
}

/* ---- Status badges ---- */
.status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-published  { background: var(--success-bg); color: #065f46; }
.status-pending_review { background: var(--warning-bg); color: #92400e; }
.status-failed     { background: var(--danger-bg);  color: #991b1b; }
.status-queued     { background: var(--info-bg);    color: #1e40af; }
.status-expired    { background: #f3f4f6; color: #6b7280; }
.status-reviewed   { background: #f3f4f6; color: #6b7280; }
.status-running    { background: var(--info-bg);    color: #1e40af; }
.status-completed  { background: var(--success-bg); color: #065f46; }
.status-sent       { background: var(--info-bg);    color: #1e40af; }

/* ---- Forms ---- */
.form-group {
    margin-bottom: 16px;
}

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

.form-group .hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,115,232,0.1);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

select.form-control {
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

/* ---- Page header ---- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--navy);
}

.page-header-actions {
    display: flex;
    gap: 8px;
}

/* ---- Digest line tabs ---- */
.digest-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}

.digest-tab {
    padding: 10px 18px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -2px;
}

.digest-tab:hover {
    color: var(--primary);
    background: rgba(26,115,232,0.04);
}

.digest-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.digest-tab-count {
    display: inline-block;
    background: var(--primary);
    color: white;
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 10px;
    margin-left: 6px;
    font-weight: 700;
}

.digest-tab.active .digest-tab-count {
    background: var(--primary);
}
.digest-tab-empty {
    opacity: 0.45;
}

/* ---- Digest collapse ---- */
.collapse-icon {
    display: inline-block;
    transition: transform 0.2s;
    font-size: 12px;
}

.digest-group-body {
    /* Animatable collapse via max-height if needed, but display toggle is simpler */
}

/* ---- Digest article cards ---- */
.digest-group {
    margin-bottom: 32px;
}

.digest-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--navy), var(--navy-light));
    color: white;
    border-radius: var(--radius) var(--radius) 0 0;
    font-weight: 600;
}

.digest-group-header .line-label {
    font-size: 16px;
}

.digest-group-header .batch-info {
    font-size: 12px;
    opacity: 0.8;
}

.article-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-top: none;
    padding: 16px 20px;
    display: flex;
    gap: 16px;
    transition: background 0.15s;
}

.article-card:last-child {
    border-radius: 0 0 var(--radius) var(--radius);
}

.article-card:hover {
    background: #f8fafc;
}

.article-check {
    display: flex;
    align-items: flex-start;
    padding-top: 4px;
}

.article-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}

.article-number {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    min-width: 36px;
    line-height: 1;
    padding-top: 2px;
}

.article-content {
    flex: 1;
    min-width: 0;
}

.article-title {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 4px;
    line-height: 1.35;
}

.article-title a {
    color: inherit;
    text-decoration: none;
}

.article-title a:hover {
    color: var(--primary);
}

.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.meta-tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.meta-category { background: #e3f2fd; color: #1565c0; }
.meta-highlight { background: #f3e5f5; color: #7b1fa2; }
.meta-player   { background: #fff3e0; color: #e65100; }
.meta-country  { background: #e8f5e9; color: #2e7d32; }

.article-summary {
    font-size: 13px;
    color: var(--text-light);
    line-height: 1.5;
    margin-bottom: 6px;
}

.article-image {
    width: 120px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.article-link {
    font-size: 12px;
    color: var(--primary);
    text-decoration: none;
}

.article-link:hover {
    text-decoration: underline;
}

/* ---- Inline edit ---- */
.editable-field {
    position: relative;
}

.btn-edit {
    background: transparent;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    padding: 1px 6px;
    color: var(--text-muted);
    margin-left: 6px;
    transition: all 0.2s;
    vertical-align: middle;
    line-height: 1;
}

.btn-edit:hover {
    background: #e3f2fd;
    border-color: var(--primary);
    color: var(--primary);
}

.edit-title-input {
    font-size: 15px;
    font-weight: 600;
    padding: 4px 8px;
    width: 100%;
}

.edit-summary-input {
    font-size: 13px;
    line-height: 1.5;
    width: 100%;
    resize: vertical;
    min-height: 60px;
}

/* ---- Digest action bar ---- */
.digest-actions {
    position: sticky;
    bottom: 0;
    background: var(--bg-card);
    border-top: 2px solid var(--border);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
    z-index: 50;
    border-radius: var(--radius) var(--radius) 0 0;
    margin-top: 24px;
}

.digest-actions .selection-info {
    font-size: 14px;
    color: var(--text-light);
}

.digest-actions .selection-count {
    font-weight: 700;
    color: var(--primary);
}

.platform-checks {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 13px;
}

.platform-checks label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-weight: 500;
}

.platform-checks input[type="checkbox"] {
    accent-color: var(--primary);
}

/* ---- Empty state ---- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text-light);
}

.empty-state p {
    font-size: 14px;
}

/* ---- Loading spinner ---- */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ---- Utility ---- */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Filter pipeline diagram ---- */
.filter-pipeline {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
}

.pipeline-step {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    flex: 1;
    min-width: 180px;
    padding: 16px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.pipeline-step .step-number {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.pipeline-step .step-content {
    min-width: 0;
}

.pipeline-step .step-content strong {
    display: block;
    margin-bottom: 4px;
    font-size: 14px;
}

.pipeline-arrow {
    display: flex;
    align-items: center;
    font-size: 24px;
    color: var(--primary);
    padding-top: 20px;
    font-weight: 700;
}

/* ---- Filter editor textarea ---- */
.filter-textarea {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre;
    tab-size: 4;
    resize: vertical;
}

.filter-help {
    margin-top: 8px;
}

.filter-help summary {
    cursor: pointer;
    color: var(--primary);
    font-weight: 500;
}

.filter-help summary:hover {
    text-decoration: underline;
}

.filter-help code {
    background: #f0f0f0;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
}

/* ---- Article action row ---- */
.article-actions-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.btn-xs {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
}

.btn-discard {
    background: transparent;
    border: 1px solid #e0e0e0;
    color: #b71c1c;
    cursor: pointer;
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-discard:hover {
    background: #ffebee;
    border-color: #e57373;
}

/* ---- Publish progress banner ---- */
.publish-progress {
    margin-bottom: 24px;
}

.publish-progress-inner {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.publish-progress-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 15px;
}

.publish-progress-header .spinner {
    border-color: rgba(26,115,232,0.2);
    border-top-color: var(--primary);
    width: 20px;
    height: 20px;
}

.publish-progress-bar-wrap {
    height: 8px;
    background: #e3e8ef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.publish-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), #42a5f5);
    border-radius: 4px;
    transition: width 0.4s ease;
}

.publish-progress-stats {
    font-size: 13px;
    color: var(--text-light);
}

.publish-progress-results {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.publish-results-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 13px;
}

.publish-results-list li {
    padding: 4px 0;
    line-height: 1.5;
}

.publish-results-list .result-ok {
    color: #2e7d32;
}

.publish-results-list .result-ok a {
    color: var(--primary);
    margin-left: 4px;
    font-size: 12px;
}

.publish-results-list .result-fail {
    color: #c62828;
}

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-box {
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid #e2e8f0;
}
.modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
    color: #1e293b;
}
.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #94a3b8;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.modal-close:hover { color: #1e293b; }
.modal-body {
    padding: 20px 24px;
}
.modal-body .form-group {
    margin-bottom: 16px;
}
.modal-body label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    color: #475569;
}
.modal-body .form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.95rem;
    box-sizing: border-box;
}
.modal-body .form-control:focus {
    outline: none;
    border-color: #1a73e8;
    box-shadow: 0 0 0 3px rgba(26,115,232,0.15);
}
.manual-lines-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
}
.manual-line-option {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 4px 0;
}
.manual-line-option input[type="checkbox"] {
    accent-color: #1a73e8;
}
.manual-status {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #f0f7ff;
    border-radius: 8px;
    margin-top: 12px;
    color: #1a73e8;
    font-size: 0.9rem;
}
.manual-result {
    margin-top: 12px;
}
.manual-result-ok {
    padding: 12px 16px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    color: #166534;
    font-size: 0.9rem;
}
.manual-result-error {
    padding: 12px 16px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    color: #991b1b;
    font-size: 0.9rem;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid #e2e8f0;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        height: auto;
        padding: 12px;
    }
    .nav-tabs {
        flex-wrap: wrap;
        justify-content: center;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .article-image {
        display: none;
    }
    .digest-actions {
        flex-direction: column;
        gap: 12px;
    }
}
