/* MurphFin — layout.css */

/* ═══════ 3. APP HEADER ═══════ */

.app-header {
  height: var(--header-h);
  background: var(--brand-navy-dark);
  border-bottom: 3px solid var(--brand-red);
  display: flex;
  align-items: center;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 1040;
}
.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
/* ── News ticker (header) ── */
.news-ticker {
  flex: 1;
  overflow: hidden;
  margin: 0 20px;
  position: relative;
  mask-image: linear-gradient(to right, transparent 0%, #000 5%, #000 95%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 5%, #000 95%, transparent 100%);
}
.news-ticker-track {
  display: flex;
  white-space: nowrap;
  will-change: transform;
  /* Animazione gestita da JS (rAF) — vedi base.html initNewsTicker.
     Niente più CSS keyframes né hover-pause: hover-pause causava stuck
     dopo click su link target=_blank. */
}
.news-ticker-item {
  color: rgba(255,255,255,0.75);
  font-size: 0.78rem;
  text-decoration: none;
  padding: 0 4px;
  transition: color 0.15s;
}
a.news-ticker-item:hover {
  color: #fff;
  text-decoration: underline;
}
.news-ticker-sep {
  color: rgba(255,255,255,0.25);
  font-size: 0.7rem;
  padding: 0 10px;
}
/* @keyframes ticker-scroll rimosso: animazione ora gestita da JS */

/* Non-auth: center header content */
body:not(.app-auth) .app-header-inner {
  max-width: 1200px;
  margin: 0 auto;
}
/* Logout button in header (authenticated) */
.header-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.header-logout:hover { color: #fff; background: rgba(255,255,255,0.1); }
.header-logout i { font-size: 0.85rem; }

.app-brand {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  color: #fff;
  text-decoration: none;
  letter-spacing: -0.02em;
}
.app-brand:hover { color: #fff; }
.app-brand span { color: var(--brand-red); }

/* Hamburger toggle (mobile) */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 1.2rem;
  padding: 4px 10px;
  margin-right: 12px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* Public header nav (non-auth) */
.app-header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
.app-header-nav a {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 6px;
  transition: all 0.15s;
}
.app-header-nav a:hover { color: #fff; background: rgba(255,255,255,0.1); }
.app-header-register {
  background: var(--brand-red) !important;
  color: #fff !important;
  font-weight: 600 !important;
  padding: 6px 16px !important;
  border-radius: 0 !important;
}
.app-header-register:hover { background: var(--brand-red-hover) !important; }

/* Mobile nav toggle (public) */
.header-mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 1.2rem;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
}
.header-mobile-toggle:hover { background: rgba(255,255,255,0.1); color: #fff; }


/* ═══════ 4. SIDEBAR (authenticated) ═══════ */

.app-sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--brand-surface);
  border-right: 1px solid var(--brand-border);
  display: flex;
  flex-direction: column;
  z-index: 1030;
  overflow: visible;
  transition: width 0.25s ease, transform 0.25s ease;
}

/* ── Sidebar collapse (desktop) ── */
.sidebar-collapse-btn {
  position: absolute;
  top: 18px;
  right: -14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--brand-border);
  background: var(--brand-surface);
  color: var(--brand-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1031;
  box-shadow: 2px 0 6px rgba(0,0,0,0.06);
  transition: all 0.15s;
}
.sidebar-collapse-btn:hover {
  background: var(--brand-surface-alt);
  color: var(--brand-text);
  box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}
.sidebar-collapse-btn i {
  font-size: 0.65rem;
  transition: transform 0.25s ease;
}

/* Anti-FOUC: applicato via <html> prima che body esista */
.sidebar-will-collapse .app-sidebar {
  width: var(--sidebar-collapsed-w) !important;
  overflow: visible;
}
.sidebar-will-collapse .app-content {
  margin-left: var(--sidebar-collapsed-w) !important;
}
.sidebar-will-collapse .footer-auth {
  left: var(--sidebar-collapsed-w) !important;
}
.sidebar-will-collapse .sidebar-label,
.sidebar-will-collapse .sidebar-link span,
.sidebar-will-collapse .sidebar-user-info,
.sidebar-will-collapse .sidebar-divider,
.sidebar-will-collapse .sidebar-badge,
.sidebar-will-collapse .sidebar-section {
  display: none !important;
}
.sidebar-will-collapse .sidebar-search-input input {
  display: none !important;
}

/* Stato collapsed */
.app-auth.sidebar-collapsed .app-sidebar {
  width: var(--sidebar-collapsed-w);
  overflow: visible;
}
.app-auth.sidebar-collapsed .app-content {
  margin-left: var(--sidebar-collapsed-w);
}
.app-auth.sidebar-collapsed .footer-auth {
  left: var(--sidebar-collapsed-w);
}
.app-auth.sidebar-collapsed .sidebar-label,
.app-auth.sidebar-collapsed .sidebar-link span,
.app-auth.sidebar-collapsed .sidebar-user-info,
.app-auth.sidebar-collapsed .sidebar-divider {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
  transition: opacity 0.15s ease, width 0.15s ease;
}
.app-auth.sidebar-collapsed .sidebar-badge {
  display: none;
}
.app-auth.sidebar-collapsed .sidebar-section {
  padding: 0;
  height: 0;
  overflow: hidden;
}
.app-auth.sidebar-collapsed .sidebar-link {
  justify-content: center;
  padding: 9px 0;
  position: relative;
}
.app-auth.sidebar-collapsed .sidebar-link i {
  width: auto;
  font-size: 0.95rem;
  opacity: 0.7;
}
.app-auth.sidebar-collapsed .sidebar-nav {
  padding: 6px 0;
  align-items: stretch;
}
.app-auth.sidebar-collapsed .sidebar-footer {
  justify-content: center;
  padding: 0;
}
.app-auth.sidebar-collapsed .sidebar-user {
  justify-content: center;
}
.app-auth.sidebar-collapsed .sidebar-avatar {
  width: 34px;
  height: 34px;
  font-size: 0.7rem;
}
.app-auth.sidebar-collapsed .sidebar-collapse-btn {
  right: -14px;
}
.app-auth.sidebar-collapsed .sidebar-collapse-btn i {
  transform: rotate(180deg);
}
.app-auth.sidebar-collapsed .bp-ai-coach {
  left: calc(var(--sidebar-collapsed-w) + 24px);
}

/* Tooltip su link quando collapsed */
.app-auth.sidebar-collapsed .sidebar-link::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--brand-navy);
  color: #fff;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  z-index: 1050;
}
.app-auth.sidebar-collapsed .sidebar-link:hover::after {
  opacity: 1;
}

