/* Modern Variables & Reset */
:root {
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --bg-color: #0f1015;
  --panel-bg: rgba(255, 255, 255, 0.03);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text-primary: #f8f9fa;
  --text-secondary: #adb5bd;
  --primary: #6366f1;
  /* Indigo */
  --primary-hover: #4f46e5;
  --accent: #ec4899;
  /* Pink */
  --accent-hover: #db2777;
  --success: #10b981;
  --error: #ef4444;
  --warning: #f59e0b;
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  --glass-backdrop: blur(16px);
  --border-radius: 16px;
  --border-radius-sm: 8px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Background Gradients & Shapes */
.bg-shape {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  opacity: 0.5;
  animation: pulse-bg 10s ease-in-out infinite alternate;
}

.bg-shape-1 {
  background: var(--primary);
  width: 500px;
  height: 500px;
  top: -200px;
  left: -100px;
}

.bg-shape-2 {
  background: var(--accent);
  width: 400px;
  height: 400px;
  bottom: -150px;
  right: -50px;
  animation-delay: -5s;
}

@keyframes pulse-bg {
  0% {
    transform: scale(1) translate(0, 0);
  }

  100% {
    transform: scale(1.1) translate(50px, 50px);
  }
}

/* Utilities */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.text-center {
  text-align: center;
}

.text-secondary {
  color: var(--text-secondary);
}

.text-success {
  color: var(--success);
}

.font-medium {
  font-weight: 500;
}

.w-full {
  width: 100%;
}

.m-0 {
  margin: 0;
}

.mb-s {
  margin-bottom: 8px;
}

.mb-m {
  margin-bottom: 16px;
}

.mb-l {
  margin-bottom: 24px;
}

.mt-s {
  margin-top: 8px;
}

.mt-m {
  margin-top: 16px;
}

.mt-l {
  margin-top: 24px;
}

.p-xl {
  padding: 48px 24px;
}

.d-flex {
  display: flex;
}

.justify-between {
  justify-content: space-between;
}

.align-center {
  align-items: center;
}

.flex-column {
  display: flex;
  flex-direction: column;
}

.card__body {
  flex: 1;
  display: flex;
  flex-direction: column;
}


/* Grid Layout */
.grid-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media (min-width: 900px) {
  .grid-layout {
    grid-template-columns: 1fr 1fr;
  }
}

/* Glassmorphism Panels */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: var(--glass-backdrop);
  -webkit-backdrop-filter: var(--glass-backdrop);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius);
  box-shadow: var(--glass-shadow);
  padding: 24px;
  transition: var(--transition);
}

.glass-panel:hover {
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
}

