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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Header ──────────────────────────────────────────── */
header {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

header h1 { font-size: 18px; font-weight: 700; }
header h1 a { color: var(--gray-900); }
header h1 a:hover { text-decoration: none; }

/* ─── Main ────────────────────────────────────────────── */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    min-height: calc(100vh - 120px);
}

.container { width: 100%; padding: 0 24px; box-sizing: border-box; max-width: 1600px; margin: 0 auto; }

/* ─── Page Header ─────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.page-header h2 { font-size: 22px; font-weight: 700; white-space: nowrap; }

.date-picker {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.date-picker input[type="date"] {
    padding: 6px 10px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}

.date-nav {
    display: flex;
    gap: 4px;
}

.date-link {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--gray-500);
    background: var(--gray-100);
    text-decoration: none;
}

.date-link:hover { background: var(--gray-200); text-decoration: none; }
.date-active { background: var(--primary); color: white; }
.date-active:hover { background: var(--primary-dark); }

.badge {
    background: var(--primary);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

/* ─── Buttons ─────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-300); }
.btn-lg { padding: 12px 24px; font-size: 16px; }

/* ─── Filter Bar ─────────────────────────────────────── */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    padding: 14px 16px;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    align-items: center;
}

.filter-bar select {
    padding: 7px 28px 7px 10px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 13px;
    color: var(--gray-700);
    background: var(--gray-50) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7280'/%3E%3C/svg%3E") no-repeat right 10px center;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor: pointer;
    min-width: 120px;
}

.filter-bar select:hover {
    border-color: var(--gray-300);
    background-color: white;
}

.filter-bar select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.filter-bar .btn-secondary {
    padding: 7px 14px;
    font-size: 13px;
}

/* ─── Country Search Filter ──────────────────────────── */
.country-filter-wrap {
    position: relative;
    min-width: 120px;
}

.country-filter-wrap input {
    padding: 7px 10px;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    font-size: 13px;
    color: var(--gray-700);
    background: var(--gray-50);
    width: 100%;
    box-sizing: border-box;
}

.country-filter-wrap input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.country-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    box-shadow: var(--shadow);
    z-index: 100;
    margin-top: 2px;
}

.country-item {
    padding: 6px 10px;
    font-size: 13px;
    cursor: pointer;
    color: var(--gray-700);
}

.country-item:hover {
    background: var(--gray-100);
}

/* ─── Date Nav Buttons ───────────────────────────────── */
.btn-nav {
    padding: 6px 10px;
    background: var(--gray-200);
    color: var(--gray-700);
    border: none;
    border-radius: 6px;
    font-size: 15px;
    cursor: pointer;
    font-weight: 600;
    line-height: 1;
    transition: all 0.15s;
}

.btn-nav:hover {
    background: var(--gray-300);
}

/* ─── Table ───────────────────────────────────────────── */
.article-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.article-table thead {
    background: var(--gray-100);
}

