/* ========================
   VARIABLES & RESET
   ======================== */

:root {
    --primary-color: #4f46e5;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #0ea5e9;
    --dark-color: #1f2937;
    --light-color: #f3f4f6;
    --border-radius: 0.5rem;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
    background-color: var(--light-color);
    color: var(--dark-color);
}

/* ========================
   CARDS & CONTAINERS
   ======================== */

.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 20px -5px rgba(0, 0, 0, 0.1);
}

.card-header {
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    font-weight: 600;
    border: none;
}

.bg-primary {
    background-color: var(--primary-color) !important;
}

.bg-success {
    background-color: var(--success-color) !important;
}

.bg-danger {
    background-color: var(--danger-color) !important;
}

.bg-warning {
    background-color: var(--warning-color) !important;
}

.bg-info {
    background-color: var(--info-color) !important;
}

/* ========================
   BUTTONS
   ======================== */

.btn {
    border-radius: var(--border-radius);
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.15);
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #4338ca;
    border-color: #4338ca;
}

.btn-sm {
    font-size: 0.85rem;
    padding: 0.375rem 0.75rem;
}

.btn-loading {
    pointer-events: none;
    opacity: 0.7;
}

/* ========================
   FORMS
   ======================== */

.form-control,
.form-select {
    border: 1px solid #e5e7eb;
    border-radius: var(--border-radius);
    padding: 0.625rem 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--dark-color);
}

/* ========================
   TABS
   ======================== */

