/* RESET BASE */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Arial, sans-serif;
}

/* CORPO PAGINA */
body {
    background-color: #f4f4f4;
    color: #333;
}

/* HEADER DASHBOARD */
header {
    background-color: #1a73e8;
    color: white;
    padding: 15px 20px;
    font-size: 1.5em;
    font-weight: bold;
}

/* CONTENITORE PRINCIPALE */
.container {
    display: flex;
    min-height: 100vh;
}


/* CONTENUTO PRINCIPALE */
.main-content {
    flex: 1;
    padding: 20px;
}

/* TABELLE */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    background-color: #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

table th, table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

table th {
    background-color: #1a73e8;
    color: #fff;
}

/* Righe alternate e hover */
table tr:nth-child(even) { background-color: #f9f9f9; }
table tr:hover { background-color: #e8f0fe; }

/* PULSANTI */
button {
    padding: 6px 12px;
    margin: 2px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    color: #ffffff;
    background-color: #1a73e8;
    transition: background 0.2s;
}

button[name="entra"] { background-color: #28a745; }
button[name="esci"] { background-color: #dc3545; }
button[name="azione"][value="conferma"] { background-color: #28a745; }
button[name="azione"][value="rifiuta"] { background-color: #dc3545; }

button:hover { opacity: 0.9; }

.btn-edit {
    background-color: #1a73e8;
    color: #fff;
}

.btn-edit-disabled {
    background-color: #d97706 !important;
    color: #fff !important;
    cursor: not-allowed !important;
    opacity: 0.8;
}

.inline-edit-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.edit-fields {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.edit-fields label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
    font-weight: 600;
}

.edit-fields .input-small,
.edit-fields select {
    min-width: 140px;
}

.details-row td {
    background: #f7f9fc;
}

/* LINK */
a {
    color: #1a73e8;
    text-decoration: none;
}

a:hover { text-decoration: underline; }

/* MESSAGGI */
p {
    margin: 10px 0;
}

p[style*="color:green"] {
    font-weight: bold;
}

/* RESPONSIVE TABLE */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #ddd;
    }
}


/* LOGIN BOX */
.login-page {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex: 1;
    background: #f4f4f4;
}

.login-page .footer {
    flex-shrink: 0;
}

.login-box {
    background: #fff;
    padding: 40px 30px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    width: 90%;
    max-width: 350px;
    text-align: center;
}

@media (max-width: 768px) {
    .login-container {
        padding: 16px;
        align-items: stretch;
    }

    .login-box {
        width: 100%;
        max-width: none;
        min-height: auto;
        border-radius: 16px;
        padding: 42px 26px;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .login-box h2 {
        font-size: 2.05rem;
        margin-bottom: 36px;
    }

    .login-box input[type="text"],
    .login-box input[type="password"],
    .login-box button {
        font-size: 1.2rem;
        padding: 16px 18px;
    }

    .login-box p.error,
    .login-box .alert {
        font-size: 1rem;
    }
}

.login-box h2 {
    margin-bottom: 30px;
    color: #1a73e8;
}

.login-box input[type="text"],
.login-box input[type="password"] {
    width: 100%;
    padding: 10px 15px;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
}

.login-box button {
    width: 100%;
    padding: 10px;
    background-color: #1a73e8;
    border: none;
    color: white;
    font-size: 1em;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.2s;
}

.login-box button:hover {
    background-color: #1669c1;
}

.login-box p.error {
    color: #dc3545;
    margin-bottom: 15px;
    font-weight: bold;
}

/* =========================
   PULSANTI EXPORT CSV
========================= */

.export-box {
    margin-bottom: 20px;
    display: inline-block;
    gap: 15px;
    flex-wrap: wrap;
}

/* Pulsante base */
.btn-export {
    display: inline-flex;
    align-items: center;
    gap: 8px;

    padding: 10px 18px;

    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;

    text-decoration: none;
    font-weight: 600;
    font-size: 14px;

    border-radius: 8px;
    border: none;

    box-shadow: 0 3px 6px rgba(0,0,0,0.15);

    transition: all 0.25s ease;
}

/* Hover */
.btn-export:hover {
    background: linear-gradient(135deg, #4cf60e, #67ff5f);
    transform: translateY(-2px);
    box-shadow: 0 6px 10px rgba(0,0,0,0.2);
}

/* Click */
.btn-export:active {
    transform: scale(0.97);
}

/* Varianti applicate a cascata */
.btn-export-all {
    background: linear-gradient(135deg, #ffdc17, #dbc234);
}

.btn-export-all:hover {
    background: linear-gradient(135deg, #fafa04, #ffff00);
}

.btn-export-dett {
    background: linear-gradient(135deg, #9b59b6, #8e44ad);
}

.btn-export-dett:hover {
    background: linear-gradient(135deg, #e84393, #c0392b);
}

/* Mobile */
@media (max-width: 600px) {
    .export-box {
        flex-direction: column;
    }

    .btn-export {
        width: 100%;
        justify-content: center;
    }
}

/* ============================
   GESTIONE CANTIERI
============================ */

.cantieri-page {
    max-width: 1440px;
    margin: 0 auto;
}

.cantieri-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 18px;
}

.cantieri-heading h2,
.cantieri-card-heading h3 {
    margin: 0;
    color: #17324d;
}

.cantieri-eyebrow,
.cantieri-section-kicker {
    display: block;
    margin-bottom: 5px;
    color: #2f80a8;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.cantieri-intro {
    margin: 7px 0 0;
    color: #657587;
}

.cantieri-page .card {
    border: 1px solid #dce6ed;
    border-radius: 10px;
    box-shadow: 0 5px 18px rgba(23, 50, 77, 0.07);
}

.cantieri-create-card {
    padding: 24px;
    background: linear-gradient(135deg, #ffffff 0%, #f5fafc 100%);
}

.cantieri-card-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.cantieri-card-icon {
    display: inline-grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 50%;
    background: #dff2f8;
    color: #176b8d;
    font-size: 28px;
    line-height: 1;
}

.cantieri-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin: 0;
}

.cantieri-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.cantieri-field-wide,
.cantieri-form-actions {
    grid-column: 1 / -1;
}

.cantieri-field label {
    color: #34495e;
    font-size: 13px;
    font-weight: 700;
}

.cantieri-field label span {
    color: #7a8a99;
    font-weight: 400;
}

.cantieri-field input,
.cantieri-field select {
    width: 100%;
    min-height: 42px;
    margin: 0;
    border: 1px solid #cbd8e2;
    border-radius: 6px;
    background: #fff;
    color: #243b53;
    font-size: 15px;
}

.cantieri-field input:focus,
.cantieri-field select:focus {
    border-color: #2f80a8;
    box-shadow: 0 0 0 3px rgba(47, 128, 168, 0.14);
    outline: none;
}

.cantieri-field small {
    color: #718096;
    font-size: 12px;
}

.cantieri-form-actions {
    display: flex;
    justify-content: flex-start;
    margin-top: 2px;
}

.cantieri-form-actions .btn-primary {
    min-height: 42px;
    padding: 10px 18px;
    border-radius: 6px;
    background: #176b8d;
    font-weight: 700;
}

.cantieri-form-actions .btn-primary:hover {
    background: #125773;
}

.cantieri-list-card {
    padding: 24px;
}

.cantieri-edit-card {
    padding: 24px;
    background: #ffffff;
}

.cantieri-edit-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.85fr);
    gap: 20px;
    align-items: stretch;
}

.cantieri-edit-form {
    align-content: start;
}

.cantieri-map {
    min-height: 320px;
    border: 1px solid #dce6ed;
    border-radius: 8px;
    overflow: hidden;
}

.cantieri-cancel-link {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 8px 14px;
    border-radius: 6px;
    background: #6b7280;
    color: #fff;
    text-decoration: none;
}

.cantieri-cancel-link:hover {
    background: #4b5563;
    color: #fff;
    text-decoration: none;
}

.cantieri-list-heading {
    margin-bottom: 16px;
}

.cantieri-count {
    color: #718096;
    font-size: 13px;
}

@media (max-width: 760px) {
    .cantieri-create-card,
    .cantieri-list-card {
        padding: 18px;
    }

    .cantieri-form {
        grid-template-columns: 1fr;
    }

    .cantieri-field-wide,
    .cantieri-form-actions {
        grid-column: auto;
    }

    .cantieri-edit-layout {
        grid-template-columns: 1fr;
    }

    .cantieri-edit-card .cantieri-card-heading {
        align-items: flex-start;
    }

    .cantieri-map {
        min-height: 260px;
    }

}

/* ============================
   RESPONSIVE GLOBAL LAYOUT
============================ */

/* Reset base */
* {
    box-sizing: border-box;
}

/* Header */
header {
    padding: 15px;
    font-size: 20px;
    text-align: center;
}

/* Container principale */
.container {
    display: flex;
    min-height: 100vh;
}

/* Struttura pagina admin: header + contenuto + footer senza overflow forzato */
.app-page {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.app-page .container {
    flex: 1;
    min-height: 0;
}

.app-page .footer {
    flex-shrink: 0;
}

/* ============================
   SIDEBAR
============================ */

.sidebar {
    width: 220px;
    background: #003586;
    padding: 15px;
    flex-shrink: 0;
}

.sidebar a {
    display: block;
    padding: 10px;
    margin-bottom: 6px;
    font-weight: bold;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    background: #113c7c;
    transition: 0.2s;
}

.sidebar a:hover {
    background: #8dc6ff;
}

/* ============================
   MAIN CONTENT
============================ */

.main-content {
    flex: 1;
    padding: 20px;
    overflow-x: auto;
}

/* ============================
   TABELLE RESPONSIVE
============================ */

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

th, td {
    padding: 8px;
    text-align: center;
    border: 1px solid #ddd;
}

th {
    background: #f2f2f2;
}

/* Scroll orizzontale su mobile */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.hours-input {
    width: 8ch;
    min-width: 8ch;
    text-align: center;
}

/* ============================
   FORM
============================ */

form {
    margin-bottom: 15px;
}

input,
select,
button {
    padding: 8px;
    margin: 5px 0;

    border-radius: 5px;
    border: 1px solid #ccc;

    font-size: 14px;
}

button {
    cursor: pointer;
    background: #3498db;
    color: white;
    border: none;
}

button:hover {
    background: #2980b9;
}

/* Controlli gestione dipendenti */
#mostra-gestione,
#mostra-assenze {
    min-height: 34px;
    padding: 7px 12px;
    font-size: 13px;
}

#mostra-gestione[aria-pressed="true"],
#mostra-assenze[aria-pressed="true"] {
    background-color: #1a73e8;
}

#mostra-gestione[aria-pressed="false"],
#mostra-assenze[aria-pressed="false"] {
    background-color: #6b7280;
}

#mostra-gestione:hover,
#mostra-assenze:hover {
    background-color: #155fc0;
}

#menu-gestione input,
#menu-gestione select,
#menu-assenze input,
#menu-assenze select {
    padding: 7px 8px;
    font-size: 13px;
}

#menu-gestione button.btn-success,
#menu-assenze button.btn-success {
    background-color: #28a745;
}

#menu-gestione button.btn-danger,
#menu-assenze button.btn-danger {
    background-color: #dc3545;
}

/* ============================
   RESPONSIVE MOBILE
============================ */

@media (max-width: 900px) {

    /* Sidebar sopra */
    .container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 5px;
    }

    .sidebar a {
        flex: 1 1 45%;
        text-align: center;
        font-size: 14px;
    }

    header {
        font-size: 18px;
    }

    .hours-input {
        width: 100%;
        min-width: 8.5rem;
        font-size: 16px;
        padding-left: 12px;
        padding-right: 12px;
    }
}

