/* ============================================================
   CSS VARIABLES — Clean / Google-style palette
   ============================================================ */
:root {
  --primary:        #1A73E8;
  --primary-dark:   #1557B0;
  --primary-light:  rgba(26, 115, 232, 0.10);
  --accent:         #FBBC04;
  --sidebar-bg:     #FFFFFF;
  --sidebar-width:  260px;
  --topbar-height:  56px;
  --content-bg:     #F8F9FA;
  --text-primary:   #202124;
  --text-muted:     #5F6368;
  --border:         #DADCE0;
  --shadow-sm:      0 1px 2px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.08);
  --shadow:         0 2px 8px rgba(0,0,0,0.12);
  --radius:         8px;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--content-bg);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  overflow: hidden;
  transition: width 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  min-height: var(--topbar-height);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-brand a {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
  text-decoration: none;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.sidebar-brand a span { color: var(--primary); }

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0 1.5rem;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-section-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 1rem 1.5rem 0.35rem;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 1.5rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.sidebar-nav a:hover {
  color: var(--primary);
  background: rgba(26, 115, 232, 0.06);
  border-left-color: var(--primary);
}
.sidebar-nav a.active {
  color: var(--primary);
  background: rgba(26, 115, 232, 0.10);
  border-left-color: var(--primary);
  font-weight: 600;
}
.sidebar-nav a i {
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.5rem 1.25rem;
}


/* ============================================================
   MOBILE SIDEBAR OVERLAY
   ============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1039;
  cursor: pointer;
}
body.sidebar-open .sidebar-overlay { display: block; }

/* ============================================================
   MAIN AREA
   ============================================================ */
.main-area {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s ease;
}

/* ============================================================
   SIDEBAR — full / collapsed variants
   ============================================================ */
:root { --sidebar-collapsed-width: 60px; }

/* Default: show full, hide icon-only */
.sidebar-icon { display: none !important; }
.sidebar-full { display: flex !important; }
.sidebar-brand.sidebar-full { display: flex !important; }
.sidebar-brand.sidebar-icon { display: none !important; }
nav.sidebar-full { display: flex !important; flex-direction: column; }
nav.sidebar-icon  { display: none !important; }

/* Collapsed: show icon-only, hide full */
body.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed-width); }
body.sidebar-collapsed .main-area { margin-left: var(--sidebar-collapsed-width); }
body.sidebar-collapsed .sidebar-full { display: none !important; }
body.sidebar-collapsed .sidebar-icon { display: flex !important; flex-direction: column; }
body.sidebar-collapsed .sidebar-brand.sidebar-icon { display: flex !important; }
body.sidebar-collapsed nav.sidebar-icon { display: flex !important; }

/* Icon-only brand */
.sidebar-brand.sidebar-icon {
  justify-content: center;
  padding: 0;
}
.sidebar-brand.sidebar-icon a {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
}

/* Icon-only nav links */
.nav-icon-link {
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 0;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  border-left: 3px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.nav-icon-link i { font-size: 1.2rem; }
.nav-icon-link:hover {
  color: var(--primary);
  background: rgba(26, 115, 232, 0.06);
  border-left-color: var(--primary);
}
.nav-icon-link.active {
  color: var(--primary);
  background: rgba(26, 115, 232, 0.10);
  border-left-color: var(--primary);
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 0.75rem;
  z-index: 1030;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

.topbar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 0.25rem 0.4rem;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 1.35rem;
  line-height: 1;
  border-radius: 4px;
}
.topbar-toggle:hover { background: var(--content-bg); }

.topbar-spacer { flex: 1; }

.topbar-org-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 500;
  font-size: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  white-space: nowrap;
  border: 1px solid rgba(26, 115, 232, 0.25);
}

/* Badge come trigger dropdown */
button.topbar-org-badge,
button.dropdown-toggle-org {
  border: none;
  cursor: pointer;
  transition: background 0.15s;
}
button.topbar-org-badge:hover,
button.dropdown-toggle-org:hover {
  background: rgba(26, 115, 232, 0.15);
}
/* Rimuovi la freccia Bootstrap dal dropdown-toggle */
button.dropdown-toggle-org::after { display: none; }

.topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
}

/* ============================================================
   ORG BANNER (superadmin operating as org)
   ============================================================ */
