/* ============================================================
   AtoM WP Bridge — Estilos que heredan de Elementor
   Paleta: violeta #493C70 · celeste #00C4F0 · hover #00C8A0
   Tipografía: Nunito Sans
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@300;400;600;700&display=swap');

/* ── Variables de color del plugin ───────────────────────────── */
.atom-bridge-wrapper {
    --atom-accent:        #493C70;
    --atom-accent-hover:  #00C8A0;
    --atom-accent-light:  rgba(73, 60, 112, 0.08);
    --atom-secondary:     #00C4F0;
    --atom-master:        #6b4c11;
    --atom-master-bg:     #fdf4e3;
    --atom-master-border: #e8c97a;
    --atom-border:        rgba(0,0,0,.10);
    --atom-bg:            rgba(0,0,0,.03);
    --atom-card-bg:       #ffffff;
    --atom-radius:        8px;
    --atom-shadow:        0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
    --atom-shadow-hover:  0 4px 16px rgba(0,0,0,.10), 0 12px 28px rgba(0,0,0,.06);
}

/* Nunito Sans + heredar del tema */
.atom-bridge-wrapper,
.atom-bridge-wrapper input,
.atom-bridge-wrapper textarea,
.atom-bridge-wrapper select,
.atom-bridge-wrapper button {
    font-family: 'Nunito Sans', inherit;
    font-size: inherit;
    color: inherit;
    box-sizing: border-box;
}

/* ── Título del fondo ─────────────────────────────────────────── */
.atom-bridge-title {
    font-size: 1.8em;
    font-weight: 700;
    margin: 0 0 1.25rem;
    padding-bottom: .75rem;
    border-bottom: 2px solid var(--atom-accent);
    font-family: 'Nunito Sans', inherit;
    text-align: center;
}

/* ── Search bar ───────────────────────────────────────────────── */
.atom-bridge-search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 1rem;
    align-items: stretch;
}
.atom-bridge-input-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}
.atom-bridge-search-icon {
    position: absolute;
    left: 12px;
    opacity: .45;
    pointer-events: none;
    display: flex;
    align-items: center;
}
.atom-bridge-search-icon svg { width: 16px; height: 16px; }
.atom-bridge-input {
    width: 100%;
    padding: 11px 38px 11px 40px;
    border: 1.5px solid var(--atom-border);
    border-radius: var(--atom-radius);
    background: var(--atom-card-bg);
    outline: none;
    transition: border-color .18s, box-shadow .18s;
    -webkit-appearance: none;
    appearance: none;
}
.atom-bridge-input:focus {
    border-color: var(--atom-accent);
    box-shadow: 0 0 0 3px var(--atom-accent-light);
}
.atom-bridge-input::placeholder { opacity: .5; }
.atom-bridge-clear-btn {
    position: absolute; right: 10px;
    background: none; border: none; cursor: pointer;
    opacity: .4; font-size: 12px; padding: 4px;
    transition: opacity .14s; line-height: 1;
}
.atom-bridge-clear-btn:hover { opacity: .8; }
.atom-bridge-search-btn {
    padding: 11px 20px;
    background: var(--atom-accent) !important;
    color: #fff;
    border: none;
    border-radius: var(--atom-radius);
    font-weight: 700;
    font-size: .9em;
    cursor: pointer;
    transition: background .22s ease, transform .1s;
    white-space: nowrap;
    letter-spacing: .02em;
}
.atom-bridge-search-btn:hover  { background: var(--atom-accent-hover); }
.atom-bridge-search-btn:active { transform: scale(.98); }

/* ── Toolbar ──────────────────────────────────────────────────── */
.atom-bridge-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .875rem;
    flex-wrap: wrap;
    gap: 8px;
    font-size: .82em;
    opacity: .7;
}
.atom-bridge-sort label { display: flex; align-items: center; gap: 6px; }
.atom-bridge-sort-select {
    font-size: .9em;
    padding: 4px 24px 4px 8px;
    border: 1px solid var(--atom-border);
    border-radius: 5px;
    background: var(--atom-card-bg);
    cursor: pointer;
    -webkit-appearance: none; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
}

/* ── Estados vacíos ───────────────────────────────────────────── */
.atom-bridge-initial-state,
.atom-bridge-no-results {
    text-align: center;
    padding: 2.5rem 1rem;
    opacity: .55;
    background: var(--atom-bg);
    border-radius: var(--atom-radius);
    border: 1px dashed var(--atom-border);
}
.atom-bridge-initial-state svg {
    width: 44px; height: 44px;
    margin: 0 auto .75rem;
    display: block;
}
.atom-bridge-initial-state p,
.atom-bridge-no-results p { font-size: .88em; line-height: 1.6; margin: 0; }
.atom-bridge-error {
    text-align: center; padding: 1.5rem;
    color: #922; background: #fff5f5;
    border: 1px solid #f0c0c0; border-radius: var(--atom-radius); font-size: .88em;
}

