/* =====================================================
   GREVI Portail Client - CSS Principal
   ===================================================== */

:root {
  --cyan: #22D3EE;
  --blue: #6366F1;
  --black: #050505;
  --text: #333333;
  --muted: #8E929D;
  --soft: #F7F7F8;
  --line: #E6E8EE;
  --pale: #EEF3FF;
  --danger: #EF4444;
  --ok: #16A34A;
  --grad: linear-gradient(90deg, #22D3EE, #6366F1);
  --shadow: 0 24px 70px rgba(17, 24, 39, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Avenir Next Cyr", "Avenir Next LT Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 10% 5%, rgba(34, 211, 238, 0.11), transparent 32%),
              radial-gradient(circle at 95% 20%, rgba(99, 102, 241, 0.10), transparent 34%),
              #fff;
}

a {
  color: inherit;
}

button, input, select, textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.small {
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.875rem;
}

code {
  background: var(--soft);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}

/* ===== LOGIN PAGE ===== */

.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 520px;
}

.login-hero {
  padding: 8vw;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.eyebrow {
  font-size: 13px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 30px 0 20px;
}

h1 {
  font-size: clamp(44px, 6vw, 84px);
  line-height: 0.96;
  letter-spacing: -0.055em;
  margin: 0 0 26px;
  color: #000;
}

h2 {
  font-size: 32px;
  letter-spacing: -0.04em;
  color: #000;
  margin: 0 0 8px;
}

h3 {
  font-size: 24px;
  letter-spacing: -0.03em;
  color: #000;
  margin: 0 0 8px;
}

.lead {
  font-size: 20px;
  line-height: 1.55;
  color: #626873;
  max-width: 690px;
  margin: 26px 0;
}

.login-panel {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(20px);
  border-left: 1px solid var(--line);
  padding: 54px;
  display: flex;
  align-items: center;
}

.card {
  width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 34px;
  padding: 32px;
  box-shadow: var(--shadow);
}

.field {
  margin-top: 18px;
}

label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #858B96;
  margin-bottom: 8px;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 15px;
  background: #fff;
  color: #111;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.10);
}

/* ===== BUTTONS ===== */

.btn {
  border: 0;
  border-radius: 999px;
  padding: 14px 18px;
  background: #fff;
  border: 1px solid var(--line);
  color: #111;
  font-weight: 650;
  text-decoration: none;
  display: inline-block;
  transition: all 0.2s ease;
}

.btn:hover {
  background: var(--soft);
}

.btn-primary {
  background: var(--black);
  color: #fff;
  border-color: var(--black);
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-gradient {
  background: var(--grad);
  color: #fff;
  border: 0;
}

.btn-gradient:hover {
  opacity: 0.9;
}

.btn-secondary {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--soft);
}

.btn-danger {
  color: #fff;
  background: var(--danger);
  border: 0;
}

.btn.full {
  width: 100%;
  margin-top: 22px;
}

.btn-role {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-role.active {
  background: var(--grad);
  color: white;
  border-color: var(--grad);
}

.btn-role:hover {
  border-color: var(--blue);
}

/* ===== DEMO BOX ===== */

.demo-box {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  margin-top: 20px;
  font-size: 13px;
}

.demo-box b {
  display: block;
  margin-bottom: 8px;
}

.demo-box p {
  margin: 6px 0;
}

/* ===== ALERTS ===== */

.alert {
  padding: 14px 16px;
  border-radius: 16px;
  margin-bottom: 16px;
}

.alert-danger {
  background: #FEF2F2;
  color: var(--danger);
  border: 1px solid #FECACA;
}

.alert-success {
  background: #ECFDF5;
  color: var(--ok);
  border: 1px solid #BBFCD6;
}

/* ===== APP SHELL ===== */

.app-shell {
  display: grid;
  grid-template-columns: 292px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--black);
  color: #fff;
  padding: 28px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.logo-svg {
  width: 168px;
}

.brand-logo {
  width: 180px;
  max-width: 100%;
  margin: 0 0 34px;
  display: block;
}

.brand-logo .brand-main {
  font-family: "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 76px;
  font-weight: 300;
  letter-spacing: 12px;
  fill: currentColor;
}

.brand-logo .brand-sub {
  font-family: "Avenir Next", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 22px;
  font-weight: 400;
  letter-spacing: 22px;
  fill: #9EA0A8;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.nav-btn {
  background: transparent;
  border: 0;
  color: #BEC4CF;
  text-align: left;
  padding: 13px 14px;
  border-radius: 16px;
  display: flex;
  gap: 11px;
  align-items: center;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  font-size: 0.95rem;
}

.nav-btn:hover, .nav-btn.active {
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
}

.nav-danger {
  color: #F87171;
}

.side-footer {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 24px;
  color: #9EA0A8;
  font-size: 13px;
  line-height: 1.6;
}

.main {
  padding: 30px 42px 60px;
}

/* ===== TOPBAR ===== */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 30px;
}

