/**
 * Settings View Styles
 *
 * Styles pour le panneau de configuration organisé par plugin
 * - Overlay modal
 * - Onglets latéraux
 * - Formulaires générés dynamiquement
 * - Notifications toast
 */

/* ==========================================================================
   Settings View Container
   ========================================================================== */

.settings-view {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: none;
}

.settings-view.visible {
  display: block;
}

/* Overlay */
.settings-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  cursor: pointer;
}

/* Panel principal */
.settings-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 1200px;
  height: 80vh;
  max-height: 800px;
  background: var(--bg-primary, #ffffff);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ==========================================================================
   Header
   ========================================================================== */

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color, #e0e0e0);
  background: var(--bg-secondary, #f9f9f9);
}

.settings-header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary, #333);
}

.btn-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-secondary, #666);
  font-size: 20px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close:hover {
  background: var(--bg-hover, #f0f0f0);
  color: var(--text-primary, #333);
}

/* ==========================================================================
   Body (Tabs + Content)
   ========================================================================== */

.settings-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ==========================================================================
   Tabs (Sidebar)
   ========================================================================== */

.settings-tabs {
  width: 220px;
  background: var(--bg-secondary, #f9f9f9);
  border-right: 1px solid var(--border-color, #e0e0e0);
  overflow-y: auto;
  padding: 12px 0;
}

.settings-tab {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 20px;
  border: none;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--text-secondary, #666);
  font-size: 14px;
  transition: all 0.2s;
  position: relative;
}

.settings-tab:hover {
  background: var(--bg-hover, #f0f0f0);
  color: var(--text-primary, #333);
}

.settings-tab.active {
  background: var(--bg-primary, #ffffff);
  color: var(--accent-color, #007bff);
  font-weight: 500;
}

.settings-tab.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent-color, #007bff);
}

.settings-tab.no-config {
  opacity: 0.5;
  cursor: not-allowed;
}

.settings-tab[disabled] {
  pointer-events: none;
}

.tab-icon {
  font-size: 18px;
  width: 20px;
  text-align: center;
}

.tab-label {
  flex: 1;
}

.tab-badge {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--badge-bg, #e0e0e0);
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ==========================================================================
   Content Area
   ========================================================================== */

.settings-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.settings-tab-content {
  display: none;
}

.settings-tab-content.active {
  display: block;
}

.settings-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary, #666);
}

.plugin-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.plugin-settings-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary, #333);
}

/* ==========================================================================
   Forms (Generated by JSONSchemaFormBuilder)
   ========================================================================== */

.json-schema-form {
  max-width: 800px;
}

.form-title {
  margin: 0 0 8px 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary, #333);
}

.form-description {
  margin: 0 0 24px 0;
  color: var(--text-secondary, #666);
  font-size: 14px;
  line-height: 1.5;
}

.form-fields {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 24px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary, #333);
}

.form-label .required {
  color: var(--error-color, #dc3545);
  margin-left: 2px;
}

.form-field-description {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary, #666);
  line-height: 1.4;
}

/* Input styles */
.form-input,
.form-textarea,
.form-select {
  padding: 10px 12px;
  border: 1px solid var(--border-color, #e0e0e0);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary, #333);
  background: var(--bg-primary, #ffffff);
  transition: all 0.2s;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--accent-color, #007bff);
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

/* Input error state */
.form-input.error,
.form-textarea.error,
.form-select.error {
  border-color: var(--error-color, #dc3545);
  background-color: rgba(220, 53, 69, 0.05);
}

.form-input.error:focus,
.form-textarea.error:focus,
.form-select.error:focus {
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

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

/* Checkbox */
.form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-checkbox-input {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

/* Array fields */
.form-array {
  border: 1px solid var(--border-color, #e0e0e0);
  border-radius: 6px;
  padding: 16px;
  background: var(--bg-secondary, #f9f9f9);
}

.form-array-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.form-array-item {
  display: flex;
  gap: 8px;
  align-items: center;
}

.form-array-item .form-input {
  flex: 1;
}

.btn-add-item,
.btn-remove-item {
  padding: 8px 12px;
  font-size: 13px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Object fields */
.form-object {
  border-left: 3px solid var(--accent-color, #007bff);
  padding-left: 16px;
  margin-left: 8px;
}

/* ==========================================================================
   Footer
   ========================================================================== */

.settings-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--border-color, #e0e0e0);
  background: var(--bg-secondary, #f9f9f9);
}

/* Form actions (inside forms) */
.form-actions {
  display: flex;
  gap: 12px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color, #e0e0e0);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: var(--accent-color, #007bff);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover, #0056b3);
}

.btn-secondary {
  background: var(--bg-secondary, #f0f0f0);
  color: var(--text-primary, #333);
  border: 1px solid var(--border-color, #e0e0e0);
}

.btn-secondary:hover {
  background: var(--bg-hover, #e0e0e0);
}

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

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

/* ==========================================================================
   Notifications
   ========================================================================== */

.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  font-size: 14px;
  z-index: 10000;
  opacity: 0;
  transform: translateX(400px);
  transition: all 0.3s ease;
  max-width: 400px;
}

.notification.visible {
  opacity: 1;
  transform: translateX(0);
}

.notification-success {
  background: #d4edda;
  color: #155724;
  border-left: 4px solid #28a745;
}

.notification-error {
  background: #f8d7da;
  color: #721c24;
  border-left: 4px solid #dc3545;
}

.notification-warning {
  background: #fff3cd;
  color: #856404;
  border-left: 4px solid #ffc107;
}

.notification-info {
  background: #d1ecf1;
  color: #0c5460;
  border-left: 4px solid #17a2b8;
}

/* ==========================================================================
   Dark Mode Support
   ========================================================================== */

@media (prefers-color-scheme: dark) {
  .settings-panel {
    --bg-primary: #1e1e1e;
    --bg-secondary: #2d2d2d;
    --bg-hover: #3d3d3d;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --border-color: #404040;
    --accent-color: #4d9fff;
    --accent-hover: #3a8eef;
  }

  .settings-overlay {
    background: rgba(0, 0, 0, 0.7);
  }
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
  .settings-panel {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }

  .settings-body {
    flex-direction: column;
  }

  .settings-tabs {
    width: 100%;
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-bottom: 1px solid var(--border-color, #e0e0e0);
    padding: 0;
  }

  .settings-tab {
    flex-shrink: 0;
    padding: 12px 16px;
  }

  .settings-tab.active::before {
    left: auto;
    right: auto;
    top: auto;
    bottom: 0;
    width: auto;
    height: 3px;
    left: 0;
    right: 0;
  }

  .settings-content {
    padding: 16px;
  }

  .json-schema-form {
    max-width: 100%;
  }

  .settings-footer {
    flex-direction: column;
    align-items: stretch;
  }

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