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

:root {
  --orange: #ff7900;
  --orange-dark: #e56a00;
  --bg: #f4f4f6;
  --card: #ffffff;
  --text: #1a1a1a;
  --text-muted: #666;
  --border: #d0d0d6;
  --ok: #1a6433;
  --ok-bg: #e6ffec;
  --err: #a82424;
  --err-bg: #ffe6e6;
  --warn: #8a5500;
  --warn-bg: #fff4d6;
  --radius: 6px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

html, body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

html { scroll-behavior: smooth; }

a { color: var(--orange-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout */
.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* Layout 2-colonnes : sidebar + main */
.layout {
  display: grid;
  grid-template-columns: 230px 1fr;
  gap: 1.5rem;
  max-width: 1240px;
  margin: 0 auto;
  padding: 1.25rem 1rem;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 1rem;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.75rem 0.5rem;
  align-self: start;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}
.sidebar nav ul {
  list-style: none;
  margin: 0 0 0.5rem 0;
  padding: 0;
}
.sidebar-cat {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0.6rem 0.75rem 0.25rem;
  margin: 0;
}
.sidebar-link {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.88rem;
  border-left: 3px solid transparent;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.sidebar-link:hover {
  background: #f4f4f6;
  text-decoration: none;
}
.sidebar-link.active {
  background: rgba(255, 121, 0, 0.08);
  border-left-color: var(--orange);
  color: var(--orange-dark);
  font-weight: 600;
}

.content {
  min-width: 0;
}
.content > .section {
  scroll-margin-top: 1.25rem;
}

/* Mobile : sidebar masquable */
.sidebar-toggle {
  display: none;
  background: none;
  border: 0;
  font-size: 1.5rem;
  cursor: pointer;
  margin-right: 0.75rem;
  color: var(--text);
}

@media (max-width: 820px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 0.75rem;
  }
  .sidebar-toggle {
    display: inline-block;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: -100%;
    width: 260px;
    height: 100vh;
    max-height: none;
    z-index: 50;
    transition: left 0.2s ease-out;
    border-radius: 0;
    padding-top: 1.5rem;
  }
  .sidebar.open {
    left: 0;
    box-shadow: 4px 0 16px rgba(0,0,0,0.15);
  }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 40;
    display: none;
  }
  .sidebar-backdrop.open {
    display: block;
  }
}

.center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.card {
  background: var(--card);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 440px;
}

/* Header (dashboard) */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--card);
  border-bottom: 3px solid var(--orange);
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.app-header .brand {
  font-size: 1.1rem;
  font-weight: 700;
}
.app-header .brand .accent { color: var(--orange); }
.app-header .user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
}
.app-header .user .email { color: var(--text-muted); }

/* Typography */
h1 { font-size: 1.4rem; margin-bottom: 0.4rem; }
h2 { font-size: 1.1rem; margin-bottom: 0.75rem; font-weight: 600; }
.sub { color: var(--text-muted); font-size: 0.88rem; }

/* Forms */
form label {
  display: block;
  margin-top: 1rem;
  font-size: 0.85rem;
  font-weight: 600;
}
form input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  margin-top: 0.3rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  min-height: 48px;
}
form input:focus {
  outline: 2px solid var(--orange);
  outline-offset: -2px;
  border-color: transparent;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.55rem 1rem;
  border: 0;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  min-height: 40px;
}
.btn-primary {
  background: var(--orange);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--orange-dark); }
.btn-primary:disabled { background: #aaa; cursor: not-allowed; }
.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #eee; }
.btn-block { width: 100%; min-height: 48px; }

/* Messages */
.msg {
  margin-top: 1rem;
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
}
.msg.err { background: var(--err-bg); color: var(--err); border: 1px solid #f5c2c2; }
.msg.ok  { background: var(--ok-bg);  color: var(--ok);  border: 1px solid #b6e7c4; }
.msg.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #f0d68f; }

/* Hints */
.hint { font-size: 0.78rem; color: #888; margin-top: 0.3rem; }

/* Cards grid (dashboard sections) */
.section {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-top: 1.25rem;
}

/* Status pills */
.pill {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: middle;
}
.pill-ok    { background: var(--ok-bg);   color: var(--ok); }
.pill-err   { background: var(--err-bg);  color: var(--err); }
.pill-warn  { background: var(--warn-bg); color: var(--warn); }
.pill-muted { background: #eee;           color: #555; }

/* Filtres dropdown + toggle */
.filters {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
  font-size: 0.88rem;
}
.filters label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  font-weight: normal;
  cursor: pointer;
}
.filters select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  min-height: 36px;
  background: #fff;
  cursor: pointer;
}

/* Combobox searchable */
.combobox {
  position: relative;
  display: inline-block;
}
.combobox-input {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  min-height: 36px;
  min-width: 240px;
  background: #fff;
  cursor: text;
}
.combobox-input:focus {
  outline: 2px solid var(--orange);
  outline-offset: -1px;
  border-color: transparent;
}
.combobox-clear {
  position: absolute;
  right: 0.4rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.1rem;
  padding: 0 0.3rem;
  display: none;
}
.combobox.has-value .combobox-clear { display: block; }
.combobox-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  min-width: 100%;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 280px;
  overflow-y: auto;
  z-index: 100;
  list-style: none;
  padding: 0.2rem 0;
  margin: 0;
}
.combobox-option {
  padding: 0.5rem 0.7rem;
  cursor: pointer;
  font-size: 0.88rem;
  border-radius: 4px;
}
.combobox-option:hover,
.combobox-option[aria-selected="true"] {
  background: rgba(255, 121, 0, 0.1);
  color: var(--orange-dark);
}
.combobox-option.empty {
  color: var(--text-muted);
  font-style: italic;
  cursor: default;
}
.combobox-option.empty:hover { background: transparent; color: var(--text-muted); }
.filters input[type="checkbox"] {
  width: auto;
  min-height: auto;
  margin: 0;
}

/* Lists */
.list {
  list-style: none;
  display: grid;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.list .row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.85rem;
  background: #fafafb;
  border-radius: var(--radius);
  border: 1px solid #eee;
}
.list .row .label { font-weight: 500; }
.list .row .meta { color: var(--text-muted); font-size: 0.8rem; }

.empty {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.9rem;
  padding: 0.5rem 0;
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}
