/* Base styles */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.6;
    color: #333;
    margin: 0;
    padding: 0;
    background: #f5f5f5;
    transition: background 0.3s ease, color 0.3s ease;
}

/* Top bar */
.top-bar {
    background: #2c3e50;
    color: white;
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

body {
    padding-top: 2.75rem;
}

.unread-count {
    font-size: 1.25rem;
    font-weight: bold;
    color: white;
    margin-left: 0;
}

.top-bar .brand {
    font-size: 1.25rem;
    font-weight: bold;
    color: white;
    text-decoration: none;
}

/* Hamburger button */
.hamburger-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    color: white;
}

.hamburger-btn:hover {
    background: #34495e;
    border-radius: 4px;
}

/* Nav overlay */
.nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
}

.nav-overlay.open {
    display: block;
}

/* Nav drawer */
.nav-drawer {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100%;
    background: white;
    box-shadow: 2px 0 8px rgba(0,0,0,0.2);
    z-index: 201;
    transition: left 0.3s ease;
    overflow-y: auto;
}

.nav-drawer.open {
    left: 0;
}

.nav-drawer-header {
    background: #2c3e50;
    color: white;
    padding: 1rem;
    font-size: 1.25rem;
    font-weight: bold;
}

.nav-drawer a {
    display: block;
    padding: 0.75rem 1rem;
    color: #333;
    text-decoration: none;
    border-bottom: 1px solid #eee;
}

.nav-drawer a:hover {
    background: #f5f5f5;
}

.nav-drawer .nav-user {
    padding: 0.75rem 1rem;
    color: #666;
    font-size: 0.9rem;
    border-bottom: 1px solid #eee;
}

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

/* Footer */
.footer {
    text-align: center;
    padding: 1rem;
    color: #666;
    font-size: 0.875rem;
    border-top: 1px solid #ddd;
    margin-top: 2rem;
}

.footer a {
    color: #3498db;
}

/* Typography */
h1 {
    margin-top: 0;
    color: #2c3e50;
}

h2 {
    color: #34495e;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.5rem;
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.25rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}

.stat-card h3 {
    margin: 0 0 0.5rem 0;
    font-size: 0.875rem;
    color: #666;
    text-transform: uppercase;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: #2c3e50;
}

/* Two column layout */
.two-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 2rem;
}

.column {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

#items-table .data-table {
    table-layout: fixed;
}

.data-table th,
.data-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #eee;
    overflow-wrap: break-word; /* Allows long words to break */
}

/* Items table-specific column widths (don't apply to other data-tables) */
#items-table .data-table td:nth-child(2) { /* Title/Topics column */
    white-space: nowrap;
    overflow: hidden;
}

#items-table .data-table th:nth-child(1),
#items-table .data-table td:nth-child(1) { /* Score column */
    width: 80px;
}

#items-table .data-table th:nth-child(3),
#items-table .data-table td:nth-child(3) { /* Status column */
    width: 100px;
}

#items-table .data-table th:nth-child(4),
#items-table .data-table td:nth-child(4) { /* Published column */
    width: 120px;
}

#items-table .data-table th:nth-child(5),
#items-table .data-table td:nth-child(5) { /* Actions column */
    width: 80px;
}

.data-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
}

.data-table tr:hover {
    background: #f8f9fa;
}

.data-table a {
    color: #3498db;
    text-decoration: none;
}

.data-table a:hover {
    text-decoration: underline;
}

/* Score styling */
.score {
    font-family: monospace;
    font-weight: bold;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: #ecf0f1;
}

.score.hot {
    background: #e74c3c;
    color: white;
}

.score.cold {
    background: #3498db;
    color: white;
}

