/* ── APP LAYOUT ── */

body {
  font-family: var(--font);
  background: var(--cream);
  color: var(--black);
  display: flex;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── SIDEBAR ── */

#sidebar {
  width: 240px;
  min-width: 240px;
  background: linear-gradient(180deg, #0a2538 0%, var(--blue-deep) 100%);
  color: rgba(255,255,255,0.78);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--duration-md) var(--ease-out);
  z-index: 100;
  border-right: 1px solid rgba(255,255,255,0.05);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}

#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }

.sidebar-header {
  padding: 18px 16px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.sidebar-workspace {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  padding: 4px 2px;
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.sidebar-logo {
  height: 44px;
  width: 33px;
  object-fit: contain;
  flex-shrink: 0;
  filter: brightness(0) invert(1);
  opacity: 0.92;
  display: block;
}

.sidebar-section {
  padding: 14px 0 6px;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.32);
  padding: 0 16px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
}

.sidebar-new-folder-btn {
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.32);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
  flex-shrink: 0;
  padding: 0;
}

.sidebar-section:hover .sidebar-new-folder-btn,
.sidebar-new-folder-btn:focus { opacity: 1; }
.sidebar-new-folder-btn:hover {
  background: rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.9);
}

@media (hover: none) {
  .sidebar-new-folder-btn { opacity: 1; }
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 14px 7px 12px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,0.72);
  border-left: 3px solid transparent;
  cursor: pointer;
  transition: background var(--duration-sm) ease, color var(--duration-sm) ease, border-color var(--duration-sm) ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 0 6px 6px 0;
  margin-right: 8px;
  position: relative;
}

.sidebar-item:hover {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.95);
}

/* Drag verticale riordino */
.sidebar-item[data-launch] { cursor: grab; }
.sidebar-item.sidebar-dragging { opacity: 0.4; }
.sidebar-item.sidebar-drop-before { box-shadow: inset 0 2px 0 var(--gold); }
.sidebar-item.sidebar-drop-after  { box-shadow: inset 0 -2px 0 var(--gold); }

.sidebar-item.active {
  background: rgba(201,169,110,0.12);
  border-left-color: var(--gold);
  color: #fff;
  font-weight: 600;
}

.sidebar-item-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  opacity: 0.65;
  transition: opacity var(--duration-sm) ease;
}

.sidebar-item:hover .sidebar-item-icon,
.sidebar-item.active .sidebar-item-icon { opacity: 1; }

.sidebar-launch-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
  transition: transform var(--duration-sm) var(--ease-spring);
}

.sidebar-item:hover .sidebar-launch-dot { transform: scale(1.2); }

/* ── SIDEBAR MENU BTN (3 puntini) ── */

.sidebar-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 5px;
  color: rgba(255,255,255,0.45);
  cursor: pointer;
  opacity: 0;
  flex-shrink: 0;
  transition: opacity 0.12s, background 0.12s, color 0.12s;
  margin-left: 2px;
}

.sidebar-item:hover .sidebar-menu-btn { opacity: 1; }
.sidebar-menu-btn:hover {
  background: rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.9);
}

.sidebar-fav-star {
  color: #C9A96E;
  flex-shrink: 0;
  margin-right: 2px;
}

/* ── SIDEBAR DROPDOWN ── */

.sidebar-dropdown {
  display: none;
  position: fixed;
  z-index: 9999;
  background: #fff;
  border: 1px solid #e0e4ea;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(16,24,40,0.14);
  padding: 4px;
  min-width: 200px;
}

.sidebar-dropdown button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  background: transparent;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  font-family: var(--font);
  text-align: left;
  transition: background 0.1s, color 0.1s;
}

.sidebar-dropdown button:hover {
  background: #f0f4f9;
  color: var(--blue);
}

.sidebar-dropdown button svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  opacity: 0.65;
}

.sidebar-dropdown button:hover svg { opacity: 1; }

/* ── SIDEBAR FOLDER ── */

.sidebar-folder { }

.sidebar-folder-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px 6px 10px;
  cursor: pointer;
  color: rgba(255,255,255,0.65);
  font-size: 12px;
  font-weight: 600;
  border-radius: 0 6px 6px 0;
  margin-right: 8px;
  transition: background 0.12s, color 0.12s;
  user-select: none;
}

.sidebar-folder-header:hover {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.9);
}

.sidebar-folder-drop-target {
  background: rgba(201,169,110,0.18) !important;
  color: rgba(255,255,255,0.95) !important;
  border-radius: 0 6px 6px 0;
  box-shadow: inset 0 0 0 1.5px rgba(201,169,110,0.55);
}

.sidebar-folder-header:hover .sidebar-menu-btn { opacity: 1; }

.sidebar-folder-chevron {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  transition: transform 0.18s ease;
  transform: rotate(0deg);
  opacity: 0.55;
}

.sidebar-folder-chevron.open {
  transform: rotate(90deg);
}

.sidebar-folder-icon {
  flex-shrink: 0;
}

.sidebar-folder-name-empty {
  opacity: 0.45;
  font-style: italic;
}

.sidebar-folder-empty {
  padding: 6px 12px 6px 28px;
  font-size: 11px;
  color: rgba(255,255,255,0.28);
  font-style: italic;
  line-height: 1.4;
}

.sidebar-folder-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-folder-body {
  padding-left: 8px;
}

.sidebar-coach-search {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 8px 6px 0;
  padding: 5px 9px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 7px;
  color: rgba(255,255,255,0.45);
}

.sidebar-coach-search input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  outline: none;
  font-size: 12px;
  color: rgba(255,255,255,0.85);
  font-family: var(--font);
}

