/* ══════════════════════════════════════════════════
   Fallos Judiciales — Frontend
   ══════════════════════════════════════════════════ */

:root {
    --fj-primary:    #1a2744;
    --fj-accent:     #2563eb;
    --fj-accent-lt:  #dbeafe;
    --fj-green:      #15803d;
    --fj-green-lt:   #dcfce7;
    --fj-border:     #e2e8f0;
    --fj-bg:         #f8fafc;
    --fj-card-bg:    #ffffff;
    --fj-text:       #1e293b;
    --fj-muted:      #64748b;
    --fj-mark:       #fef08a;
    --fj-radius:     8px;
    --fj-shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --fj-shadow-md:  0 4px 12px rgba(0,0,0,.10);
}

/* ── Wrap ── */
.fj-wrap {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 0 40px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--fj-text);
}

/* ── Header buscador ── */
.fj-search-header {
    margin-bottom: 20px;
}
.fj-search-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--fj-primary);
    margin: 0 0 6px;
}
.fj-search-desc {
    color: var(--fj-muted);
    font-size: .95rem;
    margin: 0;
}

/* ── Caja de búsqueda ── */
.fj-search-box {
    margin-bottom: 20px;
}
.fj-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}
.fj-icon-search {
    position: absolute;
    left: 14px;
    width: 20px;
    height: 20px;
    color: var(--fj-muted);
    pointer-events: none;
}
.fj-input {
    width: 100%;
    padding: 13px 44px 13px 44px;
    font-size: 1rem;
    border: 2px solid var(--fj-border);
    border-radius: var(--fj-radius);
    background: var(--fj-card-bg);
    color: var(--fj-text);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    box-sizing: border-box;
}
.fj-input:focus {
    border-color: var(--fj-accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.fj-clear-btn {
    position: absolute;
    right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--fj-muted);
    cursor: pointer;
    padding: 0;
    border-radius: 50%;
    transition: color .15s, background .15s;
}
.fj-clear-btn:hover {
    color: var(--fj-text);
    background: var(--fj-border);
}
.fj-clear-btn svg { width: 18px; height: 18px; }

/* ── Loading ── */
.fj-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--fj-muted);
    font-size: .9rem;
    margin-bottom: 12px;
}
.fj-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--fj-border);
    border-top-color: var(--fj-accent);
    border-radius: 50%;
    animation: fj-spin .7s linear infinite;
}
@keyframes fj-spin { to { transform: rotate(360deg); } }

/* ── Conteo resultados ── */
.fj-result-count {
    font-size: .875rem;
    color: var(--fj-muted);
    margin-bottom: 16px;
}

/* ── Resultados ── */
.fj-results {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.fj-no-results {
    color: var(--fj-muted);
    font-style: italic;
}

/* ── Card ── */
.fj-card {
    background: var(--fj-card-bg);
    border: 1px solid var(--fj-border);
    border-radius: var(--fj-radius);
    padding: 20px 22px;
    box-shadow: var(--fj-shadow);
    transition: box-shadow .15s;
}
.fj-card:hover {
    box-shadow: var(--fj-shadow-md);
}
.fj-card-title-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.fj-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--fj-primary);
    margin: 0;
    flex: 1;
    min-width: 0;
}
.fj-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 6px;
}
.fj-meta-item {
    font-size: .82rem;
    color: var(--fj-muted);
}
.fj-partes {
    font-size: .85rem;
    color: var(--fj-muted);
    margin: 4px 0 8px;
    font-style: italic;
}

/* ── Badges ── */
.fj-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .02em;
    white-space: nowrap;
    flex-shrink: 0;
}
.fj-badge-text { background: var(--fj-accent-lt); color: var(--fj-accent); }
.fj-badge-tax  { background: var(--fj-green-lt);  color: var(--fj-green); }

