/**
 * Configuration OS / Versions - Styles
 */

:root {
  --bg: #0f1419;
  --panel: #1a1f2e;
  --border: #2d3548;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --purple: #8b5cf6;
  --header-height: 56px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  min-height: 100vh;
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
  max-width: 800px;
  margin: 0 auto;
  padding: calc(var(--header-height) + 2rem) 1.5rem 6rem;
}

/* ============================================
   Page Header
   ============================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.page-header-left h1 {
  font-size: 1.375rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.page-header-left h1 i {
  color: var(--purple);
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.page-header-right {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ============================================
   Buttons
   ============================================ */
.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

.btn-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--panel);
  border-color: var(--border);
  color: var(--text-muted);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
  color: var(--text);
}

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

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

/* ============================================
   OS Config Wrapper
   ============================================ */
.os-config-wrapper {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.os-config-list {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.os-loading, .os-error, .os-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.os-error {
  color: var(--danger);
}

.os-error i, .os-loading i {
  font-size: 1.25rem;
}

/* ============================================
   OS Family Card
   ============================================ */
.os-family-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.os-family-card:hover {
  border-color: rgba(139, 92, 246, 0.3);
}

.os-family-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.625rem 0.75rem;
  background: rgba(139, 92, 246, 0.05);
  cursor: pointer;
  transition: background 0.2s;
}

.os-family-header:hover {
  background: rgba(139, 92, 246, 0.1);
}

.os-family-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.os-family-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.os-family-toggle i {
  font-size: 0.75rem;
  transition: transform 0.2s;
}

.os-family-name-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.os-family-name {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  padding: 0.25rem 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  transition: border-color 0.2s;
  min-width: 0;
}

.os-family-name:hover {
  border-bottom-color: var(--border);
}

.os-family-name:focus {
  outline: none;
  border-bottom-color: var(--purple);
}

.os-family-name::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.os-family-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 0.1875rem 0.5rem;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
}

.os-family-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  opacity: 0;
  transition: all 0.2s;
  flex-shrink: 0;
}

.os-family-header:hover .os-family-delete {
  opacity: 1;
}

.os-family-delete:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

/* ============================================
   Drag Handle
   ============================================ */
.os-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: var(--text-muted);
  cursor: grab;
  opacity: 0.4;
  transition: all 0.2s;
  flex-shrink: 0;
}

.os-drag-handle:hover {
  opacity: 1;
  color: var(--purple);
}

.os-drag-handle:active {
  cursor: grabbing;
}

.os-drag-handle-sm {
  width: 20px;
  height: 20px;
  font-size: 0.75rem;
}

/* Drag & Drop States */
.os-family-card.dragging {
  opacity: 0.5;
  border-color: var(--purple) !important;
}

/* Effet d'espacement pour indiquer la position de drop */
.os-family-card.drag-space-above {
  margin-top: 40px;
  transition: margin 0.15s ease-out;
}

.os-family-card.drag-space-below {
  margin-bottom: 40px;
  transition: margin 0.15s ease-out;
}

.os-version-item.dragging {
  opacity: 0.5;
}

.os-version-item.drag-space-above {
  margin-top: 28px;
  transition: margin 0.15s ease-out;
}

.os-version-item.drag-space-below {
  margin-bottom: 28px;
  transition: margin 0.15s ease-out;
}

/* ============================================
   OS Family Content (versions)
   ============================================ */
.os-family-content {
  border-top: 1px solid var(--border);
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
}

.os-versions-list {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-bottom: 0.5rem;
}

.os-version-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.os-version-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 0.4375rem 0.625rem;
  font-size: 0.8125rem;
  color: var(--text);
  transition: all 0.2s;
}

.os-version-input:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border);
}

.os-version-input:focus {
  outline: none;
  background: rgba(139, 92, 246, 0.05);
  border-color: rgba(139, 92, 246, 0.3);
}

.os-version-input::placeholder {
  color: var(--text-muted);
}

.os-version-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  opacity: 0;
  transition: all 0.15s;
  flex-shrink: 0;
}

.os-version-item:hover .os-version-delete {
  opacity: 0.7;
}

.os-version-delete:hover {
  opacity: 1 !important;
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.os-version-add {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 5px;
  padding: 0.375rem 0.625rem;
  margin-left: 0.875rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.os-version-add:hover {
  background: rgba(139, 92, 246, 0.1);
  border-color: var(--purple);
  color: var(--purple);
}

.os-version-add i {
  font-size: 0.625rem;
}

/* ============================================
   Add Family Button
   ============================================ */
.os-add-family-wrapper {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.btn-add-family {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.625rem 1rem;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-add-family:hover {
  background: rgba(139, 92, 246, 0.1);
  border-color: var(--purple);
  color: var(--purple);
}

/* ============================================
   Actions Bar (bas de page)
   ============================================ */
.os-actions-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1.5rem;
  background: var(--panel);
  border-top: 1px solid var(--border);
  z-index: 100;
}

.os-actions-left {
  flex: 1;
}

.status-message {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.status-message.warning {
  color: var(--warning);
}

.status-message.success {
  color: var(--success);
}

.status-message.error {
  color: var(--danger);
}

.os-actions-right {
  display: flex;
  gap: 0.5rem;
}

/* ============================================
   Toast
   ============================================ */
.toast {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.875rem;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success {
  border-color: var(--success);
  color: var(--success);
}

.toast.error {
  border-color: var(--danger);
  color: var(--danger);
}

/* ============================================
   Modale de Confirmation
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.modal-overlay.hidden {
  display: none;
}

.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: modalSlideIn 0.2s ease-out;
}

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

.modal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  border-radius: 12px 12px 0 0;
}

.modal-header.modal-warning {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(239, 68, 68, 0.1));
}

.modal-header.modal-warning i {
  color: var(--warning);
  font-size: 1.25rem;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.modal-body {
  padding: 1.25rem;
}

.modal-body p {
  color: var(--text-muted);
  font-size: 0.9375rem;
  line-height: 1.5;
  margin: 0;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.625rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
  border-radius: 0 0 12px 12px;
}

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

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
  border-color: #dc2626;
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 640px) {
  .main-content {
    padding: calc(var(--header-height) + 1rem) 1rem 5rem;
  }

  .page-header {
    flex-direction: column;
    gap: 1rem;
  }

  .page-header-right {
    width: 100%;
    justify-content: flex-end;
  }

  .os-actions-bar {
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
  }

  .os-actions-left {
    width: 100%;
    text-align: center;
  }

  .os-actions-right {
    width: 100%;
    justify-content: center;
  }
}
