/* SOSGroup Fichajes - Frontend (mobile first) */

/* Modo app: cuando la página es solo este shortcode, ocupar pantalla */
body.sos-app-mode {
    margin: 0;
    padding: 0;
    background: #f3f4f6;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

body.sos-app-mode .sos-app-shell {
    min-height: 100vh;
    padding: 16px 0 24px;
}

.sos-fichajes-wrapper {
    max-width: 560px;
    margin: 0 auto;
    padding: 16px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #1f2937;
}

.sos-fichajes-wrapper * {
    box-sizing: border-box;
}

.sos-header {
    text-align: center;
    margin-bottom: 16px;
}

.sos-header h1 {
    font-size: 1.4rem;
    margin: 0 0 4px;
    color: #0b3d91;
}

.sos-user {
    font-weight: 600;
    margin: 0;
}

.sos-server-time {
    color: #6b7280;
    font-size: 0.9rem;
    margin: 4px 0 0;
}

.sos-status-box {
    min-height: 0;
    margin-bottom: 12px;
}

.sos-status-box.success,
.sos-status-box.error,
.sos-status-box.info {
    padding: 12px 14px;
    border-radius: 8px;
    font-weight: 500;
    line-height: 1.35;
}

.sos-status-box.success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.sos-status-box.error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.sos-status-box.info    { background: #eff6ff; color: #1e3a8a; border: 1px solid #bfdbfe; }

.sos-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.sos-card h2 {
    margin: 0 0 10px;
    font-size: 1.1rem;
    color: #111827;
}

.sos-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    margin: 8px 0 4px;
}

.sos-select,
.sos-input {
    width: 100%;
    padding: 12px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    background: #fff;
}

.sos-btn {
    display: block;
    width: 100%;
    border: none;
    border-radius: 10px;
    padding: 18px 14px;
    font-size: 1.05rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    margin-top: 12px;
    text-decoration: none;
    text-align: center;
}

.sos-btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

.sos-btn-icon {
    margin-right: 6px;
}

.sos-btn-in {
    background: #16a34a;
    color: #fff;
}

.sos-btn-out {
    background: #dc2626;
    color: #fff;
}

.sos-btn-primary {
    background: #0b3d91;
    color: #fff;
}

.sos-btn-secondary {
    background: #f3f4f6;
    color: #111827;
    border: 1px solid #d1d5db;
}

.sos-help {
    color: #6b7280;
    font-size: 0.85rem;
    margin: 10px 0 0;
    text-align: center;
}

.sos-empty {
    color: #6b7280;
    font-style: italic;
}

.sos-table-wrap {
    overflow-x: auto;
}

.sos-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.sos-table th,
.sos-table td {
    text-align: left;
    padding: 8px 6px;
    border-bottom: 1px solid #f1f5f9;
}

.sos-table thead th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
}

