/* ── Search Page ───────────────────────────────────────────────────── */

.search-page {
    max-width: 760px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

.search-page-wide {
    max-width: none;
}

/* ── Header ────────────────────────────────────────────────────────── */
.search-header {
    margin-bottom: 2rem;
}

.search-header-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 0.25rem;
    letter-spacing: -0.01em;
}

.search-header-subtitle {
    font-size: 0.88rem;
    color: #64748b;
    margin: 0;
}

/* ── Search Bar ────────────────────────────────────────────────────── */
.search-box {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 14px;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.25s;
    margin-bottom: 1.75rem;
}

.search-box:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1), 0 1px 4px rgba(0, 0, 0, 0.04);
}

.search-box-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0 0 1.1rem;
    color: #94a3b8;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.search-box-input {
    flex: 1;
    border: none;
    padding: 0.85rem 1rem;
    font-size: 0.95rem;
    outline: none;
    background: transparent;
    color: #0f172a;
}

.search-box-input::placeholder {
    color: #94a3b8;
}

.search-box-btn {
    border: none;
    background: #3b82f6;
    color: #fff;
    padding: 0.85rem 1.5rem;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.search-box-btn:hover:not(:disabled) {
    background: #2563eb;
}

.search-box-btn:disabled {
    background: #94a3b8;
    cursor: default;
}

/* ── Stats ─────────────────────────────────────────────────────────── */
.search-stats {
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 1.25rem;
    padding-left: 0.25rem;
}

/* ── Result Card ───────────────────────────────────────────────────── */
.search-card {
    background: linear-gradient(135deg, rgba(255,255,255,0.96), rgba(255,255,255,0.88));
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 12px;
    padding: 1.15rem 1.25rem;
    margin-bottom: 0.75rem;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.8),
        0 2px 12px rgba(0, 0, 0, 0.05),
        0 1px 3px rgba(0, 0, 0, 0.03);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.search-card-open {
    border-color: #93c5fd;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.08);
}

/* ── Card Top Row (badge + score) ──────────────────────────────────── */
.search-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.search-card-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
}

.search-card-badge::before {
    content: "";
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.search-card-badge-blue {
    background: #eff6ff;
    color: #1d4ed8;
}
.search-card-badge-blue::before { background: #3b82f6; }

.search-card-badge-green {
    background: #f0fdf4;
    color: #15803d;
}
.search-card-badge-green::before { background: #22c55e; }

.search-card-score {
    font-size: 0.72rem;
    font-weight: 600;
    color: #64748b;
    background: #f1f5f9;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

/* ── Card Title + Meta ─────────────────────────────────────────────── */
.search-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.3;
    margin: 0 0 0.3rem;
    cursor: pointer;
}

.search-card-title:hover {
    color: #1d4ed8;
}

.search-card-meta {
    font-size: 0.82rem;
    color: #475569;
    margin: 0;
}

.search-card-meta-dot {
    margin: 0 0.4rem;
    color: #cbd5e1;
}

/* ── Divider ───────────────────────────────────────────────────────── */
.search-card-divider {
    border: none;
    border-top: 1px solid #f1f5f9;
    margin: 0.75rem 0;
}

/* ── Actions ───────────────────────────────────────────────────────── */
.search-card-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.search-card-action {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: none;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.35rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 500;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s;
}

.search-card-action:hover {
    border-color: #3b82f6;
    color: #1d4ed8;
    background: #f0f7ff;
}

.search-card-action-active {
    border-color: #3b82f6;
    color: #1d4ed8;
    background: #eff6ff;
}

/* ── Expanded Fields ───────────────────────────────────────────────── */
.search-card-fields {
    margin-top: 0.75rem;
    border-top: 1px solid #f1f5f9;
    padding-top: 0.75rem;
}

.search-fields-table {
    width: 100%;
    border-collapse: collapse;
}

.search-fields-table tr:nth-child(even) {
    background: #f8fafc;
}

.search-fields-table td {
    padding: 0.35rem 0.6rem;
    font-size: 0.78rem;
    vertical-align: top;
}

.search-fields-label {
    color: #64748b;
    font-weight: 500;
    width: 38%;
    white-space: nowrap;
}

.search-fields-value {
    color: #0f172a;
    word-break: break-word;
}

.search-fields-empty {
    color: #94a3b8;
    font-style: italic;
}

/* ── Empty State ───────────────────────────────────────────────────── */
.search-empty {
    text-align: center;
    padding: 4rem 1rem;
}

.search-empty-icon {
    font-size: 2.5rem;
    color: #cbd5e1;
    margin-bottom: 1rem;
}

.search-empty-title {
    font-size: 1rem;
    font-weight: 600;
    color: #334155;
    margin: 0 0 0.35rem;
}

.search-empty-hint {
    font-size: 0.82rem;
    color: #94a3b8;
    margin: 0;
}

/* ── Loading ───────────────────────────────────────────────────────── */
.search-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 3rem 0;
    color: #94a3b8;
    font-size: 0.88rem;
}

.search-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: search-spin 0.6s linear infinite;
}

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

/* ── Split layout con visor PDF ────────────────────────────────────── */
.search-layout {
    display: flex;
    gap: 0;
    align-items: flex-start;
    min-height: calc(100vh - 120px);
}

.search-col {
    flex: 1;
    min-width: 0;
}

.search-col-narrow {
    flex: 0 0 25%;
    min-width: 300px;
    padding-right: 1.25rem;
    overflow-y: auto;
    max-height: calc(100vh - 120px);
}

.pdf-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
}

