/* NewsFlow - AgentDefenders Inspired Design */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600;700&display=swap');

/* AgentDefenders Light Mode Tokens */
:root {
    --color-bg: #F2EDE4;
    --color-surface: #FFFFFF;
    --color-text-primary: #1A1A18;
    --color-text-muted: #5F5E5A;
    --color-accent: #C0392B;
    --color-border: #E8E0D6;
    --color-code-bg: #1A1A18;
    --color-code-syntax: #4A9CE8;

    --font-display: Georgia, 'Times New Roman', serif;
    --font-ui: 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'JetBrains Mono', 'Courier New', monospace;

    --shadow-sm: 0 1px 3px rgba(26, 26, 24, 0.08);
    --shadow: 0 2px 8px rgba(26, 26, 24, 0.12);
    --shadow-lg: 0 8px 24px rgba(26, 26, 24, 0.16);
}

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

body {
    font-family: var(--font-ui);
    background: var(--color-bg);
    color: var(--color-text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Header */
header {
    background: var(--color-surface);
    border-bottom: 2px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

header .header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 32px;
}

header h1 {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 400;
    color: var(--color-text-primary);
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.admin-link, .back-link {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
}

.admin-link:hover, .back-link:hover {
    color: #A02F24;
}

/* Tabs */
.tabs {
    background: var(--color-surface);
    border-bottom: 2px solid var(--color-border);
    padding: 0 32px;
    display: flex;
    gap: 0;
    overflow-x: auto;
}

.tab {
    padding: 16px 24px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab:hover {
    color: var(--color-text-primary);
}

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

.tab-loading {
    padding: 16px 24px;
    color: var(--color-text-muted);
    font-size: 14px;
}

/* Content Wrapper */
.content-wrapper {
    display: flex;
    max-width: 1600px;
    margin: 0 auto;
    gap: 32px;
    padding: 40px 32px;
}

/* Sidebar */
.sidebar {
    width: 300px;
    flex-shrink: 0;
}

.sidebar-header {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.sidebar-header h2 {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 400;
    color: var(--color-text-primary);
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-loading {
    text-align: center;
    padding: 20px;
    color: var(--color-text-muted);
    font-size: 14px;
}

.favorite-item {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
    cursor: pointer;
}

.favorite-item:hover {
    border-color: var(--color-accent);
    transform: translateX(4px);
}

.favorite-item-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--color-text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.favorite-item-meta {
    font-size: 11px;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
}

.favorite-item-unfavorite {
    margin-top: 8px;
    padding: 4px 8px;
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.favorite-item-unfavorite:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

/* Content */
.content {
    flex: 1;
    min-width: 0;
}

/* Date Sections */
.date-section {
    margin-bottom: 48px;
}

.date-header {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.date-header h2 {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 400;
    color: var(--color-accent);
    margin: 0;
}

/* Articles */
.articles {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Show More Section */
.show-more-container {
    margin-top: 24px;
    text-align: center;
}

.show-more-btn {
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    color: var(--color-text-muted);
    padding: 12px 32px;
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 24px;
}

.show-more-btn:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    background: rgba(192, 57, 43, 0.05);
    transform: translateY(-2px);
}

.unscored-articles {
    display: flex;
    flex-direction: column;
    gap: 24px;
    opacity: 0.7;
}

.article-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s;
}

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

.article-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 16px;
}

.article-title {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 400;
    margin-bottom: 8px;
    flex: 1;
}

.article-title a {
    color: var(--color-text-primary);
    text-decoration: none;
    transition: color 0.2s;
}

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

.article-score {
    background: transparent;
    color: var(--color-accent);
    border: 2px solid var(--color-accent);
    padding: 4px 12px;
    font-size: 13px;
    font-weight: 700;
    font-family: var(--font-mono);
    white-space: nowrap;
    flex-shrink: 0;
}

.article-favorite-btn {
    background: transparent;
    border: 1px solid var(--color-border);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 10px;
    transition: all 0.2s;
    color: var(--color-text-muted);
    line-height: 1;
}

.article-favorite-btn:hover {
    border-color: var(--color-accent);
    background: rgba(192, 57, 43, 0.05);
    transform: scale(1.1);
}

.article-favorite-btn[data-favorited="1"] {
    color: #f39c12;
    border-color: #f39c12;
}

.article-meta {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-bottom: 12px;
    font-family: var(--font-mono);
}

.article-summary {
    color: var(--color-text-primary);
    margin-bottom: 16px;
    line-height: 1.7;
}

.article-image {
    width: 30%;
    max-width: 400px;
    height: auto;
    object-fit: contain;
    margin: 0 auto 16px auto;
    display: block;
    border: 1px solid var(--color-border);
}

.similar-articles {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
}

.similar-toggle {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    padding: 8px 16px;
    font-family: var(--font-ui);
    transition: all 0.2s;
}

.similar-toggle:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
    background: rgba(192, 57, 43, 0.05);
}

.similar-list {
    margin-top: 16px;
    display: none;
    flex-direction: column;
    gap: 12px;
}

.similar-list.show {
    display: flex;
}

.similar-item {
    padding: 16px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    font-size: 14px;
    transition: all 0.2s;
}

.similar-item:hover {
    border-color: var(--color-accent);
}

.similar-item a {
    color: var(--color-text-primary);
    text-decoration: none;
    font-weight: 600;
}

.similar-item a:hover {
    color: var(--color-accent);
}

.similar-item-source {
    color: var(--color-text-muted);
    font-size: 12px;
    margin-top: 6px;
    font-family: var(--font-mono);
}

/* Loading & Error States */
.loading, .error {
    text-align: center;
    padding: 80px 20px;
    color: var(--color-text-muted);
    font-family: var(--font-display);
    font-size: 20px;
}

.error {
    color: var(--color-accent);
}

/* Footer */
footer {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-muted);
    font-size: 13px;
    font-family: var(--font-mono);
}

/* ========== LOGIN PAGE ========== */

.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--color-bg);
    padding: 40px 20px;
}

.login-container {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 48px;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
}

.login-container h1 {
    font-family: var(--font-display);
    font-size: 42px;
    font-weight: 400;
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--color-border);
}

/* ========== ADMIN PAGE ========== */

.admin-page header {
    position: static;
}

.admin-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 32px;
}