.topbar h2 {
  font-size: 34px;
  color: #000;
  letter-spacing: -0.04em;
  margin: 0;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.client-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
}

.client-switcher label {
  margin: 0;
  letter-spacing: 0.08em;
}

.client-switcher select {
  width: auto;
  min-width: 190px;
  border: 0;
  padding: 4px;
  border-radius: 8px;
}

.role-badge {
  padding: 8px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--black);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  box-shadow: 0 10px 30px rgba(17, 24, 39, 0.04);
  cursor: pointer;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--grad);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  flex-shrink: 0;
}

.user-badge b {
  display: block;
  font-size: 0.9rem;
}

/* ===== GRID ===== */

.grid3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 20px;
}

.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 24px;
  box-shadow: 0 14px 40px rgba(17, 24, 39, 0.04);
  text-decoration: none;
  display: block;
}

.stat b {
  display: block;
  font-size: 42px;
  color: #000;
  letter-spacing: -0.05em;
  margin-bottom: 8px;
}

.stat span {
  color: var(--muted);
}

.stat small {
  color: var(--muted);
}

/* ===== PANELS ===== */

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 30px;
  padding: 26px;
  box-shadow: 0 16px 50px rgba(17, 24, 39, 0.05);
  margin-top: 20px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.panel-head h3 {
  font-size: 24px;
  letter-spacing: -0.03em;
  color: #000;
  margin: 0;
  flex: 1;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.split {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  gap: 20px;
  align-items: start;
}

.folder-list {
  display: grid;
  gap: 8px;
}

.folder-item,
.task-item,
.message-row,
.signature-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: #fff;
}

.folder-item.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.08);
}

.task-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: start;
  margin-bottom: 12px;
}

.task-check {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--soft);
}

.message-thread {
  height: 420px;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  overflow-y: auto;
  background: var(--soft);
}

.message-row {
  width: min(72%, 620px);
  margin-bottom: 12px;
}

.message-row.mine {
  margin-left: auto;
  background: #050505;
  color: #fff;
}

.canvas-wrap {
  border: 1px dashed var(--line);
  border-radius: 18px;
  background: #fff;
  padding: 10px;
  touch-action: none;
}

.signature-canvas {
  width: 100%;
  height: 220px;
  display: block;
  background: #fff;
  border-radius: 12px;
}

.pdf-frame {
  width: 100%;
  height: 520px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--soft);
}

.hidden-input {
  display: none;
}

/* ===== TABLES ===== */

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}

.table thead {
  background: var(--soft);
}

.table th {
  padding: 15px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  color: var(--muted);
  font-weight: 600;
}

.table td {
  padding: 15px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

.table tbody tr:hover {
  background: var(--soft);
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

/* ===== BADGES ===== */

.badge {
  display: inline-flex;
  justify-content: center;
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 700;
  background: var(--pale);
  color: var(--blue);
}

.badge-reçu { background: #EFF6FF; color: #2563EB; }
.badge-lu_par_grevi { background: #F5F3FF; color: #7C3AED; }
.badge-à_signer { background: #FEF3C7; color: #B45309; }
.badge-signé { background: #ECFDF5; color: #15803D; }
.badge-traité { background: #ECFDF5; color: #16A34A; }
.badge-archivé { background: #F3F4F6; color: #4B5563; }

/* ===== RESPONSIVE ===== */

@media (max-width: 1180px) {
  .grid3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 1040px) {
  .login-wrap {
    grid-template-columns: 1fr;
  }

  .login-panel {
    border-left: 0;
    padding: 28px;
    min-height: 50vh;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: auto 14px 14px 14px;
    height: auto;
    border-radius: 28px;
    z-index: 20;
    padding: 10px;
  }

  .sidebar .logo-svg,
  .sidebar .brand-logo,
  .side-footer {
    display: none;
  }

  .side-nav {
    display: flex;
    overflow: auto;
    gap: 8px;
  }

  .nav-btn {
    white-space: nowrap;
    font-size: 13px;
  }

  .main {
    padding: 26px 18px 120px;
  }

  .grid3 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .login-hero {
    padding: 32px 22px;
  }

  .card {
    padding: 22px;
    border-radius: 26px;
  }

  .panel {
    padding: 18px;
    border-radius: 24px;
  }

  h1 {
    font-size: 44px;
  }

  .topbar {
    display: block;
  }

  .top-actions {
    margin-top: 14px;
  }

  .split {
    grid-template-columns: 1fr;
  }

  .client-switcher {
    width: 100%;
    border-radius: 16px;
  }

  .client-switcher select {
    flex: 1;
    min-width: 0;
  }
}
