/* ========================================
   TPV Panel - Licencia, Empleados y Widget
   ======================================== */

/* ── Overlay compartido ── */
.tpv-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f9fafb;
    animation: tpvFadeIn .3s ease;
}

@keyframes tpvFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes tpvSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes tpvShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}

/* ========================================
   1. PANTALLA DE LICENCIA (estilo Apple/OpenAI)
   ======================================== */
.equipo-licencia-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f9fafb;
    animation: tpvFadeIn .3s ease;
}

.equipo-licencia-card {
    width: 100%;
    max-width: 420px;
    padding: 48px 40px;
    text-align: center;
    animation: tpvSlideUp .4s ease;
}

.equipo-licencia-brand {
    margin-bottom: 36px;
}

.equipo-licencia-logo {
    width: 56px;
    height: 56px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 600;
    color: #3b82f6;
    background: #eff6ff;
    border-radius: 16px;
    border: 1px solid #dbeafe;
}

.equipo-licencia-card h1 {
    font-size: 22px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 8px;
    letter-spacing: -.3px;
}

.equipo-licencia-sub {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
    line-height: 1.5;
}

.equipo-licencia-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    text-align: left;
    margin-bottom: 6px;
}

.equipo-licencia-input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 16px;
    font-size: 18px;
    font-weight: 500;
    letter-spacing: 4px;
    text-align: center;
    text-transform: uppercase;
    color: #111827;
    background: #fff;
    border: 1.5px solid #d1d5db;
    border-radius: 12px;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}

.equipo-licencia-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .12);
}

.equipo-licencia-hint {
    font-size: 12px;
    color: #9ca3af;
    margin: 8px 0 0;
    text-align: left;
}

.equipo-licencia-error {
    font-size: 13px;
    color: #dc2626;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 10px 14px;
    margin-top: 12px;
    text-align: left;
}

.equipo-licencia-submit {
    width: 100%;
    padding: 12px;
    margin-top: 20px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    background: #111827;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: background .2s, opacity .2s;
}

.equipo-licencia-submit:hover {
    background: #1f2937;
}

.equipo-licencia-submit:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ========================================
   2. PANEL DE EMPLEADOS
   ======================================== */
.tpv-employee-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f9fafb;
    animation: tpvFadeIn .3s ease;
}

.tpv-employee-card {
    width: 100%;
    max-width: 560px;
    padding: 40px 32px;
    text-align: center;
    animation: tpvSlideUp .4s ease;
}

.tpv-employee-header {
    margin-bottom: 32px;
}

.tpv-employee-header h1 {
    font-size: 22px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 6px;
    letter-spacing: -.3px;
}

.tpv-employee-header p {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

/* Grid de avatares de empleados */
.tpv-employee-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    margin-bottom: 16px;
}

.tpv-employee-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 12px;
    border-radius: 16px;
    border: 2px solid transparent;
    transition: background .2s, border-color .2s, transform .15s;
    min-width: 88px;
}

.tpv-employee-item:hover {
    background: #f3f4f6;
    transform: translateY(-2px);
}

.tpv-employee-item:active {
    transform: scale(.97);
}

.tpv-employee-item.tpv-employee-item--active {
    border-color: #3b82f6;
    background: #eff6ff;
}

.tpv-employee-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
    position: relative;
}

.tpv-employee-status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #f9fafb;
    background: #9ca3af;
}

.tpv-employee-status-dot[data-status="trabajando"] {
    background: #22c55e;
}

.tpv-employee-status-dot[data-status="en_pausa"] {
    background: #f59e0b;
}

.tpv-employee-name {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Vista de PIN ── */
.tpv-pin-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f9fafb;
    animation: tpvFadeIn .2s ease;
}

.tpv-pin-layout {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
}

.tpv-pin-layout--with-actions {
    gap: 40px;
}

.tpv-pin-card {
    width: 100%;
    max-width: 360px;
    padding: 48px 36px;
    text-align: center;
    animation: tpvSlideUp .35s ease;
}