.admin-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 32px;
    margin-bottom: 32px;
    box-shadow: var(--shadow-sm);
}

.admin-section h2 {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 400;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--color-border);
}

.admin-form {
    max-width: 600px;
}

.items-list {
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.item-card {
    background: var(--color-bg);
    padding: 20px;
    border: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
    gap: 20px;
}

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

.item-card-error {
    border-left: 3px solid var(--color-accent);
    background: rgba(192, 57, 43, 0.03);
}

.feed-error {
    margin-top: 12px;
    padding: 12px;
    background: rgba(192, 57, 43, 0.1);
    border: 1px solid rgba(192, 57, 43, 0.3);
    font-size: 13px;
    color: var(--color-accent);
    font-family: var(--font-mono);
    border-radius: 4px;
}

.item-info {
    flex: 1;
}

.item-title {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 6px;
    color: var(--color-text-primary);
}

.item-meta {
    font-size: 13px;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
}

.item-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

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

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

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group input[type="url"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-primary);
    font-family: var(--font-mono);
    font-size: 14px;
    transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.1);
}

.form-group input::placeholder {
    color: var(--color-text-muted);
    opacity: 0.6;
}

/* Buttons */
button, .btn {
    padding: 10px 20px;
    border: 2px solid var(--color-accent);
    background: var(--color-accent);
    color: white;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-block;
    text-align: center;
}

