/* Archives page styles */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: #1a1a1a; color: #eee; font-family: -apple-system, BlinkMacSystemFont, sans-serif; min-height: 100vh; }
.header { padding: 24px 32px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.header h1 { font-size: 20px; font-weight: 600; }
.header .company { font-size: 13px; color: rgba(255,255,255,0.5); margin-top: 4px; }
.search-section { padding: 24px 32px; }
.search-bar { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; padding: 12px 16px; }
.search-bar input { background: none; border: none; color: #eee; font-size: 15px; outline: none; flex: 1; }
.search-bar input::placeholder { color: rgba(255,255,255,0.4); }
.search-btn { background: #c0392b; border: none; color: #fff; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 13px; white-space: nowrap; }
.search-btn:hover { opacity: 0.9; }
.search-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.voice-input-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; flex: 0 0 36px; background: rgba(192,57,43,0.16); border: 1px solid rgba(231,76,60,0.7); border-radius: 6px; color: #ffb4ab; font-size: 14px; cursor: pointer; box-shadow: 0 0 0 2px rgba(192,57,43,0.08); }
.voice-input-btn:hover { color: #fff; background: rgba(192,57,43,0.3); border-color: #e74c3c; }
.voice-input-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.voice-input-btn.is-listening { color: #fff; background: #c0392b; border-color: #e74c3c; }
.voice-input-status { min-height: 18px; margin-top: 6px; color: rgba(255,255,255,0.55); font-size: 12px; }
#results { padding: 0 32px 32px; }
.result-card { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; padding: 20px; margin-top: 16px; }
.result-card h3 { font-size: 14px; margin-bottom: 12px; color: #fff; }
.result-answer { font-size: 14px; line-height: 1.7; white-space: pre-wrap; }
.result-sources { margin-top: 16px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.1); font-size: 11px; color: rgba(255,255,255,0.4); }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.issues { padding: 24px 32px; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.issue { background: rgba(255,255,255,0.05); border-radius: 8px; font-size: 13px; text-decoration: none; color: inherit; transition: transform 0.15s, box-shadow 0.15s; }
.issue:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.issue-full { display: block; overflow: hidden; }
.issue-cover { background: #111; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; height: 0; transition: height 0.3s ease; }
.issue-cover canvas { width: 100%; height: 100%; object-fit: cover; }
.issue-info { padding: 10px 12px; }
.issue-compact { padding: 12px 16px; display: flex; flex-direction: column; justify-content: center; min-height: 60px; opacity: 0.6; }
.issue-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.issue-meta { color: rgba(255,255,255,0.4); font-size: 11px; margin-top: 4px; }

/* ── AI "Save prompt & results" subsystem (ported from the reader) ────────── */

/* Toolbar row under the search bar holding the Saved toggle. */
.search-toolbar { display: flex; align-items: center; gap: 10px; margin-top: 12px; }

/* Saved toggle button — subtle dark fill (secondary action), brand-red accent
   once the reader has saved prompts. */
.saved-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 6px 12px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    color: rgba(255,255,255,0.75);
    font-size: 13px;
    cursor: pointer;
}
.saved-toggle-btn:hover { color: #fff; background: rgba(255,255,255,0.14); }
.saved-toggle-btn i.fa-bookmark { color: rgba(255,255,255,0.55); transition: color .15s ease; }
.saved-toggle-btn.has-saved { border-color: var(--color-primary, #e11d2a); }
.saved-toggle-btn.has-saved i.fa-bookmark { color: var(--color-primary, #e11d2a); }
.archive-reset-btn { color: rgba(255,255,255,0.75); }
.archive-reset-btn:hover { color: #fff; border-color: rgba(231,76,60,0.7); }

.ai-saved-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 5px;
    border-radius: 8px;
    background: var(--color-primary, #e11d2a);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
}

/* Per-answer action row: Save (secondary) sits next to Download (primary). */
.result-ai-actions {
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
/* Save — subtle dark fill (secondary action) mirroring the reader .ai-save-btn. */
.ai-save-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 4px 10px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    color: rgba(255,255,255,0.75);
    font-size: 12px;
    cursor: pointer;
}
.ai-save-btn:hover { color: #fff; background: rgba(255,255,255,0.14); }
.ai-save-btn.saved { color: #c0392b; border-color: #c0392b; }
.ai-save-btn:disabled { cursor: default; }

/* Sign-in prompt inside the saved list (reuses renderLoginRequired for results). */
.ai-signin { text-align: center; padding: 16px 8px; }
.ai-signin .ai-signin-icon { font-size: 22px; color: rgba(255,255,255,0.4); margin-bottom: 10px; }
.ai-signin p { font-size: 13px; color: #eee; margin-bottom: 14px; }
.ai-signin a.ai-signin-link {
    display: inline-block;
    background: #c0392b;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 10px 20px;
    border-radius: 6px;
    text-decoration: none;
}

/* Saved-prompts list overlay (replaces #results while browsing). */
#archivesSavedList { padding: 0 32px 32px; }
.ai-saved-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    margin-top: 12px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    cursor: pointer;
}
.ai-saved-item:hover { background: rgba(255,255,255,0.1); }
.ai-saved-body { flex: 1; min-width: 0; }
.ai-saved-query {
    font-size: 13px;
    font-weight: 600;
    color: #eee;
    margin-bottom: 3px;
}
.ai-saved-snippet {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.ai-saved-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
}
.ai-saved-edit, .ai-saved-del {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.55);
    font-size: 13px;
    cursor: pointer;
    border-radius: 6px;
}
.ai-saved-edit:hover { color: #fff; background: var(--color-primary, #e11d2a); border-color: var(--color-primary, #e11d2a); }
.ai-saved-del:hover { color: #fff; background: #c0392b; border-color: #c0392b; }
.ai-saved-empty { color: rgba(255,255,255,0.5); font-size: 13px; text-align: center; padding: 24px 8px; }

/* Mobile: 44px touch targets per the reader rules. */
@media (pointer: coarse) {
    .ai-saved-edit, .ai-saved-del { width: 44px; height: 44px; font-size: 15px; }
    .saved-toggle-btn, .ai-save-btn { min-height: 44px; }
}

/* ── PDF page-picker modal ────────────────────────────────────────────────── */
.pdf-modal-overlay {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,0.6);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.pdf-modal {
    background: #1f1f1f;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    width: 100%; max-width: 640px;
    max-height: 85vh; display: flex; flex-direction: column;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}
.pdf-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,0.1);
}
.pdf-modal-header h3 { font-size: 15px; font-weight: 600; color: #fff; display: flex; align-items: center; gap: 8px; }
.pdf-modal-header h3 i { color: #c0392b; }
.pdf-modal-close {
    background: none; border: none; color: rgba(255,255,255,0.6);
    font-size: 24px; line-height: 1; cursor: pointer; padding: 0 4px;
}
.pdf-modal-close:hover { color: #fff; }
.pdf-modal-intro { padding: 14px 20px 4px; font-size: 13px; line-height: 1.6; color: rgba(255,255,255,0.75); }
.pdf-modal-counter { padding: 4px 20px 12px; font-size: 12px; color: rgba(255,255,255,0.55); }
.pdf-modal-counter strong { color: #fff; }

/* Structured rows/columns grid of pages. */
.pdf-modal-grid {
    padding: 0 20px; overflow-y: auto;
    display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
}
@media (max-width: 520px) { .pdf-modal-grid { grid-template-columns: 1fr; } }
.pdf-modal-cell {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px; border-radius: 6px;
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
    cursor: pointer; min-height: 44px;
}
.pdf-modal-cell:hover { background: rgba(255,255,255,0.09); }
.pdf-modal-cell input[type="checkbox"] { width: 16px; height: 16px; flex: 0 0 auto; accent-color: #c0392b; }
.pdf-modal-cell input[type="checkbox"]:disabled { opacity: 0.4; }
.pdf-modal-cell-meta { display: flex; flex-direction: column; min-width: 0; }
.pdf-modal-cell-title { font-size: 13px; color: #eee; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pdf-modal-cell-page { font-size: 11px; color: rgba(255,255,255,0.5); margin-top: 2px; }

.pdf-modal-footer {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.1); margin-top: 14px;
}
.pdf-modal-msg { flex: 1; font-size: 12px; min-width: 0; }
.pdf-modal-cancel {
    background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.8); padding: 8px 16px; border-radius: 6px;
    font-size: 13px; cursor: pointer;
}
.pdf-modal-cancel:hover { color: #fff; background: rgba(255,255,255,0.14); }
.pdf-modal-confirm { display: inline-flex; align-items: center; gap: 6px; }

/* Mobile: 44px touch targets. */
@media (pointer: coarse) {
    .pdf-modal-cancel, .pdf-modal-confirm { min-height: 44px; }
}
