/* ML_Suivi_Navire - Style Clair Moderne avec Micro-animations */
:root {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: #e0f2fe;
  
  --state-normal: #10b981;
  --state-normal-light: #d1fae5;
  --state-slow: #f59e0b;
  --state-slow-light: #fef3c7;
  --state-stop: #ef4444;
  --state-stop-light: #fee2e2;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.07);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Navbar */
.navbar {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
}

.nav-brand span.badge-beta {
  font-size: 0.75rem;
  background: var(--primary-light);
  color: var(--primary);
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  font-weight: 600;
}

.nav-links {
  display: flex;
  gap: 0.5rem;
  list-style: none;
}

.nav-links a {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.nav-links a:hover {
  color: var(--primary);
  background: var(--primary-light);
  transform: translateY(-1px);
}

.nav-links a.active {
  color: #ffffff;
  background: var(--primary);
  box-shadow: 0 2px 4px rgba(2, 132, 199, 0.25);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-badge {
  background: #f1f5f9;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.role-tag {
  background: var(--primary);
  color: #fff;
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
}

/* Layout */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  flex: 1;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.page-title h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #0f172a;
}

.page-title p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.25rem;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.kpi-card.normal::before { background: var(--state-normal); }
.kpi-card.slow::before { background: var(--state-slow); }
.kpi-card.stop::before { background: var(--state-stop); }
.kpi-card.info::before { background: var(--primary); }

.kpi-title {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.kpi-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 0.5rem;
}

/* Boat & Tanks Live Grid */
.boat-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}

.boat-card:hover {
  box-shadow: var(--shadow-md);
}

.boat-header {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.boat-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.tank-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  padding: 1.5rem;
}

.tank-card {
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  background: #ffffff;
  position: relative;
  transition: all 0.25s ease;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.tank-card.state-NORMAL {
  border-color: #a7f3d0;
  background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 100%);
}

.tank-card.state-SLOWDOWN {
  border-color: #fde68a;
  background: linear-gradient(180deg, #fffbeb 0%, #ffffff 100%);
}

.tank-card.state-STOP {
  border-color: #fecaca;
  background: linear-gradient(180deg, #fef2f2 0%, #ffffff 100%);
}

.tank-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.tank-number {
  font-weight: 700;
  font-size: 1.1rem;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.3rem 0.6rem;
  border-radius: 9999px;
  text-transform: uppercase;
}

.status-badge.NORMAL {
  background: var(--state-normal-light);
  color: #065f46;
}

.status-badge.SLOWDOWN {
  background: var(--state-slow-light);
  color: #92400e;
}

.status-badge.STOP {
  background: var(--state-stop-light);
  color: #991b1b;
}

/* Animations de pulsation pour état direct */
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.pulse-dot.NORMAL {
  background-color: var(--state-normal);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse-green 1.8s infinite;
}

.pulse-dot.SLOWDOWN {
  background-color: var(--state-slow);
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
  animation: pulse-orange 1.8s infinite;
}

.pulse-dot.STOP {
  background-color: var(--state-stop);
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  animation: pulse-red 1.8s infinite;
}

@keyframes pulse-green {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes pulse-orange {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

@keyframes pulse-red {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.tank-detail {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 0.5rem;
}

.tank-detail strong {
  color: var(--text-main);
}

.resp-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  background: #ede9fe;
  color: #5b21b6;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
}

/* Tables */
.table-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

thead th {
  background: #f8fafc;
  padding: 0.9rem 1.25rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

tbody tr:hover {
  background: #f8fafc;
}

/* Boutons & Formulaires */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #f1f5f9;
  color: var(--text-main);
}

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

.btn-danger {
  background: var(--state-stop);
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-success {
  background: var(--state-normal);
  color: #fff;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s ease;
  background: #fff;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* Modales */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 500px;
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
  transform: translateY(10px) scale(0.98);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-overlay.open .modal-box {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-muted);
}

/* Toast */
#toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 200;
}

.toast {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  padding: 0.85rem 1.25rem;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slide-in 0.25s ease-out;
}

.toast.success { border-left-color: var(--state-normal); }
.toast.error { border-left-color: var(--state-stop); }

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