/* ── Panel de acciones de fichaje (columna derecha) ── */
.tpv-pin-actions-card {
    width: 220px;
    padding: 20px;
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 16px;
    animation: tpvSlideUp .4s ease;
    flex-shrink: 0;
    margin-top: 48px;
}

.tpv-pin-actions-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f3f4f6;
}

.tpv-action-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tpv-action-status-dot.working {
    background: #22c55e;
}

.tpv-action-status-dot.paused {
    background: #f59e0b;
}

.tpv-action-status-label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.tpv-pin-actions-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tpv-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    cursor: pointer;
    transition: all .15s;
    text-align: left;
}

.tpv-action-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.tpv-action-btn--selected {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #1d4ed8;
}

.tpv-action-btn--resume {
    color: #16a34a;
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.tpv-action-btn--resume:hover {
    background: #dcfce7;
}

.tpv-action-btn--resume.tpv-action-btn--selected {
    background: #dcfce7;
    border-color: #16a34a;
    color: #15803d;
}

.tpv-action-btn--end {
    color: #dc2626;
    background: #fef2f2;
    border-color: #fecaca;
}

.tpv-action-btn--end:hover {
    background: #fee2e2;
    border-color: #fca5a5;
}

.tpv-action-btn--end.tpv-action-btn--selected {
    background: #fee2e2;
    border-color: #dc2626;
    color: #b91c1c;
}

.tpv-action-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    font-size: 14px;
}

.tpv-action-separator {
    height: 1px;
    background: #e5e7eb;
    margin: 4px 0;
}

.tpv-pin-back {
    position: absolute;
    top: 28px;
    left: 28px;
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: 8px;
    transition: background .15s, color .15s;
}

.tpv-pin-back:hover {
    background: #f3f4f6;
    color: #111827;
}

.tpv-pin-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 600;
    color: #fff;
    margin: 0 auto 16px;
}

.tpv-pin-card h2 {
    font-size: 20px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 4px;
}

.tpv-pin-card .tpv-pin-subtitle {
    font-size: 14px;
    color: #6b7280;
    margin: 0 0 28px;
}

/* Dots del PIN */
.tpv-pin-dots {
    display: flex;
    gap: 14px;
    justify-content: center;
    margin-bottom: 28px;
}

.tpv-pin-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #d1d5db;
    background: transparent;
    transition: background .15s, border-color .15s, transform .15s;
}

.tpv-pin-dot.filled {
    background: #111827;
    border-color: #111827;
    transform: scale(1.1);
}

.tpv-pin-dot.error {
    border-color: #dc2626;
    background: #dc2626;
    animation: tpvShake .4s ease;
}

/* Teclado numérico */
.tpv-pin-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    max-width: 240px;
    margin: 0 auto;
}

