/* ═══════════════════════════════════════════════════
   COSAVE Inspectores — Frontend Styles v1.1
   ═══════════════════════════════════════════════════ */

/* ── Login required ──────────────────────────────── */
.cosave-login-required {
    background: #fff3e0;
    border-left: 4px solid #ff9800;
    padding: 16px 20px;
    border-radius: 4px;
    font-size: 15px;
}
.cosave-login-required a { color: #e65100; }

/* ── Contenedor ──────────────────────────────────── */
.cosave-front-wrap {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #333;
    margin: 0 0 24px;
}

.cosave-front-header {
    background: linear-gradient(135deg, #1b5e20 0%, #2e7d32 100%);
    color: #fff;
    padding: 18px 24px;
    border-radius: 8px 8px 0 0;
}
.cosave-front-header h3 { margin: 0 0 6px; font-size: 17px; color: #fff; }
.cosave-front-desc      { margin: 0; font-size: 13px; opacity: .82; }

/* ── Filtros ─────────────────────────────────────── */
.cosave-front-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    padding: 12px 16px;
    background: #f1f8e9;
    border: 1px solid #c5e1a5;
    border-top: 0;
}
.cosave-front-filters input[type="search"],
.cosave-front-filters select {
    height: 34px;
    border: 1px solid #aed581;
    border-radius: 5px;
    padding: 0 12px;
    font-size: 13px;
    background: #fff;
}
.cosave-front-filters input[type="search"] { flex: 1; min-width: 180px; }
.cosave-count-badge {
    margin-left: auto;
    font-size: 12px;
    color: #558b2f;
    font-weight: 600;
    white-space: nowrap;
}
.cosave-count-zero { color: #c62828; }

/* ── Tabla ───────────────────────────────────────── */
.cosave-table-responsive { overflow-x: auto; }
.cosave-front-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    border: 1px solid #c5e1a5;
    border-top: 0;
}
.cosave-front-table thead th {
    background: #2e7d32;
    color: #fff;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}
.cosave-th-firma { text-align: center !important; width: 95px; }
.cosave-front-table tbody tr { border-bottom: 1px solid #e8f5e9; transition: background .12s; }
.cosave-front-table tbody tr:hover { background: #f9fbe7; }
.cosave-front-table tbody td { padding: 9px 12px; vertical-align: middle; }
.cosave-front-table tbody tr:last-child { border-bottom: none; }

.cosave-empty-row { text-align: center; padding: 30px !important; color: #888; }
.cosave-date-col  { white-space: nowrap; font-size: 12px; color: #555; }

.cosave-front-row-baja td { opacity: .45; }
.cosave-badge-baja-front {
    display: inline-block;
    background: #ffebee;
    color: #b71c1c;
    border: 1px solid #ef9a9a;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    padding: 0 5px;
    margin-left: 4px;
    vertical-align: middle;
    text-transform: uppercase;
}
.cosave-activo-dot { color: #43a047; font-size: 10px; }

/* ── Firmas en tabla ─────────────────────────────── */
.cosave-front-firma { text-align: center; }
.cosave-no-firma    { color: #bbb; font-size: 18px; }

.cosave-firma-btn {
    position: relative;
    display: inline-block;
    background: none;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    padding: 3px;
    cursor: zoom-in;
    transition: border-color .15s, box-shadow .15s;
    vertical-align: middle;
}
.cosave-firma-btn:hover,
.cosave-firma-btn:focus {
    border-color: #2e7d32;
    box-shadow: 0 0 0 3px rgba(46,125,50,.18);
    outline: none;
}
.cosave-firma-thumb-front {
    display: block;
    max-width: 88px;
    max-height: 44px;
    background: #fff;
}
.cosave-zoom-icon {
    position: absolute;
    bottom: 2px;
    right: 3px;
    font-size: 11px;
    color: #2e7d32;
    background: rgba(255,255,255,.85);
    border-radius: 50%;
    line-height: 1;
    pointer-events: none;
}

/* ── Banderas ────────────────────────────────────── */
.cosave-flag::before { font-size: 15px; margin-right: 4px; vertical-align: middle; }
.cosave-flag-ar::before { content: '🇦🇷'; }
.cosave-flag-bo::before { content: '🇧🇴'; }
.cosave-flag-br::before { content: '🇧🇷'; }
.cosave-flag-cl::before { content: '🇨🇱'; }
.cosave-flag-py::before { content: '🇵🇾'; }
.cosave-flag-pe::before { content: '🇵🇪'; }
.cosave-flag-uy::before { content: '🇺🇾'; }

/* ── Footer ──────────────────────────────────────── */
.cosave-front-footer {
    font-size: 11px;
    color: #aaa;
    text-align: right;
    margin: 6px 0 0;
    padding: 4px 0;
    border-top: 1px solid #eee;
}

/* ═══════════════════════════════════════════════════
   LIGHTBOX
   ═══════════════════════════════════════════════════ */

/* Bloquear scroll del body cuando lightbox está abierto */
body.cosave-lb-open { overflow: hidden; }

.cosave-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cosave-lightbox[hidden] { display: none !important; }

.cosave-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .72);
    backdrop-filter: blur(3px);
    cursor: zoom-out;
}

.cosave-lightbox-container {
    position: relative;
    z-index: 1;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0,0,0,.45);
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 280px;
}

/* Header */
.cosave-lightbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #1b5e20;
    color: #fff;
    gap: 12px;
    flex-shrink: 0;
}
.cosave-lightbox-title {
    font-size: 13px;
    font-weight: 600;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cosave-lightbox-close {
    background: rgba(255,255,255,.15);
    border: none;
    color: #fff;
    font-size: 16px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
.cosave-lightbox-close:hover,
.cosave-lightbox-close:focus { background: rgba(255,255,255,.3); outline: none; }

/* Body */
.cosave-lightbox-body {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    min-height: 120px;
    background: #fafafa;
}

.cosave-lightbox-img {
    max-width: 100%;
    max-height: calc(90vh - 130px);
    display: block;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 2px 12px rgba(0,0,0,.12);
}

/* Loading */
.cosave-lightbox-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #666;
    font-size: 14px;
}
.cosave-spinner {
    display: inline-block;
    width: 22px;
    height: 22px;
    border: 3px solid #c8e6c9;
    border-top-color: #2e7d32;
    border-radius: 50%;
    animation: cosave-spin .7s linear infinite;
    flex-shrink: 0;
}
@keyframes cosave-spin { to { transform: rotate(360deg); } }

.cosave-lightbox-error {
    color: #c62828;
    font-size: 14px;
    padding: 20px;
    text-align: center;
}

/* Footer */
.cosave-lightbox-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    border-top: 1px solid #e8f5e9;
    background: #f9fbe7;
    flex-shrink: 0;
    gap: 12px;
}
.cosave-lightbox-hint {
    font-size: 11px;
    color: #888;
}
.cosave-lightbox-hint kbd {
    background: #eee;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 0 4px;
    font-size: 10px;
}
.cosave-lightbox-open-btn {
    font-size: 12px;
    color: #2e7d32;
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
}
.cosave-lightbox-open-btn:hover { text-decoration: underline; }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 680px) {
    .cosave-front-table thead th:nth-child(5),
    .cosave-front-table tbody td:nth-child(5) { display: none; }
    .cosave-lightbox-footer { flex-direction: column; align-items: flex-start; gap: 6px; }
    .cosave-lightbox-hint   { display: none; }
}

/* ── Lightbox ────────────────────────────────────── */
.cosave-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: cosaveLbFadeIn .18s ease;
}
@keyframes cosaveLbFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.cosave-lightbox[hidden] { display: none !important; }

.cosave-lb-inner {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    max-width: 90vw;
    max-height: 90vh;
}

.cosave-lb-img {
    width: clamp(320px, 60vw, 800px);
    height: 260px;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 8px 40px rgba(0,0,0,.6);
    background: #fff;
    padding: 16px;
    transition: opacity .25s;
    display: block;
}

.cosave-lb-label {
    color: rgba(255,255,255,.85);
    font-size: 13px;
    text-align: center;
    margin: 0;
    max-width: 80vw;
}

.cosave-lb-spinner {
    color: rgba(255,255,255,.7);
    font-size: 15px;
}

.cosave-lb-close {
    position: fixed;
    top: 18px;
    right: 22px;
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.25);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    cursor: pointer;
    transition: background .15s, transform .15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cosave-lb-close:hover {
    background: rgba(255,255,255,.3);
    transform: rotate(90deg);
}

/* Cursor en thumbnails */
.cosave-firma-img {
    cursor: zoom-in;
    max-width: 90px;
    max-height: 45px;
    display: block;
    margin: auto;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    background: #fff;
    transition: box-shadow .15s, transform .15s;
}
.cosave-firma-img:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,.18);
    transform: scale(1.05);
}

/* Link admin ────────────────────────────────────── */
.cosave-admin-link {
    display: inline-block;
    margin-top: 8px;
    background: rgba(255,255,255,.2);
    color: #fff;
    border: 1px solid rgba(255,255,255,.35);
    border-radius: 4px;
    padding: 4px 12px;
    font-size: 12px;
    text-decoration: none;
    transition: background .15s;
}
.cosave-admin-link:hover {
    background: rgba(255,255,255,.35);
    color: #fff;
}
