/* ═══════════════════════════════════════════════════════════════
   TRACTS VIEWER — Styles
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@0,300..800;1,300..800&display=swap');

#tracts-viewer {
    font-family: 'Open Sans', sans-serif;
    color: #1a1a1a;
    max-width: 760px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ─── SEARCH ─────────────────────────────────────────────────── */
.tv-search-section {
    position: relative;
    margin-bottom: 28px;
}

.tv-search-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
    padding-left: 4px;
}

.tv-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.tv-search-icon {
    position: absolute;
    left: 16px;
    color: #007D8F;
    pointer-events: none;
}

#tv-search-input {
    width: 100%;
    padding: 6px 48px;
    font-size: 16px;
    font-family: 'DM Sans', sans-serif;
    border: 2px solid #e8e6e1;
    border-radius: 14px;
    background: #fff;
    color: #1a1a1a;
    outline: none;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
    transition: border-color 0.2s, box-shadow 0.2s;
}

#tv-search-input:focus {
    border-color: #007D8F;
    box-shadow: 0 4px 20px rgba(45,90,61,0.12);
}

#tv-search-input::placeholder {
    color: #aaa;
}

.tv-clear-btn {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
}

.tv-clear-btn:hover {
    color: #333;
}

/* ─── SUGGESTIONS ────────────────────────────────────────────── */
.tv-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 14px;
    border: 1px solid #e8e6e1;
    box-shadow: 0 12px 32px rgba(0,0,0,0.1);
    overflow: hidden;
    z-index: 50;
    margin-top: 6px;
}

.tv-suggestion-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 20px;
    font-size: 15px;
    font-family: 'Open Sans', sans-serif;
    color: #333;
    background: none;
    border: none;
    border-bottom: 1px solid #f2f0ec;
    cursor: pointer;
    text-align: left;
    transition: background 0.1s;
}

.tv-suggestion-item:last-child {
    border-bottom: none;
}

.tv-suggestion-item:hover,
.tv-suggestion-item.is-active {
    background: #f0f7f2;
}

.tv-suggestion-item svg {
    flex-shrink: 0;
    opacity: 0.4;
}

.tv-suggestion-match {
    color: #007D8F;
    font-weight: 700;
}

.tv-suggestion-empty {
    padding: 16px 20px;
    color: #999;
    font-size: 14px;
    text-align: center;
}

/* ─── RESULTS ────────────────────────────────────────────────── */
.tv-results {
    min-height: 200px;
}

.tv-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
    color: #888;
    font-size: 15px;
}

.tv-empty-state svg {
    color: #007D8F;
    margin-bottom: 12px;
}

.tv-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.tv-store-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #007D8F;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 10px;
}

.tv-count-badge {
    font-size: 13px;
    color: #888;
    font-weight: 500;
}

/* ─── GRID DE CARTES ─────────────────────────────────────────── */
.tv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.tv-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    cursor: pointer;
    border: none;
    padding: 0;
    text-align: left;
    font-family: 'DM Sans', sans-serif;
    color: inherit;
    width: 100%;
}

.tv-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.12);
}

.tv-card:hover .tv-card-overlay {
    opacity: 1;
}

.tv-card-header {
    padding: 14px 16px;
    background: #fff;
    border-bottom: 1px solid #f0ede8;
    z-index: 2;
}

.tv-card-title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 4px;
}

.tv-card-date {
    font-size: 12px;
    color: #007D8F;
    font-weight: 600;
    margin: 0;
}

.tv-card-img-wrap {
    position: relative;
    flex-grow: 1;
    background: #f0ede8;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.tv-card-img-wrap img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

.tv-card-overlay {
    position: absolute;
    inset: 0;
    background: rgba(45,90,61,0.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #fff;
    opacity: 0;
    transition: opacity 0.25s ease;
    font-size: 13px;
    font-weight: 500;
}

/* ─── SPINNER ────────────────────────────────────────────────── */
@keyframes tv-spin {
    to { transform: rotate(360deg); }
}

.tv-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e8e6e1;
    border-top-color: #007D8F;
    border-radius: 50%;
    animation: tv-spin 0.8s linear infinite;
    margin-bottom: 12px;
}

.tv-spinner--light {
    border-color: #444;
    border-top-color: #007D8F;
}

/* ═══════════════════════════════════════════════════════════════
   PDF VIEWER MODAL
   ═══════════════════════════════════════════════════════════════ */

@keyframes tv-fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes tv-slideUp {
    from { opacity: 0; transform: translateY(20px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.tv-pdf-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(6px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: tv-fadeIn 0.2s ease;
}

.tv-pdf-viewer {
    width: 96vw;
    max-width: 1000px;
    height: 94vh;
    background: #1a1a1a;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 32px 64px rgba(0,0,0,0.5);
    animation: tv-slideUp 0.3s ease;
}

/* Top bar */
.tv-pdf-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #242424;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
}

.tv-pdf-topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.tv-pdf-title {
    font-size: 15px;
    font-weight: 600;
    color: #eee;
    font-family: 'Open Sans', sans-serif;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.tv-pdf-icon-btn {
    background: rgba(255,255,255,0.07);
    border: none;
    color: #ccc;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}

.tv-pdf-icon-btn:hover {
    background: rgba(255,255,255,0.14);
}

.tv-pdf-icon-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.tv-pdf-dl-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    background: rgba(255,255,255,0.07);
    color: #ccc;
    text-decoration: none;
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    flex-shrink: 0;
    transition: background 0.15s;
}

.tv-pdf-dl-btn:hover {
    background: rgba(255,255,255,0.14);
    color: #fff;
}

/* Canvas */
.tv-pdf-canvas-wrap {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 24px;
    background: #2e2e2e;
}

#tv-pdf-canvas {
    border-radius: 4px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.3);
    transition: opacity 0.15s;
}

.tv-pdf-centered {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 40px;
    color: #888;
    font-size: 14px;
}

/* Bottom toolbar */
.tv-pdf-bottombar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    background: #242424;
    border-top: 1px solid #333;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.tv-pdf-page-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #bbb;
    font-family: 'DM Sans', sans-serif;
    font-weight: 500;
    padding: 0 4px;
}

.tv-pdf-page-sep {
    color: #666;
}

#tv-pdf-page-input {
    width: 44px;
    text-align: center;
    background: rgba(255,255,255,0.1);
    border: 1px solid #555;
    border-radius: 6px;
    color: #fff;
    font-size: 14px;
    padding: 4px 2px;
    font-family: 'Open Sans', sans-serif;
    outline: none;
}

#tv-pdf-page-input:focus {
    border-color: #007D8F;
    box-shadow: none;
}

.tv-pdf-zoom-label {
    background: none;
    border: none;
    color: #999;
    font-size: 13px;
    cursor: pointer;
    font-family: 'Open Sans', sans-serif;
    padding: 4px 8px;
    min-width: 48px;
    text-align: center;
}

.tv-pdf-zoom-label:hover {
    color: #ccc;
}

.tv-pdf-sep {
    width: 1px;
    height: 22px;
    background: #444;
    margin: 0 6px;
}

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 600px) {
    .tv-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .tv-pdf-viewer {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }

    .tv-pdf-bottombar {
        gap: 4px;
        padding: 8px 10px;
    }

    .tv-pdf-dl-btn span {
        display: none;
    }
}