/* =====================================================================
   Smart2T AI Learning Hub — Custom CSS
   Bootstrap 5.3 + Bootstrap Icons 1.11 via CDN
   Due temi: .theme-student (studenti) | .theme-staff (docenti)
   ===================================================================== */

/* ─── Font & Base ────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  /* Palette studenti */
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --secondary:      #7c3aed;
  --ai-gradient:    linear-gradient(135deg, #7c3aed 0%, #2563eb 100%);
  --sidebar-bg:     #ffffff;
  --sidebar-border: #e2e8f0;
  --sidebar-active: #2563eb;
  --sidebar-text:   #475569;
  --sidebar-width:  240px;
  --topbar-height:  60px;
  --page-bg:        #f8fafc;
  --card-radius:    16px;
  --card-shadow:    0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --card-shadow-hover: 0 4px 6px rgba(0,0,0,.1), 0 10px 30px rgba(0,0,0,.1);

  /* Palette docenti */
  --staff-accent:   #f59e0b;
  --staff-sidebar:  #0f172a;
}

* { box-sizing: border-box; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  background: var(--page-bg);
  color: #1e293b;
}

/* ─── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ─── Layout Shell ───────────────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ─── Topbar ─────────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  z-index: 1000;
  gap: 1rem;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
}
.topbar-brand .brand-icon {
  width: 32px; height: 32px;
  background: var(--ai-gradient);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
}
.topbar-spacer { flex: 1; }
.topbar-user {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: .875rem;
  color: #64748b;
}
.topbar-user strong { color: #1e293b; }
.topbar-avatar {
  width: 34px; height: 34px;
  background: var(--ai-gradient);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: .875rem;
  flex-shrink: 0;
}
.badge-staff {
  background: var(--staff-accent);
  color: #fff;
  font-size: .7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 50px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ─── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  overflow-y: auto;
  padding: 1rem 0;
  z-index: 900;
  transition: transform .3s ease;
}
.sidebar-nav { list-style: none; margin: 0; padding: 0; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 1.25rem;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: 8px;
  margin: 2px .5rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.sidebar-nav a:hover {
  background: #f1f5f9;
  color: var(--primary);
}
.sidebar-nav a.active {
  background: #eff6ff;
  color: var(--primary);
}
.sidebar-nav a i { font-size: 1.1rem; }

/* ─── Staff sidebar ──────────────────────────────────────────────── */
.theme-staff .sidebar {
  background: var(--staff-sidebar);
  border-right-color: #1e293b;
}
.theme-staff .sidebar-nav a { color: #94a3b8; }
.theme-staff .sidebar-nav a:hover {
  background: #1e293b;
  color: #f1f5f9;
}
.theme-staff .sidebar-nav a.active {
  background: rgba(245,158,11,.15);
  color: var(--staff-accent);
}

/* ─── Main content ───────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: var(--topbar-height);
  flex: 1;
  padding: 1.75rem;
  min-height: calc(100vh - var(--topbar-height));
}

/* ─── Page header ────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.5rem;
}
.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  color: #0f172a;
}
.page-header .breadcrumb { margin: 0; font-size: .8rem; }

/* ─── Hero Dashboard ─────────────────────────────────────────────── */
.hero-banner {
  background: var(--ai-gradient);
  border-radius: var(--card-radius);
  padding: 2rem 2.5rem;
  color: #fff;
  position: relative;
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.hero-banner::after {
  content: '🎓';
  position: absolute;
  right: 2rem; top: 50%;
  transform: translateY(-50%);
  font-size: 5rem;
  opacity: .15;
}
.hero-banner h2 { font-size: 1.6rem; font-weight: 700; margin-bottom: .4rem; }
.hero-banner p  { opacity: .9; margin: 0; font-size: .95rem; }

/* ─── Cards corsi ────────────────────────────────────────────────── */
.corso-card {
  background: #fff;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}
.corso-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--card-shadow-hover);
}
.corso-card-top {
  height: 6px;
  width: 100%;
}
.corso-card-body {
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.corso-avatar {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 1.3rem;
  font-weight: 700;
  flex-shrink: 0;
}
.corso-title { font-weight: 600; color: #0f172a; margin: 0 0 .2rem; }
.corso-sub   { font-size: .8rem; color: #94a3b8; margin: 0; }
.corso-actions { margin-left: auto; }

/* ─── AI Tool Cards ──────────────────────────────────────────────── */
.tool-card {
  background: var(--ai-gradient);
  border-radius: var(--card-radius);
  padding: 1.5rem 1rem;
  color: #fff;
  text-align: center;
  text-decoration: none;
  display: block;
  transition: filter .2s, transform .2s;
}
.tool-card:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
  color: #fff;
}
.tool-card-staff {
  background: linear-gradient(135deg, #d97706, #f59e0b);
}
.tool-card i { font-size: 2rem; display: block; margin-bottom: .5rem; }
.tool-card span { font-weight: 600; font-size: .9rem; display: block; }

/* ─── Stat badges (dashboard) ────────────────────────────────────── */
.stat-badge {
  background: #fff;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 1.2rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.stat-badge .stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-badge .stat-val { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-badge .stat-lbl { font-size: .8rem; color: #94a3b8; margin-top: .2rem; }

/* ─── Chat ───────────────────────────────────────────────────────── */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 160px);
  background: #fff;
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}
.chat-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.chat-ai-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--ai-gradient);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.1rem;
  flex-shrink: 0;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.msg-row { display: flex; gap: .75rem; max-width: 85%; }
.msg-row.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-bubble {
  padding: .75rem 1rem;
  border-radius: 16px;
  font-size: .9rem;
  line-height: 1.5;
}
.msg-row.ai .msg-bubble {
  background: #f1f5f9;
  color: #1e293b;
  border-bottom-left-radius: 4px;
}
.msg-row.user .msg-bubble {
  background: var(--ai-gradient);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.msg-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem;
  flex-shrink: 0;
}
.msg-row.ai .msg-avatar  { background: var(--ai-gradient); color: #fff; }
.msg-row.user .msg-avatar { background: #e2e8f0; color: #475569; }
.chat-typing { display: flex; gap: 4px; align-items: center; padding: 8px 0; }
.chat-typing span {
  width: 8px; height: 8px; border-radius: 50%; background: #94a3b8;
  animation: bounce .8s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: .15s; }
.chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-6px); }
}
.chat-input-area {
  border-top: 1px solid #e2e8f0;
  padding: .75rem 1.25rem;
  display: flex;
  gap: .5rem;
  align-items: center;
}
.chat-input-area input {
  flex: 1;
  border: 1px solid #e2e8f0;
  border-radius: 50px;
  padding: .55rem 1.2rem;
  outline: none;
  font-size: .9rem;
}
.chat-input-area input:focus { border-color: var(--primary); }
.chat-send-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--ai-gradient);
  border: none;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