.tabs-carousel {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

.tabs-scroll-container {
    overflow-x: auto;
    overflow-y: hidden;
    flex: 1 1 auto;
    scrollbar-width: none; /* Firefox */
}

.tabs-scroll-container::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.tabs-scroll-container .nav-tabs {
    flex-wrap: nowrap;
    white-space: nowrap;
}

.tabs-scroll-btn {
    border: 1px solid #e5e7eb;
    background: #ffffff;
    color: #6b7280;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    transition: all 0.2s;
}

.tabs-scroll-btn:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.tabs-scroll-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.nav-tabs {
    border-bottom: 2px solid #e5e7eb;
}

.nav-tabs .nav-link {
    color: #6b7280;
    border: none;
    border-bottom: 3px solid transparent;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-tabs .nav-link:hover {
    color: var(--primary-color);
    border-bottom-color: #e5e7eb;
}

.nav-tabs .nav-link.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background-color: transparent;
}

/* ========================
   LIST ITEMS
   ======================== */

.list-group-item {
    border: 1px solid #e5e7eb;
    border-radius: 0;
    transition: all 0.2s;
}

.list-group-item:first-child {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.list-group-item:last-child {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.list-group-item:hover {
    background-color: #f9fafb;
    cursor: pointer;
}

.list-group-item.active {
    background-color: #f0f4ff;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* ========================
   STATUS BADGES & INDICATORS
   ======================== */

.status-badge {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-draft {
    background-color: #fef3c7;
    color: #92400e;
}

.status-evaluated {
    background-color: #dbeafe;
    color: #0c2d6b;
}

.status-published {
    background-color: #dcfce7;
    color: #166534;
}

.status-failed {
    background-color: #fee2e2;
    color: #7f1d1d;
}

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

.status-indicator.draft {
    background-color: #fbbf24;
}

.status-indicator.evaluated {
    background-color: #3b82f6;
}

.status-indicator.published {
    background-color: #10b981;
}

.status-indicator.failed {
    background-color: #ef4444;
}

/* ========================
   TOASTS
   ======================== */

.toast {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
}

.toast.success {
    background-color: #dcfce7;
    color: #166534;
}

.toast.error {
    background-color: #fee2e2;
    color: #7f1d1d;
}

.toast.info {
    background-color: #dbeafe;
    color: #0c2d6b;
}

.toast-close {
    font-size: 1.25rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}

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

/* ========================
   SPINNERS
   ======================== */

.spinner-border {
    width: 2rem;
    height: 2rem;
    border-width: 0.25rem;
}

.spinner-small {
    width: 1.5rem;
    height: 1.5rem;
    border-width: 0.2rem;
    display: inline-block;
    margin-left: 0.5rem;
}

/* ========================
   DETAIL PANEL
   ======================== */

.detail-section {
    margin-bottom: 1.5rem;
}

.detail-section h6 {
    font-weight: 600;
    color: var(--dark-color);
    margin-bottom: 0.75rem;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #e5e7eb;
}

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

.score-value {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary-color);
}

.score-threshold {
    font-size: 0.85rem;
    color: #6b7280;
}

.score-passed {
    color: var(--success-color);
}

.score-failed {
    color: var(--danger-color);
}

/* ========================
   NAVBAR
   ======================== */

.navbar {
    box-shadow: var(--shadow);
    border-bottom: 2px solid #e5e7eb;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
}

/* ========================
   RESPONSIVE DESIGN
   ======================== */

@media (max-width: 768px) {
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .card {
        margin-bottom: 1.5rem;
    }

    .toast {
        min-width: 100%;
        max-width: 400px;
    }

    .nav-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .btn-group-vertical {
        width: 100%;
    }

    .detail-section {
        margin-bottom: 1rem;
    }
}

@media (max-width: 576px) {
    :root {
        --border-radius: 0.375rem;
    }

    .card {
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    h6 {
        font-size: 1rem;
    }

    .status-badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }

    .toast-container {
        width: 100%;
        padding: 0.5rem !important;
    }

    .toast {
        min-width: 100%;
        width: calc(100% - 1rem);
    }
}

/* ========================
   UTILITIES
   ======================== */

.text-muted {
    color: #6b7280 !important;
}

.text-success {
    color: var(--success-color) !important;
}

.text-danger {
    color: var(--danger-color) !important;
}

.text-primary {
    color: var(--primary-color) !important;
}

.d-none {
    display: none !important;
}

.overflow-auto {
    overflow: auto;
}

.cursor-pointer {
    cursor: pointer;
}

.opacity-75 {
    opacity: 0.75;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

hr {
    border-color: #e5e7eb;
}

/* ========================
   ANIMATIONS
   ======================== */

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

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

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

.spin {
    animation: spin 1s linear infinite;
}

/* ========================
   DRAG AND DROP
   ======================== */

.criterion-badge {
    display: inline-block;
    padding: 8px 12px;
    margin: 4px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 6px;
    cursor: move;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    user-select: none;
}

.criterion-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.criterion-badge.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.criterion-badge .remove-btn {
    margin-left: 8px;
    cursor: pointer;
    opacity: 0.7;
    font-weight: bold;
}

.criterion-badge .remove-btn:hover {
    opacity: 1;
}

.criteria-dropzone {
    min-height: 100px;
    padding: 12px;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    transition: all 0.2s;
}

.criteria-dropzone.drag-over {
    background: #e7f5ff;
    border-color: #4dabf7;
    border-style: solid;
}

.group-card {
    margin-bottom: 16px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: white;
    transition: all 0.2s;
}

.group-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.group-header {
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.group-body {
    padding: 12px;
    min-height: 80px;
}

.group-delete-btn {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.group-delete-btn:hover {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.5);
}

.min-vh-25 {
    min-height: 25vh;
}

.groups-container {
    max-height: 70vh;
    overflow-y: auto;
}

.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: #6c757d;
}

/* ========================
   NEWS PAGE ENHANCEMENTS
   ======================== */

.stat-card {
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    background: white;
    border: 2px solid #e9ecef;
    transition: all 0.2s;
    cursor: pointer;
    user-select: none;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    border-color: #0d6efd;
}

.stat-card.stat-active {
    border-color: #0d6efd;
    background: #e7f1ff;
    box-shadow: 0 4px 12px rgba(13,110,253,0.3);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    margin-top: 4px;
    opacity: 0.8;
}

.stat-collected {
    border-color: #0dcaf0;
    background: linear-gradient(135deg, #e0f7fa 0%, #f0fdff 100%);
}

.stat-collected .stat-value {
    color: #0891b2;
}

.stat-excluded {
    border-color: #dc3545;
    background: linear-gradient(135deg, #ffe0e0 0%, #fff5f5 100%);
}

.stat-excluded .stat-value {
    color: #dc3545;
}

.stat-matched {
    border-color: #0d6efd;
    background: linear-gradient(135deg, #e7f1ff 0%, #f0f7ff 100%);
}

.stat-matched .stat-value {
    color: #0d6efd;
}

.stat-evaluated {
    border-color: #ffc107;
    background: linear-gradient(135deg, #fff4e0 0%, #fffbf0 100%);
}

.stat-evaluated .stat-value {
    color: #d97706;
}

.stat-duplicate {
    border-color: #dc2626;
    background: linear-gradient(135deg, #fee2e2 0%, #fef2f2 100%);
}

.stat-duplicate .stat-value {
    color: #dc2626;
}

.stat-rewritten {
    border-color: #9333ea;
    background: linear-gradient(135deg, #f3e8ff 0%, #faf5ff 100%);
}

.stat-rewritten .stat-value {
    color: #9333ea;
}

.stat-queued {
    border-color: #f59e0b;
    background: linear-gradient(135deg, #ffedd5 0%, #fff7ed 100%);
}

.stat-queued .stat-value {
    color: #ea580c;
}

.stat-published {
    border-color: #10b981;
    background: linear-gradient(135deg, #d1fae5 0%, #ecfdf5 100%);
}

.stat-published .stat-value {
    color: #059669;
}

.news-list-container {
    max-height: 70vh;
    overflow-y: auto;
}

.news-item {
    padding: 16px;
    border-bottom: 1px solid #e9ecef;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.news-item:hover {
    background: #f8f9fa;
}

.news-item.active {
    background: #e7f1ff;
    border-left: 4px solid #0d6efd;
}

.news-item-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 8px;
}

.news-item-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: #212529;
    margin: 0;
    flex: 1;
}

.news-item-actions {
    display: flex;
    gap: 4px;
    margin-left: 8px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.news-item:hover .news-item-actions {
    opacity: 1;
}

.news-item-actions .btn {
    padding: 2px 6px;
    font-size: 0.75rem;
}

.news-item-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 8px;
}

.news-status-badge {
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.news-status-draft {
    background: #e9ecef;
    color: #495057;
}

.news-status-collected {
    background: #cff4fc;
    color: #055160;
}
.news-status-excluded {
    background: #e2e3e5;
    color: #41464b;
    text-decoration: line-through;
}
.news-status-keyword_matched {
    background: #cfe2ff;
    color: #052c65;
}

.news-status-evaluated {
    background: #fff3cd;
    color: #664d03;
}

.news-status-duplicate {
    background: #f8d7da;
    color: #721c24;
    font-weight: 600;
}

.news-status-rewritten {
    background: #f3e8ff;
    color: #6b21a8;
}

.news-status-queued {
    background: #fed7aa;
    color: #7c2d12;
}

.news-status-published {
    background: #d1e7dd;
    color: #0a3622;
}

.news-status-rejected {
    background: #f8d7da;
    color: #721c24;
    text-decoration: line-through;
}

.news-item-source {
    font-size: 0.75rem;
    color: #6c757d;
    display: flex;
    align-items: center;
    gap: 4px;
}

.news-item-date {
    font-size: 0.7rem;
    color: #adb5bd;
}

.news-item-preview {
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.news-detail-section {
    margin-bottom: 20px;
}

.news-detail-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 600;
    color: #6c757d;
    margin-bottom: 8px;
}

.news-detail-content {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    line-height: 1.6;
    max-height: 300px;
    overflow-y: auto;
}

.news-detail-url {
    word-break: break-all;
    color: #0d6efd;
    text-decoration: none;
}

.news-detail-url:hover {
    text-decoration: underline;
}

.score-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-right: 8px;
    margin-bottom: 4px;
}

.score-high {
    background: #d1e7dd;
    color: #0a3622;
}

.score-medium {
    background: #fff3cd;
    color: #664d03;
}

.score-low {
    background: #f8d7da;
    color: #58151c;
}

.criteria-failed {
    background: #f8d7da;
    color: #58151c;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    margin-top: 8px;
}

.sticky-top {
    position: sticky;
}

/* ========================
   KEYWORD HIGHLIGHTING
   ======================== */

.keyword-highlight {
    background-color: #fef08a;
    color: #854d0e;
    font-weight: 600;
    padding: 2px 4px;
    border-radius: 3px;
    border: 1px solid #fde047;
}

.stopword-highlight {
    background-color: #fecaca;
    color: #991b1b;
    font-weight: 700;
    padding: 2px 4px;
    border-radius: 3px;
    border: 1px solid #f87171;
}

