/* ========== RESET & BASE ========== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  width: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0d0d0d;
  color: #f0f0f0;
  line-height: 1.6;
}

/* ========== LOGIN VIEW ========== */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #0d0d0d;
  padding: 20px;
}

.login-box {
  background: #1a1a1a;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  width: 100%;
  max-width: 320px;
  text-align: center;
  border: 1px solid #2a2a2a;
}

.login-box h1 {
  font-size: 2.2em;
  margin-bottom: 8px;
  color: #f0f0f0;
}

.login-box p {
  color: #a0a0a0;
  margin-bottom: 32px;
  font-size: 0.9em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.login-box input {
  width: 100%;
  padding: 12px;
  margin-bottom: 16px;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  font-size: 1em;
  background: #0d0d0d;
  color: #f0f0f0;
  transition: all 0.2s;
}

.login-box input:focus {
  outline: none;
  border-color: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.2);
}

.login-box button {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1em;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.login-box button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.login-box #error {
  color: #f97316;
  margin-top: 16px;
  font-size: 0.9em;
}

/* ========== DASHBOARD LAYOUT ========== */
.dashboard-container {
  display: grid;
  grid-template-columns: 240px 1fr 280px;
  gap: 0;
  height: 100vh;
  overflow: hidden;
}

/* ========== SIDEBAR ========== */
.sidebar {
  background: #1a1a1a;
  border-right: 1px solid #2a2a2a;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 24px 16px;
}

.sidebar-logo {
  font-size: 1.3em;
  font-weight: 700;
  margin-bottom: 32px;
  color: #f0f0f0;
  padding: 12px;
  text-align: center;
  border-bottom: 1px solid #2a2a2a;
  padding-bottom: 16px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.nav-item {
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-left: 3px solid transparent;
  color: #a0a0a0;
  cursor: pointer;
  font-size: 0.95em;
  text-align: left;
  transition: all 0.2s;
  border-radius: 0 6px 6px 0;
}

.nav-item:hover {
  color: #f0f0f0;
  background: rgba(34, 197, 94, 0.1);
}

.nav-item.active {
  border-left-color: #22c55e;
  color: #22c55e;
  background: rgba(34, 197, 94, 0.15);
  font-weight: 600;
}

.sidebar-footer {
  border-top: 1px solid #2a2a2a;
  padding-top: 16px;
  margin-top: 16px;
}

.logout-btn {
  width: 100%;
  padding: 10px 12px;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: #a0a0a0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85em;
  transition: all 0.2s;
}

.logout-btn:hover {
  background: #3a3a3a;
  color: #f0f0f0;
}

/* ========== MAIN CONTENT ========== */
.main-content {
  display: flex;
  flex-direction: column;
  background: #0d0d0d;
  overflow: hidden;
}

.main-header {
  padding: 20px 32px;
  border-bottom: 1px solid #2a2a2a;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.header-title h1 {
  font-size: 1.6em;
  color: #f0f0f0;
  font-weight: 700;
}

.header-controls {
  display: flex;
  gap: 16px;
  align-items: center;
}

.btn-refresh {
  padding: 10px 16px;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
  font-size: 0.9em;
}

.btn-refresh:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.timestamp-container {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-size: 0.85em;
}

#timestamp {
  color: #f0f0f0;
  font-weight: 500;
}

.timezone {
  color: #a0a0a0;
  font-size: 0.75em;
  margin-top: 2px;
}

.content-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.content-section {
  display: none;
}

.content-section.active {
  display: block;
  animation: fadeIn 0.2s ease-in;
}

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

/* ========== PULSE SECTION ========== */
.pulse-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 32px;
  margin-bottom: 32px;
}

.pulse-chart-container {
  background: #1a1a1a;
  padding: 24px;
  border-radius: 12px;
  border: 1px solid #2a2a2a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#chart {
  max-height: 300px;
}

.pulse-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.kpi-card {
  background: #1a1a1a;
  padding: 24px;
  border-radius: 12px;
  border: 1px solid #2a2a2a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.kpi-label {
  font-size: 0.85em;
  color: #a0a0a0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 2.2em;
  font-weight: 700;
  color: #22c55e;
  margin-bottom: 4px;
}

.kpi-subtext {
  font-size: 0.9em;
  color: #a0a0a0;
  margin-bottom: 12px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: #2a2a2a;
  border-radius: 4px;
  overflow: hidden;
}

#progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  transition: width 0.4s ease;
}

