/* Reset e Variabili BASE */
:root {
    --bg-gradient: linear-gradient(135deg, #0d1b2a, #1b263b);
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.15);
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --text-primary: #ffffff;
    --text-secondary: #a0aec0;

    --color-in: #22c55e;
    /* Verde per ingresso */
    --color-out: #f43f5e;
    /* Rosso per uscita */
    --color-in-glow: rgba(34, 197, 94, 0.4);
    --color-out-glow: rgba(244, 63, 94, 0.4);

    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    /* Evita selezioni e scroll su Tablet Touch */
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

/* Sfondo Blobs */
.bg-animated {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.6;
    animation: moveBlob 20s infinite alternate;
}

.blob-1 {
    width: 600px;
    height: 600px;
    background: rgba(37, 99, 235, 0.4);
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: rgba(139, 92, 246, 0.3);
    bottom: -50px;
    right: -50px;
    animation-delay: -10s;
}

@keyframes moveBlob {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(150px, 150px) scale(1.1);
    }
}

/* Container Layout */
.app-container {
    max-width: 1600px;
    /* Più largo per ospitare fino a 5-6 card per riga */
    margin: 0 auto;
    padding: 1.5rem 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header & Clock */
.header {
    text-align: center;
    margin-bottom: 3rem;
    padding-top: 2rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem 3rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--card-shadow);
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 1.5rem;
}

.brand i {
    color: #60a5fa;
    font-size: 2rem;
}

.date-time {
    text-align: right;
}

#clock_time {
    font-size: 3rem;
    font-weight: 700;
    line-height: 1;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    font-variant-numeric: tabular-nums;
}

#clock_date {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-top: 0.2rem;
    text-transform: capitalize;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.2rem;
    margin-top: 1rem;
}

/* Formazione Griglia Dipendenti */
.employee-grid {
    flex: 1;
    display: grid;
    /* auto-fill si adatta: 5~6 colonne su tablet 1280px, 3~4 su tablet 768px */
    grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
    gap: 1rem;
    padding-bottom: 2rem;
    align-content: start;
    /* Le card iniziano dall'alto, non si espandono verticalmente */
}

.loader {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-secondary);
    padding: 4rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--glass-border);
    border-top-color: #60a5fa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Cards */
.emp-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem 1rem;
    /* Compattate rispetto alle prime 2rem */
    text-align: center;
    cursor: pointer;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    min-height: 160px;
    /* Altezza minima uniforme */
}

.emp-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, transparent 100%);
    opacity: 0;
    transition: var(--transition);
}

.emp-card:hover,
.emp-card:active {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    background: rgba(255, 255, 255, 0.12);
}

.emp-card:hover::before {
    opacity: 1;
}

.emp-avatar {
    width: 64px;
    height: 64px;
    /* Ridotto da 80px */
    border-radius: 32px;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    /* Ridotto da 2rem */
    color: #e2e8f0;
    margin-bottom: 0.2rem;
    position: relative;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 3px solid #1e293b;
    transition: var(--transition);
}

.status-in .status-dot {
    background: var(--color-in);
    box-shadow: 0 0 10px var(--color-in-glow);
}

.status-out .status-dot {
    background: var(--color-secondary);
    /* Default spento/grigio */
    background: #64748b;
}

.emp-name {
    font-size: 1.05rem;
    /* Ridotto da 1.4rem per nomi lunghi */
    font-weight: 600;
    line-height: 1.2;
}

.emp-status-text {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
}

.status-in .emp-status-text {
    color: var(--color-in);
}

.status-out .emp-status-text {
    color: var(--text-secondary);
}

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem 0;
}

.admin-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.2);
    transition: var(--transition);
}

.admin-link:hover {
    color: white;
    background: rgba(0, 0, 0, 0.4);
}

/* Modale */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-card {
    background: #1e293b;
    border: 1px solid var(--glass-border);
    padding: 2.5rem;
    border-radius: 24px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75);
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: 90%;
    max-width: 400px;
}

.modal.hidden .modal-card {
    transform: scale(0.9);
}

.modal-card h2 {
    margin-bottom: 0.5rem;
    font-size: 1.8rem;
}

.modal-card p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
}

.btn {
    flex: 1;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-confirm {
    background: #3b82f6;
    color: white;
}

.btn-confirm:hover {
    background: #2563eb;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    z-index: 1000;
    opacity: 1;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(50px);
    pointer-events: none;
}

.toast-content {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 100px;
    /* Pillow shape for apple-like feeling */
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    gap: 1.2rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
}

.toast i {
    font-size: 2rem;
}

.toast i.success {
    color: var(--color-in);
}

.toast i.logout {
    color: var(--color-out);
}

.toast i.error {
    color: #f59e0b;
}

.toast-body h3 {
    font-size: 1.1rem;
    margin-bottom: 0.1rem;
}

.toast-body p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .employee-grid {
        grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    #clock_time {
        font-size: 2.5rem;
    }

    .employee-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 0.8rem;
    }

    .emp-card {
        padding: 1rem 0.8rem;
        min-height: 130px;
    }

    .emp-avatar {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }

    .emp-name {
        font-size: 0.9rem;
    }
}

/* Footer Branding */
.kiosk-footer {
    text-align: center;
    padding: 1.5rem 0 0.5rem;
    color: rgba(255, 255, 255, 0.15);
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    user-select: none;
}