/* ════════════════════════════════════════════════════════════════════
   COFFRESIV PRO — Design System
   Cohérent avec coffresiv.fr (gov français)
   ════════════════════════════════════════════════════════════════════ */

:root {
  /* Couleurs principales */
  --bg: #FFFFFF;
  --bg-soft: #F6F6F6;
  --bg-tint: #F0F2FE;
  --blue: #000091;
  --blue-hover: #1212A1;
  --blue-soft: #E3E3FD;
  --red: #E1000F;
  --red-soft: #FCEEEE;
  --green: #18753C;
  --green-soft: #DFFEE6;
  --orange: #B34000;
  --orange-soft: #FEECC2;
  --text: #161616;
  --text-soft: #3A3A3A;
  --muted: #666666;
  --border: #DDDDDD;
  --border-soft: #EEEEEE;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-soft);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .serif {
  font-family: 'Spectral', Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

a {
  color: var(--blue);
}

/* TRICOLOR BAR */
.tricolor {
  display: flex;
  height: 3px;
}
.tricolor span {
  flex: 1;
}
.tricolor span:nth-child(1) { background: var(--blue); }
.tricolor span:nth-child(2) { background: white; border-top: 1px solid #DDD; border-bottom: 1px solid #DDD; }
.tricolor span:nth-child(3) { background: var(--red); }

/* HEADER APP */
header.app {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: 'Spectral', serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--blue);
  text-decoration: none;
}
.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--blue);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}
.user-info {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
}
.user-info .session {
  color: var(--muted);
}
.user-info .session strong {
  color: var(--text);
}
.btn-logout {
  background: transparent;
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-soft);
  font-family: inherit;
}
.btn-logout:hover {
  border-color: var(--red);
  color: var(--red);
}

/* MAIN LAYOUT */
.app-body {
  padding: 32px;
  max-width: 1280px;
  margin: 0 auto;
}

/* PAGE LOGIN */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-soft) 0%, var(--blue-soft) 100%);
  padding: 32px;
}
.login-card {
  background: white;
  padding: 48px;
  border-radius: 8px;
  max-width: 460px;
  width: 100%;
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(0,0,128,0.06);
}
.login-card .logo {
  justify-content: center;
  margin-bottom: 24px;
}
.login-card h1 {
  font-size: 24px;
  text-align: center;
  margin-bottom: 8px;
}
.login-card .sub {
  text-align: center;
  color: var(--muted);
  margin-bottom: 32px;
  font-size: 14px;
}
.session-info {
  background: var(--blue-soft);
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--blue);
  margin-bottom: 24px;
  line-height: 1.5;
}
.session-info strong {
  display: block;
  margin-bottom: 4px;
}

