@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap');

/* ============================================================
   ROOT & CSS VARS  (replica assets.php)
   ============================================================ */
:root {
  --navbar-height: 48px;
  --navbar-bg-color: #0d6efd;
  --navbar-bg-color-hover: rgba(13,110,253,0.1);
  --navbar-logo-font-size: 14px;
}

/* ============================================================
   BASE  (replica styles.css)
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: "Inter", sans-serif;
  font-optical-sizing: auto;
  font-weight: 400;
  font-style: normal;
  font-size: var(--navbar-logo-font-size) !important;
}

.card {
  box-shadow: none !important;
}

.btn-xs {
  padding: 1px 5px !important;
  font-size: 12px !important;
  line-height: 1.5 !important;
  border-radius: 3px !important;
}

.form-label {
  margin-bottom: 0.25rem;
  font-size: 0.95rem;
}

/* ============================================================
   NAVBAR  (replica navbar.php)
   ============================================================ */
#main-navbar {
  z-index: 1050 !important;
}

.navbar-brand {
  width: 250px;
  text-align: center;
}

/* ============================================================
   SIDEBAR  (replica sidebar.css esattamente)
   ============================================================ */
#sidebar {
  width: 250px;
  height: calc(100vh - var(--navbar-height));
  position: fixed;
  top: var(--navbar-height);
  left: 0;
  transition: all 0.3s;
  display: flex;
  flex-direction: column;
  z-index: 1045;
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
}

#sidebar .offcanvas-header {
  display: none; /* nascosto su desktop, visibile su mobile via Bootstrap */
}

#sidebar .sidebar-content {
  flex-grow: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 0.5rem;
}

#sidebar .sidebar-content::-webkit-scrollbar { width: 4px; }
#sidebar .sidebar-content::-webkit-scrollbar-track { background: transparent; }
#sidebar .sidebar-content::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 2px; }

#sidebar .sidebar-menu { height: 100%; }

#sidebar .sidebar-menu .navbar-nav { gap: 0.25rem; }

#sidebar .sidebar-menu .nav-link {
  display: flex;
  align-items: center;
  padding: 0.35rem;
  border-radius: 0.35rem;
  color: #6b7280;
  font-weight: 500;
  text-decoration: none;
  border: none;
  background: transparent;
  position: relative;
}

#sidebar .sidebar-menu .nav-link:hover {
  background-color: var(--navbar-bg-color-hover);
  color: var(--navbar-bg-color);
}

#sidebar .sidebar-menu .nav-link.nav-active,
#sidebar .sidebar-menu .nav-item.menu-open > .nav-link {
  background-color: var(--navbar-bg-color);
  color: white;
}

#sidebar .sidebar-menu .nav-link .nav-icon {
  min-width: 1.25rem;
  margin-right: 0.75rem;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

#sidebar .sidebar-menu .nav-link .nav-arrow {
  margin-left: auto;
  transition: transform 0.2s ease;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(0deg) !important;
}

#sidebar .sidebar-menu .nav-link:not(.collapsed) .nav-arrow,
#sidebar .sidebar-menu .nav-link[aria-expanded="true"] .nav-arrow {
  transform: rotate(90deg) !important;
}

#sidebar .sidebar-menu .nav-link.collapsed .nav-arrow,
#sidebar .sidebar-menu .nav-link[aria-expanded="false"] .nav-arrow {
  transform: rotate(0deg) !important;
}

#sidebar .sidebar-menu .collapse .nav-link:hover {
  background-color: var(--navbar-bg-color-hover);
  color: var(--navbar-bg-color);
}

#sidebar .sidebar-menu .collapse .nav-link.nav-active {
  background-color: var(--navbar-bg-color-hover);
  color: rgb(0, 71, 142);
  font-weight: 600;
}

#sidebar .sidebar-menu .nav-link-figlio {
  font-size: 12px;
  margin-left: 1.5rem;
  margin-right: 1.5rem;
  margin-top: 0.25rem;
}

/* Leaf items (senza figli) */
#sidebar .nav-item-testo {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
  flex-grow: 1;
}

#sidebar .d-flex.nav-link {
  padding: 0.35rem;
  border-radius: 0.35rem;
  color: #6b7280;
  font-weight: 500;
}

#sidebar .d-flex.nav-link:hover {
  background-color: var(--navbar-bg-color-hover);
  color: var(--navbar-bg-color);
}

#sidebar .d-flex.nav-link.nav-active {
  background-color: var(--navbar-bg-color);
  color: white;
}

#sidebar .d-flex.nav-link.nav-active .nav-item-testo {
  color: white;
}

/* Profile */
#sidebar .sidebar-profile {
  flex-shrink: 0;
  padding: 0.75rem;
  border-bottom: 1px solid #e5e7eb;
  background-color: inherit;
}