/* Status badges */
.status-pending { color: #f39c12; }
.status-scoring { color: #3498db; }
.status-scored { color: #27ae60; }
.status-failed { color: #e74c3c; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    text-decoration: none;
    background: #ecf0f1;
    color: #2c3e50;
}

.btn:hover {
    background: #bdc3c7;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
    color: #2c3e50;
}

.form-group input:not([type="checkbox"]),
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.form-group input.wide {
    min-width: 400px;
}

.edit-input {
    padding: 0.375rem 0.5rem;
    border: 1px solid #3498db;
    border-radius: 4px;
    font-size: 0.9rem;
}

.edit-input.wide {
    width: 100%;
    min-width: 300px;
}

.form-inline {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.help-text {
    font-size: 0.875rem;
    color: #666;
    margin-top: 0.25rem;
}

.validation-errors {
    display: none;
    margin-top: 0.25rem;
}

.validation-error {
    font-size: 0.875rem;
    color: #c0392b;
    padding: 2px 0;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

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

/* Filters */
.filters {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.filters form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.filters select,
.filters input {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Sections */
.section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.settings-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.settings-section h2 {
    margin-top: 0;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

/* Info section */
.info-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Utilities */
.text-success { color: #27ae60; }
.text-danger { color: #e74c3c; }
.text-warning { color: #f39c12; }
.nowrap { white-space: nowrap; }

.empty-state {
    color: #666;
    font-style: italic;
    padding: 2rem;
    text-align: center;
}

code {
    background: #f4f4f4;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-size: 0.875em;
}

/* Login page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
}

.login-box {
    background: white;
    padding: 2.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 0.5rem;
}

.login-box > p {
    text-align: center;
    color: #666;
    margin-bottom: 1.5rem;
}

.login-box .note {
    font-size: 0.875rem;
    color: #666;
    text-align: center;
    margin-top: 1.5rem;
}

/* Item detail page */
.item-detail {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.detail-section {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #eee;
}

.detail-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.detail-section h2 {
    margin-top: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.detail-section h3 {
    margin-top: 0;
    color: #34495e;
}

.detail-table {
    width: 100%;
    max-width: 500px;
}

.detail-table th {
    text-align: left;
    padding: 0.5rem;
    color: #666;
    font-weight: 500;
    width: 140px;
    vertical-align: top;
}

.detail-table td {
    padding: 0.5rem;
}

.topics-list {
    margin: 0;
    padding-left: 1.5rem;
    columns: 2;
    column-gap: 2rem;
}

.topics-list li {
    margin-bottom: 0.25rem;
}

.topics-list .weight {
    color: #666;
    font-size: 0.85em;
}

.content-preview {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
    max-height: 400px;
    overflow-y: auto;
    font-size: 0.9rem;
    line-height: 1.7;
}

.error {
    color: #e74c3c;
    background: #fdf2f2;
    padding: 0.75rem;
    border-radius: 4px;
    border-left: 3px solid #e74c3c;
}
.item-topics {
    margin-top: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%; /* Ensure it takes full width of its parent to allow wrapping */
}

.topic-lozenge {
    background-color: #e0e0e0;
    color: #333;
    padding: 0.2em 0.6em;
    border-radius: 1em;
    font-size: 0.75em;
    white-space: nowrap;
    max-width: 100%; /* Prevent individual lozenge overflow */
}

.item-summary {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.95em;
    color: #444;
}

.detail-summary {
    font-size: 1.1em;
    color: #444;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.media-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.media-thumbnail {
    max-width: 300px;
    max-height: 200px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.media-thumbnail:hover {
    border-color: #3498db;
}

/* Reader page styles */
.reader-list {
    display: flex;
    flex-direction: column;
}

.reader-item {
    padding: 1rem;
    background: white;
}

.reader-item.alt {
    background: #f0f0f0;
}

.reader-item-header {
    margin-bottom: 0.5rem;
}

.reader-title {
    font-size: 1.1em;
    font-weight: bold;
    color: #2c3e50;
    text-decoration: none;
}

.reader-title:hover {
    color: #3498db;
    text-decoration: underline;
}

.reader-domain {
    font-size: 0.85em;
    color: #888;
    font-weight: normal;
    margin-right: 0.5em;
}

.reader-summary {
    font-size: 0.95em;
    color: #333;
    margin-bottom: 0.75rem;
    line-height: 1.4;
    font-style: italic;
}

.reader-lozenges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.score-lozenge {
    font-family: monospace;
    font-weight: bold;
    font-size: 0.8em;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: #e0e0e0;
    min-width: 2.5em;
    text-align: center;
}

.score-lozenge.hot {
    background: #e74c3c;
    color: white;
}

.score-lozenge.cold {
    background: #3498db;
    color: white;
}

.date-lozenge {
    font-family: monospace;
    font-size: 0.8em;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: #e0e0e0;
    color: #666;
}

.reader-actions {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

.loading-indicator {
    text-align: center;
    padding: 1rem;
    color: #666;
    font-style: italic;
}

/* Specific column widths for the Logs table */
#logs-table .data-table th:nth-child(1),
#logs-table .data-table td:nth-child(1) { /* Time column */
    width: 160px;
}

#logs-table .data-table th:nth-child(2),
#logs-table .data-table td:nth-child(2) { /* Level column */
    width: 90px;
}

#logs-table .data-table th:nth-child(3),
#logs-table .data-table td:nth-child(3) { /* Source column */
    width: 150px;
}

#logs-table .data-table th:nth-child(4),
#logs-table .data-table td:nth-child(4) { /* Message column */
    width: auto; /* Take remaining space */
}

/* Report bar chart */
.interval-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.report-bar-chart {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.report-bar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.report-bar-label {
    width: 200px;
    min-width: 200px;
    text-align: right;
    font-size: 0.9rem;
    color: #2c3e50;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.report-bar-track {
    flex: 1;
    background: #ecf0f1;
    border-radius: 4px;
    height: 1.5rem;
    display: flex;
}

.report-bar {
    height: 100%;
    min-width: 0;
    transition: width 0.3s ease;
}

.report-bar-clicked {
    background: #3498db;
    border-radius: 4px 0 0 4px;
}

.report-bar-unclicked {
    background: #b0c4de;
    border-radius: 0 4px 4px 0;
}

.report-bar-clicked:last-child {
    border-radius: 4px;
}

.report-bar-unclicked:first-child {
    border-radius: 4px;
}

.report-bar-count {
    width: 4rem;
    min-width: 4rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #2c3e50;
}

.report-legend {
    display: flex;
    gap: 1.5rem;
    margin-top: 1.5rem;
    justify-content: center;
}

.report-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: #555;
}

.report-legend-swatch {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border-radius: 3px;
}