/* ============================
   MOBILE SMALL
============================ */

@media (max-width: 600px) {

    header {
        font-size: 16px;
        padding: 10px;
    }

    .main-content {
        padding: 10px;
    }

    /* Tabelle scrollabili */
    table {
        font-size: 13px;
    }

    th, td {
        padding: 6px;
    }

    /* Form verticali */
    form {
        display: flex;
        flex-direction: column;
    }

    input,
    select,
    button {
        width: 100%;
    }

    /* Sidebar link grandi */
    .sidebar a {
        font-size: 13px;
        padding: 8px;
    }

    /* Gestione dipendenti: controlli leggibili e utilizzabili al tocco */
    #mostra-gestione,
    #mostra-assenze {
        flex: 1 1 auto;
        width: auto;
        min-height: 34px;
        padding: 7px 10px;
        font-size: 13px;
        margin: 0;
    }

    #mostra-gestione[aria-pressed="true"],
    #mostra-assenze[aria-pressed="true"] {
        background-color: #1a73e8;
    }

    #mostra-gestione[aria-pressed="false"],
    #mostra-assenze[aria-pressed="false"] {
        background-color: #6b7280;
    }

    #mostra-gestione:hover,
    #mostra-assenze:hover {
        background-color: #155fc0;
    }

    #menu-gestione .card,
    #menu-assenze .card {
        margin-bottom: 12px;
        padding: 12px;
    }

    #menu-gestione .inline-form,
    #menu-assenze .inline-form {
        align-items: stretch !important;
        gap: 6px !important;
    }

    #menu-gestione .inline-form label,
    #menu-assenze .inline-form label {
        width: 100%;
    }

    #menu-gestione input,
    #menu-gestione select,
    #menu-assenze input,
    #menu-assenze select {
        width: 100%;
        min-height: 36px;
        padding: 6px 8px;
        font-size: 13px;
        margin: 3px 0;
    }

    #menu-gestione button,
    #menu-assenze button {
        width: auto;
        min-height: 34px;
        padding: 6px 10px;
        font-size: 13px;
    }

    #menu-gestione button.btn-success,
    #menu-assenze button.btn-success {
        background-color: #28a745;
    }

    #menu-gestione button.btn-danger,
    #menu-assenze button.btn-danger {
        background-color: #dc3545;
    }

    #menu-gestione .table-wrapper,
    #menu-assenze .table-wrapper {
        margin: 0 -2px;
        overflow-x: auto;
    }

    #menu-gestione table,
    #menu-assenze table {
        min-width: 700px;
    }

    #menu-gestione th,
    #menu-gestione td,
    #menu-assenze th,
    #menu-assenze td {
        vertical-align: top;
        white-space: normal;
    }

    #menu-assenze h3,
    #menu-gestione h3 {
        font-size: 1.05rem;
        margin-bottom: 8px;
    }
}

