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

:root {
  --primary-blue: #00bfff;
  --primary-yellow: #ffcc00;
  --primary-green: #00ff88;
  --primary-red: #ff4d4d;
  --dark-bg: #0a0e14;
  --card-bg: #12243d;
  --sidebar-bg: #0d1b2a;
  --text-light: #e4efff;
  --text-muted: #7a8ba0;
  --border-glow: rgba(0, 191, 255, 0.15);
}

body {
  font-family: 'Inter', 'Segoe UI', 'Roboto', sans-serif;
  background: #0a0e14;
  color: #e4efff;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  letter-spacing: 0.2px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}


/* === TRANSITIONS === */
button, a, input, select, .card, .sidebar nav ul li {
  transition: all 0.2s ease;
}

/* === ANIMATIONS === */
@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

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

/* LOGIN */
#loginBox {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #0a0e14;
  z-index: 9999;
}

.login-card {
  width: 380px;
  background: #12243d;
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  color: #fff;
  border: 1px solid rgba(0, 191, 255, 0.2);
  animation: slideIn 0.4s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.login-card h2 {
  color: var(--primary-yellow);
  margin-bottom: 20px;
  font-size: 28px;
  text-align: center;
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  letter-spacing: 1px;
  position: relative;
  z-index: 1;
}

.login-card label {
  font-size: 13px;
  color: #cbd6e6;
  display: block;
  margin-top: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
  position: relative;
  z-index: 1;
}

.login-card input {
  width: 100%;
  padding: 12px 16px;
  margin-top: 8px;
  border-radius: 10px;
  border: 1px solid rgba(0, 191, 255, 0.4);
  background: rgba(0, 0, 0, 0.3);
  color: #fff;
  font-size: 14px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 1;
}

.login-card input:focus {
  outline: none;
  border-color: #ffcc00;
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 12px rgba(0, 191, 255, 0.3), inset 0 0 8px rgba(0, 191, 255, 0.1);
}

.login-card button {
  width: 100%;
  padding: 14px;
  margin-top: 20px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #ffcc00 0%, #ffb700 100%);
  color: #081622;
  font-weight: 700;
  cursor: pointer;
  font-size: 16px;
  letter-spacing: 1px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 1;
  box-shadow: 0 4px 12px rgba(255, 204, 0, 0.3);
}

.login-card button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(255, 204, 0, 0.4);
}

.login-card button:active {
  transform: translateY(0);
}

#error-msg {
  margin-top: 15px;
  color: #ff6b6b;
  font-size: 14px;
  min-height: 18px;
  position: relative;
  z-index: 1;
}

/* DASHBOARD */
#dashboard {
  display: none;
  width: 100%;
  height: 100%;
}

/* Sidebar */
.sidebar {
  width: 230px;
  min-width: 230px;
  background: #0d1b2a;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100vh;
  padding: 20px 12px;
  color: #8a9bb5;
  border-right: 1px solid rgba(0, 191, 255, 0.12);
  overflow-y: auto;
}

.logo {
  text-align: center;
  margin-bottom: 20px;
  padding: 16px 0;
  border-bottom: 1px solid rgba(0, 191, 255, 0.1);
}

.logo-img {
  display: block;
  width: 70px;
  height: 70px;
  margin: 0 auto 10px;
  object-fit: contain;
  border-radius: 12px;
}

.logo h3 {
  font-size: 13px;
  letter-spacing: 3px;
  color: #00bfff;
  margin: 6px 0 0 0;
  font-weight: 700;
  text-transform: uppercase;
}

.logo-icon {
  display: none !important;
}

.sidebar nav ul {
  list-style: none;
  padding: 0;
}

.sidebar nav ul li {
  padding: 10px 14px;
  margin: 2px 0;
  cursor: pointer;
  border-radius: 8px;
  color: #8a9bb5;
  font-size: 13px;
  border-left: 3px solid transparent;
}

