/**
 * Fichaje Simple - estilo Glovo / Apple HIG
 * Mobile-first. Diseño limpio, botones circulares grandes, animaciones suaves.
 */

/* ===== Modo global cuando un usuario solo-fichaje está logueado ===== */
body.solo-fichaje-mode {
    overflow: hidden;
    background: #f5f7fa;
}
body.solo-fichaje-mode #sidebar,
body.solo-fichaje-mode .sidebar,
body.solo-fichaje-mode header,
body.solo-fichaje-mode .app-header,
body.solo-fichaje-mode .main-header,
body.solo-fichaje-mode #header-widget-fichaje,
body.solo-fichaje-mode .topbar,
body.solo-fichaje-mode .breadcrumbs {
    display: none !important;
}
body.solo-fichaje-mode #main-app,
body.solo-fichaje-mode .main-content,
body.solo-fichaje-mode #content-area,
body.solo-fichaje-mode main {
    margin: 0 !important;
    padding: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    min-height: 100vh;
    min-height: 100dvh;
}
body.solo-fichaje-mode .content-wrapper,
body.solo-fichaje-mode .module-content,
body.solo-fichaje-mode #fichaje-simple-content {
    margin: 0 !important;
    padding: 0 !important;
}

/* ===== Contenedor principal ===== */
.fs-root {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    /* Fallback iOS Safari < 15.4 */
    min-height: -webkit-fill-available;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
    color: #1d1d1f;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Inter', 'Segoe UI', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    overflow: hidden;
    box-sizing: border-box;
}

/* ===== Header ===== */
.fs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 8px;
    gap: 12px;
    flex-shrink: 0;
}
.fs-header-user {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.fs-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid rgba(0, 0, 0, 0.06);
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.fs-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.fs-user-name {
    font-size: 15px;
    font-weight: 600;
    color: #1d1d1f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60vw;
}
.fs-user-meta {
    font-size: 12px;
    color: #86868b;
    margin-top: 2px;
}
.fs-logout-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.04);
    color: #1d1d1f;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background 0.15s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}
.fs-logout-btn:active {
    background: rgba(0, 0, 0, 0.08);
    transform: scale(0.94);
}

/* ===== Pill de estado ===== */
.fs-status-pill {
    margin: 8px 20px 0;
    padding: 10px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    display: inline-flex;
    align-self: center;
    align-items: center;
    gap: 8px;
    transition: all 0.25s ease;
    flex-shrink: 0;
}
.fs-status-pill .fs-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: fs-pulse 1.5s ease-in-out infinite;
}
.fs-status-pill[data-status="no_fichado"] {
    background: rgba(142, 142, 147, 0.12);
    color: #6e6e73;
}
.fs-status-pill[data-status="trabajando"] {
    background: rgba(52, 199, 89, 0.14);
    color: #1d8a3d;
}
.fs-status-pill[data-status="en_pausa"] {
    background: rgba(255, 159, 10, 0.16);
    color: #b8651f;
}

@keyframes fs-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.fs-user-name-below {
    margin: 10px 20px 0;
    font-size: clamp(1.125rem, 4.5vw, 1.375rem);
    font-weight: 600;
    color: #1d1d1f;
    text-align: center;
    line-height: 1.25;
    flex-shrink: 0;
}

/* ===== Reloj ===== */
.fs-clock-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    gap: 8px;
    min-height: 0;
}
.fs-clock-label {
    font-size: 13px;
    color: #86868b;
    font-weight: 500;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.fs-clock {
    font-size: clamp(2.5rem, 13vw, 4.5rem);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    line-height: 1;
    color: #1d1d1f;
}
.fs-clock-meta {
    font-size: 14px;
    color: #86868b;
    margin-top: 4px;
}

/* ===== Zona de botones ===== */
.fs-actions {
    padding: 0 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex-shrink: 0;
}

/* Botón principal grande (entrada / salida primaria) */
.fs-action-main-wrap {
    display: flex;
    justify-content: center;
    padding: 8px 0;
}
.fs-btn-circle {
    width: min(70vw, 260px);
    height: min(70vw, 260px);
    max-width: 260px;
    max-height: 260px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18), inset 0 -8px 16px rgba(0, 0, 0, 0.12);
    transition: transform 0.12s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    overflow: hidden;
}
.fs-btn-circle::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0) 50%);
    pointer-events: none;
}
.fs-btn-circle:active {
    transform: scale(0.96);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18), inset 0 -4px 10px rgba(0, 0, 0, 0.16);
}
.fs-btn-circle:disabled {
    opacity: 0.55;
    cursor: wait;
    transform: none;
}
.fs-btn-circle .fs-btn-icon {
    font-size: 56px;
    line-height: 1;
}
.fs-btn-circle .fs-btn-label {
    font-size: 17px;
    font-weight: 700;
    text-align: center;
    padding: 0 12px;
}