/* DASHBOARD */

.dashboard-box{
    display: grid;
    grid-template-columns: repeat(auto-fit,minmax(180px,1fr));
    gap: 20px;
    margin: 20px 0;
}

.box{
    background: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;

    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
}

.box h3{
    margin-bottom: 10px;
    color: #333;
}

.box p{
    font-size: 28px;
    font-weight: bold;
    color: #2ecc71;
}

/* HEADER USER */



header.top-header{
    background: #2c3e50 !important;
    color: white !important;

    padding: 15px 20px !important;

    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;

    font-size: 18px;
    font-weight: bold;
}

.header-right{
    font-size: 14px !important;

    background: rgba(255,255,255,0.2) !important;

    padding: 6px 14px !important;
    border-radius: 20px !important;
}

.footer{
    text-align:center;
    padding:10px;
    background:#2c3e50;
    color:#fff;
    font-size: 13px;
    font-weight: bold;
}

.badge-orange{
    background:#f39c12;
    color:#fff;
    padding:4px 8px;
    border-radius:6px;
    font-size:12px;
    font-weight:bold;
    display:inline-block;
    white-space:nowrap;
}

/* Generic badge: evita andare a capo su dispositivi mobili */
.badge, .badge-orange, .badge-warning, .badge-success {
    white-space: nowrap;
}

.warning-text{
    margin-top:4px;
    font-size:12px;
    color:#e67e22;
    font-weight:bold;
}

.alert{
  padding:12px;
  border-radius:10px;
  margin-bottom:15px;
  font-weight:bold;
  font-size:14px;
}

.alert.success{ background:#eafaf1; color:#1e8449; border:1px solid #c8f0da; }
.alert.error{ background:#fdecea; color:#c0392b; border:1px solid #f5c6cb; }
.alert.warn{ background:#fff4e5; color:#b9770e; border:1px solid #ffe0b2; }

.form-card{
    background:#fff;
    padding:20px;
    border-radius:10px;
    box-shadow:0 3px 8px rgba(0,0,0,0.15);
    margin-bottom:20px;
}





