/* Feed generator page (templates/scraper.html.php) */

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --border: #dfe3e8;
    --text: #1d2330;
    --muted: #5d6778;
    --accent: #e8590c;
    --accent-hover: #c94c09;
    --accent-soft: #fff0e6;
    --focus: rgba(232, 89, 12, 0.35);
    --success-bg: #ebf8ef;
    --success-border: #9fd8b0;
    --info-bg: #eaf2fd;
    --info-border: #a9c8f2;
    --warning-bg: #fff7e0;
    --warning-border: #f0d27a;
    --error-bg: #fdecec;
    --error-border: #f0a8a8;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
    --radius: 12px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12151b;
        --surface: #1a1f27;
        --surface-2: #232a34;
        --border: #2f3844;
        --text: #e6e9ee;
        --muted: #9aa4b2;
        --accent: #ff7a33;
        --accent-hover: #ff8f52;
        --accent-soft: #3a2518;
        --focus: rgba(255, 122, 51, 0.4);
        --success-bg: #15291d;
        --success-border: #2f6b43;
        --info-bg: #15233a;
        --info-border: #2d4f80;
        --warning-bg: #2d2612;
        --warning-border: #6b5a20;
        --error-bg: #301818;
        --error-border: #7a3333;
        --shadow: none;
        color-scheme: dark;
    }
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
}

a {
    color: var(--accent);
}

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.9em;
    background: var(--surface-2);
    padding: 0.1em 0.35em;
    border-radius: 4px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Layout */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
}

.topbar nav a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.95rem;
}

.topbar nav a:hover {
    color: var(--accent);
}

.wrap {
    max-width: 920px;
    margin: 0 auto;
    padding: 0 16px 48px;
}

.footer {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    padding: 24px 16px 40px;
}

.footer a {
    color: inherit;
}

.system-message {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: var(--radius);
    background: var(--info-bg);
    border: 1px solid var(--info-border);
}

/* Hero */

.hero {
    text-align: center;
    padding: 56px 0 28px;
}

.hero h1 {
    font-size: clamp(1.7rem, 4vw, 2.4rem);
    line-height: 1.2;
    margin: 0 0 12px;
    letter-spacing: -0.02em;
}

.lead {
    color: var(--muted);
    font-size: 1.1rem;
    max-width: 620px;
    margin: 0 auto 28px;
}

.url-form {
    display: flex;
    gap: 8px;
    max-width: 720px;
    margin: 0 auto;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.url-form:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--focus);
}

.url-form input[type=text] {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 1.05rem;
    padding: 10px 12px;
}

.examples {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 16px 0 0;
}

.chip {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 999px;
    padding: 3px 12px;
    margin: 2px;
    font-size: 0.85rem;
    cursor: pointer;
}

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

/* Buttons and inputs */

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 10px;
    padding: 9px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
}

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

.button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    padding: 10px 22px;
}

.button.primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
}

.button:disabled {
    opacity: 0.6;
    cursor: progress;
}

input[type=text],
input[type=number] {
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
}

.options input[type=text],
.options input[type=number],
.feed-url input {
    width: 100%;
}

input:focus-visible,
button:focus-visible,
a:focus-visible,
summary:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 1px;
}

/* Status */

.status {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    margin: 8px 0 20px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
}

.status.error {
    background: var(--error-bg);
    border-color: var(--error-border);
}

.status .detail {
    display: block;
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: 4px;
    word-break: break-word;
}

.spinner {
    flex: none;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Results */

.site {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 8px 0 18px;
}

.site-icon {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--surface-2);
    object-fit: contain;
}

.site-text {
    min-width: 0;
}

.site h2 {
    margin: 0;
    font-size: 1.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.site a {
    color: var(--muted);
    font-size: 0.9rem;
    word-break: break-all;
}

.notice {
    padding: 14px 18px;
    margin-bottom: 16px;
    border-radius: var(--radius);
    border: 1px solid;
}

.notice h3 {
    margin: 0 0 4px;
    font-size: 1rem;
}

.notice p {
    margin: 0 0 8px;
    color: var(--muted);
}

.notice.success {
    background: var(--success-bg);
    border-color: var(--success-border);
}

.notice.info {
    background: var(--info-bg);
    border-color: var(--info-border);
}

.notice.warning {
    background: var(--warning-bg);
    border-color: var(--warning-border);
}

.link-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.link-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}

.link-list .tag {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1px 6px;
}

.link-list a {
    word-break: break-all;
}

.link-list .button {
    padding: 4px 10px;
    font-size: 0.8rem;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.panel-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.panel h2 {
    margin: 0;
    font-size: 1.15rem;
}

.label {
    margin: 0 0 8px;
    font-weight: 600;
    font-size: 0.9rem;
}

.hint {
    color: var(--muted);
    font-size: 0.85rem;
    margin: 6px 0 0;
}

.badge {
    background: var(--surface-2);
    color: var(--muted);
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 0.85rem;
}

.segmented {
    display: inline-flex;
    background: var(--surface-2);
    border-radius: 10px;
    padding: 3px;
}

.segmented button {
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
}

.segmented button[aria-checked=true] {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}

.candidates {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.candidate {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    text-align: left;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    cursor: pointer;
    max-width: 100%;
}

.candidate strong {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    max-width: 320px;
}

.candidate .tag {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--accent);
    border: 1px solid var(--accent);
    border-radius: 6px;
    padding: 0 5px;
    white-space: nowrap;
}

.candidate-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--muted);
    max-width: 320px;
    min-width: 0;
}

