/* =====================================================================
   NEXUS DESIGN SYSTEM  —  shared UI pattern
   Estratto dalle pagine ridisegnate (Contacts, Organizations, ...).
   Classi con nome univoco -> globali (sicure).
   Override generici Bootstrap (.table/.form-control/.progress) ->
   scopati sotto .nexus-page per non toccare le pagine non migrate.
   ===================================================================== */

:root {
    --nexus-primary: #4F46E5;
    --nexus-primary-hover: #4338ca;
    --nexus-card-bg: #FFFFFF;
    --nexus-text-dark: #111827;
    --nexus-text-gray: #6B7280;
    --nexus-border: #E5E7EB;
    --icon-blue-bg: #E0F2FE;
    --icon-blue-text: #0284C7;
    --icon-green-bg: #DCFCE7;
    --icon-green-text: #166534;
    --icon-orange-bg: #FEF3C7;
    --icon-orange-text: #D97706;
    --icon-red-bg: #FEE2E2;
    --icon-red-text: #DC2626;
    --icon-purple-bg: #EDE9FE;
    --icon-purple-text: #7C3AED;
    --radius-card: 12px;
    --input-radius: 8px;
    --shadow-soft: 0 1px 3px 0 rgba(0,0,0,.05), 0 1px 2px 0 rgba(0,0,0,.03);
}

/* ══════ PAGE WRAPPER ══════ */
.nexus-page { padding: 24px 20px; max-width: 1600px; margin: 0 auto; }
.nexus-page.narrow { max-width: 1400px; }
.nexus-page.compact { max-width: 1100px; }