#sidebar .sidebar-profile .dropdown button {
  background: transparent;
  border: none;
  border-radius: 0.5rem;
  padding: 0.5rem;
  transition: all 0.2s ease;
  gap: 0.75rem;
  width: 100%;
  display: flex;
  align-items: center;
}

#sidebar .sidebar-profile .dropdown button:hover {
  background: rgba(0,0,0,0.03);
}

#sidebar .profile-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navbar-bg-color, #6366f1) 0%, rgba(99,102,241,0.8) 100%);
  color: white;
  font-size: 0.875rem;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#sidebar .profile-info {
  overflow: hidden;
  flex: 1;
  min-width: 0;
  text-align: left;
}

#sidebar .profile-name {
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  font-weight: 600;
  color: #1f2937;
  font-size: 0.875rem;
  line-height: 1.25;
  margin-bottom: 0.125rem;
}

#sidebar .profile-email {
  color: #6b7280;
  font-size: 0.75rem;
  display: block;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  line-height: 1.2;
}

#sidebar .dropdown-menu {
  width: 100%;
  margin-top: 0.5rem !important;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  padding: 0.5rem;
}

#sidebar .dropdown-item {
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  transition: all 0.2s ease;
}

#sidebar .dropdown-item:hover { background-color: #f3f4f6; }
#sidebar .dropdown-item.text-danger:hover { background-color: #fef2f2; color: #dc2626 !important; }

/* ============================================================
   MAIN CONTENT  (replica sidebar.css)
   ============================================================ */
.main-content {
  margin-left: 250px;
  padding-top: var(--navbar-height);
  min-height: 100vh;
  transition: all 0.3s;
}

.sidebar-collapsed #sidebar { margin-left: -250px; }
.sidebar-collapsed .main-content { margin-left: 0; }

.page-header {
  padding: 1rem 1rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.page-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.page-subtitle {
  font-size: 0.75rem;
  color: var(--bs-secondary-color);
  margin: 0.15rem 0 0;
}

.page-body {
  padding: 1rem;
}

@media (max-width: 991.98px) {
  #sidebar {
    margin-left: -250px;
    top: 0;
    height: 100vh;
  }

  #sidebar .offcanvas-header { display: flex; }

  #sidebar .sidebar-profile {
    padding: 0.5rem 0.75rem;
    padding-top: calc(var(--navbar-height) + 0.5rem);
  }

  .main-content { margin-left: 0; }

  #sidebar.show { margin-left: 0; }

  .navbar-brand { width: initial !important; }
}

/* ============================================================
   STATUS BADGES  (replica status.css esattamente)
   ============================================================ */
.status {
  --tblr-status-height: 1.5rem;
  --tblr-status-color: #6c7a91;
  --tblr-status-color-rgb: 108,122,145;
  display: inline-flex;
  align-items: center;
  height: var(--tblr-status-height);
  padding: .25rem .75rem;
  gap: .5rem;
  color: var(--tblr-status-color);
  background: rgba(var(--tblr-status-color-rgb),.1);
  font-size: .875rem;
  text-transform: none;
  letter-spacing: normal;
  border-radius: 100rem;
  line-height: 1;
  margin: 0;
}

