/* FTV HR - Stile Zucchetti Paghe / HR Infinity */
:root {
    --zuc-primary: #004785;
    --zuc-primary-dark: #003566;
    --zuc-primary-light: #0066b3;
    --zuc-accent: #ff7900;
    --zuc-accent-dark: #e56a00;
    --zuc-sidebar: #003d66;
    --zuc-sidebar-hover: #00508a;
    --zuc-topbar: #005baa;
    --zuc-bg: #e8ecf0;
    --zuc-panel: #ffffff;
    --zuc-border: #c5cdd6;
    --zuc-border-light: #dde3ea;
    --zuc-text: #2c3e50;
    --zuc-text-muted: #5f6b7a;
    --zuc-success: #2e7d32;
    --zuc-warning: #ed6c02;
    --zuc-error: #c62828;
    --zuc-radius: 3px;
    --zuc-shadow: 0 1px 3px rgba(0,55,100,.12);
    --font: 'Segoe UI', Tahoma, 'Source Sans 3', Arial, sans-serif;
    --sidebar-w: 220px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    font-size: 13px;
    color: var(--zuc-text);
    background: var(--zuc-bg);
    min-height: 100vh;
    line-height: 1.45;
}

body.app-layout {
    display: flex;
    flex-direction: column;
}

/* ===== TOP BAR ===== */
.zuc-topbar {
    background: linear-gradient(180deg, var(--zuc-topbar) 0%, var(--zuc-primary) 100%);
    color: #fff;
    height: 46px;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
    position: sticky;
    top: 0;
    z-index: 200;
    flex-shrink: 0;
}

.zuc-topbar-inner {
    width: 100%;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.zuc-brand {
    display: flex;
    align-items: center;
    gap: .65rem;
    text-decoration: none;
    color: #fff;
}

.zuc-brand-logo {
    background: #fff;
    color: var(--zuc-primary);
    font-weight: 800;
    font-size: .7rem;
    padding: .25rem .45rem;
    border-radius: 2px;
    letter-spacing: -.02em;
}

.zuc-brand-text {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: .01em;
}

.zuc-brand-sub {
    font-size: .65rem;
    opacity: .75;
    font-weight: 400;
    display: block;
    line-height: 1;
    margin-top: 1px;
}

.zuc-topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: .8rem;
}

.zuc-topbar-user {
    opacity: .95;
    padding-right: 1rem;
    border-right: 1px solid rgba(255,255,255,.25);
}

.zuc-topbar-date {
    opacity: .8;
    font-size: .75rem;
}

/* Legacy header compat */
.sap-header { display: none; }

.logo, .header-inner, .header-user, .main-nav { display: none; }

/* ===== APP SHELL ===== */
.app-shell {
    display: flex;
    flex: 1;
    min-height: calc(100vh - 46px);
}

/* ===== SIDEBAR ===== */
.zuc-sidebar {
    width: var(--sidebar-w);
    background: var(--zuc-sidebar);
    color: #fff;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 6px rgba(0,0,0,.15);
}

.zuc-sidebar-title {
    padding: .75rem 1rem .5rem;
    font-size: .65rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    opacity: .55;
    font-weight: 600;
}

.zuc-nav {
    list-style: none;
    padding: .25rem 0 1rem;
    flex: 1;
}

.zuc-nav a {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem 1rem;
    color: rgba(255,255,255,.88);
    text-decoration: none;
    font-size: .82rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: background .12s, border-color .12s;
}

.zuc-nav a:hover {
    background: var(--zuc-sidebar-hover);
    color: #fff;
}

.zuc-nav a.active {
    background: rgba(255,121,0,.15);
    border-left-color: var(--zuc-accent);
    color: #fff;
    font-weight: 600;
}

.zuc-nav-icon {
    width: 18px;
    text-align: center;
    font-size: .9rem;
    opacity: .9;
}

.zuc-sidebar-footer {
    padding: .75rem 1rem;
    border-top: 1px solid rgba(255,255,255,.1);
    font-size: .7rem;
    opacity: .5;
}

/* ===== MAIN CONTENT ===== */
.zuc-main-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.zuc-page-bar {
    background: var(--zuc-panel);
    border-bottom: 1px solid var(--zuc-border-light);
    padding: .6rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
}

.zuc-breadcrumb {
    font-size: .78rem;
    color: var(--zuc-text-muted);
}

.zuc-breadcrumb strong {
    color: var(--zuc-primary);
    font-weight: 600;
}

.sap-main, .zuc-main {
    flex: 1;
    padding: 1rem 1.25rem 1.5rem;
    max-width: 100%;
    width: 100%;
}