.pdf-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.82rem;
    font-weight: 500;
    color: #334155;
    gap: 0.5rem;
}

.pdf-panel-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pdf-panel-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    font-size: 1rem;
    line-height: 1;
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    flex-shrink: 0;
}
.pdf-panel-close:hover { background: #f1f5f9; color: #475569; }

.pdf-iframe {
    border: none;
    width: 100%;
    height: calc(100vh - 175px);
    display: block;
}

/* ── Idle State ────────────────────────────────────────────────────── */
.search-idle {
    text-align: center;
    padding: 4rem 1rem;
    color: #94a3b8;
    font-size: 0.88rem;
}

/* ── Toolbar (index count + rebuild btn) ───────────────────────────── */
.search-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.8rem;
    color: #94a3b8;
}

.search-toolbar-info { flex: 1; }

.search-toolbar-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.75rem;
    font-size: 0.78rem;
    border: 1px solid #334155;
    border-radius: 6px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.15s;
}

.search-toolbar-btn:hover:not(:disabled) {
    border-color: #64748b;
    color: #cbd5e1;
}

.search-toolbar-btn:disabled { opacity: 0.5; cursor: default; }

/* ── Google-like result card ───────────────────────────────────────── */

/* Estado chips */
.sr-estado {
    display: inline-flex;
    align-items: center;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}
.sr-estado-valido     { background: #f0fdf4; color: #15803d; }
.sr-estado-incompleto { background: #fef3c7; color: #92400e; }
.sr-estado-exportado  { background: #eff6ff; color: #1d4ed8; }
.sr-estado-pendiente  { background: #f1f5f9; color: #64748b; }

/* Clickable title (Google link style) */
.sr-link {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    flex-wrap: wrap;
    cursor: pointer;
    margin-bottom: 0.5rem;
    text-decoration: none;
}

.sr-cc {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.sr-nombre {
    font-size: 1.05rem;
    font-weight: 600;
    color: #1d4ed8;
    line-height: 1.3;
}

.sr-link:hover .sr-nombre {
    text-decoration: underline;
    color: #1e40af;
}

.sr-sesion {
    font-size: 0.78rem;
    color: #94a3b8;
}

.sr-ext-icon {
    font-size: 0.65rem;
    color: #94a3b8;
    flex-shrink: 0;
    align-self: center;
}

/* Snippet rows */
.sr-snippet {
    font-size: 0.82rem;
    color: #475569;
    line-height: 1;
    margin-bottom: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.sr-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.sr-icon {
    font-size: 0.75rem;
    color: #94a3b8;
    flex-shrink: 0;
}

/* Toggle "Ver todos los campos" */
.sr-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.76rem;
    color: #3b82f6;
    cursor: pointer;
    padding: 0.2rem 0;
    transition: color 0.15s;
    user-select: none;
}

.sr-toggle:hover { color: #1d4ed8; text-decoration: underline; }
