/*
==================================================
File: public/CSS/components.css
Reusable UI components – OTS
==================================================
*/

/* =================================================
   PANELS / CARDS
   ================================================= */

.panel {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-card);
  padding: var(--space-lg);
}

/* =================================================
   CARD (UI)
   ================================================= */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
}

/* =================================================
   SEPARATOR
   ================================================= */

.separator {
  height: 1px;
  background: linear-gradient(
    to right,
    transparent,
    var(--border-color),
    transparent
  );
  margin: 18px 0;
}

/* =================================================
   ACTIONS
   ================================================= */

.actions {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.actions a,
.actions button {
  background-color: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.actions a:hover,
.actions button:hover {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* =================================================
   TABLES (GÉNÉRIQUES)
   ================================================= */

.table-wrapper {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table thead {
  background: var(--bg-card-alt);
}

.table th {
  text-align: left;
  padding: 14px 16px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.table td {
  padding: 14px 16px;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
}

.table tbody tr:hover {
  background: color-mix(in srgb, var(--primary) 6%, transparent);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* =================================================
   TABLE ACTION
   ================================================= */

.table-action {
  padding: 6px 14px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.table-action:hover {
  background: var(--primary);
  color: #ffffff;
}

/* =================================================
   EMPTY STATE
   ================================================= */

.empty-state {
  padding: 48px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}

/* =================================================
   ROLES / AVATARS HALO
   ================================================= */

/* Halo animations */
@keyframes haloPulseSoft {
  0%   { box-shadow: 0 0 12px rgba(var(--halo), 0.4); }
  50%  { box-shadow: 0 0 28px rgba(var(--halo), 0.9); }
  100% { box-shadow: 0 0 12px rgba(var(--halo), 0.4); }
}

@keyframes haloPulseStrong {
  0%   { box-shadow: 0 0 18px rgba(var(--halo), 0.5); }
  50%  { box-shadow: 0 0 45px rgba(var(--halo), 1); }
  100% { box-shadow: 0 0 18px rgba(var(--halo), 0.5); }
}

/* SuperAdmin */
.avatar.role-superadmin {
  --halo: 255, 0, 204;
  background: linear-gradient(135deg, #ff00cc, #ff66e6);
  animation: haloPulseStrong 2.8s ease-in-out infinite;
}

.profile-role.role-superadmin {
  color: #ff00cc;
}

/* Admin */
.avatar.role-admin {
  --halo: 255, 26, 26;
  background: linear-gradient(135deg, #ff1a1a, #ff4d4d);
  animation: haloPulseSoft 2.2s ease-in-out infinite;
}

.profile-role.role-admin {
  color: #ff1a1a;
}

/* Moderator */
.avatar.role-moderator {
  --halo: 34, 197, 94;
  background: linear-gradient(135deg, #22c55e, #4ade80);
  animation: haloPulseSoft 3.2s ease-in-out infinite;
}

.profile-role.role-moderator {
  color: #22c55e;
}

/* Player */
.avatar.role-player {
  --halo: 30, 144, 255;
  background: linear-gradient(135deg, #1e90ff, #3fa9f5);
  animation: haloPulseSoft 4s ease-in-out infinite;
}

.profile-role.role-player {
  color: #1e90ff;
}

/* Texte glow */
@keyframes roleGlowPremium {
  0%   { text-shadow: 0 0 0 transparent; opacity: 0.85; }
  50%  { text-shadow: 0 0 10px currentColor; opacity: 1; }
  100% { text-shadow: 0 0 0 transparent; opacity: 0.85; }
}

.profile-role {
  animation: roleGlowPremium 3.8s ease-in-out infinite;
}

/* =================================================
   PROFILE / INFO LIST
   ================================================= */

.info-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.info-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--border-color);
}

.info-list li:last-child {
  border-bottom: none;
}

.info-list span {
  color: var(--text-muted);
}

/* =================================================
   PROFILE CARD (SPECIALIZED PANEL)
   ================================================= */

.profile-card {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow:
    0 30px 60px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

.profile-card h2 {
  font-size: 16px;
  margin-bottom: 16px;
  color: var(--text-main);
}

/* =================================================
   PROFILE ACTIONS
   ================================================= */

.profile-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

/* =================================================
   SIDEBAR THEME SWITCH
   ================================================= */

.sidebar-theme {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 12px;
}

.sidebar-theme button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  transition: color 0.15s ease, border-color 0.15s ease;
}

.sidebar-theme button:hover,
.sidebar-theme button.active {
  color: var(--primary);
  border-color: var(--primary);
}

/* =================================================
   AUTH / LOGIN COMPONENTS
   ================================================= */

/* Card auth */
.auth-card {
  max-width: 420px;
  margin: auto;
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  box-shadow: var(--shadow-card);
  text-align: center;
  border: 1px solid var(--border-color);
}

/* Icon */
.auth-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 28px;
  box-shadow: 0 8px 20px rgba(59, 130, 246, 0.35);
}

/* Error message */
.auth-error {
  background-color: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

/* Input with icon */
.input-group {
  position: relative;
  margin-bottom: 16px;
}

.input-group i {
  position: absolute;
  top: 50%;
  left: 14px;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}

.input-group input {
  width: 100%;
  padding: 12px 14px 12px 40px;
}

.input-group input:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Options (checkbox / links) */
.auth-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  margin-bottom: 20px;
  color: var(--text-muted);
}

.auth-options label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.auth-options input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
}

.auth-options a {
  color: var(--primary);
}

.auth-options a:hover {
  text-decoration: underline;
}

/* Button full width */
.btn-block {
  width: 100%;
  padding: 14px;
  font-size: 15px;
  font-weight: 500;
}

/* ================================================== */
/* LOADING SPINNER                                    */
/* ================================================== */

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

.ots-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: ots-spin 0.65s linear infinite;
  flex-shrink: 0;
}

.ots-spinner--lg {
  width: 28px;
  height: 28px;
  border-width: 3px;
}

.ots-loading-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px;
  color: var(--text-muted);
  font-size: var(--font-base);
}

/* ================================================== */
/* EMPTY STATE                                        */
/* ================================================== */

.ots-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  gap: 8px;
}

.ots-empty-icon {
  font-size: 36px;
  line-height: 1;
  opacity: 0.35;
  margin-bottom: 4px;
}

.ots-empty-title {
  font-size: var(--font-base);
  font-weight: 600;
  color: var(--text-muted);
}

.ots-empty-sub {
  font-size: var(--font-sm);
  color: var(--text-muted);
  opacity: 0.75;
  max-width: 320px;
}

/* ================================================== */
/* STAT CARDS GRID (réutilisable)                     */
/* ================================================== */

.ots-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.ots-kpi-card {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ots-kpi-card:hover {
  border-color: color-mix(in srgb, var(--primary) 40%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 6%, transparent);
}

.ots-kpi-label {
  font-size: var(--font-xs);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  font-weight: 600;
}

.ots-kpi-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
}

.ots-kpi-value span {
  font-size: var(--font-base);
  font-weight: 500;
  color: var(--text-muted);
}

.ots-kpi-sub {
  font-size: var(--font-sm);
  color: var(--text-muted);
  margin-top: 2px;
}

.ots-kpi-card--success { border-left: 3px solid var(--success); }
.ots-kpi-card--danger  { border-left: 3px solid var(--danger);  }
.ots-kpi-card--primary { border-left: 3px solid var(--primary); }
.ots-kpi-card--rep     { border-left: 3px solid #7c3aed; }

.ots-kpi-card--rep .ots-kpi-value { color: #7c3aed; }

/* ================================================== */
/* MODAL GÉNÉRIQUE                                    */
/* ================================================== */

@keyframes modalFadeIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

@keyframes overlayFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.ots-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  z-index: 9000;
  overflow-y: auto;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px 48px;
  animation: overlayFadeIn 0.2s ease;
}

.ots-modal-overlay[hidden],
.ots-modal-overlay.is-hidden {
  display: none;
}

.ots-modal {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.45),
    0 0 0 1px color-mix(in srgb, var(--primary) 8%, transparent);
  width: 100%;
  max-width: 520px;
  padding: 32px 28px;
  animation: modalFadeIn 0.22s ease;
}

.ots-modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 14px;
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.ots-modal-close:hover {
  background: var(--bg-card-alt);
  color: var(--text-main);
  border-color: var(--text-muted);
}

.ots-modal-header {
  text-align: center;
  margin-bottom: 24px;
}

.ots-modal-header-icon {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 10px;
}

.ots-modal-header h2 {
  font-size: var(--font-xl);
  font-weight: 700;
  margin-bottom: 6px;
}

.ots-modal-section {
  background: var(--bg-card-alt);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.ots-modal-section-label {
  font-size: var(--font-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 10px;
}

.ots-modal-footer {
  margin-top: 24px;
  display: flex;
  justify-content: center;
}

/* =================================================
   RECAP MODAL (post-trajet)
   ================================================= */

.recap-costs-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  font-size: var(--font-base);
}

.recap-costs-grid-total {
  font-weight: 700;
  border-top: 1px solid var(--border-color);
  padding-top: 8px;
  margin-top: 2px;
}

.recap-costs-amount {
  text-align: right;
  color: var(--danger);
}

.recap-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.recap-result-details {
  font-size: var(--font-base);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.recap-net {
  font-size: var(--font-3xl);
  font-weight: 800;
  text-align: right;
  line-height: 1;
  transition: color 0.15s ease;
}

.recap-net--positive { color: var(--success); }
.recap-net--negative { color: var(--danger);  }

.recap-rep-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.recap-rep-gain {
  font-size: var(--font-2xl);
  font-weight: 800;
  color: #7c3aed;
}

.recap-rep-total-label {
  font-size: var(--font-sm);
  color: var(--text-muted);
  text-align: right;
  margin-bottom: 2px;
}

.recap-rep-total-value {
  font-size: var(--font-lg);
  font-weight: 700;
  text-align: right;
}

.recap-balance-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-md);
  padding: 0 4px;
  margin-top: 2px;
}

.recap-balance-value {
  font-size: var(--font-lg);
  font-weight: 700;
}

/* ================================================== */
/* TOAST NOTIFICATIONS                                */
/* ================================================== */
/* BADGE SIDEBAR POP                                  */
/* ================================================== */

@keyframes ms-badge-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.55); }
  70%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}

.ms-badge-pop {
  animation: ms-badge-pop 0.42s cubic-bezier(.36,.07,.19,.97) forwards;
}

/* ================================================== */

#ots-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.ots-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  min-width: 260px;
  max-width: 380px;
  box-shadow: 0 4px 20px rgba(0,0,0,.18);
  pointer-events: all;
  opacity: 0;
  transform: translateX(32px);
  transition: opacity .32s ease, transform .32s ease;
}