.sos-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.sos-pill-valid    { background: #dcfce7; color: #166534; }
.sos-pill-pending  { background: #fef9c3; color: #854d0e; }
.sos-pill-approved { background: #dbeafe; color: #1e40af; }
.sos-pill-rejected { background: #fee2e2; color: #991b1b; }

.sos-form { margin-top: 12px; }

.sos-locked {
    text-align: center;
    padding: 30px 16px;
}

.sos-boot-indicator {
    text-align: center;
    font-size: 0.75rem;
    color: #9ca3af;
    margin: 8px 0 0;
    font-style: italic;
}

.sos-boot-indicator.sos-boot-ready {
    color: #16a34a;
    font-style: normal;
}

/* ------------------------------------------------------------------ */
/* Header de app (saludo + cronómetro)                                 */
/* ------------------------------------------------------------------ */

.sos-header-app {
    background: linear-gradient(135deg, #0b3d91 0%, #1d4ed8 100%);
    color: #fff;
    border-radius: 16px;
    padding: 20px 18px;
    margin-bottom: 14px;
    text-align: left;
}

.sos-header-app .sos-greeting {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sos-header-app .sos-hi {
    font-size: 0.9rem;
    opacity: 0.85;
}

.sos-header-app .sos-name {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.sos-header-app .sos-server-time {
    color: rgba(255,255,255,0.85);
    margin: 10px 0 0;
    font-size: 0.85rem;
}

.sos-active-shift {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
    padding: 10px 12px;
    background: rgba(255,255,255,0.15);
    border-radius: 10px;
    font-size: 0.95rem;
}

.sos-active-shift-label { opacity: 0.85; }
.sos-active-shift-from  { font-weight: 700; }
.sos-active-shift-elapsed {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}

/* Botones extra grandes para app */
.sos-btn-lg {
    padding: 22px 14px;
    font-size: 1.15rem;
    border-radius: 14px;
}

/* ------------------------------------------------------------------ */
/* Login mobile-first                                                  */
/* ------------------------------------------------------------------ */

.sos-login-wrapper {
    max-width: 420px;
    padding-top: 32px;
}

.sos-login-brand {
    text-align: center;
    margin-bottom: 28px;
}

.sos-login-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.sos-login-title {
    color: #0b3d91;
    font-size: 1.6rem;
    margin: 6px 0 2px;
    font-weight: 700;
}

.sos-login-subtitle {
    margin: 0;
    color: #6b7280;
    letter-spacing: 0.2em;
    font-size: 0.85rem;
}

.sos-login-form {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 20px 18px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.sos-input-lg {
    padding: 14px 14px;
    font-size: 1.05rem;
    border-radius: 10px;
}

.sos-login-links {
    text-align: center;
    margin: 14px 0 0;
}
.sos-login-links a {
    color: #0b3d91;
    text-decoration: none;
    font-size: 0.9rem;
}
.sos-login-links a:hover { text-decoration: underline; }

.sos-login-foot {
    text-align: center;
    color: #9ca3af;
    font-size: 0.8rem;
    margin-top: 22px;
}

/* ------------------------------------------------------------------ */
/* Footer app (logout + boot)                                          */
/* ------------------------------------------------------------------ */

.sos-app-footer {
    text-align: center;
    padding-top: 14px;
    margin-top: 8px;
}

.sos-logout {
    display: inline-block;
    color: #6b7280;
    text-decoration: none;
    font-size: 0.9rem;
    padding: 8px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
}
.sos-logout:hover { color: #dc2626; border-color: #fecaca; }

/* Instalación fija (cuando empleado tiene una sola asignada) */
.sos-worksite-fixed {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 14px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    font-size: 1.05rem;
    font-weight: 600;
    color: #1e3a8a;
    margin-top: 4px;
}
.sos-worksite-icon { font-size: 1.3rem; line-height: 1; }
.sos-worksite-name { flex: 1; }
.sos-worksite-address {
    color: #6b7280;
    font-weight: normal;
    font-size: 0.82rem;
    line-height: 1.3;
}

.sos-no-worksite {
    background: #fef9c3;
    border: 1px solid #fde68a;
    border-radius: 10px;
    padding: 14px;
    text-align: center;
    color: #854d0e;
}

/* Vista coordinador: empleados fichados ahora */
.sos-card-supervisor h2 {
    display: flex;
    align-items: center;
    gap: 8px;
}
.sos-card-supervisor .sos-live-dot {
    display: inline-block;
    width: 10px; height: 10px;
    background: #16a34a;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(22,163,74,0.15);
    animation: sosPulseLive 1.6s ease-in-out infinite;
}
@keyframes sosPulseLive {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.85; }
}
.sos-supervisor-count {
    background: #16a34a;
    color: #fff;
    font-size: 0.75rem;
    padding: 2px 10px;
    border-radius: 999px;
    font-weight: 700;
    margin-left: auto;
}
.sos-supervisor-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.sos-supervisor-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
}
.sos-supervisor-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}
.sos-supervisor-info strong {
    font-size: 0.95rem;
    color: #111827;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sos-supervisor-meta {
    font-size: 0.8rem;
    color: #6b7280;
}

/* PWA install */
.sos-pwa-install {
    margin: 12px 0;
    padding: 14px;
    background: #eff6ff;
    border: 1px dashed #bfdbfe;
    border-radius: 10px;
    text-align: center;
}
.sos-pwa-instructions {
    margin-top: 10px;
    text-align: left;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 12px;
}
.sos-pwa-instructions summary {
    cursor: pointer;
    font-weight: 600;
    color: #0b3d91;
}

/* Rangos horarios regularización */
.sos-corr-range-title {
    font-weight: 700;
    color: #0b3d91;
    margin: 8px 0 4px;
    font-size: 0.95rem;
}
.sos-corr-range-title:empty { display: none; }
.sos-corr-times {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}
.sos-corr-times label {
    display: flex;
    flex-direction: column;
}
.sos-corr-times .sos-label {
    font-size: 0.78rem;
    margin-bottom: 2px;
}

/* Historial colapsable */
.sos-history-collapse {
    border-top: 1px dashed #e5e7eb;
    padding-top: 10px;
}
.sos-history-toggle {
    cursor: pointer;
    color: #0b3d91;
    font-weight: 600;
    font-size: 0.9rem;
    list-style: none;
    padding: 8px 12px;
    background: #eff6ff;
    border-radius: 8px;
    text-align: center;
}
.sos-history-toggle::-webkit-details-marker { display: none; }
.sos-history-collapse[open] .sos-history-toggle::after {
    content: ' ▴';
}
.sos-history-collapse:not([open]) .sos-history-toggle::after {
    content: ' ▾';
}

/* Documentos del empleado (agrupados) */
.sos-doc-group { margin-bottom: 16px; }
.sos-doc-group:last-child { margin-bottom: 0; }

.sos-doc-group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 14px 0 8px;
    font-size: 1rem;
    color: #0b3d91;
    border-bottom: 2px solid #eff6ff;
    padding-bottom: 6px;
}
.sos-doc-group-count {
    display: inline-block;
    min-width: 22px;
    text-align: center;
    background: #0b3d91;
    color: #fff;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 700;
}
.sos-doc-group-nominas .sos-doc-group-title    { color: #166534; border-bottom-color: #dcfce7; }
.sos-doc-group-nominas .sos-doc-group-count    { background: #16a34a; }
.sos-doc-group-contratos .sos-doc-group-title  { color: #5b21b6; border-bottom-color: #ede9fe; }
.sos-doc-group-contratos .sos-doc-group-count  { background: #7c3aed; }
.sos-doc-group-otros .sos-doc-group-title      { color: #92400e; border-bottom-color: #fef3c7; }
.sos-doc-group-otros .sos-doc-group-count      { background: #f59e0b; }

.sos-doc-group-empty {
    color: #9ca3af;
    font-style: italic;
    font-size: 0.85rem;
    margin: 4px 0 8px;
}

.sos-docs-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sos-doc-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}
.sos-doc-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sos-doc-type {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: 6px;
    background: #eff6ff;
    color: #1e3a8a;
}
.sos-doc-type-contrato    { background: #ede9fe; color: #5b21b6; }
.sos-doc-type-nomina      { background: #dcfce7; color: #166534; }
.sos-doc-type-certificado { background: #fef3c7; color: #92400e; }
.sos-doc-type-parte       { background: #fee2e2; color: #991b1b; }
.sos-doc-type-otro        { background: #e5e7eb; color: #374151; }

.sos-doc-title { font-size: 0.95rem; color: #111827; line-height: 1.2; }
.sos-doc-meta  { font-size: 0.78rem; color: #6b7280; }

.sos-doc-actions { display: flex; gap: 6px; flex-shrink: 0; }
.sos-doc-btn {
    display: inline-block !important;
    width: auto !important;
    padding: 8px 12px !important;
    font-size: 0.8rem !important;
    margin: 0 !important;
    border-radius: 6px !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
}

@media (max-width: 480px) {
    .sos-doc-item { flex-direction: column; align-items: stretch; }
    .sos-doc-actions { justify-content: flex-end; }
}

/* Registro: CTA en pantalla de login */
.sos-login-register-cta {
    margin-top: 18px;
    text-align: center;
    padding: 14px;
    background: #fff;
    border: 1px dashed #d1d5db;
    border-radius: 10px;
}
.sos-login-register-cta p {
    margin: 0 0 8px;
    color: #6b7280;
    font-size: 0.9rem;
}

/* Firma de documentos */
.sos-btn-sign {
    background: #7c3aed;
    color: #fff;
    border: none;
    cursor: pointer;
}
.sos-btn-sign:hover { background: #6d28d9; }
.sos-doc-signed {
    display: inline-block;
    background: #d1fae5;
    color: #065f46;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 9999px;
    margin-left: 4px;
}
.sos-sign-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0,0,0,.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.sos-sign-modal {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 580px;
    padding: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    position: relative;
}
.sos-sign-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.sos-sign-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #1e293b;
}
.sos-sign-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6b7280;
    line-height: 1;
    padding: 4px;
}
.sos-sign-instructions {
    color: #6b7280;
    font-size: 0.85rem;
    margin: 0 0 12px;
}
.sos-sign-banner {
    background: #ede9fe;
    color: #5b21b6;
    font-weight: 700;
    font-size: 0.95rem;
    text-align: center;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 10px;
}
.sos-sign-banner-draw {
    background: #dbeafe;
    color: #1d4ed8;
}
.sos-sign-page-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}
.sos-sign-page-info {
    font-weight: 600;
    font-size: 0.9rem;
    color: #475569;
    min-width: 100px;
    text-align: center;
}
.sos-btn-sm { font-size: 0.8rem; padding: 6px 12px; }
.sos-btn-lg { font-size: 1rem; padding: 14px 24px; }
.sos-sign-pdf-wrap {
    position: relative;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    background: #f1f5f9;
    margin-bottom: 10px;
    touch-action: none;
    cursor: crosshair;
    max-height: 55vh;
    overflow-y: auto;
}
.sos-sign-pdf-wrap canvas {
    display: block;
    width: 100%;
}
.sos-sign-marker {
    position: absolute;
    pointer-events: none;
    z-index: 2;
}
.sos-sign-marker-box {
    border: 3px dashed #7c3aed;
    background: rgba(124, 58, 237, 0.10);
    border-radius: 6px;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #7c3aed;
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
}
.sos-sign-canvas-wrap {
    border: 2px dashed #cbd5e1;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    touch-action: none;
}
.sos-sign-canvas-wrap canvas {
    display: block;
    width: 100%;
    cursor: crosshair;
}
.sos-sign-buttons {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    justify-content: flex-end;
}
.sos-sign-status {
    font-size: 0.95rem;
    margin-top: 12px;
    min-height: 1.4em;
    text-align: center;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 600;
}
.sos-sign-info  { color: #1d4ed8; background: #dbeafe; }
.sos-sign-ok    { color: #065f46; background: #d1fae5; }
.sos-sign-error { color: #991b1b; background: #fee2e2; }
