/**
 * RSS Feed Reader - App Styles
 */

/* ============================================================
   APP CONTAINER (same base as other apps)
   ============================================================ */

.app-container {
    background: var(--ont-surface);
    border-radius: var(--ont-radius-lg);
    padding: 2rem;
    box-shadow: var(--ont-shadow-soft);
}

/* ============================================================
   FEED URL INPUT SECTION
   ============================================================ */

.rss-input-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.rss-input-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ont-text-main);
}

.rss-urls-textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    line-height: 1.6;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    color: var(--ont-text-main);
    background: var(--ont-bg);
    border: 1px solid var(--ont-border-subtle);
    border-radius: var(--ont-radius-lg);
    resize: vertical;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.rss-urls-textarea:focus {
    outline: none;
    border-color: var(--ont-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.rss-urls-textarea::placeholder {
    color: var(--ont-text-muted);
    font-family: var(--ont-font-sans);
}

.rss-input-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.rss-save-hint {
    font-size: 0.8125rem;
    color: var(--ont-text-muted);
}

/* ============================================================
   BUTTONS
   ============================================================ */

.rss-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    border: 1.5px solid var(--ont-border-subtle);
    border-radius: var(--ont-radius-lg);
    background: var(--ont-surface);
    color: var(--ont-text-main);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
    white-space: nowrap;
}

.rss-btn:hover {
    background: var(--ont-bg);
}

.rss-btn-primary {
    background: var(--ont-primary);
    border-color: var(--ont-primary);
    color: #ffffff;
}

.rss-btn-primary:hover {
    background: var(--ont-primary-hover, #4338ca);
    border-color: var(--ont-primary-hover, #4338ca);
}

.rss-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ============================================================
   STATUS BAR
   ============================================================ */

.rss-status-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.875rem;
    margin-bottom: 1.25rem;
    background: var(--ont-primary-soft, #eef0ff);
    border-radius: var(--ont-radius-md, 8px);
    font-size: 0.8125rem;
    color: var(--ont-primary-strong, #312e81);
    flex-wrap: wrap;
}

.rss-status-count {
    font-weight: 600;
}

.rss-status-time {
    opacity: 0.75;
}

/* ============================================================
   FEED ERRORS
   ============================================================ */

.rss-errors {
    margin-bottom: 1rem;
}

.rss-error-item {
    padding: 0.5rem 0.875rem;
    margin-bottom: 0.375rem;
    background: var(--ont-error-light, #fee2e2);
    color: var(--ont-error, #ef4444);
    border-radius: var(--ont-radius-md, 8px);
    font-size: 0.8125rem;
    word-break: break-all;
}

.rss-stale-item {
    background: #fef9c3;
    color: #854d0e;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.rss-stale-remove-btn {
    flex-shrink: 0;
    padding: 0.1rem 0.55rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #854d0e;
    background: rgba(133, 77, 14, 0.12);
    border: 1px solid rgba(133, 77, 14, 0.3);
    border-radius: 4px;
    cursor: pointer;
    line-height: 1.4;
}

.rss-stale-remove-btn:hover {
    background: rgba(133, 77, 14, 0.22);
}

/* ============================================================
   ARTICLES LIST
   ============================================================ */

.rss-articles-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ============================================================
   ARTICLE CARD
   ============================================================ */

.rss-article-card {
    padding: 1.125rem 0;
    border-bottom: 1px solid var(--ont-border-subtle);
    transition: background 0.1s ease;
}

.rss-article-card:first-child {
    padding-top: 0.25rem;
}

.rss-article-card:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

/* Meta row: source badge + date */
.rss-article-meta {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 0.4rem;
    flex-wrap: wrap;
}

/* Source badge — uses --feed-color CSS custom property */
.rss-source-badge {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.725rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    background: color-mix(in srgb, var(--feed-color, #4f46e5) 12%, transparent);
    color: var(--feed-color, #4f46e5);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Fallback for browsers without color-mix */
@supports not (background: color-mix(in srgb, red 10%, white)) {
    .rss-source-badge {
        background: rgba(79, 70, 229, 0.12);
    }
}

.rss-article-date {
    font-size: 0.775rem;
    color: var(--ont-text-muted);
}

/* Article title */
.rss-article-title {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.4;
    margin: 0 0 0.3rem 0;
}

.rss-article-title a {
    color: var(--ont-text-main);
    text-decoration: none;
    transition: color 0.15s ease;
}

.rss-article-title a:hover {
    color: var(--ont-primary);
    text-decoration: underline;
}

/* Excerpt */
.rss-article-excerpt {
    font-size: 0.875rem;
    color: var(--ont-text-muted);
    line-height: 1.55;
    margin: 0;
}

/* ============================================================
   ARTICLE BODY (image + content side by side)
   ============================================================ */

.rss-article-body {
    display: flex;
    gap: 0.875rem;
    align-items: flex-start;
}

.rss-article-content {
    flex: 1;
    min-width: 0; /* prevent text overflow on long titles */
}

/* Thumbnail — displayed on the right */
.rss-article-image-wrap {
    flex-shrink: 0;
    width: 96px;
    height: 72px;
    border-radius: var(--ont-radius-md, 8px);
    overflow: hidden;
    background: var(--ont-bg);
    order: 2;
}

.rss-article-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Author badge in meta row */
.rss-author-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.725rem;
    font-weight: 600;
    background: var(--ont-accent-soft, #fff7e0);
    color: var(--ont-gray-700, #374151);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Per-article category tags */
.rss-article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.45rem;
}

.rss-category-tag {
    padding: 0.1rem 0.5rem;
    background: var(--ont-gray-100, #f3f4f6);
    color: var(--ont-text-muted);
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
}

/* ============================================================
   LOADING / EMPTY STATES
   ============================================================ */

.rss-loading,
.rss-empty-state {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--ont-text-muted);
    font-size: 0.9375rem;
}

.rss-loading::before {
    content: '';
    display: block;
    width: 2rem;
    height: 2rem;
    margin: 0 auto 1rem;
    border: 3px solid var(--ont-border-subtle);
    border-top-color: var(--ont-primary);
    border-radius: 50%;
    animation: rss-spin 0.7s linear infinite;
}

@keyframes rss-spin {
    to { transform: rotate(360deg); }
}

.rss-empty-state--error {
    color: var(--ont-error, #ef4444);
}

/* ============================================================
   TAGS SECTION  (shared pattern)
   ============================================================ */

.tags-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--ont-border-subtle);
    flex-wrap: wrap;
}

.tags-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--ont-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    padding: 0.2rem 0.65rem;
    background: var(--ont-primary-soft, #eef0ff);
    color: var(--ont-primary);
    border-radius: 999px;
    font-size: 0.775rem;
    font-weight: 500;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 640px) {
    .app-container {
        padding: 1.25rem;
    }

    .rss-article-title {
        font-size: 0.9375rem;
    }

    .rss-input-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .rss-btn {
        width: 100%;
        justify-content: center;
    }

    /* On mobile: stack thumbnail above text */
    .rss-article-body {
        flex-direction: column;
    }

    .rss-article-image-wrap {
        width: 100%;
        height: 160px;
        order: -1;
    }

    .rss-author-badge {
        max-width: 220px;
    }
}

/* ============================================================
   AI SUMMARIZE BUTTON (in status bar)
   ============================================================ */

.rss-btn-ai {
    margin-left: auto;
    background: linear-gradient(135deg, #7c3aed 0%, #4f46e5 100%);
    border-color: transparent;
    color: #ffffff;
    font-size: 0.8125rem;
    padding: 0.375rem 0.9rem;
    gap: 0.35rem;
}

.rss-btn-ai:hover {
    background: linear-gradient(135deg, #6d28d9 0%, #4338ca 100%);
    border-color: transparent;
}

/* ============================================================
   AI PREMIUM MODAL
   ============================================================ */

.ai-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.ai-modal {
    background: var(--ont-surface);
    border-radius: var(--ont-radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 2rem;
    max-width: 440px;
    width: 100%;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.ai-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--ont-text-muted);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--ont-radius-md, 8px);
    transition: background 0.15s ease, color 0.15s ease;
}

.ai-modal-close:hover {
    background: var(--ont-bg);
    color: var(--ont-text-main);
}

.ai-modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--ont-text-main);
    margin: 0 0 0.4rem 0;
    padding-right: 2rem;
}

.ai-modal-tagline {
    font-size: 0.875rem;
    color: var(--ont-text-muted);
    line-height: 1.5;
    margin: 0 0 1.5rem 0;
}

/* Tabs */
.ai-modal-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.25rem;
    border-bottom: 2px solid var(--ont-border-subtle);
}

.ai-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ont-text-muted);
    cursor: pointer;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.ai-tab:hover {
    color: var(--ont-text-main);
}

.ai-tab--active {
    color: var(--ont-primary);
    border-bottom-color: var(--ont-primary);
}

/* Tab panels */
.ai-tab-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ai-field-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ont-text-main);
}

.ai-text-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    color: var(--ont-text-main);
    background: var(--ont-bg);
    border: 1.5px solid var(--ont-border-subtle);
    border-radius: var(--ont-radius-lg);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.ai-text-input:focus {
    outline: none;
    border-color: var(--ont-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.ai-submit-btn {
    width: 100%;
    justify-content: center;
    padding: 0.75rem 1.5rem;
}

.ai-pay-note {
    font-size: 0.775rem;
    color: var(--ont-text-muted);
    text-align: center;
    margin: 0;
    line-height: 1.5;
}

.ai-modal-status {
    margin-top: 0.75rem;
    padding: 0.625rem 0.875rem;
    border-radius: var(--ont-radius-md, 8px);
    font-size: 0.8125rem;
    line-height: 1.5;
}

.ai-modal-status--info {
    background: var(--ont-primary-soft, #eef0ff);
    color: var(--ont-primary-strong, #312e81);
}

.ai-modal-status--error {
    background: var(--ont-error-light, #fee2e2);
    color: var(--ont-error, #ef4444);
}

/* ============================================================
   AI DIGEST PANEL
   ============================================================ */

.ai-digest-panel {
    margin-bottom: 1.5rem;
}

.ai-digest {
    background: linear-gradient(135deg,
        color-mix(in srgb, #7c3aed 8%, var(--ont-surface)) 0%,
        color-mix(in srgb, #4f46e5 6%, var(--ont-surface)) 100%);
    border: 1.5px solid color-mix(in srgb, #7c3aed 25%, transparent);
    border-radius: var(--ont-radius-lg);
    padding: 1.25rem 1.5rem;
}

/* Fallback for browsers without color-mix */
@supports not (background: color-mix(in srgb, red 10%, white)) {
    .ai-digest {
        background: var(--ont-primary-soft, #eef0ff);
        border-color: rgba(124, 58, 237, 0.25);
    }
}

.ai-digest-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.875rem;
}

.ai-digest-icon {
    font-size: 1.1rem;
    color: #7c3aed;
}

.ai-digest-title {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--ont-text-main);
    flex: 1;
}

.ai-digest-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    line-height: 1;
    color: var(--ont-text-muted);
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.ai-digest-close:hover {
    background: rgba(0, 0, 0, 0.07);
}

.ai-digest-summary {
    font-size: 0.925rem;
    line-height: 1.6;
    color: var(--ont-text-main);
    margin: 0 0 1rem 0;
}

/* Topic pills */
.ai-digest-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.ai-topic-pill {
    padding: 0.2rem 0.7rem;
    background: rgba(124, 58, 237, 0.12);
    color: #7c3aed;
    border-radius: 999px;
    font-size: 0.775rem;
    font-weight: 600;
}

/* Highlights */
.ai-digest-highlights-title {
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--ont-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 0.625rem 0;
}

.ai-highlight-item {
    padding: 0.625rem 0;
    border-top: 1px solid color-mix(in srgb, #7c3aed 15%, transparent);
}

@supports not (background: color-mix(in srgb, red 10%, white)) {
    .ai-highlight-item {
        border-top-color: rgba(124, 58, 237, 0.15);
    }
}

.ai-highlight-item:first-child {
    border-top: none;
    padding-top: 0;
}

.ai-highlight-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--ont-text-main);
    text-decoration: none;
    display: block;
    margin-bottom: 0.2rem;
    transition: color 0.15s ease;
}

a.ai-highlight-title:hover {
    color: var(--ont-primary);
    text-decoration: underline;
}

.ai-highlight-why {
    font-size: 0.825rem;
    color: var(--ont-text-muted);
    line-height: 1.4;
    margin: 0;
}

/* ============================================================
   RESPONSIVE — AI
   ============================================================ */

@media (max-width: 640px) {
    .rss-btn-ai {
        margin-left: 0;
        width: 100%;
        justify-content: center;
    }

    .ai-modal {
        padding: 1.5rem 1.25rem;
    }
}

/* ============================================================
   AI ISSUE CARDS
   ============================================================ */

.ai-issue-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.ai-issue-card {
    display: flex;
    gap: 0.875rem;
    align-items: flex-start;
    padding: 0.875rem 0;
    border-top: 1px solid color-mix(in srgb, #7c3aed 15%, transparent);
}

@supports not (background: color-mix(in srgb, red 10%, white)) {
    .ai-issue-card {
        border-top-color: rgba(124, 58, 237, 0.15);
    }
}

.ai-issue-card:first-child {
    border-top: none;
    padding-top: 0;
}

.ai-issue-card:last-child {
    padding-bottom: 0;
}

/* Image — right side */
.ai-issue-image-wrap {
    flex-shrink: 0;
    width: 100px;
    height: 75px;
    border-radius: var(--ont-radius-md, 8px);
    overflow: hidden;
    background: var(--ont-bg);
    order: 2;
}

.ai-issue-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Content — left side */
.ai-issue-content {
    flex: 1;
    min-width: 0;
}

.ai-issue-headline-row {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
    flex-wrap: wrap;
}

.ai-issue-number {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 50%;
    background: rgba(124, 58, 237, 0.15);
    color: #7c3aed;
    font-size: 0.675rem;
    font-weight: 800;
    line-height: 1;
}

.ai-issue-tag {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    background: rgba(124, 58, 237, 0.07);
    color: rgba(124, 58, 237, 0.7);
    border: 1px solid rgba(124, 58, 237, 0.18);
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    white-space: nowrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    flex-shrink: 0;
}

.ai-issue-headline {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--ont-text-main);
    line-height: 1.35;
    margin: 0;
}

.ai-issue-why {
    font-size: 0.85rem;
    color: var(--ont-text-muted);
    line-height: 1.55;
    margin: 0 0 0.5rem 0;
}

/* Source badges */
.ai-issue-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.4rem;
}

.ai-issue-source-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    background: rgba(124, 58, 237, 0.1);
    color: #7c3aed;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s ease;
}

a.ai-issue-source-badge:hover {
    background: rgba(124, 58, 237, 0.2);
}

/* ── Watchlist ─────────────────────────────────────────────────────────────── */
.ai-watchlist {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 2px solid rgba(124, 58, 237, 0.2);
}

.ai-watchlist-title {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ont-text-muted, #6b7280);
    margin: 0 0 0.75rem;
}

.ai-watchlist-list {
    margin: 0;
    padding: 0 0 0 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.ai-watchlist-item {
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--ont-text, #111827);
}

.ai-watchlist-link {
    color: inherit;
    text-decoration: none;
    font-weight: 500;
}

.ai-watchlist-link:hover {
    text-decoration: underline;
    color: #7c3aed;
}

.ai-watchlist-source {
    font-size: 0.75rem;
    color: var(--ont-text-muted, #6b7280);
    margin-left: 0.35rem;
}

/* Responsive — stack image above content on mobile */
@media (max-width: 640px) {
    .ai-issue-card {
        flex-direction: column;
    }

    .ai-issue-image-wrap {
        width: 100%;
        height: 140px;
        order: -1;
    }
}