.sidebar-coach-search input::placeholder { color: rgba(255,255,255,0.35); }

.sidebar-item-nested {
  padding-left: 18px;
}

/* Folder picker dropdown */
.sidebar-folder-picker {
  min-width: 180px;
  max-width: 220px;
}

.sidebar-folder-picker-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #9AA3AF;
  padding: 6px 12px 4px;
}

.sidebar-folder-picker button.active {
  background: #f0f4f9;
  color: var(--blue);
  font-weight: 600;
}

/* ── SIDEBAR ADD BTN ── */

.sidebar-add-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.38);
  cursor: pointer;
  transition: color var(--duration-sm) ease;
  border: none;
  background: none;
  font-family: var(--font);
}

.sidebar-add-btn:hover { color: rgba(255,255,255,0.80); }

.sidebar-footer {
  padding: 10px 12px 14px;
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: auto;
}

.sidebar-footer-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.45);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--duration-sm) ease;
  background: transparent;
  font-family: var(--font);
}

.sidebar-footer-btn:hover {
  color: rgba(255,255,255,0.85);
  border-color: rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.06);
}

/* ── MAIN AREA ── */

#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--cream);
}

/* ── HEADER ── */

#app-header {
  height: 54px;
  min-height: 54px;
  background: #fff;
  border-bottom: 1px solid rgba(0,0,0,0.07);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: relative;
  z-index: 10;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.header-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--blue-deep);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.3px;
}

.header-title[contenteditable="true"] {
  outline: none;
  border-bottom: 2px solid var(--blue);
  padding-bottom: 1px;
  cursor: text;
}

/* ── VIEW TABS ── */

.view-tabs {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid rgba(0,0,0,0.07);
  background: #fff;
  padding: 0 20px;
  height: 38px;
  min-height: 38px;
}

.view-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  height: 38px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--duration-sm) ease, border-color var(--duration-sm) ease;
  white-space: nowrap;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font);
}

.view-tab:hover { color: var(--black); }

.view-tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
  font-weight: 600;
}

.view-tab svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ── TOOLBAR ── */

.toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  background: var(--warm-white);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  flex-wrap: wrap;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  transition: background var(--duration-sm) ease, color var(--duration-sm) ease, border-color var(--duration-sm) ease, transform var(--duration-xs) ease, box-shadow var(--duration-sm) ease;
  white-space: nowrap;
  cursor: pointer;
  font-family: var(--font);
}

.toolbar-btn:hover {
  background: rgba(42,109,144,0.07);
  color: var(--blue);
  border-color: rgba(42,109,144,0.18);
}

.toolbar-btn:active { transform: scale(0.97); }

.toolbar-btn.primary {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  font-weight: 600;
  box-shadow: var(--shadow-blue);
}

.toolbar-btn.primary:hover {
  background: var(--blue-dark);
  border-color: var(--blue-dark);
  box-shadow: 0 6px 16px rgba(42,109,144,0.32);
  transform: translateY(-1px);
}

.toolbar-btn.primary:active { transform: translateY(0) scale(0.97); }

.toolbar-btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.toolbar-search {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 7px;
  font-size: 13px;
  color: var(--gray);
  transition: border-color var(--duration-sm) ease, box-shadow var(--duration-sm) ease;
}

.toolbar-search:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(42,109,144,0.12);
}

.toolbar-search svg { width: 14px; height: 14px; color: var(--gray-light); flex-shrink: 0; }

.toolbar-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  color: var(--black);
  width: 160px;
  font-family: var(--font);
}

.toolbar-search input::placeholder { color: var(--gray-light); }

.toolbar-sep {
  width: 1px;
  height: 18px;
  background: rgba(0,0,0,0.09);
  margin: 0 2px;
}

/* ── CONTENT AREA ── */

#content {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  background: var(--cream);
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.12) transparent;
}

#content::-webkit-scrollbar { width: 6px; height: 6px; }
#content::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 4px; }

/* ── TOAST ── */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--blue-deep);
  color: #fff;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
  animation: toast-in 0.25s var(--ease-out) both;
  letter-spacing: -0.1px;
  pointer-events: auto;
  border: 1px solid rgba(255,255,255,0.10);
}

.toast.success { background: #1a6b2e; }
.toast.error   { background: #9b2424; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── HAMBURGER ── */

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  padding: 6px;
  cursor: pointer;
  border-radius: 6px;
  transition: background var(--duration-sm) ease;
}

.hamburger:hover { background: rgba(0,0,0,0.06); }

.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--gray);
  border-radius: 2px;
  transition: transform var(--duration-md) var(--ease-out);
}

#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 99;
  backdrop-filter: blur(2px);
}

/* ── MODAL ── */

#modal-container input:focus,
#modal-container textarea:focus,
#modal-container select:focus {
  border-color: var(--blue) !important;
  box-shadow: 0 0 0 3px rgba(42,109,144,0.12) !important;
  outline: none;
}

/* ── RESPONSIVE ── */

@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transform: translateX(-100%);
    box-shadow: none;
  }
  #sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.25);
  }
  #sidebar-overlay.show { display: block; }
  .hamburger { display: flex; }
  .toolbar-search input { width: 100px; }
}

/* ── LOGOUT BUTTON ── */

#btn-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.40);
  background: transparent;
  border: none;
  border-top: 1px solid rgba(255,255,255,0.07);
  cursor: pointer;
  font-family: var(--font);
  transition: color 0.15s ease;
  margin-top: auto;
}

#btn-logout:hover { color: rgba(255,255,255,0.80); }
#btn-logout svg { width: 14px; height: 14px; flex-shrink: 0; }