/* ── Loading ──────────────────────────────────────────────────── */
.atom-bridge-loading { text-align: center; padding: 2rem; opacity: .6; font-size: .88em; }
.atom-bridge-loading-spinner {
    width: 26px; height: 26px;
    border: 2px solid var(--atom-border);
    border-top-color: var(--atom-accent);
    border-radius: 50%;
    animation: atom-spin .65s linear infinite;
    margin: 0 auto .75rem;
}
@keyframes atom-spin { to { transform: rotate(360deg); } }

/* ── Grid ─────────────────────────────────────────────────────── */
.atom-bridge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: .875rem;
}

/* ── Tarjeta ──────────────────────────────────────────────────── */
.atom-record-card {
    display: flex;
    flex-direction: column;
    background: var(--atom-card-bg);
    border: 1px solid var(--atom-border);
    border-radius: var(--atom-radius);
    padding: 1.1rem;
    text-decoration: none !important;
    color: inherit !important;
    cursor: pointer;
    transition: box-shadow .2s, transform .15s, border-color .2s;
    box-shadow: var(--atom-shadow);
    position: relative;
    overflow: hidden;
}
.atom-record-card:hover {
    box-shadow: var(--atom-shadow-hover);
    transform: translateY(-2px);
    border-color: var(--atom-accent);
    color: inherit !important;
    text-decoration: none !important;
}
.atom-record-card.has-master {
    border-color: var(--atom-master-border);
    background: linear-gradient(to bottom, var(--atom-master-bg) 0%, var(--atom-card-bg) 55%);
}
.atom-record-card.has-master:hover { border-color: var(--atom-master); }

.atom-master-badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: .68em; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em;
    color: var(--atom-master);
    background: var(--atom-master-bg);
    border: 1px solid var(--atom-master-border);
    border-radius: 4px; padding: 3px 8px; margin-bottom: 9px;
}
.atom-master-badge svg { width: 11px; height: 11px; }

.atom-record-header { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 10px; }
.atom-record-level {
    font-size: .68em; font-weight: 700;
    text-transform: uppercase; letter-spacing: .07em;
    color: var(--atom-accent);
    background: var(--atom-accent-light);
    padding: 2px 7px; border-radius: 100px;
}
.atom-record-ref {
    font-size: .68em;
    font-family: 'Nunito Sans', monospace;
    opacity: .55;
    background: var(--atom-bg);
    padding: 3px 10px; border-radius: 100px;
    border: 1px solid var(--atom-border);
    letter-spacing: .01em;
}
.atom-record-title {
    font-size: 1.05em;
    font-weight: 700;
    line-height: 1.35;
    margin: 0 0 10px;
}
.atom-record-excerpt {
    font-size: .84em;
    line-height: 1.55;
    opacity: .7;
    margin: 0;
    flex: 1;
}
.atom-record-meta {
    display: flex; flex-wrap: wrap; gap: 9px;
    margin-top: auto; padding-top: 10px;
    font-size: .76em; opacity: .55;
}
.atom-meta-item { display: flex; align-items: center; gap: 4px; }
.atom-meta-item svg { width: 11px; height: 11px; flex-shrink: 0; }
.atom-card-footer { margin-top: 10px; }
.atom-access-hint { font-size: .78em; font-weight: 700; color: var(--atom-accent); opacity: 0; transition: opacity .18s; }
.has-master .atom-access-hint { color: var(--atom-master); }
.atom-record-card:hover .atom-access-hint { opacity: 1; }

/* ── Paginación ───────────────────────────────────────────────── */
.atom-bridge-pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 4px; margin-top: 1.75rem; flex-wrap: wrap;
}
.atom-page-btn {
    padding: 7px 12px;
    border: 1px solid var(--atom-border);
    border-radius: 5px;
    background: var(--atom-card-bg);
    font-size: .84em; cursor: pointer;
    transition: all .14s;
    min-width: 34px; text-align: center; color: inherit;
}
.atom-page-btn:hover:not(:disabled) {
    border-color: var(--atom-accent-hover); color: var(--atom-accent-hover); background: rgba(0,200,160,.08);
}
.atom-page-btn.atom-page-active {
    background: var(--atom-accent); border-color: var(--atom-accent); color: #fff !important; font-weight: 700;
}
.atom-page-btn:disabled { opacity: .35; cursor: not-allowed; }
.atom-page-ellipsis { padding: 7px 2px; opacity: .45; font-size: .84em; }