/* ── Sidebar search ── */
.sidebar-search {
  padding: 10px 10px 0;
  flex-shrink: 0;
  position: relative;
}
.sidebar-search-input {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--brand-surface-alt);
  border: 1px solid var(--brand-border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.sidebar-search-input:focus-within {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.sidebar-search-input i {
  color: var(--brand-muted);
  font-size: 0.8rem;
  flex-shrink: 0;
}
.sidebar-search-input input {
  border: none;
  background: none;
  outline: none;
  font-size: 0.82rem;
  color: var(--brand-text);
  width: 100%;
  font-family: inherit;
}
.sidebar-search-input input::placeholder {
  color: var(--brand-muted);
  opacity: 0.7;
}
.sidebar-search-results {
  position: absolute;
  top: 100%;
  left: 10px;
  right: 10px;
  background: var(--brand-surface);
  border: 1px solid var(--brand-border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  max-height: 360px;
  overflow-y: auto;
  z-index: 1060;
  display: none;
  margin-top: 4px;
}
.sidebar-search-results.open { display: block; }
.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  text-decoration: none;
  color: var(--brand-text);
  font-size: 0.82rem;
  transition: background 0.1s;
}
.search-result-item:hover {
  background: var(--brand-surface-alt);
  color: var(--brand-text);
}
.search-result-item i {
  width: 18px;
  text-align: center;
  color: var(--brand-muted);
  font-size: 0.85rem;
  flex-shrink: 0;
}
.search-result-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-result-sub {
  font-size: 0.7rem;
  color: var(--brand-muted);
  margin-left: auto;
  flex-shrink: 0;
}
.search-no-results {
  padding: 12px;
  text-align: center;
  color: var(--brand-muted);
  font-size: 0.8rem;
}
.search-result-divider {
  height: 1px;
  background: var(--brand-border);
  margin: 2px 0;
}

/* Collapsed: mostra solo icona lente */
.app-auth.sidebar-collapsed .sidebar-search {
  padding: 10px 0 0;
  display: flex;
  justify-content: center;
}
.app-auth.sidebar-collapsed .sidebar-search-input {
  width: 38px;
  height: 38px;
  padding: 0;
  justify-content: center;
  cursor: pointer;
  border: none;
  background: transparent;
}
.app-auth.sidebar-collapsed .sidebar-search-input input {
  display: none;
}
.app-auth.sidebar-collapsed .sidebar-search-input i {
  font-size: 0.95rem;
}
.app-auth.sidebar-collapsed .sidebar-search-results {
  left: var(--sidebar-collapsed-w);
  right: auto;
  width: 300px;
  top: 0;
}

.sidebar-section { padding: 12px 14px 4px; }
.sidebar-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--brand-muted);
  padding: 0 12px;
  margin-bottom: 2px;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 6px 8px;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--brand-gray-300); border-radius: 2px; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  color: var(--brand-muted);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 500;
  transition: all 0.12s;
}
.sidebar-link i {
  width: 18px;
  text-align: center;
  font-size: 0.85rem;
  opacity: 0.6;
}
/* Sidebar badge counts */
.sidebar-badge {
  margin-left: auto;
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  border-radius: var(--radius-sm);
  background: var(--brand-surface-alt);
  color: var(--brand-muted);
}
.sidebar-badge--danger { background: var(--brand-danger-bg); color: #ef4444; }
.sidebar-badge--info { background: var(--brand-info-bg); color: #3b82f6; }

/* Sidebar notification dot (pulsing red) */
.sidebar-dot-pulse {
  margin-left: auto;
  width: 8px;
  height: 8px;
  background: var(--brand-red);
  border-radius: 50%;
  animation: dot-pulse 1.5s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.sidebar-link:hover {
  background: var(--brand-surface-alt);
  color: var(--brand-text);
}
.sidebar-link:hover i { opacity: 1; }
.sidebar-link.active {
  background: rgba(59,130,246,0.08);
  color: var(--brand-navy);
  font-weight: 600;
}
.sidebar-link.active i { opacity: 1; color: var(--brand-blue); }

.sidebar-divider {
  height: 1px;
  background: var(--brand-border);
  margin: 4px 14px;
}

.sidebar-footer {
  padding: 0 12px;
  border-top: 1px solid var(--brand-border);
  flex-shrink: 0;
  height: var(--footer-auth-h);
  display: flex;
  align-items: center;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
  cursor: pointer;
  text-decoration: none;
  color: var(--brand-text);
}
.sidebar-user:hover { background: var(--brand-surface-alt); color: var(--brand-text); }
.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}
.sidebar-user-info { overflow: hidden; }
.sidebar-user-name { font-size: 0.85rem; font-weight: 600; line-height: 1.3; }
.sidebar-user-email {
  font-size: 0.72rem;
  color: var(--brand-muted);
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}


/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--header-h);
  background: rgba(0,0,0,0.3);
  z-index: 1029;
}