.status-primary   { --tblr-status-color: #066fd1; --tblr-status-color-rgb: 6,111,209; }
.status-secondary { --tblr-status-color: #6c7a91; --tblr-status-color-rgb: 108,122,145; }
.status-success   { --tblr-status-color: #2fb344; --tblr-status-color-rgb: 47,179,68; }
.status-info      { --tblr-status-color: #4299e1; --tblr-status-color-rgb: 66,153,225; }
.status-warning   { --tblr-status-color: #f76707; --tblr-status-color-rgb: 247,103,7; }
.status-danger    { --tblr-status-color: #d63939; --tblr-status-color-rgb: 214,57,57; }
.status-dark      { --tblr-status-color: #182433; --tblr-status-color-rgb: 24,36,51; }
.status-purple    { --tblr-status-color: #ae3ec9; --tblr-status-color-rgb: 174,62,201; }
.status-teal      { --tblr-status-color: #0ca678; --tblr-status-color-rgb: 12,166,120; }
.status-orange    { --tblr-status-color: #f76707; --tblr-status-color-rgb: 247,103,7; }

/* ============================================================
   SIDEBAR OVERLAY (mobile)
   ============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1044;
}
.sidebar-overlay.active { display: block; }

/* ============================================================
   KPI CARDS
   ============================================================ */
.kpi-card {
  border-radius: 0.5rem;
  border: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  box-shadow: none;
}

.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.kpi-icon.blue   { background: #dbeafe; color: #1d4ed8; }
.kpi-icon.green  { background: #dcfce7; color: #15803d; }
.kpi-icon.orange { background: #ffedd5; color: #c2410c; }
.kpi-icon.red    { background: #fee2e2; color: #b91c1c; }
.kpi-icon.purple { background: #ede9fe; color: #7c3aed; }
.kpi-icon.teal   { background: #ccfbf1; color: #0f766e; }

.kpi-label {
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bs-secondary-color);
  margin-bottom: 0.2rem;
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  color: var(--bs-body-color);
  margin-bottom: 0.15rem;
}

.kpi-sub {
  font-size: 0.72rem;
  color: var(--bs-secondary-color);
}

/* ============================================================
   BELT BADGES
   ============================================================ */
.belt-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 100rem;
  height: 1.5rem;
}

.belt-bianca    { background: #f8fafc; color: #334155; border: 1px solid #cbd5e1; }
.belt-gialla    { background: #fef9c3; color: #713f12; }
.belt-arancione { background: #ffedd5; color: #9a3412; }
.belt-verde     { background: #dcfce7; color: #14532d; }
.belt-blu       { background: #dbeafe; color: #1e3a8a; }
.belt-marrone   { background: #fef3c7; color: #78350f; }
.belt-nera      { background: #1e293b; color: #f8fafc; }

/* ============================================================
   AVATAR INIZIALI
   ============================================================ */
.avatar-sm {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.avatar-blue   { background: #3b82f6; }
.avatar-green  { background: #22c55e; }
.avatar-red    { background: #ef4444; }
.avatar-purple { background: #a855f7; }
.avatar-orange { background: #f97316; }
.avatar-teal   { background: #14b8a6; }
.avatar-pink   { background: #ec4899; }

/* ============================================================
   TABELLE
   ============================================================ */
.table thead th {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bs-secondary-color);
  white-space: nowrap;
}

/* ============================================================
   REMINDER ITEMS
   ============================================================ */
.reminder-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--bs-border-color);
}
.reminder-item:last-child { border-bottom: none; }
.reminder-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.reminder-dot-danger  { background: #dc3545; }
.reminder-dot-warning { background: #f59e0b; }
.reminder-dot-info    { background: #3b82f6; }
.reminder-text { font-size: 0.8rem; line-height: 1.4; }
.reminder-sub  { font-size: 0.72rem; color: var(--bs-secondary-color); }

/* ============================================================
   BREADCRUMB
   ============================================================ */
.page-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--bs-secondary-color);
  padding: 0.75rem 1rem 0;
}
.page-breadcrumb a { color: var(--bs-secondary-color); text-decoration: none; }
.page-breadcrumb a:hover { color: var(--bs-body-color); }
.page-breadcrumb .bc-sep { opacity: 0.4; font-size: 0.65rem; }
.page-breadcrumb .bc-current { color: var(--bs-body-color); font-weight: 500; }

/* ============================================================
   DETAIL ROWS
   ============================================================ */
.detail-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--bs-secondary-color);
  margin-bottom: 0.6rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--bs-border-color);
}
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0;
  font-size: 0.82rem;
}
.detail-label { color: var(--bs-secondary-color); font-size: 0.75rem; }
.detail-value { font-weight: 500; }

/* ============================================================
   MISC UTILITY
   ============================================================ */
.text-muted-sm { font-size: 0.72rem; color: var(--bs-secondary-color); }
.fw-medium { font-weight: 500; }

.course-type-fixed { --tblr-status-color: #ae3ec9; --tblr-status-color-rgb: 174,62,201; }
.course-type-temp  { --tblr-status-color: #f76707; --tblr-status-color-rgb: 247,103,7; }

.table-search { position: relative; max-width: 260px; flex: 1; }
.table-search .search-icon {
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--bs-secondary-color);
  font-size: 0.75rem;
}
.table-search input { padding-left: 2rem; font-size: 0.8rem; }

/* ============================================================
   CALENDARIO
   ============================================================ */
.cal-grid {
  display: grid;
  grid-template-columns: 56px repeat(7, 1fr);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  overflow: hidden;
  font-size: 0.75rem;
}
.cal-head-cell {
  background: var(--bs-tertiary-bg);
  border-bottom: 2px solid var(--bs-border-color);
  border-right: 1px solid var(--bs-border-color);
  padding: 0.5rem 0.4rem;
  text-align: center;
}
.cal-head-cell.today { background: #dbeafe; color: #1d4ed8; font-weight: 700; }
.cal-head-cell:last-child { border-right: none; }
.cal-time-cell {
  background: var(--bs-tertiary-bg);
  border-bottom: 1px solid var(--bs-border-color);
  border-right: 1px solid var(--bs-border-color);
  padding: 0.3rem 0.4rem;
  color: var(--bs-secondary-color);
  font-size: 0.65rem;
  white-space: nowrap;
  text-align: right;
  vertical-align: top;
}
.cal-slot {
  border-bottom: 1px solid var(--bs-border-color);
  border-right: 1px solid var(--bs-border-color);
  min-height: 48px;
  padding: 2px 3px;
}
.cal-slot:last-child { border-right: none; }
.cal-slot.today { background: #f8faff; }
.cal-event {
  border-radius: 4px;
  padding: 3px 6px;
  margin-bottom: 2px;
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
  transition: opacity 0.15s;
}
.cal-event:hover { opacity: 0.8; }
.ev-blue   { background:#dbeafe; color:#1d4ed8; border-left:3px solid #3b82f6; }
.ev-green  { background:#dcfce7; color:#15803d; border-left:3px solid #22c55e; }
.ev-red    { background:#fee2e2; color:#b91c1c; border-left:3px solid #ef4444; }
.ev-purple { background:#ede9fe; color:#7c3aed; border-left:3px solid #a855f7; }
.ev-orange { background:#ffedd5; color:#c2410c; border-left:3px solid #f97316; }
.ev-teal   { background:#ccfbf1; color:#0f766e; border-left:3px solid #14b8a6; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--bs-secondary-color); }
.empty-state i { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.3; display: block; }
.empty-state p { font-size: 0.85rem; }

/* ============================================================
   NOTIFICATIONS SIDEBAR (static)
   ============================================================ */
:root {
  --notify-bg: rgba(255, 255, 255, 0.92);
  --notify-border: rgba(32, 32, 32, 0.12);
  --notify-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  --notify-item-hover: rgba(0, 0, 0, 0.03);
  --notify-text: #202020;
  --notify-text-secondary: #666666;
  --notify-type-system: #0078d4;
  --notify-type-alert: #d83b01;
  --notify-type-task: #8661c5;
  --notify-type-calendar: #00b7c3;
}

.notify-panel {
  position: fixed;
  top: 0;
  right: -100%;
  width: 340px;
  height: 100vh;
  background: var(--notify-bg);
  border-left: 1px solid var(--notify-border);
  box-shadow: var(--notify-shadow);
  z-index: 1060;
  transition: right 0.3s ease-in-out;
  color: var(--notify-text);
}

.notify-panel.show { right: 0; }

.notify-header { padding: 0.75rem; border-bottom: 1px solid var(--notify-border); }
.notify-header-content { display: flex; justify-content: space-between; align-items: center; }
.notify-header h5 { margin: 0; font-size: 1rem; font-weight: 500; }

.notify-actions { display: flex; gap: 0.25rem; }
.notify-actions button {
  background: transparent;
  border: none;
  padding: 0.4rem;
  border-radius: 4px;
  color: var(--notify-text);
}
.notify-actions button:hover { background-color: var(--notify-item-hover); }

.notify-body { height: calc(100vh - 54px); overflow-y: auto; }
.notify-group { padding: 0.5rem 0; }
.notify-group-header {
  padding: 0 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--notify-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}

.notify-item {
  padding: 0.5rem 0.75rem;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  gap: 0.5rem;
  align-items: start;
  position: relative;
  border-bottom: 1px solid var(--notify-border);
}

.notify-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
}

.notify-type-system::before { background-color: var(--notify-type-system); }
.notify-type-alert::before { background-color: var(--notify-type-alert); }
.notify-type-task::before { background-color: var(--notify-type-task); }
.notify-type-calendar::before { background-color: var(--notify-type-calendar); }

.notify-item:hover { background-color: var(--notify-item-hover); }
.notify-item-icon { width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; color: var(--notify-text-secondary); }
.notify-item-header { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; margin-bottom: 0.25rem; }
.notify-item-title { font-size: 0.875rem; font-weight: 500; color: var(--notify-text); }
.notify-item-time { font-size: 0.75rem; color: var(--notify-text-secondary); white-space: nowrap; }
.notify-item-message { font-size: 0.8125rem; color: var(--notify-text-secondary); line-height: 1.3; }

.notify-item.unread { background-color: rgba(13, 110, 253, 0.05); }
.notify-item.unread .notify-item-title { font-weight: 600; }

.notify-item-close {
  background: transparent;
  border: none;
  color: var(--notify-text);
  padding: 0.25rem;
  opacity: 0.7;
}
.notify-item-close:hover { opacity: 1; }

.notify-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: calc(100vh - 54px);
  color: var(--notify-text-secondary);
  text-align: center;
  padding: 2rem;
}
.notify-empty i { font-size: 2rem; margin-bottom: 0.75rem; opacity: 0.6; }

#notify-trigger .notify-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #0d6efd;
  color: #fff;
  padding: 0 5px;
}

@media (max-width: 768px) {
  .notify-panel {
    width: 100%;
    border-left: none;
  }
}