.tpv-pin-key {
    width: 100%;
    aspect-ratio: 1.3;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 500;
    color: #111827;
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 14px;
    cursor: pointer;
    transition: background .12s, transform .1s, border-color .12s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.tpv-pin-key:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.tpv-pin-key:active {
    transform: scale(.95);
    background: #e5e7eb;
}

.tpv-pin-key--empty {
    visibility: hidden;
}

.tpv-pin-key--delete {
    font-size: 16px;
    color: #6b7280;
}

.tpv-pin-error {
    font-size: 13px;
    color: #dc2626;
    margin-top: 16px;
    min-height: 20px;
}

/* ── PIN + acciones fichaje: escala táctil (sin tocar el PIN solo-admin) ── */
.tpv-pin-layout--with-actions {
    align-items: center;
    gap: clamp(28px, 4vw, 56px);
    width: 100%;
    max-width: min(920px, calc(100vw - 32px));
    padding: 0 12px;
    box-sizing: border-box;
}

.tpv-pin-layout--with-actions .tpv-pin-card {
    max-width: 440px;
    padding: clamp(40px, 5vw, 56px) clamp(32px, 4vw, 48px);
}

.tpv-pin-layout--with-actions .tpv-pin-avatar {
    width: 88px;
    height: 88px;
    font-size: 34px;
    margin-bottom: 20px;
}

.tpv-pin-layout--with-actions .tpv-pin-card h2 {
    font-size: clamp(22px, 2.6vw, 26px);
    margin-bottom: 6px;
}

.tpv-pin-layout--with-actions .tpv-pin-card .tpv-pin-subtitle {
    font-size: 16px;
    line-height: 1.45;
    margin-bottom: 32px;
    max-width: 28em;
    margin-left: auto;
    margin-right: auto;
}

.tpv-pin-layout--with-actions .tpv-pin-dots {
    gap: 18px;
    margin-bottom: 32px;
}

.tpv-pin-layout--with-actions .tpv-pin-dot {
    width: 20px;
    height: 20px;
    border-width: 2.5px;
}

.tpv-pin-layout--with-actions .tpv-pin-keypad {
    gap: 4px;
    max-width: 300px;
}

.tpv-pin-layout--with-actions .tpv-pin-key {
    font-size: clamp(24px, 3.2vw, 30px);
    font-weight: 600;
    border-radius: 16px;
    min-height: 80px;
    aspect-ratio: auto;
}

.tpv-pin-layout--with-actions .tpv-pin-key--delete svg {
    width: 24px;
    height: 24px;
}

.tpv-pin-layout--with-actions .tpv-pin-error {
    font-size: 15px;
    margin-top: 20px;
    min-height: 24px;
}

.tpv-pin-layout--with-actions .tpv-pin-actions-card {
    width: min(300px, 100%);
    padding: 24px 22px;
    border-radius: 20px;
    margin-top: 0;
    border-width: 2px;
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
}

.tpv-pin-layout--with-actions .tpv-pin-actions-header {
    gap: 10px;
    margin-bottom: 18px;
    padding-bottom: 14px;
}

.tpv-pin-layout--with-actions .tpv-action-status-dot {
    width: 10px;
    height: 10px;
}

.tpv-pin-layout--with-actions .tpv-action-status-label {
    font-size: 15px;
    letter-spacing: -0.02em;
}

.tpv-pin-layout--with-actions .tpv-pin-actions-list {
    gap: 10px;
}

.tpv-pin-layout--with-actions .tpv-action-btn {
    min-height: 48px;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 600;
    gap: 12px;
    border-radius: 14px;
}

.tpv-pin-layout--with-actions .tpv-action-icon {
    width: 28px;
    font-size: 18px;
}

.tpv-pin-layout--with-actions .tpv-action-separator {
    margin: 8px 0;
}

/* Botón volver más cómodo en la misma vista */
.tpv-pin-overlay:has(.tpv-pin-layout--with-actions) .tpv-pin-back {
    top: clamp(16px, 3vw, 28px);
    left: clamp(16px, 3vw, 28px);
    font-size: 16px;
    padding: 12px 16px;
    border-radius: 12px;
    gap: 6px;
}

.tpv-pin-overlay:has(.tpv-pin-layout--with-actions) .tpv-pin-back svg {
    width: 20px;
    height: 20px;
}

/* ========================================
   3. WIDGET DE EMPLEADO ACTIVO EN HEADER
   ======================================== */
.tpv-header-employee-widget {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    margin-right: 6px;
    border-radius: 20px;
    border: 1px solid #e5e7eb;
    background: #f0fdf4;
    cursor: pointer;
    transition: box-shadow .2s, background .2s;
    user-select: none;
    position: relative;
}

.tpv-header-employee-widget:hover {
    box-shadow: 0 1px 4px rgba(0, 0, 0, .08);
}

.tpv-header-employee-widget[data-status="en_pausa"] {
    background: #fef3c7;
    border-color: #fde68a;
}

.tpv-header-employee-widget[data-status="no_fichado"] {
    background: #f1f5f9;
    border-color: #e2e8f0;
}

.tpv-header-employee-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.tpv-header-employee-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.tpv-header-employee-name {
    font-size: 12px;
    font-weight: 600;
    color: #111827;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tpv-header-employee-crono {
    font-size: 11px;
    font-weight: 500;
    color: #16a34a;
    font-variant-numeric: tabular-nums;
}

.tpv-header-employee-widget[data-status="en_pausa"] .tpv-header-employee-crono {
    color: #d97706;
}

.tpv-header-employee-widget[data-status="no_fichado"] .tpv-header-employee-crono {
    color: #94a3b8;
}

/* ── Botón de pausa/reanudación rápida ── */
.tpv-header-employee-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 4px;
}

