/* ============================================
   Inside Web — Briefing Tool
   Style principal
   ============================================ */

:root {
  --green:  #00deb5;
  --blue:   #2f3653;
  --bg:     #fbf6f3;
  --white:  #ffffff;
  --black:  #000000;
  --gray:   #888;
  --border: rgba(47,54,83,.12);
  --shadow: 0 2px 12px rgba(47,54,83,.08);
  --radius: 10px;
  --font:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--blue);
  min-height: 100vh;
  line-height: 1.6;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--blue); text-decoration: none; transition: color .2s; }
a:hover { color: var(--green); }

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── LOGIN ─── */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--blue);
  padding: 20px;
}

.login-card {
  background: var(--white);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo img { filter: none; }
.login-logo p { font-size: 12px; color: var(--gray); margin-top: 8px; letter-spacing: 1px; text-transform: uppercase; }

.login-card h2 { font-size: 16px; font-weight: 600; margin-bottom: 20px; color: var(--blue); }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--gray); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .5px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="tel"],
select,
textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--blue);
  background: var(--white);
  transition: border-color .2s, box-shadow .2s;
  outline: none;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(0,222,181,.12);
}

textarea { resize: vertical; min-height: 80px; line-height: 1.6; }

.error-inline { font-size: 12px; color: #e53e3e; margin-top: 8px; display: none; }
.error-inline.show { display: block; }

/* ─── BOUTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .2s;
  white-space: nowrap;
}

.btn-primary { background: var(--blue); color: var(--white); }
.btn-primary:hover { background: #3d4668; }

.btn-green { background: var(--green); color: var(--blue); }
.btn-green:hover { opacity: .85; }

.btn-ghost { background: transparent; color: var(--blue); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }

.btn-danger { background: transparent; color: #e53e3e; border: 1.5px solid rgba(229,62,62,.3); }
.btn-danger:hover { background: rgba(229,62,62,.06); }

.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* Spinner dans bouton */
.btn .spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── LAYOUT APP ─── */
#app { display: none; min-height: 100vh; flex-direction: column; }

/* Topbar */
.topbar {
  background: var(--blue);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 3px solid var(--green);
}

.topbar-logo { display: flex; align-items: center; gap: 12px; }
.topbar-logo small { font-size: 10px; color: rgba(255,255,255,.4); font-weight: 400; letter-spacing: 1px; text-transform: uppercase; }

.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-user { font-size: 12px; color: rgba(255,255,255,.5); }
.btn-logout { background: transparent; border: 1px solid rgba(255,255,255,.2); color: rgba(255,255,255,.7); padding: 6px 14px; border-radius: 6px; font-size: 12px; cursor: pointer; transition: all .2s; font-family: var(--font); }
.btn-logout:hover { border-color: var(--green); color: var(--green); }

/* Main layout */
.app-body { display: flex; flex: 1; }

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--white);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  flex-shrink: 0;
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 24px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--gray);
  border-left: 3px solid transparent;
  transition: all .2s;
}

.sidebar-nav a:hover, .sidebar-nav a.active {
  color: var(--blue);
  background: var(--bg);
  border-left-color: var(--green);
}

.sidebar-nav a svg { flex-shrink: 0; }
.sidebar-divider { height: 1px; background: var(--border); margin: 12px 24px; }
.sidebar-label { font-size: 10px; font-weight: 600; color: var(--gray); letter-spacing: 1px; text-transform: uppercase; padding: 8px 24px 4px; }

/* Main content */
.main-content { flex: 1; padding: 32px; min-width: 0; }

/* ─── DASHBOARD ─── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h1 { font-size: 22px; font-weight: 700; }
.page-header p { font-size: 13px; color: var(--gray); margin-top: 3px; }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px 20px;
  border: 1px solid var(--border);
}

.stat-card .stat-val { font-size: 28px; font-weight: 700; color: var(--blue); line-height: 1; }
.stat-card .stat-label { font-size: 11px; color: var(--gray); margin-top: 4px; font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
.stat-card.accent { border-left: 3px solid var(--green); }

/* Toolbar */
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.search-wrap { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--gray); pointer-events: none; }
.search-wrap input { padding-left: 38px; }

.filter-select { min-width: 140px; }

/* Table */
.table-wrap {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.briefs-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.briefs-table th {
  background: var(--bg);
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.briefs-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--blue);
  vertical-align: middle;
}

.briefs-table tr:last-child td { border-bottom: none; }
.briefs-table tbody tr { transition: background .15s; }
.briefs-table tbody tr:hover { background: var(--bg); }

