/* ── SP CRM Frontend CSS ────────────────────────────────────────────────────
   Design moderno SaaS — sidebar scura + contenuto pulito
   ──────────────────────────────────────────────────────────────────────── */

/* ── Reset & base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w:      240px;
  --header-h:       56px;
  --sidebar-bg:     #0f172a;
  --sidebar-hover:  rgba(255,255,255,.06);
  --sidebar-active-bg: rgba(56,189,248,.12);
  --sidebar-active: #38bdf8;
  --sidebar-text:   #94a3b8;
  --primary:        #0ea5e9;
  --primary-dark:   #0284c7;
  --bg:             #f1f5f9;
  --surface:        #ffffff;
  --text:           #1e293b;
  --text-muted:     #64748b;
  --border:         #e2e8f0;
  --radius:         10px;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08);
  --shadow:         0 4px 16px rgba(0,0,0,.1);
}

body.sp-crm-frontend {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.crm-sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform .25s ease;
  overflow: hidden;
}

.crm-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Sidebar brand ──────────────────────────────────────────────────────── */
.crm-brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.crm-brand h2 {
  color: #f8fafc;
  font-size: .95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.crm-brand span {
  display: block;
  color: #38bdf8;
  font-size: .7rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-top: 3px;
  font-weight: 500;
}

/* ── Sidebar nav ────────────────────────────────────────────────────────── */
.crm-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}
.crm-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .845rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .15s;
  white-space: nowrap;
}
.crm-nav a:hover {
  color: #e2e8f0;
  background: var(--sidebar-hover);
}
.crm-nav a.active {
  color: var(--sidebar-active);
  background: var(--sidebar-active-bg);
  border-left-color: var(--sidebar-active);
}
.nav-icon {
  font-size: .9rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.crm-nav-divider {
  height: 1px;
  background: rgba(255,255,255,.07);
  margin: 6px 18px;
}

/* ── Sidebar footer ─────────────────────────────────────────────────────── */
.crm-sidebar-footer {
  padding: 12px 18px;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}
.crm-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}
.crm-user-avatar {
  width: 30px;
  height: 30px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: .8rem;
  flex-shrink: 0;
}
.crm-user-name {
  color: #cbd5e1;
  font-size: .8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crm-logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .75rem;
  color: #94a3b8;
  text-decoration: none;
  padding: 5px 8px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px;
  transition: all .15s;
  white-space: nowrap;
}
.crm-logout-btn:hover {
  background: rgba(239,68,68,.15);
  color: #fca5a5;
  border-color: rgba(239,68,68,.3);
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.crm-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.crm-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.crm-user-avatar-sm {
  width: 28px;
  height: 28px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: .75rem;
}
.crm-user-name-sm {
  font-size: .8rem;
  color: var(--text-muted);
}
.crm-header .crm-logout-btn {
  color: var(--text-muted);
  border-color: var(--border);
}
.crm-header .crm-logout-btn:hover {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}
.crm-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: 4px;
  line-height: 1;
}

/* ── Content ─────────────────────────────────────────────────────────────── */
.crm-content {
  flex: 1;
  padding: 24px;
}

/* Override WP .wrap inside frontend */
.crm-content .wrap {
  max-width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}
.crm-content .wrap h1 {
  font-size: 1.4rem !important;
  font-weight: 700 !important;
  color: var(--text) !important;
  margin-bottom: 0 !important;
}

/* ── Sidebar overlay (mobile) ───────────────────────────────────────────── */
.crm-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 199;
  opacity: 0;
  transition: opacity .25s;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .crm-sidebar { transform: translateX(-100%); }
  .crm-sidebar.open { transform: translateX(0); }
  .crm-main { margin-left: 0; }
  .crm-hamburger { display: block; }
  .crm-sidebar-overlay { display: block; }
  .crm-sidebar-overlay.open { opacity: 1; pointer-events: all; }
  .crm-user-name-sm { display: none; }
  .crm-content { padding: 16px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   LOGIN PAGE
   ═════════════════════════════════════════════════════════════════════════ */
body.crm-login-body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
}
.crm-login-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #0c2340 50%, #0f2d4a 100%);
  padding: 20px;
}
.crm-login-box {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: 0 24px 64px rgba(0,0,0,.4);
}
.crm-login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.crm-login-wave {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 8px;
}
.crm-login-logo h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -.02em;
}
.crm-login-logo p {
  font-size: .825rem;
  color: #64748b;
  margin-top: 4px;
}
.crm-login-alert {
  background: #fff7ed;
  border: 1px solid #fb923c;
  color: #9a3412;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: .85rem;
  margin-bottom: 20px;
}
.crm-login-form { display: flex; flex-direction: column; gap: 18px; }
.crm-field { display: flex; flex-direction: column; gap: 5px; }
.crm-field label {
  font-size: .8rem;
  font-weight: 600;
  color: #374151;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.crm-field input[type=text],
.crm-field input[type=password],
.crm-field input[type=email] {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid #d1d5db;
  border-radius: 8px;
  font-size: .9rem;
  color: #1e293b;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  background: #f9fafb;
}
.crm-field input:focus {
  border-color: #0ea5e9;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(14,165,233,.15);
}
.crm-pw-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  color: #94a3b8;
  line-height: 1;
  padding: 2px 4px;
}
.crm-login-submit {
  width: 100%;
  padding: 13px;
  background: #0ea5e9;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .02em;
  transition: background .15s, transform .1s;
}
.crm-login-submit:hover { background: #0284c7; }
.crm-login-submit:active { transform: scale(.98); }

/* ═══════════════════════════════════════════════════════════════════════════
   LANDING PAGE
   ═════════════════════════════════════════════════════════════════════════ */
body.crm-landing-body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  margin: 0;
}
.crm-landing-bg {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #0c2340 50%, #0f2d4a 100%);
  padding: 20px;
}
.crm-landing-card {
  text-align: center;
  color: #fff;
  max-width: 440px;
}
.crm-landing-logo {
  margin-bottom: 24px;
}
.crm-landing-logo img {
  max-width: 240px;
  height: auto;
}
.crm-landing-title {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -.04em;
  margin-bottom: 12px;
}
.crm-landing-subtitle {
  font-size: 1rem;
  color: #94a3b8;
  margin-bottom: 36px;
  line-height: 1.6;
}
.crm-landing-btn {
  display: inline-block;
  padding: 14px 36px;
  background: #0ea5e9;
  color: #fff;
  text-decoration: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .02em;
  transition: background .15s, transform .1s;
  box-shadow: 0 8px 24px rgba(14,165,233,.35);
}
.crm-landing-btn:hover { background: #0284c7; transform: translateY(-2px); }
.crm-landing-note {
  margin-top: 20px;
  font-size: .78rem;
  color: #475569;
}
