/* Grafica principale */
:root {
  --bg1: #EEF2FF; --bg2: #F0FDFA; --bg3: #FFF7ED;
  --glass-bg: rgba(255,255,255,0.72);
}
html, body { height: 100%; margin: 0; font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial; }
body { background: linear-gradient(135deg, var(--bg1) 0%, var(--bg2) 50%, var(--bg3) 100%); color: #102a43; }

/* ===== GLASS ===== */
.glass { background: var(--glass-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid rgba(255,255,255,0.4); border-radius: 20px; box-shadow: 0 8px 32px rgba(0,0,0,0.06); }

/* ===== HEADER (top sticky bar) ===== */
.wc-header { padding: 14px 20px 12px; background: rgba(255,255,255,0.6); backdrop-filter: blur(20px); position: sticky; top: 0; z-index: 50; border-bottom: 1px solid rgba(255,255,255,0.5); }
.wc-header .inner { max-width: 1200px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.wc-title { margin: 0; font-size: 20px; font-weight: 900; color: #1E293B; }
.wc-sub { margin: 2px 0 0; font-size: 12px; color: #94A3B8; font-weight: 500; }

/* ===== TABS ===== */
.wc-tabs { max-width: 1200px; margin: 10px auto 0; }
.tabs { display: flex; gap: 4px; background: rgba(0,0,0,0.04); border-radius: 14px; padding: 4px; }
.tabs button { flex: 1; padding: 9px 12px; border: none; border-radius: 11px; cursor: pointer; font-size: 12px; font-weight: 600; transition: all .15s; background: transparent; color: #94A3B8; white-space: nowrap; }
.tabs button.active { background: white; color: #1E293B; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }

/* ===== TOPBAR (area titolo pagina dentro main-content) ===== */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 8px; flex-wrap: wrap; gap: 10px; }
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-title { margin: 0; font-size: 22px; font-weight: 900; color: #1E293B; }
.topbar-subtitle { margin: 2px 0 0; font-size: 13px; color: #64748B; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ===== MONTH SELECTOR ===== */
.month-selector { display: flex; gap: 6px; align-items: center; }
.month-selector select, .month-selector input { padding: 7px 10px; border-radius: 10px; border: 2px solid #E2E8F0; background: white; font-size: 13px; font-family: inherit; }
.month-selector input { width: 76px; }

/* ===== NOTIFICATION BUTTON ===== */
.notif-btn { padding: 8px 10px; border-radius: 10px; background: rgba(239,68,68,0.1); border: 1.5px solid rgba(239,68,68,0.2); color: #EF4444; cursor: pointer; font-size: 15px; position: relative; }
.notif-dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; background: #EF4444; border-radius: 50%; border: 2px solid white; }

/* ===== SIDEBAR TOGGLE (hamburger) ===== */
.sidebar-toggle { display: none; background: none; border: 1.5px solid #E2E8F0; font-size: 18px; cursor: pointer; padding: 5px 9px; border-radius: 8px; color: #1E293B; line-height: 1; }

/* ===== SIDEBAR OVERLAY ===== */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 199; }
.sidebar-overlay.active { display: block; }

/* ===== FORMS ===== */
input[type=date], input[type=number], select, input[type=text] { padding: 8px 12px; border-radius: 12px; border: 2px solid #E2E8F0; background: white; font-size: 14px; }
button.btn-primary { padding: 10px 14px; border-radius: 12px; border: none; background: linear-gradient(135deg,#3B82F6,#6366F1); color: white; font-weight: 800; }

/* ===== BADGES ===== */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 10px; font-weight: 700; font-size: 12px; }
.op-badge { font-weight: 800; font-size: 11px; }
.badge-green { background: #ECFDF5; color: #065F46; }
.badge-red { background: #FEF2F2; color: #991B1B; }
.badge-yellow { background: #FFFBEB; color: #92400E; }
.badge-gray { background: #F1F5F9; color: #475569; }
.badge-purple { background: #F3E8FF; color: #7C3AED; }

/* ===== BUTTONS ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 10px; border: none; cursor: pointer; font-weight: 700; font-size: 14px; text-decoration: none; font-family: inherit; transition: all .15s; }
.btn-primary { background: linear-gradient(135deg,#3B82F6,#6366F1); color: white; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: #F1F5F9; color: #1E293B; border: 1px solid rgba(0,0,0,0.06); }
.btn-secondary:hover { background: #E2E8F0; }
.btn-danger { background: #EF4444; color: white; }
.btn-danger:hover { background: #DC2626; }
.btn-green { background: #10B981; color: white; }
.btn-green:hover { background: #059669; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }

/* ===== TABLES ===== */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table thead th { background: #F8FAFC; padding: 10px 8px; text-align: left; font-weight: 700; font-size: 12px; color: #64748B; border-bottom: 2px solid #E2E8F0; white-space: nowrap; }
.table tbody td { padding: 10px 8px; border-top: 1px solid rgba(0,0,0,0.04); vertical-align: middle; }
.table tbody tr:hover { background: rgba(0,0,0,0.02); }

/* ===== PAGE LAYOUT ===== */
.page-content { max-width: 1200px; margin: 0 auto; padding: 16px 20px 40px; }

/* ===== CARDS ===== */
.card { padding: 16px; }
.card-highlight { padding: 16px; }
.card-title { font-weight: 800; font-size: 14px; margin-bottom: 10px; color: #1E293B; }

/* ===== GRIDS ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.grid-6 { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }

/* ===== STAT MINI ===== */
.stat-mini { padding: 14px; text-align: center; }
.stat-num { font-weight: 800; font-size: 22px; }
.stat-lbl { font-size: 12px; color: #64748B; margin-top: 2px; }

/* ===== STAT BOX (statistiche) ===== */
.stat-box { text-align: center; padding: 8px 4px; }
.stat-box-num { font-weight: 800; font-size: 18px; }
.stat-box-lbl { font-size: 10px; color: #64748B; text-transform: uppercase; letter-spacing: .3px; }

/* ===== PROGRESS BAR ===== */
.progress-bar-wrap { height: 6px; background: rgba(0,0,0,0.07); border-radius: 6px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 6px; transition: width .4s; }

/* ===== EMPTY STATE ===== */
.empty-state { color: #64748B; text-align: center; padding: 20px 0; font-size: 13px; }

/* ===== TURNO ROW (dashboard prossimi turni) ===== */
.turno-row { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px dashed rgba(0,0,0,0.05); align-items: center; }
.turno-row:last-child { border-bottom: none; }
.turno-row.assente { opacity: 0.7; }
.turno-date { width: 56px; text-align: center; flex-shrink: 0; }
.turno-date .day-num { font-weight: 800; font-size: 18px; display: block; line-height: 1; }
.turno-date .day-name { font-size: 11px; color: #94A3B8; font-weight: 600; text-transform: uppercase; }
.turno-info { flex: 1; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }

/* ===== RICHIESTA ROW ===== */
.richiesta-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px dashed rgba(0,0,0,0.05); gap: 8px; }
.richiesta-row:last-child { border-bottom: none; }
.richiesta-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.richiesta-tipo { font-weight: 700; font-size: 13px; }
.richiesta-date { font-size: 11px; color: #94A3B8; }

/* ===== CONFLICT ROW (admin/dashboard) ===== */
.conflict-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 6px 0; border-bottom: 1px dashed rgba(0,0,0,0.05); }
.conflict-row:last-child { border-bottom: none; }
.conflict-date { font-size: 13px; font-weight: 700; color: #475569; }

/* ===== CONFLICT BLOCK (statistiche) ===== */
.conflict-block { border-top: 1px solid rgba(0,0,0,0.05); padding: 12px 0; }
.conflict-block:first-child { border-top: none; padding-top: 0; }
.conflict-day-header { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.conflict-item { margin-bottom: 10px; }
.conflict-target { font-size: 13px; color: #EF4444; font-weight: 700; margin-bottom: 6px; }
.proposals-list { display: flex; flex-direction: column; gap: 5px; }
.proposal-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; border: 1.5px solid #E2E8F0; background: white; }
.proposal-letter { font-weight: 900; font-size: 14px; min-width: 22px; }
.proposal-op { font-weight: 700; font-size: 13px; }
.proposal-note { font-size: 12px; color: #94A3B8; margin-left: auto; }

/* ===== APPROVAL CARD (admin) ===== */
.approval-card { display: flex; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px dashed rgba(0,0,0,0.06); }
.approval-card:last-child { border-bottom: none; }
.approval-info { flex: 1; min-width: 0; }
.approval-header { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 6px; }
.approval-dates { font-size: 13px; color: #475569; margin-bottom: 3px; }
.approval-note { font-size: 12px; color: #94A3B8; margin-bottom: 3px; }
.approval-meta { font-size: 11px; color: #94A3B8; }
.approval-actions { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.approval-actions .inline-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ===== FILTER CHIP ===== */
.filter-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; background: #EFF6FF; color: #1D4ED8; border: 1px solid rgba(29,78,216,0.2); }

/* ===== CALENDAR (griglia) ===== */
.cal-header { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 6px; }
.cal-hcell { padding: 6px 4px; text-align: center; font-weight: 700; color: #64748B; font-size: 11px; text-transform: uppercase; letter-spacing: .3px; }
.cal-week { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 6px; }
.cal-cell { min-height: 110px; padding: 10px; border-radius: 14px; background: rgba(255,255,255,0.6); border: 1px solid rgba(255,255,255,0.4); }
.cal-cell.empty { min-height: 110px; background: rgba(0,0,0,0.02); border: none; box-shadow: none; }
.cal-cell.festivo { border: 2px solid rgba(168,85,237,0.27); }
.cal-cell.has-warn { border: 2px solid rgba(239,68,68,0.3); }
.cal-day-num { font-weight: 800; font-size: 15px; }
.cal-day-num.festivo-num { color: #7C3AED; }
.fest-badge { background: #EDE9FE; color: #7C3AED; padding: 1px 6px; border-radius: 6px; font-weight: 700; font-size: 10px; margin-left: 6px; }
.cal-item { padding: 5px 6px; border-radius: 8px; margin-top: 5px; font-size: 11px; }
.cal-item.assigned { background: #F3E8FF; }
.cal-item.no-solution { background: #FEE2E2; }
.cal-item-inner { display: flex; justify-content: space-between; align-items: center; gap: 4px; }
.cal-label { font-weight: 700; font-size: 11px; }
.cal-op { font-weight: 800; font-size: 11px; white-space: nowrap; }
.cal-cop { font-size: 10px; color: #92400E; margin-bottom: 3px; }
.cal-prop { font-size: 11px; color: #92400E; background: #FEF3C7; padding: 4px 6px; border-radius: 6px; margin-top: 4px; }
.cal-assente { font-size: 10px; color: #991B1B; background: #FEE2E2; border-radius: 6px; padding: 3px 6px; margin-top: 4px; }

/* ===== MODAL PROPOSTE ===== */
#propsModal { display: none; }
#propsModal[style*="display:flex"] { display: flex; }

/* ===== FULLSCREEN ===== */
.calendar-fullscreen .page-content { position: fixed; inset: 0; background: white; z-index: 1000; padding: 24px; overflow: auto; }

/* ===== MISC UTILITIES ===== */
.muted { color: #94A3B8; }
.warn { color: #EF4444; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }

/* ===== FORM HELPERS ===== */
.form-stack { display: flex; flex-direction: column; gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-weight: 700; color: #475569; font-size: 13px; }
.form-input, input.form-input, textarea.form-input, select.form-input { padding: 8px 12px; border-radius: 8px; border: 1px solid #E6EEF7; font-family: inherit; font-size: 14px; }
.form-input-sm { padding: 6px 10px; border-radius: 8px; border: 1px solid #E2E8F0; font-family: inherit; font-size: 13px; }
.form-row { display: flex; gap: 12px; }

/* ===== AUTH ===== */
.auth-body { display: flex; align-items: center; justify-content: center; height: 100vh; background: linear-gradient(135deg,#F8FAFF,#F7FFFA); }
.auth-container { width: 100%; max-width: 520px; padding: 24px; }
.auth-card { padding: 32px; border-radius: 14px; }
.auth-logo { font-size: 36px; text-align: center; }
.auth-title { text-align: center; margin: 8px 0 0; font-weight: 900; font-size: 24px; }
.auth-subtitle { text-align: center; color: #64748B; margin-bottom: 18px; font-size: 13px; }
.btn-full { width: 100%; padding: 12px; border-radius: 10px; font-weight: 800; justify-content: center; }

/* ===== NOTIFICATIONS ===== */
.notif-list { display: flex; flex-direction: column; gap: 10px; }
.notif-item { display: flex; gap: 12px; padding: 12px; border-radius: 10px; background: #FFF; border: 1px solid rgba(0,0,0,0.04); align-items: center; }
.notif-item.non-letta { box-shadow: 0 4px 16px rgba(16,24,40,0.06); border-left: 4px solid #6366F1; }
.notif-item.letta { opacity: 0.6; }
.notif-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.notif-content { flex: 1; min-width: 0; }
.notif-time { font-size: 12px; color: #94A3B8; }
.notif-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }

/* ===== OP BADGE ===== */
.op-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 12px; background: rgba(0,0,0,0.04); font-weight: 800; font-size: 11px; }

/* ===== SIDEBAR LAYOUT ===== */
.app-wrapper { display: flex; gap: 0; max-width: 1300px; margin: 0 auto; }
.sidebar { width: 260px; flex: 0 0 260px; padding: 20px 16px; box-sizing: border-box; min-height: calc(100vh - 120px); }
.main-content { flex: 1; min-width: 0; padding: 0; }
.sidebar-logo h1 { margin: 0; font-size: 17px; font-weight: 800; }
.sidebar-logo p { margin: 4px 0 14px; color: #64748B; font-size: 12px; }
.sidebar-user { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; padding: 10px; background: rgba(0,0,0,0.03); border-radius: 12px; }
.sidebar-user .avatar { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; flex-shrink: 0; }
.sidebar-user .info .name { font-weight: 800; font-size: 14px; }
.sidebar-user .info .role { font-size: 11px; color: #64748B; }
.nav-section { margin-top: 12px; }
.nav-section-title { font-size: 11px; color: #94A3B8; font-weight: 700; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }
.nav-item { display: flex; align-items: center; padding: 8px 10px; border-radius: 8px; color: #1E293B; text-decoration: none; margin-bottom: 2px; font-size: 13px; font-weight: 600; transition: background .15s; }
.nav-item:hover { background: rgba(0,0,0,0.04); }
.nav-item .icon { margin-right: 8px; font-size: 15px; }
.nav-item.active { background: #EEF2FF; color: #4F46E5; }
.nav-badge { background: #EF4444; color: white; padding: 1px 6px; border-radius: 8px; margin-left: auto; font-weight: 800; font-size: 11px; }
.sidebar-footer { margin-top: 20px; padding-top: 16px; border-top: 1px solid rgba(0,0,0,0.06); }
.sidebar-footer button { width: 100%; padding: 10px; border-radius: 10px; border: 1.5px solid rgba(239,68,68,0.25); background: rgba(239,68,68,0.07); color: #EF4444; font-weight: 700; font-size: 13px; cursor: pointer; transition: all .15s; font-family: inherit; }
.sidebar-footer button:hover { background: #EF4444; color: white; }

/* ===== COMPACT TABLE ===== */
.wc-compact { overflow-x: auto; }
.wc-compact table { border-collapse: separate; border-spacing: 2px; width: 100%; font-size: 10px; }
.wc-compact thead th { background: #1E293B; color: white; padding: 6px 8px; }

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

/* Tablet ≤ 1000px */
@media (max-width: 1000px) {
  .app-wrapper { flex-direction: row; }
  .sidebar { width: 220px; flex: 0 0 220px; padding: 16px 12px; }
  .grid-6 { grid-template-columns: repeat(3, 1fr); }
}

/* Small tablet ≤ 860px */
@media (max-width: 860px) {
  .wc-header .inner { flex-direction: column; align-items: flex-start; gap: 8px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3-col { grid-template-columns: repeat(2, 1fr); }
  .grid-6 { grid-template-columns: repeat(3, 1fr); }
  .approval-card { flex-direction: column; }
  .approval-actions { flex-direction: row; flex-wrap: wrap; }
  .page-content { padding: 12px 14px 32px; }
  .topbar { padding: 12px 14px 6px; }
}

/* Mobile ≤ 640px */
@media (max-width: 640px) {
  /* Mostra hamburger */
  .sidebar-toggle { display: inline-flex; }

  /* Sidebar diventa overlay scorrevole */
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    height: 100vh;
    width: 260px;
    z-index: 200;
    background: white;
    border-right: 1px solid rgba(0,0,0,0.08);
    box-shadow: 4px 0 24px rgba(0,0,0,0.12);
    overflow-y: auto;
    transition: left 0.25s ease;
    padding: 20px 16px;
    flex: none;
    min-height: unset;
  }
  .sidebar.open { left: 0; }

  /* App wrapper senza gap per sidebar */
  .app-wrapper { padding: 0; gap: 0; }
  .main-content { width: 100%; }

  /* Grids mobili */
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3-col { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .grid-6 { grid-template-columns: repeat(2, 1fr); gap: 8px; }

  /* Topbar compatta */
  .topbar { padding: 10px 12px 4px; gap: 8px; }
  .topbar-title { font-size: 17px; }
  .topbar-actions { gap: 6px; }
  .month-selector select { font-size: 12px; padding: 6px 8px; }
  .month-selector input { width: 64px; font-size: 12px; padding: 6px 8px; }

  /* Contenuto pagina */
  .page-content { padding: 8px 10px 28px; }

  /* Header superiore */
  .wc-title { font-size: 16px; }
  .tabs button { padding: 7px 6px; font-size: 10px; }
  .wc-header { padding: 10px 12px 8px; }

  /* Calendario mobile */
  .cal-header { gap: 3px; }
  .cal-week { gap: 3px; }
  .cal-cell { min-height: 72px; padding: 6px 4px; }
  .cal-hcell { font-size: 9px; padding: 4px 2px; }
  .cal-day-num { font-size: 12px; }
  .cal-item { font-size: 9px; padding: 3px 4px; margin-top: 3px; }
  .cal-op, .cal-label { font-size: 9px; }
  .cal-prop { font-size: 9px; padding: 2px 4px; }
  .fest-badge { font-size: 8px; padding: 1px 4px; }

  /* Cards */
  .card { padding: 12px; }
  .card-highlight { padding: 12px; }
  .stat-mini { padding: 10px 6px; }
  .stat-num { font-size: 18px; }

  /* Approval admin */
  .approval-card { flex-direction: column; gap: 10px; }
  .approval-actions { flex-direction: column; gap: 6px; width: 100%; }
  .approval-actions .inline-form { width: 100%; }
  .approval-actions .inline-form input { flex: 1; min-width: 0; }

  /* Tabella imprevisti su mobile → scrollabile */
  .table { font-size: 11px; }
  .table thead th, .table tbody td { padding: 7px 5px; }

  /* Bottoni */
  .btn { font-size: 13px; padding: 7px 10px; }
  .btn-sm { font-size: 11px; padding: 5px 8px; }

  /* Form */
  .form-row { flex-direction: column; }
  .form-input-sm { width: 100%; box-sizing: border-box; }

  /* Turni */
  .turno-date { width: 44px; }
  .turno-date .day-num { font-size: 15px; }
}

/* Molto piccolo ≤ 400px */
@media (max-width: 400px) {
  .grid-4 { grid-template-columns: 1fr 1fr; gap: 6px; }
  .tabs button { font-size: 9px; padding: 6px 4px; }
  .cal-cell { min-height: 60px; }
}