/* ═══════ 5. APP CONTENT LAYOUT ═══════ */

.app-content {
  min-height: calc(100vh - var(--header-h));
  display: flex;
  flex-direction: column;
}
.app-auth .app-content {
  margin-left: var(--sidebar-w);
  transition: margin-left 0.25s ease;
}

.app-main {
  flex: 1;
  padding: 2rem;
  max-width: 1060px;
  margin: 0 auto;
  width: 100%;
}
/* Non-auth pages get standard Bootstrap container behavior */
body:not(.app-auth) .app-main {
  max-width: 1200px;
}

/* Flash messages */
.flash-container {
  position: fixed;
  top: calc(var(--header-h) + 16px);
  right: 20px;
  z-index: 9999;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ── Flash toast ── */
.flash-toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  line-height: 1.45;
  box-shadow: 0 4px 24px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.06);
  animation: flashIn 0.35s cubic-bezier(0.16,1,0.3,1) both;
  border-left: 4px solid;
}
.flash-toast.flash-out {
  animation: flashOut 0.3s ease both;
}
.flash-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 0.75rem;
  margin-top: 1px;
}
.flash-text {
  flex: 1;
  min-width: 0;
  word-wrap: break-word;
}
.flash-close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  opacity: 0.4;
  transition: opacity 0.15s, background 0.15s;
  margin: -2px -4px 0 4px;
}
.flash-close:hover {
  opacity: 0.8;
  background: rgba(0,0,0,0.06);
}

