/* ── RESET & BASE ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; color: #1a1a2e; background: #f4f6fb; }
a { color: #4361ee; text-decoration: none; }

/* ── AUTH ──────────────────────────────────────────────── */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card { background: #fff; border-radius: 16px; padding: 40px; width: 100%; max-width: 420px; box-shadow: 0 4px 24px rgba(0,0,0,0.08); }
.auth-logo { font-size: 48px; text-align: center; margin-bottom: 8px; }
.auth-card h1 { text-align: center; font-size: 22px; font-weight: 600; margin-bottom: 24px; }
.auth-card label { display: block; font-size: 12px; font-weight: 500; color: #666; margin: 14px 0 4px; }
.auth-card input { width: 100%; padding: 10px 12px; border: 1.5px solid #e0e0e0; border-radius: 8px; font-size: 14px; transition: border 0.2s; }
.auth-card input:focus { outline: none; border-color: #4361ee; }
.auth-link { text-align: center; margin-top: 20px; color: #666; font-size: 13px; }

/* ── LAYOUT ────────────────────────────────────────────── */
body:not(.auth-page) { display: flex; min-height: 100vh; }
.sidebar { width: 230px; background: #1a1a2e; color: #fff; display: flex; flex-direction: column; padding: 24px 0; flex-shrink: 0; min-height: 100vh; transition: transform 0.25s ease; }
.sidebar-logo { font-size: 32px; text-align: center; padding: 0 16px 8px; }
.sidebar-name { font-size: 13px; color: #a0a8c0; text-align: center; padding: 0 16px 20px; border-bottom: 1px solid #2a2a4a; margin-bottom: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-link { display: block; padding: 10px 20px; color: #c0c8e0; font-size: 14px; transition: background 0.15s; border-radius: 0; }
.nav-link:hover { background: #2a2a4a; color: #fff; }
.sidebar-footer { margin-top: auto; padding: 16px; border-top: 1px solid #2a2a4a; margin-bottom: 60px;}
.webhook-label { font-size: 10px; color: #888; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.05em; }
.webhook-url { font-size: 10px; color: #6ee7b7; word-break: break-all; background: #0f0f1f; padding: 6px 8px; border-radius: 6px; margin-bottom: 12px; }
.nav-logout { color: #f87171; }
.main-content { flex: 1; padding: 28px; overflow-y: auto; min-width: 0; }
.page-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.page-header h1 { font-size: 22px; font-weight: 600; }

/* ── HAMBURGER (hidden on desktop) ────────────────────── */
.hamburger { display: none; align-items: center; justify-content: center; background: none; border: 1.5px solid #e0e0e0; border-radius: 8px; cursor: pointer; padding: 6px 9px; font-size: 18px; color: #1a1a2e; flex-shrink: 0; line-height: 1; }
.hamburger:hover { background: #f4f6fb; }

/* Overlay behind open sidebar on mobile */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 199; }
.sidebar-overlay.open { display: block; }

/* ── RESPONSIVE — TABLET (≤ 900 px) ───────────────────── */
@media (max-width: 900px) {
  .stats-row  { grid-template-columns: repeat(2, 1fr); }
  .form-grid  { grid-template-columns: 1fr; }
  .main-content { padding: 20px; }
}

/* ── RESPONSIVE — MOBILE (≤ 700 px) ───────────────────── */
@media (max-width: 700px) {
  body:not(.auth-page) { display: block; }

  /* Sidebar becomes a fixed off-canvas drawer */
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100%;
    z-index: 200;
    transform: translateX(-100%);
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }

  .main-content { padding: 14px; }
  .hamburger { display: flex; }

  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px 10px; }
  .stat-val  { font-size: 24px; }

  .page-header h1 { font-size: 18px; }
  /* Tables scroll horizontally instead of overflowing */
  .card { padding: 14px; overflow-x: auto; }

  /* Calendar panel: full width on mobile */
  .app-panel { width: 100% !important; }

  /* Auth page */
  .auth-card { margin: 12px; padding: 24px 20px; }
}

/* ── COMPONENTS ────────────────────────────────────────── */
.card { background: #fff; border-radius: 12px; padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { background: #fff; border-radius: 12px; padding: 18px; text-align: center; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.stat-val { font-size: 28px; font-weight: 700; color: #4361ee; }
.stat-label { font-size: 12px; color: #888; margin-top: 4px; }

/* ── TABLE ─────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: #888; padding: 8px 10px; border-bottom: 2px solid #f0f0f0; text-transform: uppercase; letter-spacing: 0.04em; }
.table td { padding: 10px 10px; border-bottom: 1px solid #f5f5f5; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #fafbff; }
.empty { text-align: center; color: #aaa; padding: 24px !important; font-style: italic; }

/* ── FORMS ─────────────────────────────────────────────── */
label { display: block; font-size: 12px; font-weight: 500; color: #555; margin: 0 0 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=time] {
  width: 100%; padding: 9px 11px; border: 1.5px solid #e0e0e0; border-radius: 8px; font-size: 14px; transition: border 0.2s; background: #fff; }
input:focus { outline: none; border-color: #4361ee; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.section-divider { font-size: 13px; font-weight: 600; color: #4361ee; margin: 20px 0 12px; padding-top: 16px; border-top: 1px solid #f0f0f0; }

/* ── BUTTONS ───────────────────────────────────────────── */
.btn { display: inline-block; padding: 9px 18px; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; border: none; transition: opacity 0.15s, transform 0.1s; }
.btn:hover { opacity: 0.88; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: #4361ee; color: #fff; }
.btn-secondary { background: #f0f2ff; color: #4361ee; border: 1.5px solid #4361ee; }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── ALERTS ────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #dcfce7; color: #166534; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-warn { background: #fef9c3; color: #854d0e; }

/* ── SERVIZI TABLE ─────────────────────────────────────── */
#servizi-body input { padding: 6px 8px; }

/* ── RESPONSIVE GRIDS (staff, orari impostazioni) ──────── */
.staff-grid  { display:grid; grid-template-columns:1fr 1fr; gap:24px; align-items:start; }
.orario-grid { display:grid; grid-template-columns:1fr 1fr; gap:16px; margin-bottom:12px; }

@media (max-width:480px) {
  .staff-grid         { grid-template-columns:1fr; }
  .orario-grid        { grid-template-columns:1fr; }
  #servizi-body input { padding:10px 8px; }
  #servizi-body td    { padding:5px 2px; }

  /* ── Clienti: card layout (no scroll orizzontale) ─────── */
  .clienti-table                  { min-width:0 !important; }
  .clienti-table thead            { display:none; }
  .clienti-table tbody tr         { display:block; background:#fff; border:1px solid #e5e7eb;
                                    border-radius:10px; margin-bottom:8px;
                                    padding:10px 52px 10px 12px; position:relative; }
  .clienti-table tbody tr:hover td { background:transparent; }
  .clienti-table td               { display:block; border:none; padding:1px 0; }
  .clienti-table td:nth-child(1)  { font-weight:600; font-size:15px; color:#1a1a2e; margin-bottom:2px; }
  .clienti-table td:nth-child(2)  { font-size:13px; color:#64748b; margin-bottom:4px; }
  .clienti-table td:nth-child(3)  { display:inline; font-size:12px; color:#94a3b8; }
  .clienti-table td:nth-child(3)::before { content:'📅 '; }
  .clienti-table td:nth-child(4)  { display:inline; font-size:12px; color:#94a3b8; }
  .clienti-table td:nth-child(4)::before { content:' · '; }
  .clienti-table td:nth-child(5)  { display:none; }
  .clienti-table td:nth-child(6)  { position:absolute; top:10px; right:10px; padding:0; }
}