.sidebar nav ul li:hover {
  background: rgba(0, 191, 255, 0.08);
  color: #e4efff;
  border-left-color: #00bfff;
}

.sidebar nav ul li.active {
  background: rgba(0, 191, 255, 0.12);
  color: #00bfff;
  font-weight: 600;
  border-left-color: #00bfff;
}

.footer {
  font-size: 11px;
  text-align: center;
  color: #5a6b80;
  padding: 12px 0;
  border-top: 1px solid rgba(0, 191, 255, 0.08);
  margin-top: auto;
}

/* Content */
.content {
  flex: 1;
  min-width: 0;
  padding: 24px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  background: #0e1621;
}

/* Barre de recherche */
.search-bar-top {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.search-bar-top input {
  flex: 1;
  padding: 10px 16px;
  background: #12243d;
  border: 1px solid rgba(0, 191, 255, 0.15);
  border-radius: 8px;
  color: #e4efff;
  font-size: 13px;
}

.search-bar-top input:focus {
  outline: none;
  border-color: #00bfff;
}

.search-bar-top input::placeholder {
  color: #5a6b80;
}

.search-bar-top button {
  padding: 10px 20px;
  background: #00bfff;
  color: #0a0e14;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}

.search-bar-top button:hover {
  background: #33ccff;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  margin-bottom: 8px;
}

header h1 {
  font-size: 18px;
  font-weight: 600;
  color: #e4efff;
  letter-spacing: 0.5px;
}

/* Dashboard grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-top: 15px;
  flex: none;
  overflow: hidden;
  max-width: 100%;
  width: 100%;
}

.card {
  background: #12243d;
  border-radius: 12px;
  padding: 18px;
  border: 1px solid rgba(0, 191, 255, 0.08);
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  position: relative;
}

.card:hover {
  border-color: rgba(0, 191, 255, 0.2);
}

.card h3 {
  margin-bottom: 12px;
  color: #8a9bb5;
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 600;
  flex-shrink: 0;
}

.card canvas {
  max-width: 100%;
  height: 160px !important;
}

/* Pages that include a fixed navbar (e.g., pump-details, motor-control) */
.page-with-navbar {
  /* Allow vertical scrolling within the page content */
  overflow-y: auto;
  /* Reserve space for the navbar (assumed ~70px height) */
  padding-top: 80px;
  height: calc(100vh - 80px);
}

.card.wide { grid-column: span 2; max-width: 100%; }

.status-pill {
  text-align: center;
  padding: 6px 16px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 12px;
  display: inline-block;
  letter-spacing: 1px;
}
.green { background: rgba(0, 255, 136, 0.15); color: #00ff88; border: 1px solid rgba(0, 255, 136, 0.3); }
.red { background: rgba(255, 77, 77, 0.15); color: #ff4d4d; border: 1px solid rgba(255, 77, 77, 0.3); }

.tank {
  width: 80px;
  height: 160px;
  border: 2px solid rgba(0, 191, 255, 0.3);
  border-radius: 10px;
  margin: 16px auto;
  position: relative;
  background: #0a1220;
  flex-shrink: 0;
}
.tank-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 90%;
  background: linear-gradient(180deg, #00bfff, #0066cc);
  border-radius: 0 0 8px 8px;
  transition: height .5s ease;
}
.tank.low .tank-fill {
  background: linear-gradient(180deg, #ff6b6b, #cc0000);
  height: 20%;
}

/* LED */
.led {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-left: 8px;
}
.led.on { background: #00ff88; box-shadow: 0 0 8px rgba(0, 255, 136, 0.5); }
.led.off { background: #ff4d4d; box-shadow: 0 0 8px rgba(255, 77, 77, 0.5); }
.led.pause { background: #ffcc00; box-shadow: 0 0 8px rgba(255, 204, 0, 0.5); }

/* Boutons */
button {
  padding: 6px 12px;
  margin: 0 3px;
  border: none;
  border-radius: 6px;
  background: #00bfff;
  color: #0a0e14;
  font-weight: 600;
  cursor: pointer;
  font-size: 12px;
}

button:hover {
  background: #33ccff;
}

button:active {
  opacity: 0.8;
}

/* Cycle Controls */
.cycle-controls {
  background: rgba(0, 191, 255, 0.05);
  padding: 12px 16px;
  border-radius: 8px;
  margin-top: 10px;
  border: 1px solid rgba(0, 191, 255, 0.08);
}

.cycle-controls p {
  margin: 6px 0;
  font-size: 13px;
  color: #8a9bb5;
}

.cycle-controls span {
  font-weight: 600;
  color: #00bfff;
  margin-right: 10px;
  font-family: 'Courier New', monospace;
}

/* Hidden */
.hidden { display: none !important; }

/* Dashboard Layout */
#dashboard {
  display: flex;
  width: 100%;
  min-height: 100vh;
  height: 100vh;
  flex-direction: row;
}

.hidden {
  display: none !important;
}

/* === HAMBURGER MENU === */
.hamburger {
  display: none;
  flex-direction: column;
  cursor: pointer;
  gap: 5px;
  background: none;
  border: none;
  padding: 8px;
  margin-right: 10px;
}

.hamburger span {
  width: 25px;
  height: 3px;
  background: #00bfff;
  border-radius: 2px;
  transition: all 0.3s ease;
}

.hamburger.active span:nth-child(1) {
  transform: rotate(45deg) translate(10px, 10px);
}

.hamburger.active span:nth-child(2) {
  opacity: 0;
}

.hamburger.active span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -7px);
}

/* Responsive */
@media (max-width: 1200px) {
  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
  }

  .card.wide {
    grid-column: span 1;
  }
}

@media (max-width: 1024px) {
  .sidebar {
    width: 200px;
  }

  .logo-img {
    width: 50px;
    height: 50px;
  }

  .search-bar-top {
    gap: 8px;
  }

  .search-bar-top input,
  .search-bar-top button {
    font-size: 12px;
    padding: 8px 12px;
  }
}

@media (max-width: 768px) {
  /* Hamburger menu visible */
  .hamburger {
    display: flex;
  }

  /* Dashboard layout - stack on mobile */
  #dashboard {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  /* Sidebar - side drawer on mobile */
  .sidebar {
    position: fixed;
    left: -250px;
    top: 0;
    width: 250px;
    height: 100vh;
    z-index: 999;
    background: #0d1b2a;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
    transition: left 0.3s ease;
    padding: 20px 12px;
    overflow-y: auto;
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 100%;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    display: none;
  }

  .sidebar.open::after {
    display: block;
    cursor: pointer;
  }

  /* Content takes full width */
  .content {
    flex: 1;
    width: 100%;
    padding: 70px 12px 20px 12px;
    min-height: calc(100vh - 70px);
    background: #0e1621;
  }

  .logo-img {
    width: 50px;
    height: 50px;
  }

  .logo h3 {
    font-size: 12px;
  }

  .sidebar nav ul li {
    padding: 12px 14px;
    font-size: 14px;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 12px;
    overflow: visible;
    height: auto;
  }

  .card {
    height: auto;
    min-height: 200px;
  }

  .card.wide {
    grid-column: span 1;
  }

  .card canvas {
    height: 180px !important;
  }

  header {
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
  }

  header h1 {
    font-size: 16px;
    flex: 1;
    min-width: 200px;
  }

  .search-bar-top {
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
  }

  .search-bar-top input {
    flex: 1;
    min-width: 150px;
    padding: 12px 14px;
    font-size: 14px;
    min-height: 44px;
  }

  .search-bar-top button {
    padding: 12px 18px;
    font-size: 14px;
    min-height: 44px;
    font-weight: 600;
  }

  /* Login responsive */
  .login-card {
    width: 90%;
    max-width: 380px;
    padding: 30px 20px;
    border-radius: 12px;
  }

  .login-card h2 {
    font-size: 24px;
    margin-bottom: 18px;
  }

  .login-card label {
    font-size: 13px;
    margin-top: 14px;
  }

  .login-card input {
    padding: 14px 12px;
    margin-top: 6px;
    font-size: 16px;
    min-height: 44px;
  }

  .login-card button {
    padding: 16px 12px;
    margin-top: 18px;
    font-size: 16px;
    min-height: 44px;
  }

  /* Button responsive */
  button {
    padding: 10px 14px;
    font-size: 14px;
    min-height: 44px;
    margin: 4px 2px;
  }

  /* Tank responsive */
  .tank {
    width: 60px;
    height: 120px;
  }

  .tank-fill {
    border-radius: 0 0 6px 6px;
  }

  .status-pill {
    padding: 8px 14px;
    font-size: 12px;
    min-height: 34px;
    display: inline-flex;
    align-items: center;
  }

  /* Navbar responsive */
  .navbar {
    height: 60px;
    padding: 0 12px;
    gap: 10px;
    flex-wrap: wrap;
  }

  .navbar-brand {
    gap: 8px;
    font-size: 1em;
  }

  .navbar-brand img {
    height: 35px;
  }

  .navbar-title {
    font-size: 1em;
  }

  .navbar-actions {
    gap: 8px;
  }

  .navbar-btn {
    padding: 8px 12px;
    font-size: 0.85em;
    gap: 4px;
    min-height: 40px;
  }

  .page-header {
    padding: 16px 12px;
  }

  .page-header h2 {
    font-size: 1.4em;
  }

  /* Forms responsive */
  .form-group {
    margin-bottom: 14px;
  }

  .form-group label {
    font-size: 0.95em;
    margin-bottom: 6px;
  }

  .form-group input,
  .form-group textarea,
  .form-group select {
    padding: 12px;
    font-size: 16px;
    min-height: 44px;
    border-radius: 6px;
  }

  .form-group textarea {
    min-height: 100px;
  }

  /* Pump selector responsive */
  .pump-selector {
    flex-wrap: wrap;
    gap: 8px;
  }

  .pump-selector label {
    flex: 1;
    min-width: 150px;
    font-size: 0.95em;
  }

  .pump-selector select {
    flex: 1;
    min-width: 150px;
    max-width: none;
    padding: 12px;
    min-height: 44px;
  }

  /* Motor card responsive */
  .motor-card {
    padding: 16px 12px;
    margin-bottom: 16px;
  }

  .motor-card h3 {
    margin: 0 0 12px 0;
    font-size: 0.9em;
    padding-bottom: 8px;
  }

  /* Table responsive */
  .pumps-table {
    font-size: 13px;
  }

  .pumps-table th,
  .pumps-table td {
    padding: 10px;
  }

  .pumps-table thead {
    min-height: 44px;
  }

  /* Settings grid */
  .settings-sections {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .section {
    padding: 16px 12px;
  }

  .section h2 {
    font-size: 1.1em;
  }

  .section h3 {
    font-size: 1em;
  }

  /* CRUD header responsive */
  .crud-header {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
  }

  .crud-header h1 {
    font-size: 1.4em;
  }

  .btn-create {
    width: 100%;
    padding: 14px;
    font-size: 16px;
  }

  .back-btn-modern {
    width: 100%;
    padding: 12px;
    margin-bottom: 16px;
    justify-content: center;
  }

  /* Footer */
  .footer {
    font-size: 11px;
    padding: 10px 0;
  }
}

@media (max-width: 480px) {
  /* Extra small screens */
  body {
    font-size: 14px;
  }

  #dashboard {
    height: auto;
  }

  .content {
    padding: 70px 10px 16px 10px;
  }

  header h1 {
    font-size: 14px;
  }

  .search-bar-top {
    flex-direction: column;
  }

  .search-bar-top input {
    width: 100%;
  }

  .search-bar-top button {
    width: 100%;
  }

  .page-header {
    padding: 12px 10px;
  }

  .page-header h2 {
    font-size: 1.2em;
  }

  .login-card {
    width: 95%;
    padding: 20px 16px;
  }

  .login-card h2 {
    font-size: 20px;
    margin-bottom: 14px;
  }

  .login-card input {
    padding: 12px 10px;
    font-size: 16px;
  }

  .login-card button {
    padding: 14px 10px;
  }

  button {
    padding: 10px 12px;
    font-size: 13px;
    min-height: 40px;
  }

  .navbar {
    height: 56px;
    padding: 0 8px;
  }

  .navbar-brand {
    font-size: 0.9em;
    gap: 6px;
  }

  .navbar-brand img {
    height: 30px;
  }

  .navbar-title {
    display: none;
  }

  .navbar-btn {
    padding: 6px 10px;
    font-size: 0.8em;
    min-height: 36px;
  }

  .form-group input,
  .form-group textarea,
  .form-group select {
    padding: 10px;
    font-size: 16px;
    min-height: 40px;
  }

  .pump-selector {
    flex-direction: column;
  }

  .pump-selector label,
  .pump-selector select {
    width: 100%;
  }

  .card canvas {
    height: 150px !important;
  }

  .motor-card {
    padding: 12px 10px;
  }

  .section {
    padding: 12px 10px;
  }

  .back-btn-modern {
    width: 100%;
    padding: 10px;
  }

  .btn-create {
    width: 100%;
    padding: 12px;
  }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  button,
  input,
  select,
  textarea,
  .navbar-btn,
  .sidebar nav ul li {
    min-height: 44px;
    font-size: 16px;
  }

  button:active {
    transform: scale(0.98);
  }

  .hamburger:active span {
    opacity: 0.8;
  }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 191, 255, 0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 191, 255, 0.4); }

/* Card subtle entrance */
.card {
  animation: fadeIn 0.3s ease-out;
}

/* Print styles */
@media print {
  .sidebar, header, button {
    display: none;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* === NAVBAR COMMUNE === */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 70px;
  background: linear-gradient(90deg, #1b355e 0%, #143c69 50%, #1b355e 100%);
  border-bottom: 3px solid #00bfff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 30px;
  z-index: 1000;
  box-shadow: 0 4px 15px rgba(0, 191, 255, 0.2);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 15px;
  font-size: 1.3em;
  font-weight: bold;
  color: #ffcc00;
  text-decoration: none;
}

.navbar-brand img {
  height: 45px;
  width: auto;
}

.navbar-title {
  font-size: 1.2em;
  color: #e4efff;
  letter-spacing: 1px;
}

.navbar-actions {
  display: flex;
  gap: 15px;
  align-items: center;
}

.navbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(0, 191, 255, 0.1);
  color: #00bfff;
  border: 2px solid #00bfff;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  font-size: 0.9em;
  transition: all 0.3s ease;
}

.navbar-btn:hover {
  background: #00bfff;
  color: #0f1419;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 191, 255, 0.4);
}

.navbar-btn-back {
  background: rgba(255, 77, 77, 0.1);
  color: #ff4d4d;
  border-color: #ff4d4d;
}

.navbar-btn-back:hover {
  background: #ff4d4d;
  color: #fff;
  box-shadow: 0 6px 20px rgba(255, 77, 77, 0.4);
}

/* Padding pour pages avec navbar */
.page-with-navbar {
  padding-top: 80px;
}

/* === BOUTON RETOUR UNIFORME === */
.back-btn-modern {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
  padding: 12px 20px;
  background: linear-gradient(135deg, rgba(255, 77, 77, 0.1), rgba(255, 77, 77, 0.05));
  color: #ff4d4d;
  border: 2px solid #ff4d4d;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  font-weight: bold;
  font-size: 1em;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.back-btn-modern:hover {
  background: linear-gradient(135deg, #ff4d4d, #ff6666);
  color: #fff;
  transform: translateX(-5px);
  box-shadow: 0 8px 25px rgba(255, 77, 77, 0.3);
}