/* ── Modal ────────────────────────────────────────────────────── */
.atom-bridge-modal {
    position: fixed; inset: 0; z-index: 999999;
    display: flex; align-items: flex-start; justify-content: center;
    padding: 2rem 1rem; overflow-y: auto;
}
.atom-bridge-modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    cursor: pointer;
}
.atom-bridge-modal-box {
    position: relative;
    background: var(--atom-card-bg);
    border-radius: 10px;
    width: 100%; max-width: 720px;
    box-shadow: 0 24px 80px rgba(0,0,0,.22);
    z-index: 1;
    animation: atom-modal-in .2s ease;
    margin: auto;
}
@keyframes atom-modal-in {
    from { opacity:0; transform: translateY(18px) scale(.97); }
    to   { opacity:1; transform: none; }
}
.atom-bridge-modal-close {
    position: absolute; top: 14px; right: 14px;
    background: var(--atom-bg); border: 1px solid var(--atom-border);
    border-radius: 50%; width: 30px; height: 30px;
    cursor: pointer; font-size: 13px; color: inherit;
    display: flex; align-items: center; justify-content: center;
    transition: all .15s; z-index: 2; line-height: 1;
}
.atom-bridge-modal-close:hover { background: #fee; color: #c00; border-color: #fcc; }
.atom-bridge-modal-content {
    padding: 1.75rem; min-height: 60px;
    display: flex; align-items: center; justify-content: center;
}
.atom-bridge-modal-content:has(.atom-detail) { display: block; }

/* ── Detalle del registro ─────────────────────────────────────── */
.atom-detail-title {
    font-size: 1.5em; font-weight: 400; line-height: 1.3;
    margin: 0 0 1.1rem;
    padding: 0 2rem .875rem 0;
    border-bottom: 1px solid var(--atom-border);
}
.atom-detail-section {
    margin-bottom: 1rem;
    border: 1px solid var(--atom-border);
    border-radius: var(--atom-radius);
    overflow: hidden;
}
.atom-detail-section-title {
    font-size: .7em; font-weight: 700;
    text-transform: uppercase; letter-spacing: .08em;
    color: var(--atom-accent);
    background: var(--atom-accent-light);
    margin: 0; padding: 6px 12px;
    border-bottom: 1px solid var(--atom-border);
}
.atom-detail-section .atom-detail-fields { margin: 0; }
.atom-detail-section .atom-detail-row { padding: 8px 12px; border-bottom: 1px solid var(--atom-bg); }
.atom-detail-section .atom-detail-row:last-child { border-bottom: none; }
.atom-detail-row {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 8px; align-items: baseline;
}
.atom-detail-row dt {
    font-size: .72em; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em; opacity: .55;
}
.atom-detail-row dd { font-size: .88em; margin: 0; line-height: 1.55; opacity: .85; }

/* Tags puntos de acceso */
.atom-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.atom-tag {
    display: inline-block;
    font-size: .75em; padding: 3px 9px;
    background: var(--atom-accent-light);
    color: var(--atom-accent);
    border: 1px solid rgba(26,79,114,.18);
    border-radius: 100px; font-weight: 600; line-height: 1.4;
}

/* ── Bloque Archivo Maestro ───────────────────────────────────── */
.atom-master-block {
    display: flex; gap: 14px; align-items: flex-start;
    background: var(--atom-master-bg);
    border: 1px solid var(--atom-master-border);
    border-radius: var(--atom-radius);
    padding: 1rem; margin-bottom: 1.25rem;
}
.atom-master-block-icon svg { width: 40px; height: 40px; color: var(--atom-master); flex-shrink: 0; }
.atom-master-block-text strong { display: block; font-size: .9em; color: var(--atom-master); margin-bottom: 3px; }
.atom-master-block-text p { font-size: .83em; margin: 0; line-height: 1.55; opacity: .8; }

/* ── Formulario solicitud de acceso ───────────────────────────── */
.atom-access-form {
    background: var(--atom-bg);
    border: 1px solid var(--atom-border);
    border-radius: var(--atom-radius);
    padding: 1.25rem; margin-bottom: 1.125rem;
}
.atom-form-title { font-size: 1.05em; font-weight: 600; margin: 0 0 1rem; }
.atom-form-row { margin-bottom: .875rem; }
.atom-form-row label {
    display: block; font-size: .75em; font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em; opacity: .6; margin-bottom: 4px;
}
.atom-required { color: #c44; }
.atom-form-row input,
.atom-form-row textarea {
    width: 100%; padding: 9px 12px;
    border: 1.5px solid var(--atom-border);
    border-radius: 5px; background: var(--atom-card-bg);
    outline: none;
    transition: border-color .18s, box-shadow .18s;
    -webkit-appearance: none; appearance: none; resize: vertical;
}
.atom-form-row input:focus,
.atom-form-row textarea:focus {
    border-color: var(--atom-accent);
    box-shadow: 0 0 0 3px var(--atom-accent-light);
}
.atom-form-row input::placeholder,
.atom-form-row textarea::placeholder { opacity: .45; }
.atom-form-notice {
    font-size: .8em; opacity: .6; padding: 7px 11px;
    background: var(--atom-card-bg);
    border: 1px dashed var(--atom-border); border-radius: 5px; margin-bottom: 1rem;
}
.atom-form-actions { display: flex; justify-content: flex-end; }
.atom-submit-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 20px;
    background: var(--atom-accent) !important; color: #fff !important;
    border: none !important; border-radius: 6px;
    font-weight: 700; font-size: .9em; letter-spacing: .02em;
    cursor: pointer; transition: background .22s ease, transform .1s;
}
.atom-submit-btn svg { width: 13px; height: 13px; }
.atom-submit-btn:hover  { background: var(--atom-accent-hover) !important; color: #fff !important; }
.atom-submit-btn:active { transform: scale(.98); }
.atom-submit-btn:disabled { opacity: .6; cursor: not-allowed; }
.atom-form-feedback { margin-top: .75rem; padding: 9px 13px; border-radius: 5px; font-size: .875em; font-weight: 600; }
.atom-form-feedback.success { background: #edf7ed; color: #1a5c1a; border: 1px solid #b3dcb3; }
.atom-form-feedback.error   { background: #fff5f5; color: #922;    border: 1px solid #f0c0c0; }

/* ── Pie del detalle ──────────────────────────────────────────── */
.atom-detail-footer { padding-top: 1rem; border-top: 1px solid var(--atom-border); margin-top: .5rem; }
.atom-detail-link {
    font-size: .85em; font-weight: 500; opacity: .5;
    text-decoration: none; transition: opacity .15s; color: inherit;
}
.atom-detail-link:hover { opacity: .9; color: var(--atom-accent); }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 580px) {
    .atom-bridge-search-bar { flex-direction: column; }
    .atom-bridge-search-btn { width: 100%; }
    .atom-bridge-grid       { grid-template-columns: 1fr; }
    .atom-bridge-toolbar    { flex-direction: column; align-items: flex-start; }
    .atom-detail-row        { grid-template-columns: 1fr; gap: 2px; }
    .atom-bridge-modal      { padding: .5rem; }
    .atom-master-block      { flex-direction: column; gap: 10px; }
}

/* ── Thumbnail YouTube en tarjeta ─────────────────────────────── */
.atom-card-thumb {
    position: relative;
    width: calc(100% + 2.2rem);
    margin: -1.1rem -1.1rem .9rem;
    border-radius: var(--atom-radius) var(--atom-radius) 0 0;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    background: #000;
}
.atom-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .3s ease, opacity .2s;
    opacity: .92;
}
.atom-record-card:hover .atom-card-thumb img {
    transform: scale(1.03);
    opacity: 1;
}
.atom-card-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,.25);
    transition: background .2s;
}
.atom-record-card:hover .atom-card-play {
    background: rgba(0,0,0,.15);
}
.atom-card-play svg {
    width: 48px;
    height: 48px;
    color: #fff;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,.5));
    transition: transform .2s;
}
.atom-record-card:hover .atom-card-play svg {
    transform: scale(1.12);
}

/* ── Embed YouTube en modal ───────────────────────────────────── */
.atom-video-block {
    margin-bottom: 1.25rem;
    border-radius: var(--atom-radius);
    overflow: hidden;
    border: 1px solid var(--atom-border);
}
.atom-video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    background: #000;
}
.atom-video-wrapper iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
}
.atom-video-caption {
    font-size: .8em;
    padding: .6rem .9rem;
    opacity: .65;
    margin: 0;
    border-top: 1px solid var(--atom-border);
}

/* ── Miniatura en modal ───────────────────────────────────────── */
.atom-detail-thumb {
    margin-bottom: 1.25rem;
    border-radius: var(--atom-radius);
    overflow: hidden;
    border: 1px solid var(--atom-border);
    max-height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}
.atom-detail-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    max-height: 320px;
}
