/* ============================================================
   Self Manager - Feuille de style principale
   ============================================================ */

/* --- Variables --- */
:root {
  --blue:      #1565C0;
  --blue-dark: #0D47A1;
  --blue-light:#1976D2;
  --orange:    #F57C00;
  --orange-l:  #FF9800;
  --orange-d:  #E65100;
  --green:     #2E7D32;
  --green-l:   #4CAF50;
  --red:       #C62828;
  --red-l:     #EF5350;
  --grey:      #607D8B;
  --grey-l:    #ECEFF1;
  --grey-d:    #37474F;
  --white:     #FFFFFF;
  --bg:        #F0F4F8;
  --card-bg:   #FFFFFF;
  --text:      #212121;
  --text-muted:#757575;
  --shadow:    0 2px 8px rgba(0,0,0,.12);
  --shadow-lg: 0 4px 20px rgba(0,0,0,.18);
  --radius:    8px;
  --font:      'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

html { font-size: 16px; }

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

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

/* --- Layout admin --- */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: var(--blue-dark);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .3s;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-logo h1 {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
}

.sidebar-logo .subtitle {
  font-size: .75rem;
  opacity: .7;
  margin-top: 2px;
}

.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; }

.nav-section {
  padding: 8px 16px 4px;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .5;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: rgba(255,255,255,.85);
  cursor: pointer;
  transition: background .15s;
  font-size: .9rem;
  border-radius: 0;
}

.nav-item:hover, .nav-item.active {
  background: rgba(255,255,255,.12);
  color: var(--white);
}

.nav-item .icon { font-size: 1.1rem; width: 20px; text-align: center; }

.sidebar-bottom {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: .8rem;
  opacity: .6;
}

.main-content {
  margin-left: 220px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--white);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h2 { font-size: 1.1rem; font-weight: 600; flex: 1; }

.page-content { padding: 24px; flex: 1; }

/* --- Cards --- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--blue-dark);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--blue);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active:not(:disabled) { transform: translateY(0); }

.btn-primary   { background: var(--blue);    color: var(--white); }
.btn-secondary { background: var(--grey-l);  color: var(--grey-d); }
.btn-orange    { background: var(--orange);  color: var(--white); }
.btn-green     { background: var(--green);   color: var(--white); }
.btn-red       { background: var(--red);     color: var(--white); }
.btn-sm        { padding: 5px 10px; font-size: .8rem; }
.btn-lg        { padding: 12px 24px; font-size: 1rem; }
.btn-icon      { padding: 6px 10px; }

/* --- Forms --- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: 6px; }

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #CBD5E0;
  border-radius: 6px;
  font-size: .9rem;
  font-family: inherit;
  transition: border-color .15s;
  background: var(--white);
}
.form-control:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(21,101,192,.15); }

.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

/* --- Tables --- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th {
  background: var(--blue-dark);
  color: var(--white);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: .8rem;
}
td { padding: 10px 14px; border-bottom: 1px solid var(--grey-l); }
tr:hover td { background: #F5F7FA; }
tr:last-child td { border-bottom: none; }

/* --- Badges de statut --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.badge-attente  { background: #E3F2FD; color: var(--blue); }
.badge-appele   { background: #FFF3E0; color: var(--orange-d); animation: pulse 1.5s infinite; }
.badge-passe    { background: #E8F5E9; color: var(--green); }
.badge-absent   { background: #FFEBEE; color: var(--red); }
.badge-urgence  { background: var(--orange); color: var(--white); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .7; }
}

/* --- Drag and drop --- */
.sortable-list { list-style: none; }

.sortable-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--white);
  border: 1px solid #E2E8F0;
  border-radius: 6px;
  margin-bottom: 6px;
  cursor: grab;
  transition: all .15s;
  user-select: none;
}