button:hover, .btn:hover {
    background: #A02F24;
    border-color: #A02F24;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

button[type="submit"], .btn-primary {
    border-color: var(--color-accent);
    background: var(--color-accent);
    color: white;
}

.btn-secondary {
    background: transparent;
    color: var(--color-text-muted);
    border-color: var(--color-text-muted);
}

.btn-secondary:hover {
    background: var(--color-bg);
    color: var(--color-text-primary);
    border-color: var(--color-text-primary);
    transform: translateY(-1px);
}

.btn-danger {
    border-color: var(--color-accent);
    background: transparent;
    color: var(--color-accent);
}

.btn-danger:hover {
    background: var(--color-accent);
    color: white;
    transform: translateY(-1px);
}

.btn-cancel {
    background: transparent;
    color: var(--color-text-muted);
    border-color: var(--color-text-muted);
}

.btn-cancel:hover {
    background: var(--color-bg);
    color: var(--color-text-primary);
    border-color: var(--color-text-primary);
}

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}

.hint-btn {
    margin-top: 8px;
    background: transparent;
    color: var(--color-text-muted);
    border-color: var(--color-border);
    font-size: 12px;
    padding: 6px 12px;
}

.hint-display {
    margin-top: 12px;
    padding: 12px 16px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    font-style: italic;
    color: var(--color-text-muted);
    display: none;
    font-size: 13px;
}

.hint-display.show {
    display: block;
}

.error-message {
    color: var(--color-accent);
    font-size: 13px;
    margin-top: 12px;
    display: none;
    padding: 12px 16px;
    background: rgba(192, 57, 43, 0.05);
    border: 1px solid rgba(192, 57, 43, 0.2);
}

.error-message.show {
    display: block;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(26, 26, 24, 0.75);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    box-shadow: var(--shadow-lg);
}

.modal-large {
    max-width: 800px;
}

.modal-content h3 {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 400;
    padding: 24px;
    border-bottom: 2px solid var(--color-border);
    background: var(--color-bg);
}

.modal-content form {
    padding: 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 2px solid var(--color-border);
}

.modal-actions .btn {
    flex: 1;
}

/* Feed Preview */
.feed-preview {
    margin-top: 24px;
    display: none;
}

.feed-preview.show {
    display: block;
}

.feed-info {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    padding: 20px;
    margin-bottom: 20px;
}

.feed-info h4 {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 400;
    margin-bottom: 8px;
}

.feed-info p {
    font-size: 13px;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
}

.date-field-selector {
    margin: 20px 0;
}

.date-field-selector label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 13px;
}

.date-field-selector select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    font-family: var(--font-mono);
    font-size: 14px;
}

.preview-items {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.preview-item {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    padding: 16px;
}

.preview-item h5 {
    font-family: var(--font-ui);
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 15px;
}

.preview-item-meta {
    font-size: 12px;
    color: var(--color-accent);
    margin-bottom: 8px;
}

.preview-item-meta a {
    color: var(--color-accent);
    text-decoration: none;
}

.preview-item-content {
    font-size: 13px;
    color: var(--color-text-muted);
    max-height: 100px;
    overflow: hidden;
    line-height: 1.6;
}

/* Responsive */
@media (max-width: 1024px) {
    .content-wrapper {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        order: -1;
    }

    .sidebar-content {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 12px;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 24px;
    }

    .header-content {
        padding: 20px;
    }

    .tabs {
        padding: 0 20px;
    }

    .tab {
        padding: 12px 16px;
        font-size: 13px;
    }

    .content-wrapper {
        padding: 24px 16px;
    }

    .sidebar-content {
        grid-template-columns: 1fr;
    }

    .article-card {
        padding: 20px;
    }

    .article-title {
        font-size: 20px;
    }

    .admin-container {
        padding: 24px 16px;
    }

    .admin-section {
        padding: 20px;
    }

    .login-container {
        padding: 32px 24px;
    }

    .login-container h1 {
        font-size: 32px;
    }

    .modal-content {
        padding: 0;
    }

    .item-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .item-actions {
        width: 100%;
    }

    .item-actions .btn {
        flex: 1;
    }
}
