/* ==========================================================================
   Estilo Oficial — Caçador de Ilustrações (Padrão WOL)
   ========================================================================== */

:root {
    --bg-main: #f7f9fa;
    --bg-card: #ffffff;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --border-color: #e2e8f0;
    --brand-primary: #1b4965;
    --brand-hover: #133a52;
    --brand-accent: #62b6cb;
    --link-color: #2b6cb0;
    --link-hover: #1a4971;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --radius-sm: 6px;
    --radius-md: 10px;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    font-size: 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* --------------------------------------------------------------------------
   HEADER
   -------------------------------------------------------------------------- */
.app-header {
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 1rem;
    box-shadow: var(--shadow-sm);
}

.header-container {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-badge {
    display: inline-block;
    background-color: #edf2f7;
    color: var(--brand-primary);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    letter-spacing: 0.08em;
    margin-bottom: 0.35rem;
}

.main-title {
    font-family: 'Merriweather', Georgia, serif;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--brand-primary);
    letter-spacing: 0.03em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.header-stats {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.stat-pill {
    background-color: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
}

.stat-pill strong {
    color: var(--brand-primary);
}

/* --------------------------------------------------------------------------
   MAIN CONTAINER
   -------------------------------------------------------------------------- */
.main-container {
    max-width: 1000px;
    width: 100%;
    margin: 2rem auto;
    padding: 0 1rem;
    flex: 1;
}

/* --------------------------------------------------------------------------
   SEÇÃO DE INGESTÃO (FORMULÁRIO E PROGRESSO)
   -------------------------------------------------------------------------- */
.ingestion-section {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.75rem;
}

.input-group {
    display: flex;
    gap: 0.75rem;
}

.input-group input[type="url"] {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}

.input-group input[type="url"]:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(27, 73, 101, 0.15);
}

.btn-primary {
    background-color: var(--brand-primary);
    color: #ffffff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.btn-primary:hover {
    background-color: var(--brand-hover);
}

.btn-primary:active {
    transform: scale(0.98);
}

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

/* Card de Progresso */
.progress-card {
    margin-top: 1.25rem;
    padding: 1rem;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--brand-primary);
}

.progress-bar-bg {
    width: 100%;
    height: 10px;
    background-color: #e2e8f0;
    border-radius: 5px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--brand-accent);
    background-image: linear-gradient(45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent);
    background-size: 20px 20px;
    transition: width 0.4s ease;
    animation: progress-stripes 1s linear infinite;
}

@keyframes progress-stripes {
    from { background-position: 20px 0; }
    to { background-position: 0 0; }
}

.progress-details {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.alert-box {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
}

.alert-box.success {
    background-color: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-box.error {
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* --------------------------------------------------------------------------
   CONTROLES: BUSCA E ALFABETO
   -------------------------------------------------------------------------- */
.controls-section {
    margin-bottom: 1.5rem;
}

.search-bar-wrapper {
    position: relative;
    margin-bottom: 1rem;
}

.search-bar-wrapper input {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: #ffffff;
    font-size: 0.95rem;
    outline: none;
    font-family: inherit;
    box-shadow: var(--shadow-sm);
}

.search-bar-wrapper input:focus {
    border-color: var(--brand-primary);
}

.btn-clear {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}

.alphabet-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    background-color: #ffffff;
    padding: 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.btn-letter {
    background: none;
    border: 1px solid transparent;
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-letter:hover:not(:disabled) {
    background-color: #edf2f7;
    color: var(--brand-primary);
}

.btn-letter.active {
    background-color: var(--brand-primary);
    color: #ffffff;
}

.btn-letter:disabled {
    opacity: 0.3;
    cursor: default;
}

/* --------------------------------------------------------------------------
   ÁREA DO ÍNDICE (ESTILO OFICIAL DO WOL)
   -------------------------------------------------------------------------- */
.index-content-section {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    min-height: 400px;
}

.subject-block {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #edf2f7;
}

.subject-block:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* Título em Maiúsculas e Negrito */
.subject-title {
    font-family: 'Merriweather', Georgia, serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: #000000;
    letter-spacing: 0.04em;
    margin-bottom: 0.3rem;
}

/* Referência cruzada (Veja também ...) */
.cross-refs {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 0.6rem;
    padding-left: 0.5rem;
}

/* Lista de Subentradas */
.subentry-list {
    list-style: none;
    padding-left: 1rem;
}

.subentry-item {
    font-size: 0.95rem;
    margin-bottom: 0.45rem;
    line-height: 1.5;
}

.subentry-desc {
    color: var(--text-primary);
}

.subentry-type {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.85rem;
    margin-left: 0.25rem;
}

.subentry-refs {
    margin-left: 0.35rem;
}

/* Links das Referências com Âncora */
.ref-link {
    color: var(--link-color);
    text-decoration: underline;
    text-underline-offset: 2px;
    font-weight: 600;
    transition: color 0.15s;
}

.ref-link:hover {
    color: var(--link-hover);
    text-decoration: none;
}

.ref-sep {
    color: var(--text-muted);
    margin: 0 0.25rem;
}

/* Estados de Carregamento e Vazio */
.loading-state,
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 0.8s linear infinite;
}

.btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.hidden {
    display: none !important;
}

/* --------------------------------------------------------------------------
   FOOTER
   -------------------------------------------------------------------------- */
.app-footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-color);
    background-color: #ffffff;
    margin-top: auto;
}

/* --------------------------------------------------------------------------
   RESPONSIVIDADE
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
    .input-group {
        flex-direction: column;
    }
    
    .btn-primary {
        width: 100%;
        justify-content: center;
    }

    .index-content-section {
        padding: 1.25rem;
    }

    .header-container {
        flex-direction: column;
        align-items: flex-start;
    }
}