.section-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #fff, #a5b4fc);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Header */
.header {
  padding: 24px 0;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(15, 16, 21, 0.7);
  backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.logo-icon {
  font-size: 24px;
  filter: drop-shadow(0 0 8px rgba(236, 72, 153, 0.5));
}

.logo h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -1px;
  background: linear-gradient(135deg, #ffffff, #a5b4fc);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-left: 4px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: justify;
  justify-content: center;
  padding: 12px 24px;
  border-radius: var(--border-radius-sm);
  font-family: inherit;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  text-decoration: none;
  gap: 8px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn--sm {
  padding: 8px 16px;
  font-size: 0.875rem;
}

.btn--xl {
  padding: 16px 32px;
  font-size: 1.125rem;
}

.btn--icon {
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}

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

.btn--primary:hover {
  background: var(--primary-hover);
}

.btn--accent {
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: white;
}

.btn--accent:hover {
  filter: brightness(1.1);
}

.btn--outline {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
}

.btn--outline:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn--glow:hover {
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.5);
}

.shadow-hover:hover {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

/* Form Controls — champs ligne unique compacts (auth, factures, réglages) */
.custom-input {
  position: relative;
}

.form-control {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  min-height: 42px;
  line-height: 1.4;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  transition: var(--transition);
  resize: none;
}

select.form-control {
  cursor: pointer;
  min-height: 42px;
}

/* Zone de prompt IA : grande hauteur (ne pas confondre avec les inputs auth) */
textarea.form-control.prompt-textarea,
textarea.prompt-textarea {
  min-height: 120px;
  padding: 14px 16px;
  resize: vertical;
  line-height: 1.5;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.form-control::placeholder {
  color: var(--text-secondary);
}

/* Badges & Alerts */
.badge-container {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  padding: 8px 16px;
  border-radius: 30px;
  color: var(--success);
  font-weight: 500;
}

.count-badge {
  background: var(--success);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 700;
}

.pulse {
  animation: pulse-animation 2s infinite;
}

@keyframes pulse-animation {
  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 10px rgba(16, 185, 129, 0);
  }

  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.alert {
  padding: 12px 16px;
  border-radius: var(--border-radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Progress Bar */
.progress-container {
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  width: 0%;
  transition: width 0.3s ease;
  border-radius: 10px;
}

.gradient-fill {
  background: linear-gradient(90deg, var(--primary), var(--accent));
  box-shadow: 0 0 10px var(--primary);
}

/* Gallery & Results */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  max-height: 500px;
  overflow-y: auto;
  padding-right: 8px;
}

.gallery-item {
  position: relative;
  border-radius: var(--border-radius-sm);
  overflow: hidden;
  border: 1px solid var(--panel-border);
  aspect-ratio: 4/3;
  background: rgba(0, 0, 0, 0.5);
  transition: var(--transition);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.gallery-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  border-color: rgba(255, 255, 255, 0.2);
}

.gallery-item:hover img {
  transform: scale(1.05);
}

.item-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 12px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  width: max-content;
}

.badge--success {
  background: var(--success);
  color: white;
}

.item-name {
  color: white;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Modal Settings */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  width: 90%;
  max-width: 500px;
  background: var(--bg-color);
  z-index: 1001;
  padding: 32px;
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 1000;
}

.toast {
  background: var(--panel-bg);
  backdrop-filter: var(--glass-backdrop);
  -webkit-backdrop-filter: var(--glass-backdrop);
  border: 1px solid var(--panel-border);
  padding: 16px 24px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: white;
  font-weight: 500;
}

.toast--success {
  border-left: 4px solid var(--success);
}

.toast--error {
  border-left: 4px solid var(--error);
}

.toast--warning {
  border-left: 4px solid var(--warning);
}

.toast--info {
  border-left: 4px solid var(--primary);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast.toast--hiding {
  animation: fadeOut 0.3s forwards;
}

.close-modal-btn {
  position: absolute;
  top: 12px;
  right: 16px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.close-modal-btn:hover {
  color: var(--text-primary);
}

.agencia-modal-wide {
  max-width: 520px;
  width: 92%;
  max-height: 90vh;
  overflow-y: auto;
}

.agencia-modal-xl {
  max-width: 900px;
  width: 95%;
  max-height: 90vh;
  overflow-y: auto;
}

/* Header : logo + onglets + actions */
.header-container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
}

.header-agencia-nav {
  display: none;
  flex: 1 1 100%;
  justify-content: center;
  min-width: 0;
}

.header-agencia-nav.is-visible {
  display: flex;
}

@media (min-width: 960px) {
  .header-agencia-nav.is-visible {
    flex: 1 1 auto;
    max-width: min(520px, 48vw);
  }
}

.header-controls {
  margin-left: auto;
}

.header-agencia-tabs.agencia-tabs-row {
  justify-content: center;
  border-bottom: none;
  padding: 4px 0;
  gap: 2px 6px;
}

/* Onglets principaux (historique / abonnement / factures — même logique que CV'IA, pas en modale) */
.agencia-tabs-row {
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--panel-border);
}

.agencia-tab-btn {
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0;
  transition: var(--transition);
}

.agencia-tab-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.agencia-tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* Carte Google Drive : comptes multiples */
.drive-card-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.drive-accounts-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  max-width: 100%;
}

.drive-account-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.25);
  font-size: 0.8rem;
  max-width: 100%;
}

.drive-account-pill--active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(236, 72, 153, 0.35);
}

.drive-account-pill-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}

.drive-account-pill button {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  font-size: 1rem;
}

.drive-account-pill button:hover {
  color: var(--text-primary);
}

.drive-account-pill .drive-pill-use {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
}

.agencia-panel-page {
  width: 100%;
  max-width: 960px;
  margin-left: auto;
  margin-right: auto;
}

.auth-tabs-row {
  display: flex;
  gap: 8px;
}

.auth-tab {
  flex: 1;
  padding: 10px 12px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
}

.auth-tab.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(236, 72, 153, 0.12);
}

/* Champ mot de passe avec bouton œil (comme Autopostia) */
.password-field {
  position: relative;
  display: flex;
  align-items: center;
}

.password-field .form-control {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  width: 34px;
  height: 34px;
  padding: 0;
}

.password-toggle:hover {
  color: var(--accent);
}

.agencia-table th,
.agencia-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--panel-border);
}

.agencia-table th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
}

@media (max-width: 768px) {
  .invoices-two-col {
    grid-template-columns: 1fr !important;
  }
}

@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateY(10px);
  }
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 16, 21, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-left-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading-pulse {
  animation: opacity-pulse 1.5s infinite alternate;
}

@keyframes opacity-pulse {
  from {
    opacity: 0.5;
  }

  to {
    opacity: 1;
  }
}