/* Espace ArtisanGad (web app JS) — surcouche sur ag.css (mêmes tokens) */
.esp-body { background: var(--ag-bg); min-height: 100vh; }

/* Boot / spinner */
.esp-boot { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.esp-spinner { width: 38px; height: 38px; border: 3px solid var(--ag-border); border-top-color: var(--ag-accent); border-radius: 50%; animation: espspin .8s linear infinite; }
@keyframes espspin { to { transform: rotate(360deg); } }

/* Toast */
.esp-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--ag-primary); color: #fff; padding: 13px 20px; border-radius: 12px; font-weight: 700; font-size: 14px; box-shadow: var(--ag-e3); opacity: 0; pointer-events: none; transition: .25s; z-index: 200; max-width: 90vw; }
.esp-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.esp-toast.err { background: var(--ag-error); }
.esp-toast.ok { background: var(--ag-success); }

/* ── Auth (login / signup / role / verify) ── */
.esp-auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.esp-auth-aside { background: var(--ag-grad-brand); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.esp-auth-aside::before { content: ""; position: absolute; top: -80px; right: -60px; width: 320px; height: 320px; border-radius: 50%; background: radial-gradient(circle, rgba(236,106,31,.28), transparent 70%); }
.esp-auth-aside .lg { display: flex; align-items: center; gap: 12px; margin-bottom: 40px; position: relative; }
.esp-auth-aside h1 { position: relative; font-size: 40px; font-weight: 800; letter-spacing: -1.4px; line-height: 1.1; }
.esp-auth-aside p { position: relative; color: #9AA8C0; font-size: 17px; margin-top: 16px; max-width: 400px; }
.esp-auth-aside .pts { position: relative; margin-top: 32px; display: flex; flex-direction: column; gap: 14px; }
.esp-auth-aside .pt { display: flex; align-items: center; gap: 11px; font-weight: 600; color: #E2E7EF; }
.esp-auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.esp-auth-card { width: 100%; max-width: 400px; }
.esp-auth-card h2 { font-size: 26px; font-weight: 800; letter-spacing: -.5px; margin-bottom: 6px; }
.esp-auth-card .sub { color: var(--ag-text-2); margin-bottom: 26px; }
.esp-or { display: flex; align-items: center; gap: 12px; color: var(--ag-text-3); font-size: 13px; margin: 18px 0; }
.esp-or::before, .esp-or::after { content: ""; flex: 1; height: 1px; background: var(--ag-border); }
.esp-link { color: var(--ag-accent); font-weight: 700; cursor: pointer; }
.esp-btn-google { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 13px; border: 1.5px solid var(--ag-border); border-radius: var(--ag-r-md); background: #fff; font-weight: 700; font-size: 15px; cursor: pointer; color: var(--ag-text); }
.esp-btn-google:hover { border-color: var(--ag-text-3); }
.esp-role-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.esp-role { border: 1.5px solid var(--ag-border); border-radius: var(--ag-r-lg); padding: 22px; text-align: center; cursor: pointer; transition: .15s; background: #fff; }
.esp-role:hover { border-color: var(--ag-accent); transform: translateY(-2px); }
.esp-role .ag-ico { margin: 0 auto 12px; }

/* ── Shell (sidebar + main) ── */
.esp-shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; background: #EEF1F6; }
.esp-sidebar { background: linear-gradient(185deg,#1A2C50,#0F1B30); color: #fff; padding: 22px 15px 18px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.esp-brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 20px; }
.esp-logo-tile { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(140deg,#2B406B,#13223C); display: flex; align-items: center; justify-content: center; border: 1px solid rgba(255,255,255,.08); flex: none; }
.esp-brand b { font-size: 17px; font-weight: 800; letter-spacing: -.3px; line-height: 1; display: block; }
.esp-brand .sub { font-size: 10.5px; color: #7D8AA3; font-weight: 600; margin-top: 4px; font-family: var(--ag-mono); letter-spacing: 1px; }
.esp-nav-label { font-size: 10.5px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: #5E6C88; padding: 8px 10px 6px; }
.esp-nav { display: flex; flex-direction: column; gap: 4px; }
.esp-nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; color: #9AA8C0; font-weight: 700; font-size: 14px; cursor: pointer; }
.esp-nav a svg { width: 20px; height: 20px; }
.esp-nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.esp-nav a.active { background: var(--ag-accent); color: #fff; }
.esp-nav a .badge { margin-left: auto; background: var(--ag-accent); color: #fff; font-size: 11px; font-weight: 800; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 20px; display: flex; align-items: center; justify-content: center; }
.esp-nav a.active .badge { background: rgba(255,255,255,.25); }
.esp-side-cta { margin-top: 16px; display: flex; align-items: center; justify-content: center; gap: 8px; background: var(--ag-accent); color: #fff; font-weight: 800; font-size: 14px; padding: 13px; border-radius: 13px; box-shadow: 0 10px 22px rgba(236,106,31,.30); }
.esp-side-cta:hover { filter: brightness(1.06); }
.esp-side-user { margin-top: auto; display: flex; align-items: center; gap: 11px; background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.07); border-radius: 14px; padding: 11px; }
.esp-side-user .av { width: 38px; height: 38px; border-radius: 50%; background: repeating-linear-gradient(45deg,#2B3A56,#2B3A56 6px,#34456A 6px,#34456A 12px); flex: none; }
.esp-side-user .meta { flex: 1; min-width: 0; }
.esp-side-user .nm { font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.esp-side-user .ro { font-size: 11.5px; color: #7D8AA3; }
.esp-logout { background: none; border: 0; color: #7D8AA3; cursor: pointer; padding: 4px; display: flex; align-items: center; }
.esp-logout:hover { color: #fff; }

/* Topbar (desktop) */
.esp-topbar { position: sticky; top: 0; z-index: 40; background: rgba(255,255,255,.86); backdrop-filter: blur(14px); border-bottom: 1px solid #E4E8F0; padding: 0 34px; height: 74px; display: flex; align-items: center; gap: 16px; }
.esp-tb-burger { display: none; background: none; border: 0; cursor: pointer; padding: 0; margin-right: 4px; }
.esp-tb-title { min-width: 0; }
.esp-tb-title b { font-size: 19px; font-weight: 800; letter-spacing: -.4px; line-height: 1.1; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.esp-tb-title span { font-size: 13px; color: #7C89A1; margin-top: 2px; display: block; }
.esp-tb-spacer { flex: 1; }
.esp-tb-search { display: flex; align-items: center; gap: 7px; background: #F2F5FA; border: 1px solid #E6EAF1; border-radius: 11px; padding: 9px 13px; width: 220px; color: #97A2B6; font-size: 13.5px; }
.esp-tb-bell { width: 42px; height: 42px; border-radius: 11px; background: #F2F5FA; border: 1px solid #E6EAF1; display: flex; align-items: center; justify-content: center; position: relative; cursor: pointer; flex: none; }
.esp-tb-bell .dot { position: absolute; top: 9px; right: 11px; width: 8px; height: 8px; border-radius: 50%; background: var(--ag-accent); border: 2px solid #fff; }

.esp-main { padding: 28px 34px 48px; max-width: 1200px; }
.esp-main h1.title { font-size: 25px; font-weight: 800; letter-spacing: -.6px; margin-bottom: 4px; }
.esp-main .crumb { color: var(--ag-text-2); margin-bottom: 24px; }

/* KPI / Stat cards */
.esp-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 28px; }
.esp-stat { background: #fff; border: 1px solid #E9EDF3; border-radius: 18px; padding: 18px 20px; display: flex; align-items: center; gap: 15px; }
.esp-stat .ic { width: 46px; height: 46px; border-radius: 13px; display: flex; align-items: center; justify-content: center; flex: none; background: var(--ag-accent-tint); color: var(--ag-accent); }
.esp-stat .v { font-size: 25px; font-weight: 800; letter-spacing: -.6px; }
.esp-stat .l { font-size: 12.5px; color: var(--ag-text-2); font-weight: 600; margin-top: 2px; }
.esp-stat.hero { background: linear-gradient(145deg,#22365C,#13223C); border: 0; color: #fff; }
.esp-stat.hero .l { color: #9AA8C0; }
.esp-stat.hero .ic { background: rgba(255,255,255,.10); color: #fff; }

/* Listes (projets, devis, conversations) */
.esp-list { display: flex; flex-direction: column; gap: 12px; }
.esp-row { background: #fff; border: 1px solid var(--ag-border); border-radius: var(--ag-r-lg); padding: 16px 18px; display: flex; align-items: center; gap: 14px; cursor: pointer; transition: .12s; }
.esp-row:hover { box-shadow: var(--ag-e1); border-color: #D9E0EC; }
.esp-row .grow { flex: 1; min-width: 0; }
.esp-row .ttl { font-weight: 700; font-size: 15.5px; }
.esp-row .meta { font-size: 13px; color: var(--ag-text-2); margin-top: 2px; }
.esp-row .amt { font-weight: 800; font-size: 16px; }
.esp-empty { text-align: center; padding: 56px 20px; color: var(--ag-text-2); }
.esp-empty .ag-ico { margin: 0 auto 14px; }
.esp-empty > svg { width: 46px; height: 46px; display: block; margin: 0 auto 16px; color: var(--ag-text-3); opacity: .8; }

/* Status pills */
.pill { font-size: 12px; font-weight: 700; padding: 5px 10px; border-radius: var(--ag-r-full); white-space: nowrap; }
.pill.ouvert { background: var(--ag-accent-tint); color: var(--ag-accent-dark); }
.pill.enCours { background: var(--ag-info-tint); color: var(--ag-info); }
.pill.termine { background: var(--ag-success-tint); color: var(--ag-success); }
.pill.envoye { background: var(--ag-warning-tint); color: var(--ag-warning); }
.pill.accepte { background: var(--ag-success-tint); color: var(--ag-success); }
.pill.refuse { background: var(--ag-error-tint); color: var(--ag-error); }

/* Forms */
.esp-form { background: #fff; border: 1px solid var(--ag-border); border-radius: var(--ag-r-xl); padding: 28px; max-width: 640px; }
.esp-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.esp-seg { display: flex; flex-wrap: wrap; gap: 8px; }
.esp-seg button { border: 1.5px solid var(--ag-border); background: #fff; border-radius: var(--ag-r-full); padding: 8px 14px; font-weight: 700; font-size: 13.5px; cursor: pointer; color: var(--ag-text-2); }
.esp-seg button.on { background: var(--ag-accent); color: #fff; border-color: var(--ag-accent); }

/* Devis lignes + signature */
.esp-line { display: grid; grid-template-columns: 1fr 70px 90px 30px; gap: 8px; align-items: center; margin-bottom: 8px; }
.esp-line input { padding: 10px; }
.esp-sigpad { border: 1.5px dashed var(--ag-border); border-radius: var(--ag-r-md); background: #fff; touch-action: none; width: 100%; height: 150px; display: block; }

/* Chat */
.esp-chat { display: grid; grid-template-columns: 300px 1fr; gap: 18px; height: calc(100vh - 150px); }
.esp-conv-list { overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.esp-conv { background: #fff; border: 1px solid var(--ag-border); border-radius: var(--ag-r-md); padding: 12px 14px; cursor: pointer; }
.esp-conv.on { border-color: var(--ag-accent); background: var(--ag-accent-tint); }
.esp-conv .nm { font-weight: 700; font-size: 14px; }
.esp-conv .lm { font-size: 12.5px; color: var(--ag-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.esp-thread { background: #fff; border: 1px solid var(--ag-border); border-radius: var(--ag-r-lg); display: flex; flex-direction: column; overflow: hidden; }
.esp-msgs { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 8px; }
.esp-bub { max-width: 72%; padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.4; }
.esp-bub.me { align-self: flex-end; background: var(--ag-accent); color: #fff; border-bottom-right-radius: 5px; }
.esp-bub.you { align-self: flex-start; background: var(--ag-surface-muted); color: var(--ag-text); border-bottom-left-radius: 5px; }
.esp-compose { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--ag-border); }
.esp-compose input { flex: 1; }

.esp-back { display: inline-flex; align-items: center; gap: 6px; color: var(--ag-text-2); font-weight: 700; cursor: pointer; margin-bottom: 16px; }

/* Planning — calendrier semaine */
#cal { background: #fff; border: 1px solid #E9EDF3; border-radius: 18px; overflow: hidden; }
.esp-cal-row { display: grid; grid-template-columns: 54px repeat(7,1fr); }
.esp-cal-head { border-bottom: 1px solid #EDF0F5; }
.esp-cal-head .esp-cal-tc { border-right: 1px solid #EDF0F5; }
.esp-cal-dh { padding: 13px 8px; text-align: center; border-right: 1px solid #EDF0F5; }
.esp-cal-dh:last-child { border-right: 0; }
.esp-cal-dh .dn { font-size: 11px; color: var(--ag-text-3); font-weight: 700; }
.esp-cal-dh .dd { font-size: 16px; font-weight: 800; margin-top: 2px; }
.esp-cal-dh.on { background: #FBF5F0; }
.esp-cal-dh.on .dn, .esp-cal-dh.on .dd { color: var(--ag-accent); }
.esp-cal-body { display: grid; grid-template-columns: 54px repeat(7,1fr); }
.esp-cal-t { height: 108px; padding: 4px 8px 0; font-size: 11px; color: var(--ag-text-3); font-weight: 600; text-align: right; box-sizing: border-box; }
.esp-cal-body .esp-cal-tc { border-right: 1px solid #EDF0F5; }
.esp-cal-col { border-right: 1px solid #EDF0F5; position: relative; background-image: repeating-linear-gradient(#F4F6FA 0 1px, transparent 1px 108px); }
.esp-cal-col:last-child { border-right: 0; }
.esp-ev { position: absolute; left: 5px; right: 5px; border-radius: 8px; padding: 7px 9px; overflow: hidden; box-sizing: border-box; }
.esp-ev .t { font-size: 12px; font-weight: 800; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.esp-ev .m { font-size: 11px; margin-top: 2px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.esp-ev.plan { background: var(--ag-accent-tint); border-left: 3px solid var(--ag-accent); color: #A85A22; }
.esp-ev.done { background: var(--ag-success-tint); border-left: 3px solid var(--ag-success); color: #1F5E43; }
.esp-ev.cancel { background: #F2F5FA; border-left: 3px solid #C9D2E0; color: var(--ag-text-2); }

/* Clients — tableau */
.esp-table { background: #fff; border: 1px solid #E9EDF3; border-radius: 18px; overflow: hidden; }
.esp-tr { display: grid; grid-template-columns: 2fr 1.4fr 1fr 1fr; align-items: center; padding: 15px 22px; border-bottom: 1px solid #EFF2F7; }
.esp-tr:last-child { border-bottom: 0; }
.esp-th { background: #F9FAFC; font-size: 12px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; color: var(--ag-text-3); }
.esp-cl { display: flex; align-items: center; gap: 12px; min-width: 0; }
.esp-cl .av { width: 40px; height: 40px; border-radius: 50%; background: repeating-linear-gradient(45deg,#EEF1F6,#EEF1F6 5px,#E0E5EF 5px,#E0E5EF 10px); flex: none; }
.esp-cl .nm { font-weight: 800; font-size: 14px; }
.esp-cl .ci { font-size: 12px; color: var(--ag-text-3); }
.esp-tr > span { font-size: 13.5px; color: var(--ag-text); }
.esp-tr .amt { font-weight: 800; }

/* Créer un devis — 2 colonnes + panneau IA */
.esp-devis-grid { display: grid; grid-template-columns: 1fr 320px; gap: 18px; align-items: start; }
.esp-devis-side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 90px; }
.esp-ia { background: linear-gradient(150deg,#FDEFE3,#FBE3D0); border: 1px solid #F8DEC9; border-radius: 18px; padding: 18px; }
.esp-ia-h { display: flex; align-items: center; gap: 8px; font-weight: 800; color: #B5510F; font-size: 15px; }
.esp-ia p { font-size: 13px; color: #A85A22; line-height: 1.5; margin: 10px 0 0; }
.esp-tips { background: #fff; border: 1px solid #E9EDF3; border-radius: 18px; padding: 18px; }
.esp-tips-h { font-size: 12px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--ag-text-3); margin-bottom: 12px; }
.esp-tip { display: flex; gap: 8px; font-size: 13px; color: var(--ag-text); margin-bottom: 10px; line-height: 1.4; }
.esp-tip:last-child { margin-bottom: 0; }
.esp-btn-send { width: 100%; border: 0; background: var(--ag-primary); color: #fff; font-family: inherit; font-weight: 800; font-size: 15px; padding: 15px; border-radius: 14px; cursor: pointer; }
.esp-btn-send:hover { filter: brightness(1.12); }
.esp-devis-total { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--ag-border); }
.esp-devis-total .lbl { font-size: 12.5px; color: var(--ag-text-3); }
.esp-devis-total .sub { font-size: 11.5px; color: var(--ag-text-3); margin-top: 2px; }
.esp-devis-total .amt { font-size: 28px; font-weight: 800; letter-spacing: -1px; }

/* ── Responsive ── */
@media (max-width: 860px) {
  .esp-auth { grid-template-columns: 1fr; }
  .esp-auth-aside { display: none; }
  .esp-shell { grid-template-columns: 1fr; }
  .esp-sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 240px; z-index: 120; transform: translateX(-100%); transition: .2s; }
  .esp-sidebar.open { transform: none; }
  .esp-topbar { padding: 12px 18px; height: auto; gap: 12px; }
  .esp-tb-burger { display: flex; }
  .esp-tb-search { display: none; }
  .esp-tb-title b { font-size: 16px; }
  .esp-tb-title span { display: none; }
  .esp-main { padding: 20px; }
  .esp-stats { grid-template-columns: 1fr 1fr; }
  .esp-row2 { grid-template-columns: 1fr; }
  .esp-chat { grid-template-columns: 1fr; height: auto; }
  .esp-devis-grid { grid-template-columns: 1fr; }
  .esp-devis-side { position: static; }
  .esp-tr { grid-template-columns: 1fr auto; padding: 14px 16px; gap: 10px; }
  .esp-tr > span:nth-child(2), .esp-tr > span:nth-child(3) { display: none; }
  #cal { overflow-x: auto; }
  .esp-cal-row, .esp-cal-body { min-width: 720px; }
  .esp-scrim { position: fixed; inset: 0; background: rgba(19,34,60,.4); z-index: 110; display: none; }
  .esp-scrim.show { display: block; }
}