.fs-btn-entrada {
    background: linear-gradient(180deg, #34c759 0%, #28a745 100%);
}
.fs-btn-salida {
    background: linear-gradient(180deg, #ff453a 0%, #d70015 100%);
}
.fs-btn-reanudar {
    background: linear-gradient(180deg, #34c759 0%, #28a745 100%);
}

/* Grid 2x2 de pausas */
.fs-pausa-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 380px;
    margin: 0 auto;
}
.fs-btn-pausa {
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    border: none;
    background: #fff;
    color: #1d1d1f;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s;
    -webkit-tap-highlight-color: transparent;
    padding: 8px;
    min-height: 120px;
    min-width: 120px;
    max-width: 180px;
    max-height: 180px;
    margin: 0 auto;
    width: 100%;
}
.fs-btn-pausa:active {
    transform: scale(0.94);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    background: #f5f5f7;
}
.fs-btn-pausa .fs-btn-icon {
    font-size: 32px;
    line-height: 1;
}
.fs-btn-pausa .fs-btn-label {
    font-size: 13px;
    font-weight: 600;
    color: #1d1d1f;
}

/* Botón pill para "Terminar jornada" cuando hay varias acciones */
.fs-btn-pill {
    width: 100%;
    height: 56px;
    border-radius: 16px;
    border: none;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.12s ease, box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    color: #fff;
}
.fs-btn-pill:active {
    transform: scale(0.98);
}
.fs-btn-pill.fs-btn-salida {
    background: linear-gradient(180deg, #ff453a 0%, #d70015 100%);
    box-shadow: 0 4px 12px rgba(215, 0, 21, 0.25);
}
.fs-btn-pill.fs-btn-reanudar {
    background: linear-gradient(180deg, #34c759 0%, #28a745 100%);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.25);
}

/* Spinner */
.fs-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: fs-spin 0.8s linear infinite;
}
@keyframes fs-spin {
    to { transform: rotate(360deg); }
}

/* Toast (geolocalización u otros avisos no bloqueantes) */
.fs-toast {
    position: fixed;
    left: 50%;
    bottom: calc(20px + env(safe-area-inset-bottom));
    transform: translateX(-50%) translateY(120px);
    background: rgba(28, 28, 30, 0.96);
    color: #fff;
    padding: 12px 18px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 500;
    max-width: calc(100vw - 32px);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
    z-index: 9999;
    opacity: 0;
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.25s ease;
    pointer-events: none;
    text-align: center;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
.fs-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}
.fs-toast.fs-toast-warning {
    background: rgba(176, 96, 0, 0.96);
}
.fs-toast.fs-toast-error {
    background: rgba(176, 24, 16, 0.96);
}
.fs-toast.fs-toast-success {
    background: rgba(20, 130, 50, 0.96);
}

/* Loader pantalla completa al cargar estado inicial */
.fs-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(245, 247, 250, 0.85);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10;
}
.fs-loading .fs-spinner {
    width: 40px;
    height: 40px;
    border-color: rgba(0, 0, 0, 0.1);
    border-top-color: #1d8a3d;
}

/* Badge de motivo de pausa */
.fs-pausa-motivo {
    text-transform: capitalize;
}

/* ===== Tablet ===== */
@media (min-width: 481px) and (max-width: 1024px) {
    .fs-root {
        max-width: 520px;
        margin: 0 auto;
        position: fixed;
        left: 50%;
        transform: translateX(-50%);
    }
    .fs-btn-circle {
        width: 240px;
        height: 240px;
    }
    .fs-pausa-grid {
        max-width: 420px;
    }
    .fs-btn-pausa {
        max-width: 200px;
        max-height: 200px;
    }
}

/* ===== Desktop ===== */
@media (min-width: 1025px) {
    body.solo-fichaje-mode {
        background: linear-gradient(135deg, #e8eef5 0%, #f5f7fa 100%);
    }
    .fs-root {
        position: relative;
        inset: auto;
        margin: 32px auto;
        max-width: 520px;
        height: auto;
        min-height: calc(100vh - 64px);
        max-height: 800px;
        border-radius: 32px;
        box-shadow: 0 24px 60px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04);
        background: #fff;
        overflow: hidden;
    }
    .fs-btn-circle {
        width: 240px;
        height: 240px;
    }
    .fs-btn-circle:hover {
        transform: translateY(-2px);
        box-shadow: 0 18px 40px rgba(0, 0, 0, 0.2), inset 0 -8px 16px rgba(0, 0, 0, 0.12);
    }
    .fs-btn-pausa:hover {
        transform: translateY(-2px);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
        background: #fafafa;
    }
    .fs-btn-pill:hover {
        transform: translateY(-1px);
    }
    .fs-logout-btn:hover {
        background: rgba(0, 0, 0, 0.07);
    }
}

/* ===== Móvil landscape (poco alto) ===== */
@media (max-height: 500px) and (orientation: landscape) {
    .fs-root {
        flex-direction: row;
        align-items: stretch;
    }
    .fs-header {
        flex-direction: column;
        align-items: flex-start;
        justify-content: space-between;
        padding: 12px;
        width: 35%;
        max-width: 240px;
    }
    .fs-clock-wrap {
        flex: 0 0 35%;
        padding: 12px;
    }
    .fs-clock {
        font-size: clamp(2rem, 6vh, 3rem);
    }
    .fs-actions {
        flex: 1;
        padding: 12px;
        gap: 8px;
        justify-content: center;
    }
    .fs-btn-circle {
        width: min(55vh, 180px);
        height: min(55vh, 180px);
    }
    .fs-btn-circle .fs-btn-icon { font-size: 42px; }
    .fs-pausa-grid {
        gap: 8px;
        max-width: none;
    }
    .fs-btn-pausa {
        min-height: 70px;
        min-width: 70px;
        max-height: 100px;
        max-width: 100px;
    }
    .fs-btn-pausa .fs-btn-icon { font-size: 22px; }
    .fs-btn-pausa .fs-btn-label { font-size: 11px; }
    .fs-status-pill {
        margin: 4px 12px 0;
    }
}

/* Reducir animaciones si el usuario lo prefiere */
@media (prefers-reduced-motion: reduce) {
    .fs-btn-circle,
    .fs-btn-pausa,
    .fs-btn-pill,
    .fs-status-pill,
    .fs-toast,
    .fs-spinner {
        transition: none !important;
        animation: none !important;
    }
}