/* FORMS */
.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-bottom: 2px solid var(--text-soft);
  border-radius: 4px 4px 0 0;
  font-family: inherit;
  font-size: 14px;
  background: var(--bg-soft);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-bottom-color: var(--blue);
  background: white;
}
.field input.coffre-input {
  font-family: 'Courier New', monospace;
  font-size: 12px;
}
.field input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.help-text {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

/* BUTTONS */
.btn-primary {
  width: 100%;
  background: var(--blue);
  color: white;
  border: none;
  padding: 12px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
  margin-top: 8px;
  transition: background 0.15s;
}
.btn-primary:hover:not(:disabled) {
  background: var(--blue-hover);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-secondary {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
}
.btn-secondary:hover {
  border-color: var(--text);
}
.btn-create {
  background: var(--blue);
  color: white;
  border: none;
  padding: 12px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-create:hover {
  background: var(--blue-hover);
}

.login-card .links {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
}
.login-card .links a {
  color: var(--blue);
  text-decoration: none;
  margin: 0 8px;
  cursor: pointer;
}
.login-card .links a:hover {
  text-decoration: underline;
}

/* ERROR MESSAGE */
.error-banner {
  background: var(--red-soft);
  border-left: 4px solid var(--red);
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--red);
  margin-bottom: 16px;
  line-height: 1.4;
}

/* PAGE HEADER */
.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.page-header h1 {
  font-size: 28px;
}
.page-header .sub {
  color: var(--muted);
  margin-top: 4px;
  font-size: 14px;
}

/* QUOTA BANNER */
.quota-banner {
  background: white;
  border: 1px solid var(--border);
  border-left: 4px solid var(--blue);
  padding: 16px 20px;
  border-radius: 4px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}
.quota-banner .label {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.quota-banner .value {
  font-family: 'Spectral', serif;
  font-size: 22px;
  font-weight: 600;
}
.quota-bar {
  width: 240px;
  height: 8px;
  background: var(--bg-soft);
  border-radius: 4px;
  overflow: hidden;
}
.quota-bar > div {
  height: 100%;
  background: var(--blue);
  transition: width 0.3s;
}

/* SEARCH BAR */
.search-bar {
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 16px 20px;
  margin-bottom: 16px;
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}
.search-bar .field {
  margin: 0;
}
.search-bar .field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.search-bar input, .search-bar select {
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
  background: var(--bg-soft);
  width: 100%;
}
.btn-search {
  background: var(--text);
  color: white;
  border: none;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  height: fit-content;
  font-family: inherit;
}

/* TABLE DOSSIERS */
.dossiers-table {
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.dossiers-table table {
  width: 100%;
  border-collapse: collapse;
}
.dossiers-table th {
  background: var(--bg-soft);
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.dossiers-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 14px;
}
.dossiers-table tr:hover {
  background: var(--bg-soft);
  cursor: pointer;
}
.dossiers-table tr:last-child td {
  border-bottom: none;
}
.dossiers-table .empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}
.status-badge.draft {
  background: var(--orange-soft);
  color: var(--orange);
}
.status-badge.archived {
  background: var(--green-soft);
  color: var(--green);
}
.status-badge.error {
  background: var(--red-soft);
  color: var(--red);
}
.status-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

/* TABS */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border);
}
.tab {
  padding: 12px 20px;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  text-decoration: none;
}
.tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}
.tab:hover:not(.active) {
  color: var(--text);
}

/* PARAMS */
.form-card, .params-section {
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 32px;
  margin-bottom: 16px;
}
.form-card h2, .params-section h2 {
  font-size: 18px;
  margin-bottom: 4px;
}
.form-card .sub, .params-section .sub {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 20px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-grid .full {
  grid-column: 1 / -1;
}
@media (max-width: 600px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.btn-row {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: white;
  padding: 12px 20px;
  border-radius: 4px;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s;
  z-index: 1000;
  max-width: 400px;
}
.toast.show {
  transform: translateY(0);
  opacity: 1;
}
.toast.success {
  background: var(--green);
}
.toast.error {
  background: var(--red);
}

/* LOADER */
.loader {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.loader-page {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  color: var(--muted);
}
.loader-page .loader {
  width: 32px;
  height: 32px;
  border-width: 3px;
  color: var(--blue);
}

/* FOOTER */
footer.app {
  background: white;
  border-top: 1px solid var(--border);
  padding: 16px 32px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: 32px;
}

.hidden {
  display: none !important;
}

/* Setup banner (1er login, profil incomplet) */
.setup-banner {
  background: var(--orange-soft);
  border-left: 4px solid var(--orange);
  padding: 16px 20px;
  border-radius: 4px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.setup-banner .info {
  flex: 1;
}
.setup-banner h3 {
  font-family: 'Public Sans';
  font-size: 14px;
  margin-bottom: 4px;
  color: var(--orange);
}
.setup-banner p {
  font-size: 13px;
  color: var(--text-soft);
  margin: 0;
}
.setup-banner .btn-create {
  background: var(--orange);
  flex-shrink: 0;
}
.setup-banner .btn-create:hover {
  background: #8B3300;
}
