/*
  base.css
*/

:root{
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 10px 30px rgba(0,0,0,.06);

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;

  --radius: 14px;
  --radius-sm: 10px;
}

*{ box-sizing: border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 10% 0%, rgba(37,99,235,.12), transparent 55%),
    radial-gradient(900px 400px at 90% 20%, rgba(22,163,74,.10), transparent 60%),
    var(--bg);
  line-height: 1.45;
}

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

/* ===== Layout centrato ===== */
.container{
  width: min(560px, calc(100% - 32px));
  margin: 90px auto 48px auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
}

.container-lg{
  width: min(980px, calc(100% - 32px));
}

/* Titoli */
h1,h2,h3{
  margin: 0 0 14px 0;
  letter-spacing: -0.01em;
}
p{ margin: 10px 0; }

/* ===== TOOLBAR/HEADER BIANCO FISSO ===== */
.toolbar{
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  padding: 14px 0;
}

.toolbar-inner{
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar .left,
.toolbar .right{
  display:flex;
  align-items:center;
  gap: 10px;
  flex-wrap: wrap;
}

.toolbar-title{
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
}

/* ===== PULSANTE AGGIORNA ===== */
.btn-refresh{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-refresh:hover{
  background: rgba(37,99,235,0.06);
  border-color: var(--primary);
  text-decoration: none;
}

/* ===== Bottoni ===== */
.btn,
button,
input[type="submit"]{
  appearance: none;
  border: 0;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  padding: 11px 16px;
  cursor: pointer;
  transition: transform .05s ease, background .15s ease, box-shadow .15s ease;
  box-shadow: 0 8px 18px rgba(37,99,235,.18);
}

.btn:hover,
button:hover,
input[type="submit"]:hover{
  background: var(--primary-hover);
  text-decoration: none;
}

.btn:active,
button:active,
input[type="submit"]:active{
  transform: translateY(1px);
}

.btn.secondary{
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn.secondary:hover{
  background: rgba(37,99,235,.06);
}

.logout-link{ color: var(--danger); font-weight: 700; }

/* ===== Form ===== */
form{ margin-top: 12px; }

label{
  display:block;
  font-size: 14px;
  color: var(--muted);
  margin: 12px 0 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea{
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  background: #fff;
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}

textarea{ min-height: 140px; resize: vertical; }

input:focus,
select:focus,
textarea:focus{
  border-color: rgba(37,99,235,.55);
  box-shadow: 0 0 0 4px rgba(37,99,235,.12);
}

.form-actions{
  margin-top: 18px;
  display:flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items:center;
}

.form-actions .btn,
.form-actions button,
.form-actions input[type="submit"]{
  margin-top: 0;
}

form input[type="submit"]{ margin-top: 16px; }

input[type="file"]{
  width: 100%;
  padding: 10px 0;
}

/* ===== Messaggi ===== */
.message,
.success-message,
.error-message{
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f9fafb;
  margin: 12px 0;
}

.success-message{
  border-color: rgba(22,163,74,.25);
  background: rgba(22,163,74,.08);
  color: #065f46;
}

.error-message{
  border-color: rgba(220,38,38,.25);
  background: rgba(220,38,38,.08);
  color: #7f1d1d;
}

/* ===== Tabelle ===== */
table{
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
}

th,td{
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

th{
  background: #f3f4f6;
  color: #374151;
  font-weight: 700;
}

tr:last-child td{ border-bottom: 0; }

select{
  min-width: 260px;
}

/* ===== Responsive ===== */
@media (max-width: 520px){
  .container{
    margin: 80px auto 20px auto;
    padding: 18px;
    border-radius: 16px;
  }
  
  .toolbar{ 
    padding: 10px 0;
  }
  
  .toolbar-inner{
    padding: 0 12px;
  }
  
  .toolbar-title{
    font-size: 14px;
  }
  
  .btn, button, input[type="submit"]{
    width: 100%;
    justify-content: center;
  }
  
  .form-actions{
    flex-direction: column;
    align-items: stretch;
  }
  
  select{ min-width: 100%; }
}

@media (min-width: 900px){
  .container{
    margin: 90px auto 70px auto;
    padding: 32px;
  }
}

/* ===== ADMIN DASHBOARD ===== */
body.admin .admin-dashboard-wrap{
  max-width: 980px;
  margin: 90px auto 40px;
  padding: 0 16px;
}

body.admin .admin-box{
  background: rgba(255,255,255,0.92);
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.08);
  border: 1px solid rgba(0,0,0,0.06);
}

body.admin .admin-box h1{
  margin: 0 0 8px;
  font-size: 34px;
  line-height: 1.15;
}

body.admin .admin-box p{
  margin: 0 0 18px;
  opacity: .85;
}

body.admin .dash-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}

body.admin .dash-item{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,0.10);
  background: rgba(255,255,255,0.85);
  text-decoration: none;
  transition: transform .10s ease, box-shadow .10s ease, border-color .10s ease;
}

body.admin .dash-item:hover{
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(0,0,0,0.08);
  border-color: rgba(0,0,0,0.16);
}

body.admin .dash-item strong{
  display: block;
  font-size: 18px;
  line-height: 1.2;
}

body.admin .dash-item span{
  display: block;
  margin-top: 4px;
  font-size: 13px;
  opacity: .75;
}

body.admin .dash-pill{
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.12);
  font-size: 13px;
  opacity: .80;
  background: rgba(255,255,255,0.65);
}

@media (max-width: 820px){
  body.admin .dash-grid{ grid-template-columns: 1fr; }
  body.admin .admin-box h1{ font-size: 30px; }
  body.admin .admin-box{ padding: 22px; }
}

/* Varianti bottoni */
.btn.btn-danger,
.btn-danger {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  box-shadow: none;
  font-weight: 500;
}

.btn.btn-danger:hover,
.btn-danger:hover {
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.25);
  color: #991b1b;
}

.btn.btn-edit {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn.btn-edit:hover {
  background: rgba(37, 99, 235, 0.06);
  border-color: rgba(37, 99, 235, 0.25);
}

table .btn {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 8px;
}

.form-actions .btn + .btn {
  margin-left: 0;
}

/* ===== STATISTICHE DASHBOARD ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 24px 0;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: left;
}

.stat-label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.stat-footer {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* ===== STATUS BADGE ===== */
.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
}

.status-presente {
  background: rgba(22, 163, 74, 0.1);
  color: #16a34a;
}

.status-completato {
  background: rgba(37, 99, 235, 0.1);
  color: #2563eb;
}

.status-assente {
  background: rgba(107, 114, 128, 0.1);
  color: #6b7280;
}