.org-banner {
  background: #F1F3F4;
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 1.5rem;
  font-size: 0.82rem;
  text-align: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
.org-banner a { color: var(--primary); font-weight: 600; }

/* ============================================================
   FLASH MESSAGES
   ============================================================ */
.flash-container {
  padding: 0.75rem 1.75rem 0;
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  flex: 1;
  padding: 0;
  background: var(--content-bg);
  min-height: 0;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background-color: #fff !important;
}
.card-header {
  background-color: #fff !important;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0 !important;
  font-weight: 600;
  padding: 0.85rem 1.25rem;
}
.card-body { background-color: #fff !important; }
.card-footer {
  background-color: #fff !important;
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius) !important;
}

/* ============================================================
   TABLES
   ============================================================ */
.table { margin-bottom: 0; --bs-table-bg: #fff; }
.table thead th {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background-color: #ffffff !important;
  box-shadow: none !important;
  border-bottom: 2px solid var(--border) !important;
  padding: 0.85rem 1rem;
  white-space: nowrap;
}
.table thead th a {
  color: var(--text-muted);
  text-decoration: none;
}
.table thead th a:hover { color: var(--primary); }
.table td {
  padding: 0.85rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}
.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover td { background: rgba(26, 115, 232, 0.04); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 500;
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
}
.btn-primary:active { background: var(--primary-dark) !important; border-color: var(--primary-dark) !important; }

.btn-success { background: #10B981; border-color: #10B981; }
.btn-success:hover { background: #059669; border-color: #059669; }

.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ============================================================
   FORMS
   ============================================================ */
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.2rem rgba(26, 115, 232, 0.20);
}
.form-label { font-weight: 500; font-size: 0.875rem; }

/* ============================================================
   BADGES
   ============================================================ */
.badge.bg-primary { background: var(--primary) !important; }

/* ============================================================
   PAGINATION
   ============================================================ */
.page-link { color: var(--primary); border-color: var(--border); }
.page-link:hover {
  color: var(--primary-dark);
  background: rgba(26, 115, 232, 0.08);
  border-color: var(--border);
}
.page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.page-item.disabled .page-link { color: var(--text-muted); }

/* ============================================================
   ALERTS
   ============================================================ */
.alert-info    { background: #EFF6FF; border-color: #BFDBFE; color: #1E40AF; }
.alert-success { background: #ECFDF5; border-color: #A7F3D0; color: #065F46; }
.alert-warning { background: #FFFBEB; border-color: #FDE68A; color: #92400E; }
.alert-danger  { background: #FEF2F2; border-color: #FECACA; color: #991B1B; }

/* ============================================================
   DESCRIPTION CELL (media listing)
   ============================================================ */
.description-cell {
  max-height: 80px;
  overflow-y: auto;
  font-size: 0.875rem;
}

/* ============================================================
   RESPONSIVE — MOBILE (<992px)
   ============================================================ */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
    transition: transform 0.25s ease;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  /* On mobile always show full nav, hide collapsed variant */
  body.sidebar-collapsed .sidebar { width: var(--sidebar-width) !important; }
  body.sidebar-collapsed .sidebar-full  { display: flex !important; }
  body.sidebar-collapsed .sidebar-icon  { display: none !important; }
  body.sidebar-collapsed nav.sidebar-full { display: flex !important; flex-direction: column; }
  body.sidebar-collapsed nav.sidebar-icon { display: none !important; }
  .main-area { margin-left: 0 !important; }
  .flash-container { padding: 0.75rem 1rem 0; }
}

/* Summernote — rimuove la freccia Bootstrap dai dropdown della toolbar */
.note-editor .dropdown-toggle::after { display: none !important; }

/* ============================================================
   ACTION BUTTONS — icon-only per le tabelle
   ============================================================ */
.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  font-size: 0.95rem;
  text-decoration: none;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.btn-action:hover {
  color: var(--text-primary);
  background: var(--content-bg);
  border-color: #d1d5db;
}
.btn-action-danger:hover {
  color: #dc2626;
  border-color: #fca5a5;
  background: #fef2f2;
}
.btn-action-primary:hover {
  color: var(--primary-dark);
  border-color: var(--primary);
  background: var(--primary-light);
}

/* ============================================================
   STATUS TOGGLE — Published / Draft
   ============================================================ */
.status-toggle {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.65rem;
  border-radius: 20px;
  border: 1.5px solid;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.status-toggle.is-published {
  background: #ECFDF5;
  color: #065F46;
  border-color: #6EE7B7;
}
.status-toggle.is-published:hover { background: #D1FAE5; }
.status-toggle.is-draft {
  background: #F9FAFB;
  color: var(--text-muted);
  border-color: var(--border);
}
.status-toggle.is-draft:hover { background: #F3F4F6; }

/* ============================================================
   BADGES — category e media type
   ============================================================ */
.badge-category {
  display: inline-block;
  background: rgba(109, 40, 217, 0.10);
  color: #6D28D9;
  font-weight: 500;
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
}
.badge-mediatype {
  display: inline-block;
  background: #F3F4F6;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--border);
}