.candidate code {
    font-size: 0.75rem;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.candidate[aria-checked=true] {
    border-color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 0 0 1px var(--accent);
}

.feed-url {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.feed-url input {
    flex: 1;
    min-width: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.85rem;
    background: var(--surface-2);
}

.options {
    margin-top: 16px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.options summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--muted);
}

.options-grid {
    display: grid;
    grid-template-columns: minmax(180px, 260px) 1fr;
    gap: 12px 16px;
    align-items: center;
    margin-top: 14px;
}

.options-grid > label {
    font-size: 0.9rem;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox .hint {
    margin: 0;
}

.inline {
    display: flex;
    gap: 8px;
}

/* Preview */

.preview {
    list-style: none;
    margin: 0;
    padding: 0;
}

.preview li {
    display: flex;
    gap: 14px;
    padding: 14px 0;
    border-top: 1px solid var(--border);
}

.preview li:first-child {
    border-top: 0;
    padding-top: 0;
}

.preview .thumb {
    flex: none;
    width: 112px;
    height: 72px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--surface-2);
}

.preview .body {
    min-width: 0;
}

.preview h3 {
    margin: 0 0 4px;
    font-size: 1rem;
    line-height: 1.35;
}

.preview h3 a {
    color: var(--text);
    text-decoration: none;
}

.preview h3 a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.preview .meta {
    color: var(--muted);
    font-size: 0.8rem;
    margin: 0 0 4px;
}

.preview .description {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.empty {
    color: var(--muted);
    text-align: center;
    padding: 12px 0;
}

@media (max-width: 640px) {
    .topbar {
        padding: 12px 16px;
    }

    .hero {
        padding-top: 32px;
    }

    .url-form,
    .feed-url,
    .inline {
        flex-direction: column;
    }

    .options-grid {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .options-grid > label {
        margin-top: 8px;
        font-weight: 600;
    }

    .preview .thumb {
        width: 80px;
        height: 60px;
    }
}

/* Navigation */

.topbar nav {
    display: flex;
    gap: 18px;
}

.topbar nav a[aria-current=page] {
    color: var(--text);
    font-weight: 600;
}

/* Save a feed (generator) */

.save-form {
    margin-top: 12px;
}

.save-form .inline input {
    flex: 1;
    min-width: 0;
}

.save-form .hint {
    margin: 6px 0 6px;
}

/* "Meus feeds" */

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    padding: 40px 0 20px;
}

.page-head h1 {
    margin: 0 0 6px;
    font-size: clamp(1.6rem, 3.5vw, 2.1rem);
    letter-spacing: -0.02em;
}

.page-head .lead {
    margin: 0;
    font-size: 1rem;
    text-align: left;
    max-width: 560px;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.add-url {
    padding: 14px 20px;
}

.add-url summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--muted);
}

.add-form {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.add-form input:first-child {
    flex: 2;
    min-width: 0;
}

.add-form input {
    flex: 1;
    min-width: 0;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.toolbar input[type=search] {
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    min-width: 240px;
}

.feed-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.feed-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 18px;
}

.feed-item.paused {
    opacity: 0.65;
}

.feed-head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.feed-info {
    min-width: 0;
    flex: 1;
}

.feed-name {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.feed-name strong {
    font-size: 1.05rem;
    overflow-wrap: anywhere;
}

.feed-name input {
    flex: 1;
    font-weight: 600;
}

.feed-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: 2px;
}

.feed-meta a {
    color: var(--muted);
}

.tag {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1px 6px;
    white-space: nowrap;
}

.feed-item .feed-url {
    margin-top: 12px;
}

.feed-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 10px;
}

.feed-check {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.feed-check.ok {
    color: #1f8a4c;
}

.feed-check.error {
    color: #c23434;
}

.feed-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.feed-actions select {
    font: inherit;
    font-size: 0.85rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 5px 8px;
}

.button.small {
    padding: 5px 12px;
    font-size: 0.85rem;
}

.button.danger:hover {
    border-color: #c23434;
    color: #c23434;
}

.link-button {
    border: 0;
    background: none;
    color: var(--muted);
    font: inherit;
    font-size: 0.8rem;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
}

.link-button:hover {
    color: var(--accent);
}

.spinner.small {
    width: 14px;
    height: 14px;
    border-width: 2px;
}

.empty-state {
    text-align: center;
    padding: 36px 20px;
}

.empty-state h2 {
    margin: 0 0 8px;
}

.empty-state p {
    color: var(--muted);
    margin: 0 0 18px;
}

/* Active switch */

.switch {
    position: relative;
    flex: none;
    width: 40px;
    height: 22px;
    margin-top: 2px;
    cursor: pointer;
}

.switch input {
    position: absolute;
    z-index: 1;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}

.switch .slider {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: var(--border);
    transition: background 0.15s;
}

.switch .slider::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.15s;
}

.switch input:checked + .slider {
    background: var(--accent);
}

.switch input:checked + .slider::before {
    transform: translateX(18px);
}

.switch input:focus-visible + .slider {
    outline: 3px solid var(--focus);
    outline-offset: 1px;
}

@media (prefers-color-scheme: dark) {
    .feed-check.ok {
        color: #5fd38d;
    }

    .feed-check.error {
        color: #ff8080;
    }
}

@media (max-width: 640px) {
    .page-head {
        padding-top: 24px;
    }

    .add-form,
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar input[type=search] {
        min-width: 0;
    }

    .topbar {
        flex-wrap: wrap;
        gap: 8px;
    }

    .topbar nav {
        gap: 12px;
        font-size: 0.9rem;
    }
}
