/**
 * ActionBar V2 - Design Compact et Déplaçable
 *
 * Features:
 * - Design minimaliste avec icones SVG
 * - Drag & Drop pour repositionnement
 * - Animations subtiles
 * - États visuels clairs
 * - Responsive adaptatif
 */

/* ═══════════════════════════════════════════════════════════════
   VARIABLES
   ═══════════════════════════════════════════════════════════════ */
:root {
  --ab-bg: rgba(24, 27, 34, 0.95);
  --ab-border: rgba(255, 255, 255, 0.08);
  --ab-text: #e4e4e7;
  --ab-text-muted: #71717a;
  --ab-primary: #8b5cf6;
  --ab-primary-hover: #a78bfa;
  --ab-success: #22c55e;
  --ab-warning: #f59e0b;
  --ab-danger: #ef4444;
  --ab-radius: 12px;
  --ab-radius-sm: 8px;
}

/* ═══════════════════════════════════════════════════════════════
   CONTAINER PRINCIPAL
   ═══════════════════════════════════════════════════════════════ */
.action-bar-v2 {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--ab-bg);
  border: 1px solid var(--ab-border);
  border-radius: var(--ab-radius);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow:
    0 8px 24px -8px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  z-index: 1100; /* Above mobile sidebar (z-index: 1000) */
  animation: ab-slide-up 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: grab;
  user-select: none;
}

.action-bar-v2.is-dragging {
  cursor: grabbing;
  opacity: 0.9;
  box-shadow:
    0 16px 48px -12px rgba(0, 0, 0, 0.6),
    0 0 0 2px var(--ab-primary);
}

.action-bar-v2.is-custom-position {
  /* Override le centrage par défaut */
}

@keyframes ab-slide-up {
  from {
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}

/* ═══════════════════════════════════════════════════════════════
   POIGNÉE DE DRAG
   ═══════════════════════════════════════════════════════════════ */
.ab-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 24px;
  color: var(--ab-text-muted);
  cursor: grab;
  flex-shrink: 0;
}

.ab-drag-handle svg {
  width: 12px;
  height: 16px;
}

.action-bar-v2:hover .ab-drag-handle {
  color: var(--ab-text);
}

.action-bar-v2.is-dragging .ab-drag-handle {
  cursor: grabbing;
  color: var(--ab-primary);
}

/* ═══════════════════════════════════════════════════════════════
   STATUS BADGE
   ═══════════════════════════════════════════════════════════════ */
.ab-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.ab-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  transition: all 0.3s ease;
}

.ab-status-label {
  white-space: nowrap;
}

/* Status States */
.ab-status-badge.status-saved {
  background: rgba(34, 197, 94, 0.12);
  color: var(--ab-success);
}
.ab-status-badge.status-saved .ab-status-dot {
  background: var(--ab-success);
}

.ab-status-badge.status-modified {
  background: rgba(245, 158, 11, 0.12);
  color: var(--ab-warning);
}
.ab-status-badge.status-modified .ab-status-dot {
  background: var(--ab-warning);
  animation: ab-pulse 1.5s infinite;
}

.ab-status-badge.status-saving {
  background: rgba(139, 92, 246, 0.12);
  color: var(--ab-primary);
}
.ab-status-badge.status-saving .ab-status-dot {
  background: var(--ab-primary);
  animation: ab-spin 1s infinite linear;
}

@keyframes ab-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes ab-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════
   GROUPE D'ACTIONS
   ═══════════════════════════════════════════════════════════════ */
.ab-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ═══════════════════════════════════════════════════════════════
   BOUTONS
   ═══════════════════════════════════════════════════════════════ */
.ab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  border: none;
  border-radius: var(--ab-radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  background: transparent;
  color: var(--ab-text);
  white-space: nowrap;
}

.ab-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ab-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.ab-btn-label {
  /* Visible par défaut, masqué en responsive */
}