.td-projet { font-weight: 600; }
.td-client { color: var(--gray); font-size: 12.5px; }
.td-date { color: var(--gray); font-size: 12px; white-space: nowrap; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-brouillon { background: rgba(47,54,83,.08); color: var(--blue); }
.badge-genere    { background: rgba(0,222,181,.15); color: #008a70; }
.badge-archive   { background: rgba(0,0,0,.06); color: var(--gray); }

.actions-cell { display: flex; gap: 6px; align-items: center; }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; color: var(--gray); }
.empty-state svg { margin: 0 auto 16px; opacity: .3; }
.empty-state h3 { font-size: 16px; color: var(--blue); margin-bottom: 6px; }
.empty-state p { font-size: 13px; }

/* Pagination */
.pagination { display: flex; gap: 6px; align-items: center; justify-content: flex-end; margin-top: 16px; }
.pagination button { width: 34px; height: 34px; border-radius: 6px; border: 1px solid var(--border); background: var(--white); color: var(--blue); font-size: 13px; cursor: pointer; transition: all .2s; font-family: var(--font); }
.pagination button:hover { border-color: var(--green); color: var(--green); }
.pagination button.active { background: var(--blue); color: var(--white); border-color: var(--blue); }
.pagination button:disabled { opacity: .3; cursor: not-allowed; }
.pagination-info { font-size: 12px; color: var(--gray); margin-right: auto; }

/* ─── FORMULAIRE BRIEF ─── */
.form-page { max-width: 820px; }

.form-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--gray);
  padding: 0 0 8px;
  border-bottom: 1px solid var(--border);
  margin: 28px 0 16px;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field label { font-size: 12px; font-weight: 600; color: var(--gray); text-transform: uppercase; letter-spacing: .4px; }

/* Repeaters */
.repeater {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.repeater-head {
  display: grid;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.repeater-head span {
  font-size: 10px;
  font-weight: 600;
  color: var(--gray);
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 7px 12px;
}

.repeater-row {
  display: grid;
  border-bottom: 1px solid var(--border);
  align-items: stretch;
}

.repeater-row:last-child { border-bottom: none; }

.repeater-row input[type="text"],
.repeater-row input[type="password"],
.repeater-row select {
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
  width: 100%;
}

.repeater-row input:focus,
.repeater-row select:focus { background: var(--bg); }

.repeater-cell { border-right: 1px solid var(--border); display: flex; align-items: center; }
.repeater-cell:last-child { border-right: none; }
.repeater-del { width: 40px; flex-shrink: 0; justify-content: center; }

.del-btn { background: none; border: none; cursor: pointer; color: var(--gray); font-size: 15px; padding: 4px 8px; transition: color .2s; }
.del-btn:hover { color: #e53e3e; }

.repeater-footer { padding: 8px 12px; background: var(--bg); display: flex; gap: 8px; }
.add-btn { background: transparent; border: 1px solid var(--border); border-radius: 6px; padding: 5px 12px; font-size: 12px; cursor: pointer; font-family: var(--font); color: var(--gray); transition: all .2s; }
.add-btn:hover { background: var(--white); color: var(--blue); border-color: var(--blue); }

.level-indicator { width: 14px; height: 14px; border-left: 2px solid var(--border); border-bottom: 2px solid var(--border); display: inline-block; margin: 0 4px 0 8px; flex-shrink: 0; }

.repeater-notice { font-size: 11px; color: var(--gray); padding: 6px 12px; background: var(--bg); border-top: 1px solid var(--border); line-height: 1.5; }

.toggle-vis { background: none; border: none; cursor: pointer; color: var(--gray); font-size: 11px; padding: 2px 6px; font-family: var(--font); white-space: nowrap; }
.toggle-vis:hover { color: var(--blue); }

/* Form actions */
.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

/* ─── BRIEF OUTPUT ─── */
.brief-output {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-top: 24px;
  display: none;
}

.brief-output-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.brief-output-header h3 { font-size: 14px; font-weight: 600; }
.brief-output-actions { display: flex; gap: 8px; }

.brief-text { font-family: 'Courier New', monospace; font-size: 12.5px; line-height: 1.75; white-space: pre-wrap; color: var(--blue); max-height: 500px; overflow-y: auto; padding-right: 4px; }

/* ─── TOAST ─── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }

.toast {
  background: var(--blue);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: slideIn .25s ease-out;
  border-left: 3px solid var(--green);
  max-width: 320px;
}

.toast.error { border-left-color: #e53e3e; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  display: none;
}

.modal-overlay.show { display: flex; }

.modal {
  background: var(--white);
  border-radius: 14px;
  padding: 32px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.modal h3 { font-size: 17px; margin-bottom: 10px; }
.modal p { font-size: 13.5px; color: var(--gray); margin-bottom: 24px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ─── RESPONSIVE ─── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { padding: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: 1; }
  .topbar { padding: 0 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .briefs-table th:nth-child(3),
  .briefs-table td:nth-child(3),
  .briefs-table th:nth-child(4),
  .briefs-table td:nth-child(4) { display: none; }
}