.sortable-item:hover { border-color: var(--blue-light); box-shadow: var(--shadow); }
.sortable-item.dragging { opacity: .4; }
.sortable-item.drag-over { border-color: var(--orange); background: #FFF8F0; }

.drag-handle {
  color: var(--grey);
  font-size: 1.1rem;
  cursor: grab;
  padding: 0 4px;
}

.item-nom { font-weight: 600; font-size: 1rem; min-width: 50px; }
.item-fenetre { font-size: .8rem; color: var(--text-muted); }
.item-ordre { color: var(--text-muted); font-size: .8rem; min-width: 24px; }
.item-actions { margin-left: auto; display: flex; gap: 6px; }

.badge-urgence-icon { font-size: .9rem; }

/* --- Plan du jour - classes dans la liste d'appel --- */
.call-list { list-style: none; }

.call-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 8px;
  border-left: 4px solid transparent;
  background: var(--white);
  box-shadow: var(--shadow);
  transition: all .2s;
}

.call-item.status-attente  { border-left-color: var(--blue-light); }
.call-item.status-appele   { border-left-color: var(--orange); background: #FFFDE7; }
.call-item.status-passe    { border-left-color: var(--green); opacity: .65; }
.call-item.status-absent   { border-left-color: var(--red); opacity: .55; text-decoration: line-through; }
.call-item.urgence         { border-left-color: var(--orange-d) !important; background: #FFF3E0 !important; }

.call-num  { font-size: .9rem; color: var(--text-muted); min-width: 28px; text-align: right; }
.call-nom  { font-size: 1.3rem; font-weight: 700; min-width: 60px; }
.call-time { font-size: .8rem; color: var(--text-muted); }
.call-actions { margin-left: auto; display: flex; gap: 6px; }

/* --- Alertes / toasts --- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
}

.toast {
  background: var(--grey-d);
  color: var(--white);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: .875rem;
  box-shadow: var(--shadow-lg);
  animation: slideIn .3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.success { background: var(--green); }
.toast.error   { background: var(--red);   }
.toast.warning { background: var(--orange); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* --- Modal --- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .2s ease;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 28px;
  width: 90%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: zoomIn .2s ease;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--blue-dark);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes zoomIn { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* --- Fenêtre horaire selector --- */
.fenetre-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .85rem;
}

.fenetre-selector select {
  padding: 4px 8px;
  border: 1px solid #CBD5E0;
  border-radius: 4px;
  font-size: .85rem;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .form-row { flex-direction: column; }
  .page-content { padding: 16px; }
}

/* --- Utilitaires --- */
.flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.ml-auto { margin-left: auto; }
.mb-16 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); font-size: .875rem; }
.text-right { text-align: right; }
.hidden { display: none !important; }
.w-full { width: 100%; }

/* --- Loader --- */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--grey-l);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 20px auto;
}

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

.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.7);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.loading-overlay.hidden { display: none; }

/* --- Bandeau semaine --- */
.week-banner {
  background: linear-gradient(135deg, var(--blue), var(--blue-light));
  color: var(--white);
  padding: 12px 20px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.week-banner .semaine-label {
  font-size: 1.1rem;
  font-weight: 700;
}

.week-banner .week-date { font-size: .85rem; opacity: .85; }

/* --- v1.1 additions --- */
.item-creneau { font-size: .78rem; padding: 2px 8px; }
.item-urgence { border-left: 3px solid var(--orange) !important; background: #FFF8F0 !important; }
.badge-creneau { background: #E3F2FD; color: var(--blue-dark); }

/* Couleurs dynamiques appliquées via inject_css.php */

/* ====================================================
   v1.1 — Ajouts
   ==================================================== */

/* Créneau badge dans les listes */
.item-creneau {
  background: #E3F2FD;
  color: var(--blue-dark);
  font-size: .74rem;
  padding: 2px 8px;
  border-radius: 100px;
  font-weight: 600;
  white-space: nowrap;
}

/* Ligne urgente dans le plan */
.sortable-item.item-urgence {
  border-left: 3px solid var(--orange) !important;
  background: #FFF8F0 !important;
}

/* Drag & drop amélioration visuelle */
.sortable-item.dragging {
  opacity: .5;
  background: var(--grey-l) !important;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
}
.sortable-item.drag-over {
  border-top: 2px solid var(--blue);
}

/* Color picker dans paramètres */
input[type="color"] {
  cursor: pointer;
  padding: 2px;
}

/* Variantes tabs dans modèles */
#variantes-bar {
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

/* Listes sortable dans paramètres */
#creneaux-list .sortable-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: white;
  border: 1px solid #eee;
  border-radius: 6px;
  margin-bottom: 4px;
  cursor: default;
}