/* ===== FOOTER ===== */
.sap-footer, .zuc-footer {
    background: var(--zuc-panel);
    border-top: 1px solid var(--zuc-border-light);
    padding: .6rem 1.25rem;
    margin-top: auto;
}

.footer-inner, .zuc-footer-inner {
    display: flex;
    justify-content: space-between;
    font-size: .72rem;
    color: var(--zuc-text-muted);
    flex-wrap: wrap;
    gap: .5rem;
}

/* ===== PAGE HEADER ===== */
.page-header {
    margin-bottom: 1rem;
    padding-bottom: .75rem;
    border-bottom: 2px solid var(--zuc-primary);
}

.page-header h1 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--zuc-primary);
    text-transform: uppercase;
    letter-spacing: .02em;
}

.page-header p {
    color: var(--zuc-text-muted);
    margin-top: .2rem;
    font-size: .82rem;
}

/* ===== PANELS / CARDS ===== */
.card {
    background: var(--zuc-panel);
    border: 1px solid var(--zuc-border);
    border-radius: var(--zuc-radius);
    box-shadow: var(--zuc-shadow);
    margin-bottom: 1rem;
}

.card-header {
    padding: .55rem 1rem;
    background: linear-gradient(180deg, #f7f9fb 0%, #eef2f6 100%);
    border-bottom: 1px solid var(--zuc-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .5rem;
}

.card-header h2, .card-header h3 {
    font-size: .82rem;
    font-weight: 700;
    color: var(--zuc-primary);
    text-transform: uppercase;
    letter-spacing: .03em;
}

.card-body { padding: 1rem; }

/* ===== GRID ===== */
.grid { display: grid; gap: .75rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 992px) {
    .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .zuc-sidebar {
        position: fixed;
        left: -240px;
        top: 46px;
        bottom: 0;
        z-index: 150;
        transition: left .25s;
    }
    body.sidebar-open .zuc-sidebar { left: 0; }
    .zuc-menu-toggle { display: inline-flex !important; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.zuc-menu-toggle {
    display: none;
    background: rgba(255,255,255,.15);
    border: 1px solid rgba(255,255,255,.3);
    color: #fff;
    padding: .25rem .5rem;
    border-radius: 2px;
    cursor: pointer;
    font-size: 1rem;
}

/* ===== STAT TILES ===== */
.stat-tile {
    background: var(--zuc-panel);
    border: 1px solid var(--zuc-border);
    border-radius: var(--zuc-radius);
    padding: 1rem;
    border-top: 3px solid var(--zuc-primary-light);
    box-shadow: var(--zuc-shadow);
}

.stat-tile .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--zuc-primary);
    line-height: 1;
}

.stat-tile .stat-label {
    font-size: .72rem;
    color: var(--zuc-text-muted);
    margin-top: .4rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-weight: 600;
}

.stat-tile.warning { border-top-color: var(--zuc-warning); }
.stat-tile.warning .stat-value { color: var(--zuc-warning); }
.stat-tile.success { border-top-color: var(--zuc-success); }
.stat-tile.success .stat-value { color: var(--zuc-success); }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .35rem;
    padding: .4rem .85rem;
    font-family: inherit;
    font-size: .8rem;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--zuc-radius);
    cursor: pointer;
    text-decoration: none;
    transition: all .12s;
    line-height: 1.35;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(180deg, var(--zuc-accent) 0%, var(--zuc-accent-dark) 100%);
    color: #fff;
    border-color: var(--zuc-accent-dark);
    text-shadow: 0 1px 0 rgba(0,0,0,.1);
}
.btn-primary:hover {
    background: linear-gradient(180deg, #ff8c1a 0%, var(--zuc-accent) 100%);
}

.btn-secondary {
    background: linear-gradient(180deg, #fff 0%, #f0f3f7 100%);
    color: var(--zuc-primary);
    border-color: var(--zuc-border);
}
.btn-secondary:hover {
    background: #e8f0f8;
    border-color: var(--zuc-primary-light);
}

.btn-danger {
    background: linear-gradient(180deg, #e53935 0%, var(--zuc-error) 100%);
    color: #fff;
}
.btn-danger:hover { background: #b71c1c; }

.btn-ghost {
    background: rgba(255,255,255,.12);
    color: #fff;
    border: 1px solid rgba(255,255,255,.35);
}
.btn-ghost:hover { background: rgba(255,255,255,.22); }

.btn-sm { padding: .28rem .6rem; font-size: .75rem; }

/* ===== FORMS ===== */
.form-group { margin-bottom: .85rem; }

.form-group label {
    display: block;
    font-size: .75rem;
    font-weight: 600;
    color: var(--zuc-primary);
    margin-bottom: .25rem;
}

.form-control {
    width: 100%;
    padding: .45rem .6rem;
    font-family: inherit;
    font-size: .82rem;
    border: 1px solid var(--zuc-border);
    border-radius: var(--zuc-radius);
    background: #fff;
    color: var(--zuc-text);
}

.form-control:focus {
    outline: none;
    border-color: var(--zuc-primary-light);
    box-shadow: 0 0 0 2px rgba(0,102,179,.2);
}

textarea.form-control { min-height: 80px; resize: vertical; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: .75rem;
}

.form-actions {
    display: flex;
    gap: .5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
    padding-top: .75rem;
    border-top: 1px solid var(--zuc-border-light);
}

/* ===== TABLES (stile gestionale) ===== */
.table-wrap { overflow-x: auto; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .8rem;
    border: 1px solid var(--zuc-border);
}

table.data-table th {
    background: linear-gradient(180deg, var(--zuc-primary-light) 0%, var(--zuc-primary) 100%);
    color: #fff;
    text-align: left;
    padding: .5rem .75rem;
    font-weight: 600;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    border: 1px solid var(--zuc-primary-dark);
    white-space: nowrap;
}

table.data-table td {
    padding: .45rem .75rem;
    border: 1px solid var(--zuc-border-light);
    vertical-align: middle;
}

table.data-table tbody tr:nth-child(even) td { background: #f4f7fa; }
table.data-table tbody tr:hover td { background: #e3eef8; }

table.data-table code {
    font-size: .78rem;
    background: #eef2f6;
    padding: .1rem .3rem;
    border-radius: 2px;
}

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: .15rem .45rem;
    font-size: .68rem;
    font-weight: 700;
    border-radius: 2px;
    text-transform: uppercase;
    letter-spacing: .03em;
    border: 1px solid transparent;
}

.badge-success { background: #e8f5e9; color: var(--zuc-success); border-color: #a5d6a7; }
.badge-warning { background: #fff3e0; color: #e65100; border-color: #ffcc80; }
.badge-error { background: #ffebee; color: var(--zuc-error); border-color: #ef9a9a; }
.badge-neutral { background: #eceff1; color: var(--zuc-text-muted); border-color: #cfd8dc; }
.badge-info { background: #e3f2fd; color: var(--zuc-primary); border-color: #90caf9; }

/* ===== ALERTS ===== */
.alert {
    padding: .65rem 1rem;
    border-radius: var(--zuc-radius);
    margin-bottom: .75rem;
    font-size: .82rem;
    border: 1px solid;
}

.alert-success { background: #e8f5e9; border-color: #a5d6a7; color: #1b5e20; }
.alert-error { background: #ffebee; border-color: #ef9a9a; color: #b71c1c; }
.alert-warning { background: #fff3e0; border-color: #ffcc80; color: #e65100; }
.alert-info { background: #e3f2fd; border-color: #90caf9; color: var(--zuc-primary-dark); }

/* ===== LOGIN (portale Zucchetti-style) ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: stretch;
    background: var(--zuc-bg);
}

.login-page::before {
    content: '';
    flex: 1;
    background: linear-gradient(160deg, var(--zuc-topbar) 0%, var(--zuc-primary-dark) 60%, #002847 100%);
    display: none;
}

.login-card {
    background: #fff;
    width: 100%;
    max-width: 440px;
    margin: auto;
    border: 1px solid var(--zuc-border);
    box-shadow: 0 4px 24px rgba(0,55,100,.18);
    border-radius: var(--zuc-radius);
    overflow: hidden;
}

@media (min-width: 768px) {
    .login-page {
        padding: 2rem;
        background: linear-gradient(135deg, #003566 0%, #005baa 50%, #e8ecf0 50%);
    }
    .login-card { margin: auto 15% auto auto; }
}

.login-header {
    background: linear-gradient(180deg, var(--zuc-topbar) 0%, var(--zuc-primary) 100%);
    color: #fff;
    padding: 1.75rem 2rem;
    text-align: left;
    border-bottom: 3px solid var(--zuc-accent);
}

.login-header h1 {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: .15rem;
}

.login-header p {
    opacity: .85;
    font-size: .82rem;
}

.login-header .zuc-brand-logo {
    display: inline-block;
    margin-bottom: .75rem;
}

.login-body { padding: 1.5rem 2rem 2rem; }

.login-tabs {
    display: flex;
    margin-bottom: 1.25rem;
    border: 1px solid var(--zuc-border);
    border-radius: var(--zuc-radius);
    overflow: hidden;
}

.login-tabs a {
    flex: 1;
    text-align: center;
    padding: .55rem;
    text-decoration: none;
    color: var(--zuc-text-muted);
    font-weight: 600;
    font-size: .8rem;
    background: #f4f7fa;
    border-right: 1px solid var(--zuc-border);
}

.login-tabs a:last-child { border-right: none; }

.login-tabs a.active {
    color: #fff;
    background: var(--zuc-primary);
}

.login-demo {
    margin-top: 1rem;
    padding: .75rem;
    background: #f4f7fa;
    border: 1px solid var(--zuc-border-light);
    border-left: 3px solid var(--zuc-accent);
    font-size: .78rem;
    line-height: 1.55;
}

.login-demo-title {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--zuc-primary);
    margin-bottom: .4rem;
}

.login-demo code {
    background: #fff;
    padding: .05rem .3rem;
    border: 1px solid var(--zuc-border);
    font-size: .75rem;
    color: var(--zuc-primary-dark);
}

.login-demo p + p { margin-top: .4rem; }

/* ===== TILES ===== */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: .65rem;
}

.tile {
    background: linear-gradient(180deg, #fff 0%, #f7f9fb 100%);
    border: 1px solid var(--zuc-border);
    border-radius: var(--zuc-radius);
    padding: 1rem .75rem;
    text-align: center;
    text-decoration: none;
    color: var(--zuc-text);
    transition: all .12s;
    box-shadow: var(--zuc-shadow);
    border-bottom: 2px solid var(--zuc-primary-light);
}

.tile:hover {
    border-color: var(--zuc-accent);
    border-bottom-color: var(--zuc-accent);
    background: #fff;
    box-shadow: 0 3px 10px rgba(0,71,133,.15);
}

.tile-icon { font-size: 1.6rem; margin-bottom: .4rem; }
.tile-label { font-size: .75rem; font-weight: 700; color: var(--zuc-primary); text-transform: uppercase; letter-spacing: .02em; }

/* ===== QR ===== */
.qr-container { text-align: center; padding: 1.5rem; }
.qr-container img {
    border: 1px solid var(--zuc-border);
    border-radius: var(--zuc-radius);
    padding: .4rem;
    background: #fff;
}

/* ===== MISC ===== */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--zuc-text-muted);
}

.empty-state .icon { font-size: 2.5rem; margin-bottom: .75rem; opacity: .4; }

.upload-zone {
    border: 2px dashed var(--zuc-border);
    border-radius: var(--zuc-radius);
    padding: 1.5rem;
    text-align: center;
    background: #f7f9fb;
    cursor: pointer;
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--zuc-primary-light);
    background: #e8f2fa;
}

.upload-zone input[type=file] { display: none; }

.comm-item {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--zuc-border-light);
    cursor: pointer;
}

.comm-item:hover { background: #e8f2fa; }
.comm-item.unread { border-left: 3px solid var(--zuc-accent); background: #fffaf5; }
.comm-item .comm-title { font-weight: 600; font-size: .85rem; }
.comm-item .comm-meta { font-size: .75rem; color: var(--zuc-text-muted); margin-top: .15rem; }

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,40,70,.5);
    z-index: 300;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-overlay.open { display: flex; }

.modal {
    background: #fff;
    border: 1px solid var(--zuc-border);
    border-radius: var(--zuc-radius);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,.25);
}

.modal-header {
    padding: .65rem 1rem;
    background: linear-gradient(180deg, var(--zuc-primary-light) 0%, var(--zuc-primary) 100%);
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body { padding: 1rem; }

.text-muted { color: var(--zuc-text-muted); }
.text-small { font-size: .75rem; }
.mt-1 { margin-top: .4rem; }
.mt-2 { margin-top: .75rem; }
.mb-2 { margin-bottom: .75rem; }

/* Timbratura */
.timbratura-employee { text-align: center; margin-bottom: 1.25rem; }
.timbratura-name { font-size: 1.2rem; font-weight: 700; color: var(--zuc-primary); }
.timbratura-buttons { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; }
.timbratura-btn { flex: 1; min-width: 110px; padding: .85rem; font-size: .9rem; }
.timbratura-btn.in { background: linear-gradient(180deg, #43a047 0%, var(--zuc-success) 100%); color: #fff; border-color: #2e7d32; }
.timbratura-btn.out { background: linear-gradient(180deg, #fff 0%, #f0f3f7 100%); color: var(--zuc-warning); border-color: var(--zuc-warning); }
.qr-reader-box { max-width: 400px; margin: 0 auto; border: 1px solid var(--zuc-border); overflow: hidden; }

/* Area studio vs dipendente */
.area-studio .zuc-sidebar { background: #003556; }
.area-employee .zuc-sidebar { background: #003d66; }
.area-employee .zuc-nav a.active { border-left-color: #4caf50; background: rgba(76,175,80,.15); }