/* Varianti colore */
.flash-success {
  background: var(--brand-success-bg);
  color: var(--brand-success-dark);
  border-left-color: var(--brand-success);
}
.flash-success .flash-icon { background: var(--brand-success-bg); color: var(--brand-success); }
.flash-success .flash-close { color: var(--brand-success-dark); }

.flash-danger {
  background: var(--brand-danger-bg);
  color: var(--brand-danger-dark);
  border-left-color: var(--brand-danger);
}
.flash-danger .flash-icon { background: var(--brand-danger-bg); color: var(--brand-danger); }
.flash-danger .flash-close { color: var(--brand-danger-dark); }

.flash-warning {
  background: var(--brand-warning-bg);
  color: var(--brand-warning);
  border-left-color: var(--brand-warning);
}
.flash-warning .flash-icon { background: var(--brand-warning-bg); color: var(--brand-warning); }
.flash-warning .flash-close { color: var(--brand-warning); }

.flash-info {
  background: var(--brand-info-bg);
  color: var(--brand-blue);
  border-left-color: var(--brand-blue);
}
.flash-info .flash-icon { background: var(--brand-info-bg); color: var(--brand-blue); }
.flash-info .flash-close { color: var(--brand-blue); }

@keyframes flashIn {
  from { opacity: 0; transform: translateX(30px) scale(0.96); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes flashOut {
  from { opacity: 1; transform: translateX(0) scale(1); }
  to   { opacity: 0; transform: translateX(30px) scale(0.96); }
}


/* ═══════ 5b. BACKOFFICE ═══════ */

.bo-dashboard-wrap { max-width: 1200px; margin: 0 auto; }

.bo-nav {
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  border-bottom: 2px solid var(--brand-border);
  overflow: visible;
  scrollbar-width: thin;
}
.bo-nav::-webkit-scrollbar { height: 3px; }
.bo-nav::-webkit-scrollbar-thumb { background: var(--brand-border); border-radius: var(--radius-sm); }
.bo-nav a {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--brand-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.bo-nav a:hover {
  color: var(--brand-navy);
  border-bottom-color: var(--brand-blue);
}
.bo-nav a i {
  font-size: 0.78rem;
  opacity: 0.6;
}
.bo-nav a:hover i { opacity: 1; }
.bo-nav-group {
  display: flex;
  align-items: center;
  padding: 0 4px 0 12px;
  flex-shrink: 0;
}
.bo-nav-group:first-child { padding-left: 0; }
.bo-nav-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--brand-muted);
  opacity: 0.6;
  white-space: nowrap;
}