.tpv-header-employee-actions button {
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 50%;
    background: rgba(0,0,0,.06);
    color: #374151;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
    padding: 0;
}

.tpv-header-employee-actions button:hover {
    background: rgba(0,0,0,.12);
}

/* ── Sesión bloqueada ── */
.tpv-blocked-overlay {
    position: fixed;
    inset: 0;
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f9fafb;
    animation: tpvFadeIn .3s ease;
}

.tpv-blocked-card {
    max-width: 420px;
    padding: 48px 40px;
    text-align: center;
    animation: tpvSlideUp .4s ease;
}

.tpv-blocked-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    background: #fef2f2;
    border-radius: 50%;
    border: 1px solid #fecaca;
}

.tpv-blocked-card h2 {
    font-size: 20px;
    font-weight: 600;
    color: #111827;
    margin: 0 0 8px;
}

.tpv-blocked-card p {
    font-size: 14px;
    color: #6b7280;
    margin: 0 0 24px;
    line-height: 1.5;
}

.tpv-blocked-retry {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    background: #fff;
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    cursor: pointer;
    transition: background .15s;
}

.tpv-blocked-retry:hover {
    background: #f3f4f6;
}

/* ========================================
   4. MODO TPV BLOQUEADO
   ======================================== */

/* Ocultar sidebar, contenido y controles de navegación en modo TPV */
body.tpv-mode #sidebar,
body.tpv-mode .mobile-sidebar-overlay,
body.tpv-mode .mobile-menu-btn,
body.tpv-mode .containers-wrapper,
body.tpv-mode .header-project-selector,
body.tpv-mode #notif-bell-wrap,
body.tpv-mode #user-menu,
body.tpv-mode #header-fichaje-widget {
    display: none !important;
}

body.tpv-mode .header {
    justify-content: flex-end;
}

body.tpv-mode .header-actions {
    width: 100%;
    justify-content: flex-end;
}

/* Botón "Acceso administrador" en el panel de empleados */
.tpv-admin-access {
    margin-top: 24px;
    text-align: center;
}

.tpv-admin-access-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    background: none;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    cursor: pointer;
    transition: color .15s, border-color .15s, background .15s;
}

.tpv-admin-access-btn:hover {
    color: #111827;
    border-color: #d1d5db;
    background: #f9fafb;
}

/* Botón flotante "Volver a TPV" (visible en modo admin desbloqueado) */
.tpv-lock-return-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9998;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: #111827;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,.18);
    transition: background .15s, transform .1s;
}

.tpv-lock-return-btn:hover {
    background: #1f2937;
    transform: translateY(-1px);
}

.tpv-lock-return-btn:active {
    transform: scale(.97);
}

/* ========================================
   5. RESPONSIVE
   ======================================== */
@media (max-width: 700px) {
    .tpv-pin-layout--with-actions {
        flex-direction: column;
        align-items: center;
        gap: 28px;
        max-width: min(480px, calc(100vw - 24px));
    }

    .tpv-pin-layout--with-actions .tpv-pin-keypad {
        max-width: 280px;
    }

    .tpv-pin-actions-card {
        width: 100%;
        max-width: 320px;
        margin-top: 0;
    }

    .tpv-pin-layout--with-actions .tpv-pin-actions-card {
        max-width: min(340px, 100%);
    }
}

@media (max-width: 600px) {
    .equipo-licencia-card,
    .tpv-pin-card {
        padding: 32px 20px;
    }

    .tpv-employee-card {
        padding: 28px 16px;
    }

    .tpv-employee-grid {
        gap: 12px;
    }

    .tpv-employee-item {
        min-width: 72px;
        padding: 8px;
    }

    .tpv-employee-avatar {
        width: 48px;
        height: 48px;
        font-size: 18px;
    }

    .tpv-pin-keypad {
        max-width: 200px;
        gap: 8px;
    }

    .tpv-pin-key {
        font-size: 18px;
    }
}