/* ══════ HERO HEADER ══════ */
.hero-header { background: linear-gradient(135deg,#1e293b 0%,#334155 50%,#0f172a 100%) !important; border-radius: 16px !important; padding: 28px 32px !important; color: #fff !important; margin-bottom: 28px !important; box-shadow: 0 10px 30px -5px rgba(15,23,42,.45) !important; position: relative; overflow: hidden; display: flex; justify-content: space-between; align-items: center; }
.hero-header::before { content: ''; position: absolute; top: -50%; right: -10%; width: 300px; height: 300px; background: radial-gradient(circle,rgba(79,70,229,.15) 0%,transparent 70%); pointer-events: none; }
.hero-title { font-weight: 800; font-size: 1.5rem; margin: 0; color: #fff !important; letter-spacing: -.02em; }
.hero-subtitle { color: rgba(255,255,255,.6); font-size: .88rem; margin-top: 6px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.header-actions { display: flex; gap: 10px; align-items: center; position: relative; z-index: 1; flex-wrap: wrap; }
.hero-header .breadcrumb { margin-bottom: 8px; }
.hero-header .breadcrumb-item a { color: rgba(255,255,255,.65); text-decoration: none; font-size: .85rem; }
.hero-header .breadcrumb-item a:hover { color: #fff; }
.hero-header .breadcrumb-item.active { color: rgba(255,255,255,.9); font-size: .85rem; }
.hero-header .breadcrumb-item + .breadcrumb-item::before { color: rgba(255,255,255,.4); }

/* ══════ BUTTONS ══════ */
.btn-nexus-ghost { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); color: #fff; font-weight: 600; font-size: .85rem; padding: 8px 16px; border-radius: 8px; transition: all .2s; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; backdrop-filter: blur(4px); cursor: pointer; }
.btn-nexus-ghost:hover { background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.35); color: #fff; }
.btn-nexus-ghost.danger { color: #FCA5A5; }
.btn-nexus-ghost.danger:hover { background: rgba(220,38,38,.2); border-color: rgba(220,38,38,.4); color: #fff; }
.btn-nexus-primary { background-color: var(--nexus-primary); color: #fff; border: none; font-weight: 600; font-size: .85rem; padding: 8px 20px; border-radius: 8px; box-shadow: 0 4px 6px -1px rgba(79,70,229,.3); transition: all .2s; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; cursor: pointer; }
.btn-nexus-primary:hover { background-color: var(--nexus-primary-hover); transform: translateY(-1px); color: #fff; }
.btn-nexus-success { background-color: #059669; color: #fff; border: none; font-weight: 600; font-size: .85rem; padding: 8px 20px; border-radius: 8px; box-shadow: 0 4px 6px -1px rgba(5,150,105,.3); transition: all .2s; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; cursor: pointer; }
.btn-nexus-success:hover { background-color: #047857; transform: translateY(-1px); color: #fff; }

/* ══════ STATS GRID ══════ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(220px,1fr)); gap: 20px; margin-bottom: 28px; }
.stat-card { background: var(--nexus-card-bg); border-radius: var(--radius-card); padding: 20px; display: flex; align-items: center; gap: 16px; border: 1px solid var(--nexus-border); box-shadow: var(--shadow-soft); transition: transform .2s; }
.stat-card:hover { transform: translateY(-2px); }
.stat-icon-box { width: 48px; height: 48px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; flex-shrink: 0; }
.stat-icon-blue { background: var(--icon-blue-bg); color: var(--icon-blue-text); }
.stat-icon-green { background: var(--icon-green-bg); color: var(--icon-green-text); }
.stat-icon-orange { background: var(--icon-orange-bg); color: var(--icon-orange-text); }
.stat-icon-red { background: var(--icon-red-bg); color: var(--icon-red-text); }
.stat-icon-purple { background: var(--icon-purple-bg); color: var(--icon-purple-text); }
.stat-info { display: flex; flex-direction: column; }
.stat-number { font-size: 1.5rem; font-weight: 800; color: var(--nexus-text-dark); line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: .7rem; font-weight: 700; color: #9CA3AF; text-transform: uppercase; letter-spacing: .05em; }

/* ══════ FILTER BAR ══════ */
.filter-container { background: var(--nexus-card-bg); border-radius: var(--radius-card); border: 1px solid var(--nexus-border); padding: 12px 20px; display: flex; justify-content: space-between; align-items: center; box-shadow: var(--shadow-soft); margin-bottom: 24px; gap: 16px; flex-wrap: wrap; }
.filter-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; flex: 1; }
.search-wrapper { position: relative; flex: 1; min-width: 200px; }
.search-wrapper input { width: 100%; padding: 8px 16px 8px 36px; border-radius: 20px; border: 1px solid var(--nexus-border); font-size: .9rem; background: #fff; }
.search-wrapper input:focus { outline: none; border-color: var(--nexus-primary); }
.search-wrapper i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #9CA3AF; }
.filter-select { padding: 8px 12px; border-radius: 8px; border: 1px solid var(--nexus-border); font-size: .85rem; background: #F9FAFB; color: var(--nexus-text-dark); font-weight: 500; cursor: pointer; min-width: 180px; }
.filter-select:focus { outline: none; border-color: var(--nexus-primary); }
.btn-filter-apply { background: var(--nexus-primary); color: #fff; border: none; padding: 8px 18px; border-radius: 8px; font-weight: 600; font-size: .85rem; cursor: pointer; transition: background .2s; display: inline-flex; align-items: center; gap: 6px; }
.btn-filter-apply:hover { background: var(--nexus-primary-hover); color: #fff; }
.btn-reset { color: #DC2626; font-weight: 600; font-size: .8rem; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; padding: 6px 10px; border-radius: 6px; transition: background .2s; }
.btn-reset:hover { background: #FEE2E2; color: #DC2626; }

/* ══════ CONTENT / DETAIL CARDS ══════ */
.content-card { background: var(--nexus-card-bg); border-radius: var(--radius-card); border: 1px solid var(--nexus-border); overflow: hidden; box-shadow: var(--shadow-soft); }
.detail-card { background: var(--nexus-card-bg); border-radius: var(--radius-card); border: 1px solid var(--nexus-border); overflow: hidden; margin-bottom: 24px; box-shadow: var(--shadow-soft); }
.detail-card-header { padding: 16px 24px; background: #F9FAFB; border-bottom: 1px solid var(--nexus-border); font-size: .75rem; font-weight: 600; text-transform: uppercase; color: var(--nexus-text-gray); letter-spacing: .05em; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.detail-card-header i { color: #9CA3AF; font-size: .85rem; }
.detail-card-body { padding: 24px; }

/* ══════ TABLE (scoped) ══════ */
.nexus-page .table { margin-bottom: 0; width: 100%; border-collapse: collapse; }
.nexus-page .table th { background: #F9FAFB; font-size: .75rem; font-weight: 600; text-transform: uppercase; color: var(--nexus-text-gray); padding: 16px 24px; border-bottom: 1px solid var(--nexus-border); }
.nexus-page .table td { padding: 16px 24px; vertical-align: middle; border-bottom: 1px solid #f3f4f6; color: var(--nexus-text-dark); font-size: .9rem; }
.nexus-page .table tr:hover { background-color: #F9FAFB; }
.nexus-page .table tr:last-child td { border-bottom: none; }

/* ══════ AVATAR / NAME LINK ══════ */
.nexus-avatar { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; margin-right: 12px; flex-shrink: 0; background: #EEF2FF; color: var(--nexus-primary); text-decoration: none; transition: all .2s; }
.nexus-avatar:hover { background: var(--nexus-primary); color: #fff; transform: scale(1.05); }
.nexus-name-link { color: var(--nexus-text-dark); text-decoration: none; font-weight: 600; transition: color .2s; }
.nexus-name-link:hover { color: var(--nexus-primary); text-decoration: underline; }
.profile-img-circle { width: 120px; height: 120px; border-radius: 50%; object-fit: cover; border: 2px solid var(--nexus-border); padding: 4px; background: #fff; }

/* ══════ READ-ONLY FIELDS ══════ */
.read-only-label { font-size: .78rem; font-weight: 600; color: #9CA3AF; margin-bottom: 4px; display: block; text-transform: uppercase; letter-spacing: .03em; }
.read-only-field { background: #F9FAFB; border: 1px solid var(--nexus-border); border-radius: var(--input-radius); padding: 10px 14px; font-size: .9rem; color: var(--nexus-text-dark); min-height: 42px; display: flex; align-items: center; }
.read-only-field a { color: var(--nexus-primary); text-decoration: none; }
.read-only-field a:hover { text-decoration: underline; }
.read-only-field i { color: #9CA3AF; }

/* ══════ BADGES ══════ */
.badge-category { background: #F3F4F6; color: #4B5563; border: 1px solid var(--nexus-border); padding: 4px 10px; border-radius: 20px; font-size: .75rem; font-weight: 600; }
.badge-nexus { padding: 5px 12px; border-radius: 20px; font-weight: 600; font-size: .78rem; display: inline-block; }
.badge-nexus-primary { background: #EEF2FF; color: var(--nexus-primary); }
.badge-nexus-warning { background: #FEF3C7; color: #D97706; }
.badge-nexus-secondary { background: #F3F4F6; color: #4B5563; border: 1px solid var(--nexus-border); }
.badge-nexus-success { background: #DCFCE7; color: #166534; }
.badge-nexus-danger { background: #FEE2E2; color: #DC2626; }
.badge-nexus-info { background: #DBEAFE; color: #1D4ED8; }

/* ══════ ACTION BUTTONS ══════ */
.btn-tbl-action { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--nexus-border); background: #fff; color: #6B7280; display: inline-flex; align-items: center; justify-content: center; transition: all .2s; text-decoration: none; cursor: pointer; font-size: .8rem; }
.btn-tbl-action:hover { border-color: var(--nexus-primary); color: var(--nexus-primary); background: #EEF2FF; }
.btn-tbl-action.act-preview:hover { color: #2563EB; border-color: #2563EB; background: #EFF6FF; }
.btn-tbl-action.act-edit:hover { color: var(--nexus-primary); border-color: var(--nexus-primary); background: #EEF2FF; }
.btn-tbl-action.act-delete:hover { color: #DC2626; border-color: #DC2626; background: #FEF2F2; }

/* ══════ TIMELINE ══════ */
.timeline-item { position: relative; padding-left: 1.5rem; padding-bottom: 1.5rem; border-left: 2px solid var(--nexus-border); }
.timeline-item:last-child { border-left: transparent; }
.timeline-dot { position: absolute; left: -6px; top: 0; width: 10px; height: 10px; border-radius: 50%; background: var(--nexus-primary); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--nexus-primary); }
.timeline-date { font-size: .73rem; color: #9CA3AF; margin-bottom: 2px; }

/* ══════ COMPLETENESS CARD ══════ */
.completeness-card { background: #EEF2FF; border: 1px solid #C7D2FE; border-radius: var(--radius-card); padding: 20px; margin-bottom: 24px; }
.nexus-page .completeness-card .progress { height: 6px; border-radius: 3px; background: #E0E7FF; }
.nexus-page .completeness-card .progress-bar { background: var(--nexus-primary); border-radius: 3px; }

/* ══════ NAV PILLS ══════ */
.nav-pills-minimal .nav-link { color: var(--nexus-text-gray); font-weight: 500; border-radius: 8px; padding: .4rem .9rem; margin-right: .4rem; font-size: .85rem; border: none; background: transparent; }
.nav-pills-minimal .nav-link.active { background-color: #EEF2FF; color: var(--nexus-primary); font-weight: 600; }

/* ══════ EMPTY STATE ══════ */
.empty-state-nexus { padding: 60px 20px; text-align: center; }
.empty-icon { font-size: 2.2rem; color: #D1D5DB; margin-bottom: 12px; display: inline-block; }
.empty-title { font-size: 1.1rem; font-weight: 700; color: var(--nexus-text-dark); margin-bottom: 5px; }
.empty-desc { color: var(--nexus-text-gray); margin-bottom: 20px; font-size: .95rem; }

/* ══════ FORMS (scoped) ══════ */
.nexus-page .form-label { font-size: .82rem; font-weight: 600; color: #4B5563; margin-bottom: 4px; }
.nexus-page .form-control, .nexus-page .form-select { border-radius: var(--input-radius); border: 1px solid var(--nexus-border); padding: .6rem .8rem; font-size: .9rem; background: #fff; }
.nexus-page .form-control:focus, .nexus-page .form-select:focus { border-color: var(--nexus-primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }
.nexus-page .input-group-text-clean { background: transparent; border-right: none; color: #9CA3AF; }
.nexus-page .input-group-clean .form-control { border-left: none; }
.nexus-page .input-group-clean:focus-within .input-group-text-clean { border-color: var(--nexus-primary); }
.section-divider { border-top: 1px dashed var(--nexus-border); margin: 20px 0; padding-top: 20px; }
.subsection-title { font-size: .75rem; font-weight: 600; color: #9CA3AF; margin-bottom: 15px; text-transform: uppercase; letter-spacing: .05em; display: flex; align-items: center; gap: 8px; }
.field-hint { font-size: .73rem; margin-top: 3px; color: var(--nexus-text-gray); }

/* ══════ RESPONSIVE ══════ */
@media (max-width: 1400px) { .stats-grid { grid-template-columns: repeat(3,1fr); } }
@media (max-width: 1200px) { .stats-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 992px) { .hero-header { flex-direction: column; align-items: flex-start !important; gap: 20px; } .header-actions { width: 100%; } }
@media (max-width: 768px) { .stats-grid { grid-template-columns: repeat(2,1fr); } .filter-container { flex-direction: column; align-items: stretch; } .search-wrapper { width: 100%; } }
@media (max-width: 600px) { .stats-grid { grid-template-columns: 1fr; } .header-actions { justify-content: space-between; } }