.ots-toast--in  { opacity: 1; transform: translateX(0); }
.ots-toast--out { opacity: 0; transform: translateX(32px); }

.ots-toast span { flex: 1; }

.ots-toast-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 2px;
  opacity: .6;
  color: inherit;
  font-size: 13px;
}
.ots-toast-close:hover { opacity: 1; }

.ots-toast--success { background: rgba(46,213,115,.15); color: var(--success, #2ed573); border: 1px solid rgba(46,213,115,.35); }
.ots-toast--error   { background: rgba(239,68,68,.13);  color: var(--danger,  #ef4444); border: 1px solid rgba(239,68,68,.30); }
.ots-toast--info    { background: rgba(59,130,246,.12); color: var(--primary, #3b82f6); border: 1px solid rgba(59,130,246,.28); }
.ots-toast--warning { background: rgba(245,158,11,.12); color: var(--warning, #f59e0b); border: 1px solid rgba(245,158,11,.28); }

/* ================================================== */
/* MODAL CONFIRM                                       */
/* ================================================== */

.ots-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.50);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 220ms ease;
}

.ots-modal-overlay--in  { opacity: 1; }
.ots-modal-overlay--out { opacity: 0; }

.ots-modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.40), 0 8px 24px rgba(0, 0, 0, 0.20);
  padding: 36px 32px 28px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  transform: scale(0.88) translateY(16px);
  opacity: 0;
  transition: transform 260ms cubic-bezier(.34, 1.52, .64, 1), opacity 220ms ease;
}

.ots-modal-overlay--in .ots-modal {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.ots-modal-overlay--out .ots-modal {
  transform: scale(0.94) translateY(8px);
  opacity: 0;
  transition: transform 180ms ease, opacity 180ms ease;
}

.ots-modal-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  font-size: 24px;
  margin-bottom: 18px;
}

.ots-modal-icon--danger  { background: rgba(255, 77,  79,  .14); color: var(--danger,  #ff4d4f); }
.ots-modal-icon--success { background: rgba(46,  213, 115, .14); color: var(--success, #2ed573); }
.ots-modal-icon--warning { background: rgba(255, 165, 2,   .14); color: var(--warning, #ffa502); }
.ots-modal-icon--info    { background: rgba(70,  128, 255, .14); color: var(--primary, #4680ff); }

.ots-modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 8px;
}

.ots-modal-msg {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0 0 28px;
}

.ots-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.ots-modal-actions .btn {
  min-width: 112px;
  border-radius: var(--radius-md);
}

.ots-modal-btn--danger  { background: var(--danger,  #ff4d4f); color: #fff !important; border: none; }
.ots-modal-btn--success { background: var(--success, #2ed573); color: #fff !important; border: none; }
.ots-modal-btn--warning { background: var(--warning, #ffa502); color: #fff !important; border: none; }
.ots-modal-btn--info    { background: var(--primary, #4680ff); color: #fff !important; border: none; }

.ots-modal-btn--danger:hover  { background: #e03e40; }
.ots-modal-btn--success:hover { background: #20c05a; }
.ots-modal-btn--warning:hover { background: #e09200; }
.ots-modal-btn--info:hover    { background: var(--primary-hover, #2f6fed); }

/* ================================================== */
/* FEEDBACK INLINE (formulaires async)                */
/* ================================================== */

.ots-feedback {
  display: none;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 6px;
  margin-top: 8px;
}
.ots-feedback.visible   { display: block; }
.ots-feedback.success   { background: rgba(46,213,115,.12); color: var(--success, #2ed573); border: 1px solid rgba(46,213,115,.3); }
.ots-feedback.error     { background: rgba(239,68,68,.10);  color: var(--danger, #ef4444);  border: 1px solid rgba(239,68,68,.25); }
.ots-feedback.info      { background: rgba(59,130,246,.10); color: var(--primary, #3b82f6); border: 1px solid rgba(59,130,246,.25); }

/* ================================================== */
/* FLASH SERVER-SIDE (query param success/error)      */
/* ================================================== */

.ots-flash {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 16px;
}
.ots-flash.success { background: rgba(46,213,115,.12); color: var(--success, #2ed573); border: 1px solid rgba(46,213,115,.3); }
.ots-flash.error   { background: rgba(239,68,68,.10);  color: var(--danger, #ef4444);  border: 1px solid rgba(239,68,68,.25); }
.ots-flash.info    { background: rgba(59,130,246,.10); color: var(--primary, #3b82f6); border: 1px solid rgba(59,130,246,.25); }
