/* WIPcanal ! - Premium Design System - v2 */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  --brand-primary: #4F46E5;
  --brand-secondary: #06B6D4;
  --brand-accent: #8B5CF6;
  --bg-main: #1E293B;
  --bg-card: #334155;
  --bg-glass: rgba(51, 65, 85, 0.75);
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-sub: #CBD5E1;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(79, 70, 229, 0.4);
  --bg-input: rgba(15, 23, 42, 0.6);
  --bg-input-hover: rgba(30, 41, 59, 0.8);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.25);
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --btn-secondary-bg: rgba(255, 255, 255, 0.08);
  --btn-secondary-hover-bg: rgba(255, 255, 255, 0.15);
}

:root[data-theme="light"] {
  --bg-main: #F1F5F9;
  --bg-card: #FFFFFF;
  --bg-glass: rgba(255, 255, 255, 0.85);
  --text-main: #0F172A;
  --text-muted: #64748B;
  --text-sub: #475569;
  --border-color: rgba(0, 0, 0, 0.1);
  --border-highlight: rgba(79, 70, 229, 0.3);
  --bg-input: #FFFFFF;
  --bg-input-hover: #F8FAFC;
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 20px rgba(79, 70, 229, 0.15);
  --btn-secondary-bg: rgba(0, 0, 0, 0.03);
  --btn-secondary-hover-bg: rgba(0, 0, 0, 0.08);
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-image:
    radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.12) 0px, transparent 50%);
  background-attachment: fixed;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

a {
  color: var(--brand-secondary);
  text-decoration: none;
  transition: all 0.2s ease;
}

a:hover {
  color: #38BDF8;
}

/* Header & Navbar */
.app-header {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 16px 24px;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo-img {
  max-height: 44px;
  max-width: 160px;
  object-fit: contain;
}

.brand-title {
  font-size: 1.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--text-main) 0%, var(--brand-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  background: rgba(79, 70, 229, 0.2);
  color: var(--brand-secondary);
  border: 1px solid var(--border-highlight);
  border-radius: 20px;
}

/* Layout Containers */
.main-wrapper {
  max-width: 1140px;
  width: 100%;
  margin: 32px auto;
  padding: 0 20px;
  flex: 1;
}

/* Unified Project View 2-Column Grid (1/3 Specs, 2/3 Feed) */
.project-grid-2col {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 992px) {
  .project-grid-2col {
    grid-template-columns: 1fr;
  }

  .project-grid-2col>div:nth-child(1) {
    order: 1;
  }

  .project-grid-2col>div:nth-child(2) {
    order: 2;
  }

  .stakeholder-row {
    flex-wrap: wrap;
  }

  .stakeholder-row input {
    flex: 1 1 100% !important;
  }
}

/* Cards & Glass Containers */
.card-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-lg);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.card-panel:hover {
  border-color: var(--border-highlight);
}

.card-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
  margin-bottom: 20px;
}

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-accent) 100%);
  color: #ffffff;
  box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 25px rgba(79, 70, 229, 0.4);
  color: #ffffff;
}

.btn-secondary {
  background: var(--btn-secondary-bg);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--btn-secondary-hover-bg);
  color: var(--text-main);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.82rem;
}

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

.form-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 8px;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.25);
}

select.form-control option,
select option,
.form-control option {
  background-color: var(--bg-card) !important;
  color: var(--text-main) !important;
  padding: 8px 12px;
}

textarea.form-control {
  min-height: 42px;
  resize: vertical;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

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

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-info {
  background: rgba(59, 130, 246, 0.2);
  color: #60A5FA;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.2);
  color: #FBBF24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-success {
  background: rgba(16, 185, 129, 0.2);
  color: #34D399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #F87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-purple {
  background: rgba(139, 92, 246, 0.2);
  color: #A78BFA;
  border: 1px solid rgba(139, 92, 246, 0.3);
}

.badge-gray {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text-muted);
  border: 1px solid rgba(148, 163, 184, 0.3);
}

/* Timeline & Feed */
.timeline {
  position: relative;
  padding-left: 28px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 10px;
  bottom: 10px;
  width: 2px;
  background: var(--border-color);
}