.article-table th {
    padding: 10px 12px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.article-table td {
    padding: 10px 12px;
    border-top: 1px solid var(--gray-100);
    font-size: 14px;
}

.article-row { cursor: pointer; transition: background 0.1s; }
.article-row:hover { background: var(--gray-50); }

.title-line, .title-sub {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 500px;
}

.title-sub {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 2px;
}

.col-copy { width: 50px; text-align: center; }
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: none;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    cursor: pointer;
    color: var(--gray-500);
    transition: all 0.15s;
}
.btn-icon:hover { background: var(--gray-100); color: var(--gray-700); border-color: var(--gray-300); }
.btn-icon.copied { background: #dcfce7; border-color: #86efac; color: #166534; }

.btn-download {
    display: inline-flex;
    align-items: center;
    margin-left: 8px;
    padding: 7px 16px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-download:hover { background: var(--gray-50); border-color: var(--gray-300); }

.btn-outline {
    display: inline-flex;
    align-items: center;
    padding: 5px 14px;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.15s;
}
.btn-outline:hover { background: var(--gray-50); border-color: var(--primary); color: var(--primary); }
.btn-copied { background: #dcfce7 !important; border-color: #86efac !important; color: #166534 !important; }

.col-rank { width: 40px; text-align: center; color: var(--gray-500); }
.col-score { width: 60px; text-align: center; }
.col-category { width: 90px; }
.col-type { width: 100px; }
.col-source { width: 120px; }
.col-country { width: 80px; }
.col-date { width: 100px; color: var(--gray-500); }

/* ─── Score Badge ─────────────────────────────────────── */
.score-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
}

.score-high { background: #dcfce7; color: #166534; }
.score-mid { background: #fef3c7; color: #92400e; }
.score-low { background: #fee2e2; color: #991b1b; }
.score-fail { background: var(--gray-200); color: var(--gray-500); font-size: 11px; cursor: help; }

/* ─── Tags ────────────────────────────────────────────── */
.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.tag-category { background: #dbeafe; color: #1e40af; }
.tag-type { background: #f3e8ff; color: #6b21a8; }

/* ─── Article Detail ──────────────────────────────────── */
.back-link {
    display: inline-block;
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--gray-500);
}

.article-detail {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

.detail-header { margin-bottom: 24px; }
.detail-header h2 { font-size: 20px; margin-bottom: 12px; }

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

.meta-item {
    font-size: 13px;
    color: var(--gray-500);
}

.meta-link {
    font-size: 13px;
    color: var(--primary);
}

/* ─── Score Section ───────────────────────────────────── */
.score-section {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 24px;
}

.score-total {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 16px;
}

.score-number {
    font-size: 48px;
    font-weight: 800;
    line-height: 1;
    padding: 4px 12px;
    border-radius: var(--radius);
}

.score-label { font-size: 20px; color: var(--gray-500); }

.score-breakdown { display: flex; flex-direction: column; gap: 8px; }

.score-axis {
    display: flex;
    align-items: center;
    gap: 12px;
}

.axis-name {
    width: 140px;
    font-size: 13px;
    font-weight: 500;
    text-align: right;
    flex-shrink: 0;
}

.axis-bar {
    flex: 1;
    height: 20px;
    background: var(--gray-200);
    border-radius: 10px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 10px;
    transition: width 0.3s;
}

.bar-negative { background: var(--danger); }
.bar-bonus { background: var(--success); }

.axis-score {
    width: 40px;
    font-size: 14px;
    font-weight: 600;
    text-align: right;
}

.eval-reason {
    margin-top: 12px;
    font-size: 14px;
    color: var(--gray-700);
    font-style: italic;
}

/* ─── Content Section ─────────────────────────────────── */
.content-section { margin-bottom: 24px; }
.content-section h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: var(--gray-700);
}

.article-content {
    font-size: 14px;
    line-height: 1.8;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 400px;
    overflow-y: auto;
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--radius);
}

/* ─── Action Section ──────────────────────────────────── */
.action-section {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-200);
}

.status-text { font-size: 14px; color: var(--gray-500); }
.status-success { color: var(--success); font-weight: 600; }
.status-error { color: var(--danger); }

/* ─── Result / Form ───────────────────────────────────── */
.result-page {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

.result-page h2 {
    font-size: 20px;
    margin-bottom: 24px;
}

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

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

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    line-height: 1.6;
}

.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* ─── Review Checklist ────────────────────────────────── */
.review-checklist {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-top: 20px;
}

.review-checklist h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 12px;
}

.checklist-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
    cursor: pointer;
}

.checklist-item input[type="checkbox"] { margin-top: 2px; }

.checklist-warn { color: var(--danger); font-weight: 600; }

/* ─── Alerts ──────────────────────────────────────────── */
.alert {
    padding: 16px;
    border-radius: var(--radius);
    font-size: 14px;
}

.alert-info { background: #dbeafe; color: #1e40af; }
.alert-warning { background: #fef3c7; color: #92400e; }

/* ─── Loading Overlay ─────────────────────────────────── */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

/* ─── Footer ──────────────────────────────────────────── */
footer {
    text-align: center;
    padding: 20px;
    font-size: 13px;
    color: var(--gray-500);
    border-top: 1px solid var(--gray-200);
}