/* Bouton Deployer */
.ab-btn-deploy {
  background: linear-gradient(135deg, var(--ab-primary), #7c3aed);
  color: white;
  box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.ab-btn-deploy:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--ab-primary-hover), #8b5cf6);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.ab-btn-deploy:active:not(:disabled) {
  transform: translateY(0);
}

/* Bouton Sauvegarder */
.ab-btn-save {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.ab-btn-save:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

.ab-btn-save.has-changes {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--ab-warning);
}

.ab-btn-save.has-changes:hover:not(:disabled) {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
}

/* Bouton Reset */
.ab-btn-reset {
  width: 32px;
  height: 32px;
  padding: 0;
  background: rgba(255, 255, 255, 0.04);
  color: var(--ab-text-muted);
}

.ab-btn-reset:hover {
  background: rgba(239, 68, 68, 0.12);
  color: var(--ab-danger);
}

/* Spinner */
.ab-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: ab-spin 0.7s infinite linear;
}

/* Bouton Recentrer */
.ab-btn-recenter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(139, 92, 246, 0.15);
  color: var(--ab-primary);
  cursor: pointer;
  transition: all 0.15s ease;
  margin-left: 4px;
}

.ab-btn-recenter svg {
  width: 14px;
  height: 14px;
}

.ab-btn-recenter:hover {
  background: rgba(139, 92, 246, 0.25);
  transform: scale(1.1);
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE - Tablette (900px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .ab-btn-label {
    display: none;
  }

  .ab-btn {
    padding: 8px;
  }

  .ab-btn-reset {
    width: 32px;
    height: 32px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE - Mobile (600px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
  .action-bar-v2 {
    gap: 8px;
    padding: 6px 10px;
    border-radius: 10px;
  }

  .ab-status-label {
    display: none;
  }

  .ab-status-badge {
    padding: 6px;
    border-radius: 50%;
  }

  .ab-status-dot {
    width: 8px;
    height: 8px;
  }

  .ab-actions {
    gap: 4px;
  }

  .ab-btn {
    padding: 6px;
  }

  .ab-icon {
    width: 18px;
    height: 18px;
  }

  .ab-btn-reset {
    width: 30px;
    height: 30px;
  }

  .ab-drag-handle {
    width: 12px;
  }

  .ab-drag-handle svg {
    width: 10px;
    height: 14px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE - Très petit écran (400px)
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 400px) {
  .action-bar-v2 {
    gap: 6px;
    padding: 5px 8px;
  }

  .ab-icon {
    width: 16px;
    height: 16px;
  }

  .ab-btn-reset {
    width: 28px;
    height: 28px;
  }

  .ab-btn-recenter {
    width: 24px;
    height: 24px;
  }

  .ab-btn-recenter svg {
    width: 12px;
    height: 12px;
  }
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE - Éviter le chevauchement avec la sidebar
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  .action-bar-v2 {
    /* Force visibility on mobile - NO !important on positioning to allow drag */
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: fixed !important;
    max-width: calc(100vw - 20px); /* Leave margin on sides */
    /* Prevent text selection and touch callout on mobile */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    touch-action: none; /* Critical for drag on mobile */
  }

  /* Default position (centered) - only when NOT custom */
  .action-bar-v2:not(.is-custom-position) {
    left: 50%;
    transform: translateX(-50%);
    bottom: 80px; /* Above the mobile sidebar (56px visible) */
  }

  /* Custom position - inline styles from Vue will apply */
  .action-bar-v2.is-custom-position {
    /* No positioning here - let inline styles work */
  }
}

/* ═══════════════════════════════════════════════════════════════
   CONTENT PADDING - Espace pour la barre
   ═══════════════════════════════════════════════════════════════ */
.content-panel {
  padding-bottom: 80px !important;
}

@media (max-width: 767px) {
  .content-panel {
    padding-bottom: 140px !important;
  }
}
