@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

:root {
    --primary: #009ee0;
    --primary-dark: #007eb3;
    --sidebar-bg: #212529;
    --sidebar-width: 240px;
    --header-height: 56px;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
    font-family: 'Roboto', sans-serif;
    font-size: 0.9rem;
    background-color: #e7eef6;
    min-height: 100%;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* =========================================
   LAYOUT WRAPPER
   ========================================= */
#wrapper {
    display: flex;
    min-height: 100vh;
}

/* =========================================
   SIDEBAR
   ========================================= */
.main-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 8px rgba(0,0,0,0.3);
}

.main-sidebar.collapsed {
    transform: translateX(calc(-1 * var(--sidebar-width)));
}

.sidebar-brand {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    text-align: center;
}

#sidebar-logo {
    max-width: 160px;
    max-height: 50px;
    filter: brightness(0) invert(1);
}

#sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0 30px;
}

#sidebar-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#sidebar-menu ul li a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255,255,255,0.75);
    font-size: 0.88rem;
    font-weight: 400;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    text-decoration: none;
}

#sidebar-menu ul li a .fa {
    width: 20px;
    margin-right: 10px;
    font-size: 1rem;
}

#sidebar-menu ul li a span {
    flex: 1;
}

#sidebar-menu ul li a:hover {
    color: #fff;
    background-color: rgba(0,158,224,0.2);
    border-left-color: var(--primary);
}

#sidebar-menu ul li a.active {
    color: #fff;
    background-color: var(--primary);
    border-left-color: #fff;
}

.sidebar-divider {
    border-top: 1px solid rgba(255,255,255,0.1);
    margin: 8px 0;
}

/* =========================================
   PAGE CONTENT
   ========================================= */
#page-content-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

#page-content-wrapper.full-width {
    margin-left: 0;
}

/* =========================================
   HEADER BAR
   ========================================= */
.headerbar {
    background: #fff;
    height: var(--header-height);
    border-bottom: 1px solid #dee2e6;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.headerbar .navbar-text {
    font-size: 1rem;
}

/* =========================================
   MAIN CONTENT
   ========================================= */
.main-content {
    padding: 24px 20px;
    flex: 1;
}

/* =========================================
   LOGIN PAGE
   ========================================= */
body.login-page {
    background: linear-gradient(135deg, #0f5c8a 0%, #009ee0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

.login-logo {
    display: block;
    max-width: 200px;
    margin: 0 auto 24px;
}

.login-card h2 {
    text-align: center;
    color: #333;
    font-weight: 700;
    margin-bottom: 28px;
    font-size: 1.4rem;
}

/* =========================================
   CARDS E STATS
   ========================================= */
.stat-card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

.stat-card .card-body {
    padding: 20px;
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: #fff;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
}

.stat-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    font-weight: 500;
}

/* =========================================
   TIMBRA BUTTON
   ========================================= */
.timbra-container {
    text-align: center;
    padding: 20px 0;
}

.btn-timbra {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    border: none;
    box-shadow: 0 8px 30px rgba(0,158,224,0.4);
    transition: all 0.3s;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-timbra .fa {
    font-size: 2.5rem;
}

.btn-timbra:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 40px rgba(0,158,224,0.5);
}

.btn-timbra.entrata {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: #fff;
}

.btn-timbra.uscita {
    background: linear-gradient(135deg, #dc3545, #e83e8c);
    color: #fff;
}

.btn-timbra.pausa {
    background: linear-gradient(135deg, #ffc107, #fd7e14);
    color: #fff;
}

.orario-corrente {
    font-size: 3rem;
    font-weight: 300;
    letter-spacing: 2px;
    color: #333;
    font-variant-numeric: tabular-nums;
}

.data-corrente {
    color: #6c757d;
    font-size: 1rem;
}

/* =========================================
   TABLES
   ========================================= */
.table thead th {
    background-color: #f8f9fa;
    border-top: none;
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #495057;
}

/* =========================================
   BADGE COLORS
   ========================================= */
.badge {
    font-size: 0.75rem;
    padding: 4px 8px;
    font-weight: 500;
}

/* =========================================
   MOBILE / PWA
   ========================================= */
@media (max-width: 768px) {
    .main-sidebar {
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }

    .main-sidebar.show-mobile {
        transform: translateX(0);
    }

    #page-content-wrapper {
        margin-left: 0;
    }

    .main-content {
        padding: 16px 12px;
    }

    .orario-corrente {
        font-size: 2.2rem;
    }

    .btn-timbra {
        width: 150px;
        height: 150px;
    }

    .stat-value {
        font-size: 1.6rem;
    }
}

/* Overlay per sidebar mobile */
#sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

#sidebar-overlay.show {
    display: block;
}

/* Scrollbar sidebar */
#sidebar-menu::-webkit-scrollbar { width: 4px; }
#sidebar-menu::-webkit-scrollbar-track { background: transparent; }
#sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

/* Misc */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.card-header {
    background-color: #fff;
    border-bottom: 2px solid var(--primary);
    font-weight: 600;
    font-size: 0.95rem;
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.border-primary { border-color: var(--primary) !important; }
.text-primary { color: var(--primary) !important; }
.bg-primary { background-color: var(--primary) !important; }

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(0,158,224,0.25);
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #dee2e6;
}

.page-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
    color: #343a40;
}

/* PWA install banner */
#pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid #dee2e6;
    padding: 12px 16px;
    display: none;
    align-items: center;
    justify-content: space-between;
    z-index: 9999;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
}

#pwa-install-banner.show {
    display: flex;
}