.timeline-item {
  position: relative;
  margin-bottom: 36px;
}

.timeline-marker {
  position: absolute;
  left: -28px;
  top: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--brand-primary);
  border: 4px solid var(--bg-main);
  box-shadow: var(--shadow-glow);
}

.timeline-marker.marker-client {
  background: var(--brand-secondary);
}

.timeline-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.timeline-author {
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.timeline-date {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Media Attachments Lightbox Grid */
.media-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 16px;
}

.media-card {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  padding: 10px;
  position: relative;
}

.media-preview-img {
  width: 100%;
  height: auto;
  max-height: 700px;
  object-fit: contain;
  border-radius: 4px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: transform 0.3s ease;
  background: rgba(0, 0, 0, 0.05);
  /* subtle background for transparent images */
}

.media-video-player {
  width: 100%;
  max-height: 320px;
  border-radius: 4px;
  margin-bottom: 8px;
  background: #000;
}

/* Comments Section */
.comments-list {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--border-color);
}

.comment-bubble {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 12px;
}

.comment-author {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--brand-secondary);
  display: flex;
  justify-content: space-between;
}

.comment-time {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 400;
}

.comment-text {
  margin-top: 6px;
  font-size: 0.92rem;
  color: var(--text-sub);
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 30px 20px;
  border-top: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 40px;
}

/* Lightbox Modal */
.lightbox-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.lightbox-modal.active {
  display: flex;
}

.lightbox-content {
  max-width: 90%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 25px;
  font-size: 2rem;
  color: #fff;
  cursor: pointer;
}

/* --- Responsive & Media Queries Globaux --- */
@media (max-width: 768px) {

  /* En-tête de page flexible pour mobiles */
  .nav-container {
    flex-direction: column;
    gap: 14px;
    align-items: center;
    text-align: center;
  }

  .nav-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    width: 100%;
  }

  .nav-actions .btn {
    flex: 1 1 auto;
    justify-content: center;
    font-size: 0.8rem;
    padding: 8px 12px;
  }

  /* Rendre le fil d'actualité responsive */
  .timeline-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .timeline-date {
    font-size: 0.78rem;
  }

  /* Ajustements pour les marges des conteneurs */
  html,
  body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  .main-wrapper {
    margin: 8px auto !important;
    padding: 0 6px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }

  .project-grid-2col {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }

  .project-grid-2col>div {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }

  .card-panel {
    padding: 14px 10px !important;
    margin-bottom: 14px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }

  .timeline,
  .timeline-item,
  .timeline-content {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }

  .admin-accordion-header {
    padding: 10px 10px !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
  }

  .admin-accordion-header strong {
    font-size: 0.88rem !important;
    white-space: normal !important;
    word-break: break-word !important;
  }

  .form-control,
  input,
  select,
  textarea {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Modales de connexion et formulaires */
  .form-grid-2 {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }
}

/* Correctif iPadOS / iOS WebKit : font-size >= 16px sur tablettes et mobiles pour bloquer le zoom auto et la perte d'émoticône */
@media (max-width: 1194px), (pointer: coarse) {
  .form-control,
  input,
  select,
  textarea {
    font-size: 16px !important;
  }
}

@media (max-width: 480px) {
  .brand-title {
    font-size: 1.15rem;
  }

  .brand-logo-img {
    max-height: 32px;
  }

  h1 {
    font-size: 1.5rem !important;
  }

  h2 {
    font-size: 1.25rem !important;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }
}

/* Cible de notification email (surlignage) */
:target {
  animation: target-highlight 2s ease-out;
}

/* Règle systématique pour le scroll sous le bandeau sticky header */
[id^="proj-card-"],
[id^="client-"],
[id^="event-"],
[id^="comment-"],
.timeline-item,
.card-panel {
  scroll-margin-top: 160px !important;
}

@keyframes target-highlight {
  0% {
    background-color: rgba(79, 70, 229, 0.4);
    box-shadow: 0 0 20px rgba(79, 70, 229, 0.6);
    border-radius: var(--radius-md);
  }

  100% {
    background-color: transparent;
    box-shadow: none;
  }
}