.kpi-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.pulse-update {
  background: #1a1a1a;
  padding: 24px;
  border-radius: 12px;
  border: 1px solid #2a2a2a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.pulse-update h3 {
  font-size: 1em;
  color: #f0f0f0;
  margin-bottom: 16px;
  border-bottom: 1px solid #2a2a2a;
  padding-bottom: 12px;
}

.pulse-update form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pulse-update input {
  padding: 10px 12px;
  background: #0d0d0d;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  color: #f0f0f0;
  font-size: 0.95em;
  transition: all 0.2s;
}

.pulse-update input:focus {
  outline: none;
  border-color: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.2);
}

.pulse-update button {
  padding: 10px 12px;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
  font-size: 0.9em;
}

.pulse-update button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

/* ========== LIVRABLES SECTION ========== */
.livrables-header {
  margin-bottom: 24px;
}

.filter-group {
  display: flex;
  gap: 12px;
  align-items: center;
}

.filter-group label {
  color: #a0a0a0;
  font-size: 0.9em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-btn {
  padding: 8px 14px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  color: #a0a0a0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85em;
  transition: all 0.2s;
}

.filter-btn:hover {
  border-color: #22c55e;
  color: #22c55e;
}

.filter-btn.active {
  background: #22c55e;
  border-color: #22c55e;
  color: #0d0d0d;
  font-weight: 600;
}

.livrables-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
  max-height: 600px;
  overflow-y: auto;
}

.livrable-card {
  background: #1a1a1a;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #2a2a2a;
  cursor: pointer;
  transition: all 0.2s;
}

.livrable-card:hover {
  border-color: #22c55e;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.2);
  transform: translateY(-2px);
}

.livrable-card-title {
  font-weight: 600;
  color: #f0f0f0;
  margin-bottom: 8px;
  font-size: 0.95em;
}

.livrable-card-date {
  font-size: 0.8em;
  color: #a0a0a0;
  margin-bottom: 8px;
}

.livrable-card-action {
  font-size: 0.8em;
  color: #22c55e;
  font-weight: 600;
  margin-top: 8px;
}

/* ========== BESOINS SECTION ========== */
.besoins-header {
  margin-bottom: 24px;
}

.besoins-info {
  color: #a0a0a0;
  font-size: 0.9em;
}

.besoins-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 600px;
  overflow-y: auto;
}

.besoin-item {
  background: #1a1a1a;
  padding: 16px;
  border-radius: 8px;
  border-left: 3px solid #2a2a2a;
  cursor: pointer;
  transition: all 0.2s;
}

.besoin-item:hover {
  border-left-color: #22c55e;
  background: rgba(34, 197, 94, 0.1);
}

.besoin-item.pending {
  border-left-color: #f97316;
}

.besoin-item.approved {
  border-left-color: #22c55e;
}

.besoin-item.rejected {
  border-left-color: #ef4444;
}

.besoin-status {
  font-size: 0.75em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.besoin-status.pending {
  color: #f97316;
}

.besoin-status.approved {
  color: #22c55e;
}

.besoin-status.rejected {
  color: #ef4444;
}

.besoin-text {
  color: #f0f0f0;
  font-size: 0.9em;
  line-height: 1.5;
}

.besoin-empty {
  color: #a0a0a0;
  text-align: center;
  padding: 32px;
  font-size: 0.95em;
}

/* ========== MAGNUS SIDEBAR ========== */
.magnus-sidebar {
  background: #1a1a1a;
  border-left: 1px solid #2a2a2a;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.magnus-header {
  font-size: 1em;
  font-weight: 700;
  margin-bottom: 20px;
  color: #f0f0f0;
  border-bottom: 1px solid #2a2a2a;
  padding-bottom: 12px;
}

.magnus-content {
  flex: 1;
}

.cost-card {
  background: #0d0d0d;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #2a2a2a;
  margin-bottom: 12px;
  text-align: center;
}

.cost-label {
  font-size: 0.75em;
  color: #a0a0a0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.cost-value {
  font-size: 1.4em;
  font-weight: 700;
  color: #22c55e;
  margin-bottom: 2px;
}

.cost-limit {
  font-size: 0.75em;
  color: #a0a0a0;
}

.magnus-divider {
  height: 1px;
  background: #2a2a2a;
  margin: 16px 0;
}

.magnus-sidebar h4 {
  font-size: 0.85em;
  color: #f0f0f0;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.actions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.8em;
  max-height: 400px;
  overflow-y: auto;
}

.action-item {
  background: #0d0d0d;
  padding: 8px;
  border-radius: 6px;
  border-left: 2px solid #22c55e;
  color: #a0a0a0;
  line-height: 1.4;
}

.action-item-type {
  font-weight: 600;
  color: #f0f0f0;
  margin-bottom: 2px;
}

.action-item-time {
  color: #666;
  font-size: 0.75em;
}

/* ========== SCROLLBAR STYLING ========== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #1a1a1a;
}

::-webkit-scrollbar-thumb {
  background: #2a2a2a;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #3a3a3a;
}

/* ========== LIVRABLES CARDS (UPDATED) ========== */
.livrable-card {
  transition: all 0.3s ease;
}

.livrable-card:hover {
  transform: translateY(-2px);
  border-color: #22c55e;
}

.livrable-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 14px;
}

