/* ============================================================
   style.css — Styles globaux BacTracker Maroc
   Variables de design, reset, typographie, layout de base,
   navbar, footer, et règles responsive mobile-first.
   ============================================================ */

/* --- Variables de design (charte couleurs du cahier des charges) --- */
:root {
  --color-primary: #40a8cc;
  --color-primary-dark: #2f88a8;
  --color-primary-light: #e7f5fa;
  --color-gray: #606060;
  --color-gray-light: #f4f4f4;
  --color-white: #ffffff;
  --color-text: #000000;
  --color-border: #e2e2e2;

  /* Couleurs de statut */
  --color-success: #2e9e5b;
  --color-warning: #e0a722;
  --color-danger: #d9534f;
  --color-info: #40a8cc;

  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);

  --font-base: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;

  --container-max: 1200px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-base);
  color: var(--color-text);
  background: var(--color-gray-light);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  text-decoration: none;
  color: inherit;
}

ul {
  list-style: none;
}

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

button {
  font-family: inherit;
  cursor: pointer;
}

input,
select,
textarea {
  font-family: inherit;
  font-size: 1rem;
}

/* --- Layout conteneur --- */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 20px;
}

.page-wrapper {
  min-height: calc(100vh - 70px);
  padding: 32px 0 64px;
}

/* --- Navbar --- */
.navbar {
  background: var(--color-white);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 70px;
}

.navbar__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--color-primary-dark);
}

.navbar__logo .logo-badge {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: var(--color-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
}

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

.navbar__link {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  color: var(--color-gray);
  font-size: 0.95rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.navbar__link:hover,
.navbar__link.active {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.navbar__link--admin {
  color: var(--color-danger);
}

.navbar__link--profile {
  display: none;
}

@media (max-width: 768px) {
  .navbar__link--profile {
    display: block;
  }
}

.navbar__toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.6rem;
  color: var(--color-gray);
}

.navbar__user {
  display: flex;
  align-items: center;
  gap: 14px;
}

.navbar__user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-primary-dark);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.navbar__user-name:hover {
  text-decoration: underline;
}

/* --- Cloche de notifications --- */
.notif-bell-wrapper {
  position: relative;
}

.notif-bell {
  position: relative;
  background: none;
  border: none;
  font-size: 1.25rem;
  padding: 6px;
  border-radius: 50%;
  line-height: 1;
  transition: background 0.15s ease;
}

.notif-bell:hover {
  background: var(--color-gray-light);
}

.notif-badge {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--color-danger);
  color: var(--color-white);
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
}

.notif-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 320px;
  max-width: 90vw;
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 150;
}

.notif-panel__header {
  padding: 14px 18px;
  font-weight: 700;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--color-border);
}

.notif-panel__body {
  max-height: 360px;
  overflow-y: auto;
}

.notif-empty {
  text-align: center;
  padding: 24px 18px;
}

.notif-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--color-border);
  transition: background 0.15s ease;
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-item:hover {
  background: var(--color-gray-light);
}

.notif-item__content {
  flex: 1;
  min-width: 0;
}

.notif-item__content strong {
  display: block;
  font-size: 0.86rem;
  overflow-wrap: break-word;
}

.notif-item__diff {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--color-gray);
  flex-shrink: 0;
  white-space: nowrap;
}

.notif-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.notif-dot--urgent {
  background: var(--color-danger);
}

.notif-dot--soon {
  background: var(--color-warning);
}

.notif-dot--ok {
  background: var(--color-success);
}

/* --- Boutons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.95rem;
  transition: transform 0.1s ease, box-shadow 0.15s ease, opacity 0.15s ease;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-white);
}

.btn-primary:hover {
  background: var(--color-primary-dark);
  box-shadow: var(--shadow-sm);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--color-primary);
  color: var(--color-primary-dark);
}

.btn-outline:hover {
  background: var(--color-primary-light);
}

.btn-secondary {
  background: var(--color-gray-light);
  color: var(--color-gray);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  background: #e9e9e9;
}

.btn-danger {
  background: var(--color-danger);
  color: var(--color-white);
}

.btn-success {
  background: var(--color-success);
  color: var(--color-white);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* --- Formulaires --- */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--color-gray);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  background: var(--color-white);
  transition: border-color 0.15s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

.form-textarea {
  resize: vertical;
  min-height: 90px;
}

.form-error {
  color: var(--color-danger);
  font-size: 0.85rem;
  margin-top: 6px;
  display: none;
}

.form-error.visible {
  display: block;
}

/* --- Cartes génériques --- */
.card {
  background: var(--color-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}

.auth-card {
  max-width: 420px;
  margin: 60px auto;
}

/* --- Section titres --- */
.section-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 18px;
  color: var(--color-text);
}

.section-subtitle {
  color: var(--color-gray);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

/* --- Footer --- */
.footer {
  background: var(--color-white);
  border-top: 1px solid var(--color-border);
  padding: 24px 0;
  text-align: center;
  color: var(--color-gray);
  font-size: 0.85rem;
}

/* --- Spinner de chargement --- */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 40px auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-state {
  text-align: center;
  color: var(--color-gray);
  padding: 40px 0;
}

.empty-state {
  text-align: center;
  color: var(--color-gray);
  padding: 50px 20px;
}

.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
}

/* --- Toast notifications --- */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--color-text);
  color: var(--color-white);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.2s ease;
  max-width: 320px;
}

.toast--success {
  background: var(--color-success);
}

.toast--error {
  background: var(--color-danger);
}

.toast--info {
  background: var(--color-primary-dark);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Utilitaires --- */
.text-center {
  text-align: center;
}
.mt-8 {
  margin-top: 8px;
}
.mt-16 {
  margin-top: 16px;
}
.mt-24 {
  margin-top: 24px;
}
.mb-16 {
  margin-bottom: 16px;
}
.flex {
  display: flex;
}
.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.flex-wrap {
  flex-wrap: wrap;
}
.gap-8 {
  gap: 8px;
}
.gap-12 {
  gap: 12px;
}
.hidden {
  display: none !important;
}
.text-muted {
  color: var(--color-gray);
}
.text-small {
  font-size: 0.85rem;
}

/* ============================================================
   Responsive — mobile-first, breakpoints principaux
   ============================================================ */

@media (max-width: 768px) {
  .navbar__links {
    position: absolute;
    top: 70px;
    left: 0;
    right: 0;
    background: var(--color-white);
    flex-direction: column;
    align-items: stretch;
    padding: 10px 20px 18px;
    box-shadow: var(--shadow-md);
    gap: 4px;
    display: none;
  }

  .navbar__links.open {
    display: flex;
  }

  .navbar__link {
    width: 100%;
    padding: 12px 14px;
  }

  .navbar__toggle {
    display: block;
  }

  .navbar__user-name {
    display: none;
  }

  .navbar__user {
    gap: 8px;
  }

  .notif-panel {
    right: -40px;
    width: 290px;
  }

  .section-title {
    font-size: 1.2rem;
  }
}