/* ── Tags ── */
.fj-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 6px 0;
}
.fj-tag-label {
    font-size: .78rem;
    font-weight: 600;
    color: var(--fj-muted);
}
.fj-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: .78rem;
    font-weight: 500;
}
.fj-tag-voz     { background: #ede9fe; color: #6d28d9; }
.fj-tag-concepto{ background: #fef3c7; color: #92400e; }

/* ── Párrafo preview ── */
.fj-parrafo-preview {
    margin: 10px 0;
    padding: 12px 14px;
    background: var(--fj-bg);
    border-left: 3px solid var(--fj-accent);
    border-radius: 0 var(--fj-radius) var(--fj-radius) 0;
    font-size: .9rem;
    line-height: 1.65;
    color: #374151;
}
.fj-parrafo-preview p { margin: 0; }

/* ── Highlight ── */
mark {
    background: var(--fj-mark);
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

/* ── Botones ── */
.fj-card-actions {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
}
.fj-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 14px;
    border-radius: 6px;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: none;
    transition: background .15s, color .15s;
}
.fj-btn-viewer {
    background: var(--fj-primary);
    color: #fff;
}
.fj-btn-viewer:hover { background: #263660; }

.fj-btn-download {
    background: transparent;
    color: var(--fj-accent);
    border: 1.5px solid var(--fj-accent);
}
.fj-btn-download:hover {
    background: var(--fj-accent-lt);
}

.fj-btn-more {
    background: var(--fj-bg);
    color: var(--fj-accent);
    border: 1.5px solid var(--fj-accent);
    width: 100%;
    justify-content: center;
    padding: 10px;
}
.fj-btn-more:hover { background: var(--fj-accent-lt); }

.fj-load-more-wrap {
    display: flex;
    margin-top: 20px;
}

/* ── Mensajes ── */
.fj-error {
    color: #dc2626;
    font-size: .9rem;
}
.fj-login-required {
    padding: 20px;
    background: var(--fj-bg);
    border: 1px solid var(--fj-border);
    border-radius: var(--fj-radius);
    text-align: center;
    color: var(--fj-muted);
}
.fj-login-required a { color: var(--fj-accent); }

/* ── Modal ── */
.fj-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.55);
    z-index: 99999;
    align-items: flex-start;
    justify-content: center;
    padding: 32px 16px;
    overflow-y: auto;
    backdrop-filter: blur(2px);
}
.fj-modal-overlay.active {
    display: flex;
}
.fj-modal {
    position: relative;
    background: var(--fj-card-bg);
    border-radius: 10px;
    width: 100%;
    max-width: 820px;
    min-height: 300px;
    box-shadow: 0 20px 60px rgba(0,0,0,.22);
    display: flex;
    flex-direction: column;
    animation: fj-slide-in .18s ease-out;
}
@keyframes fj-slide-in {
    from { opacity: 0; transform: translateY(-12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.fj-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--fj-bg);
    color: var(--fj-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}
.fj-modal-close:hover {
    background: var(--fj-border);
    color: var(--fj-text);
}
.fj-modal-body {
    padding: 28px 28px 32px;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.fj-modal-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--fj-muted);
    padding: 40px 0;
    justify-content: center;
}

/* Viewer header */
.fj-viewer-header {
    border-bottom: 1px solid var(--fj-border);
    padding-bottom: 16px;
    margin-bottom: 20px;
}
.fj-viewer-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}
.fj-viewer-title-row h2 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--fj-primary);
    flex: 1;
}
.fj-viewer-meta {
    font-size: .85rem;
    color: var(--fj-muted);
    margin: 3px 0;
}

/* PDF iframe */
.fj-pdf-iframe {
    flex: 1;
    width: 100%;
    min-height: 600px;
    border: none;
    border-radius: 4px;
}

/* Texto viewer */
.fj-texto-viewer {
    font-size: .92rem;
    line-height: 1.8;
    color: var(--fj-text);
    overflow-y: auto;
    max-height: 72vh;
    padding-right: 6px;
}
.fj-texto-viewer p {
    margin: 0 0 1em;
    text-align: justify;
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .fj-card { padding: 16px; }
    .fj-modal { border-radius: 8px; }
    .fj-modal-body { padding: 20px 16px 24px; }
    .fj-viewer-title-row { flex-direction: column; }
    .fj-pdf-iframe { min-height: 400px; }
}