.livrable-btn {
  flex: 1;
  padding: 12px 10px;
  border: 1px solid #2a2a2a;
  background: #0d0d0d;
  color: #a0a0a0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8em;
  font-weight: 500;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.livrable-btn:hover {
  background: #1a1a1a;
  color: #22c55e;
  border-color: #22c55e;
  box-shadow: 0 0 12px rgba(34, 197, 94, 0.2);
}

.livrable-btn:active {
  transform: scale(0.98);
}

.livrable-btn-delete {
  color: #f97316;
  border-color: #2a2a2a;
}

.livrable-btn-delete:hover {
  background: #f97316;
  color: #fff;
  border-color: #f97316;
  box-shadow: 0 0 12px rgba(249, 115, 22, 0.3);
}

/* ========== MODALE ========== */
.modal {
  display: none !important;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.92);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.modal.active,
.modal[style*="display: flex"] {
  display: flex !important;
}

.modal-content {
  background: linear-gradient(135deg, #1a1a1a 0%, #0d0d0d 100%);
  border: 1px solid #2a2a2a;
  border-radius: 16px;
  max-width: 900px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid #2a2a2a;
  background: linear-gradient(90deg, #0d0d0d 0%, #1a1a1a 100%);
}

.modal-header h2 {
  font-size: 1.3em;
  color: #f0f0f0;
  margin: 0;
  word-break: break-word;
  font-weight: 600;
}

.modal-close {
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  color: #a0a0a0;
  font-size: 1.4em;
  cursor: pointer;
  padding: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.25s;
  flex-shrink: 0;
}

.modal-close:hover {
  background: #f97316;
  border-color: #f97316;
  color: #fff;
  box-shadow: 0 0 12px rgba(249, 115, 22, 0.3);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: #0d0d0d;
}

.modal-text {
  background: #1a1a1a;
  color: #c0c0c0;
  padding: 18px;
  border-radius: 10px;
  border: 1px solid #2a2a2a;
  font-family: 'Courier New', 'Monaco', monospace;
  font-size: 0.92em;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: auto;
  max-height: 100%;
}

.modal-text::-webkit-scrollbar {
  width: 6px;
}

.modal-text::-webkit-scrollbar-track {
  background: #0d0d0d;
}

.modal-text::-webkit-scrollbar-thumb {
  background: #2a2a2a;
  border-radius: 3px;
}

.modal-text::-webkit-scrollbar-thumb:hover {
  background: #3a3a3a;
}

.modal-footer {
  display: flex;
  gap: 12px;
  padding: 20px 24px;
  border-top: 1px solid #2a2a2a;
  background: linear-gradient(90deg, #0d0d0d 0%, #1a1a1a 100%);
}

.modal-btn {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #2a2a2a;
  background: #1a1a1a;
  color: #a0a0a0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9em;
  font-weight: 500;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.modal-btn:hover {
  background: #22c55e;
  color: #fff;
  border-color: #22c55e;
  box-shadow: 0 0 16px rgba(34, 197, 94, 0.3);
}

.modal-btn:active {
  transform: scale(0.98);
}

.modal-btn-close {
  background: #f97316;
  color: #fff;
  border-color: #f97316;
}

.modal-btn-close:hover {
  background: #e66312;
  border-color: #e66312;
  box-shadow: 0 0 16px rgba(249, 115, 22, 0.3);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1400px) {
  .dashboard-container {
    grid-template-columns: 200px 1fr 240px;
  }
}

@media (max-width: 1024px) {
  .dashboard-container {
    grid-template-columns: 1fr 240px;
  }

  .sidebar {
    display: none;
  }

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

  .magnus-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 240px;
    height: 100vh;
    z-index: 100;
  }
}

@media (max-width: 768px) {
  .dashboard-container {
    grid-template-columns: 1fr;
  }

  .magnus-sidebar {
    display: none;
  }

  .main-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-controls {
    flex-direction: column;
    width: 100%;
  }

  .btn-refresh {
    width: 100%;
  }

  .content-wrapper {
    padding: 16px;
  }

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