/* ─── Record page ────────────────────────────────────────────────── */
.rec-btn {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: #ef4444;
  border: none;
  color: #fff;
  font-size: 1.8rem;
  cursor: pointer;
  position: relative;
  transition: background .2s;
}
.rec-btn.recording {
  animation: pulse-red 1.2s infinite;
}
@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.4); }
  50%       { box-shadow: 0 0 0 14px rgba(239,68,68,0); }
}

/* ─── Staff section headers ──────────────────────────────────────── */
.staff-section-header {
  background: linear-gradient(135deg, rgba(245,158,11,.1), rgba(245,158,11,.05));
  border-left: 4px solid var(--staff-accent);
  border-radius: 0 8px 8px 0;
  padding: .75rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 600;
  color: #92400e;
}
.staff-section-header i { color: var(--staff-accent); }

/* ─── Login page ─────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #312e81 100%);
  padding: 1rem;
}
.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo .logo-icon {
  width: 64px; height: 64px;
  background: var(--ai-gradient);
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: #fff;
  margin-bottom: .75rem;
}
.login-logo h1 { font-size: 1.4rem; font-weight: 700; color: #0f172a; margin: 0; }
.login-logo p  { color: #64748b; font-size: .875rem; margin: .25rem 0 0; }

/* ─── Form controls ──────────────────────────────────────────────── */
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* ─── Buttons ────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  border-radius: 50px;
}
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-gradient {
  background: var(--ai-gradient);
  border: none;
  color: #fff;
  border-radius: 50px;
}
.btn-gradient:hover { filter: brightness(1.1); color: #fff; }

/* ─── Accordion lezioni ──────────────────────────────────────────── */
.accordion-button:not(.collapsed) {
  background: #eff6ff;
  color: var(--primary);
}
.accordion-button:focus { box-shadow: none; }

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 1rem; }
  .hero-banner::after { display: none; }
}
