/* Edit Page Status Bar */
.edit-status-bar {
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  z-index: 999;
  background-color: #e8f0fe;
  color: #1a73e8;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.4rem 2rem;
  border-bottom: 1px solid #c6dafc;
}

.edit-status-bar:empty {
  display: none;
}

body.dark-mode .edit-status-bar {
  background-color: #1e2a3a;
  color: #8ab4f8;
  border-bottom-color: #2d3f54;
}

/* Edit Empty State */
.edit-empty-state {
  margin-top: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 100px);
}

/* Edit Container */
.edit-container {
  margin-top: 86px;
  max-width: 1500px;
  margin-left: auto;
  margin-right: auto;
  padding: 0.75rem 1.5rem 2rem;
}

/* Three-Column Layout */
.edit-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.edit-layout-left {
  width: 330px;
  flex-shrink: 0;
  position: sticky;
  top: 90px;
}

.edit-layout-center {
  flex: 1;
  min-width: 0;
}

.edit-layout-right {
  width: 280px;
  flex-shrink: 0;
  position: sticky;
  top: 90px;
}

/* Edit Card */
.edit-card {
  background-color: #ffffff;
  border: 1px solid #e5e5e7;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

body.dark-mode .edit-card {
  background-color: #2c2c2c;
  border-color: #555;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

/* Palette Header */
.edit-palette-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #e5e5e7;
}

body.dark-mode .edit-palette-header {
  border-bottom-color: #444;
}

.edit-palette-header-text {
  flex: 1;
}

.edit-palette-name {
  font-size: 1.5rem;
  font-weight: 600;
  color: #1d1d1f;
  outline: none;
  padding: 0.125rem 0.25rem;
  border-radius: 4px;
  margin-bottom: 0.25rem;
}

.edit-palette-name:hover,
.edit-palette-name:focus {
  background-color: #f0f0f2;
}

body.dark-mode .edit-palette-name {
  color: #ffffff;
}

body.dark-mode .edit-palette-name:hover,
body.dark-mode .edit-palette-name:focus {
  background-color: #3a3a3a;
}

.edit-palette-description {
  font-size: 0.875rem;
  color: #6e6e73;
  outline: none;
  padding: 0.125rem 0.25rem;
  border-radius: 4px;
}

.edit-palette-description:hover,
.edit-palette-description:focus {
  background-color: #f0f0f2;
}

body.dark-mode .edit-palette-description {
  color: #999;
}

body.dark-mode .edit-palette-description:hover,
body.dark-mode .edit-palette-description:focus {
  background-color: #3a3a3a;
}

/* Sections */
.edit-section {
  margin-bottom: 2rem;
}

.edit-section:last-of-type {
  margin-bottom: 1.5rem;
}

.edit-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.edit-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1d1d1f;
}

body.dark-mode .edit-section-title {
  color: #e5e5e7;
}

/* Swatches Row */
.edit-swatches-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.edit-swatch {
  width: 140px;
  height: 120px;
  border-radius: 10px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border: 2px solid transparent;
}

.edit-swatch:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.edit-swatch-hex {
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.edit-swatch-role {
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  opacity: 0.85;
}

.edit-swatch-edit-icon,
.edit-swatch-delete-icon {
  position: absolute;
  top: 6px;
  width: 24px;
  height: 24px;
  background-color: rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
  color: #333;
}

.edit-swatch-edit-icon {
  right: 6px;
}

.edit-swatch-delete-icon {
  left: 6px;
  color: #cc0000;
}

.edit-swatch-delete-icon:hover {
  background-color: rgba(255, 200, 200, 0.95);
}

.edit-swatch:hover .edit-swatch-edit-icon,
.edit-swatch:hover .edit-swatch-delete-icon {
  opacity: 1;
}

/* Add Swatch Button */
.edit-add-swatch {
  width: 140px;
  height: 120px;
  border-radius: 10px;
  border: 2px dashed #d2d2d7;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  color: #6e6e73;
  font-size: 0.8125rem;
  font-weight: 500;
  gap: 0.25rem;
}

.edit-add-swatch:hover {
  border-color: #0066cc;
  background-color: rgba(0, 102, 204, 0.04);
  color: #0066cc;
}

body.dark-mode .edit-add-swatch {
  border-color: #555;
  color: #999;
}

body.dark-mode .edit-add-swatch:hover {
  border-color: #3399ff;
  background-color: rgba(51, 153, 255, 0.08);
  color: #3399ff;
}

/* Roles Grid */
.edit-roles-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.edit-role-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid #e5e5e7;
  border-radius: 8px;
  background-color: #fafafa;
  transition: background-color 0.15s ease;
}

.edit-role-item:hover {
  background-color: #f0f0f2;
}

body.dark-mode .edit-role-item {
  border-color: #444;
  background-color: #333;
}

body.dark-mode .edit-role-item:hover {
  background-color: #3a3a3a;
}

.edit-role-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(0, 0, 0, 0.1);
}

body.dark-mode .edit-role-dot {
  border-color: rgba(255, 255, 255, 0.15);
}

.edit-role-info {
  flex: 1;
  min-width: 0;
}

.edit-role-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1d1d1f;
  text-transform: capitalize;
}

body.dark-mode .edit-role-name {
  color: #e5e5e7;
}

.edit-role-description {
  font-size: 0.75rem;
  color: #6e6e73;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

body.dark-mode .edit-role-description {
  color: #999;
}

.edit-role-select {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  border: 1px solid #d2d2d7;
  border-radius: 6px;
  background-color: #ffffff;
  color: #1d1d1f;
  cursor: pointer;
}

body.dark-mode .edit-role-select {
  background-color: #2c2c2c;
  color: #e0e0e0;
  border-color: #555;
}

/* WCAG Warning */
.wcag-warning {
  background-color: #fff3cd;
  color: #856404;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid #ffc107;
  margin-bottom: 0.75rem;
}

body.dark-mode .wcag-warning {
  background-color: #3d3213;
  color: #ffc107;
  border-color: #665a1e;
}

/* WCAG Legend */
.wcag-legend {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.8125rem;
  color: #6e6e73;
}

body.dark-mode .wcag-legend {
  color: #999;
}

.wcag-legend-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.wcag-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.wcag-compliant {
  background-color: #34c759;
}

.wcag-noncompliant {
  background-color: #ff3b30;
}

/* WCAG Table */
.wcag-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.wcag-table th {
  text-align: left;
  padding: 0.625rem 0.75rem;
  font-size: 0.6875rem;
  font-weight: 600;
  color: #6e6e73;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid #e5e5e7;
}

body.dark-mode .wcag-table th {
  color: #999;
  border-bottom-color: #444;
}

.wcag-table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid #f0f0f2;
  color: #1d1d1f;
}

body.dark-mode .wcag-table td {
  border-bottom-color: #3a3a3a;
  color: #e0e0e0;
}

.wcag-color-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.wcag-color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

body.dark-mode .wcag-color-swatch {
  border-color: rgba(255, 255, 255, 0.15);
}

.wcag-compliance-cell {
  font-weight: 600;
}

.wcag-compliance-cell.pass {
  color: #34c759;
}

.wcag-compliance-cell.fail {
  color: #ff3b30;
}

body.dark-mode .wcag-compliance-cell {
  font-weight: 600;
}

body.dark-mode .wcag-compliance-cell.pass {
  color: #34c759;
}

body.dark-mode .wcag-compliance-cell.fail {
  color: #ff3b30;
}

/* Tools Card */
.edit-tools-card {
  padding: 1.5rem 2rem;
}

.edit-tools-subtitle {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1d1d1f;
  margin-bottom: 0.75rem;
}

body.dark-mode .edit-tools-subtitle {
  color: #e5e5e7;
}

/* Color on Color Test */
.color-test-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.color-test-inputs {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.color-test-field {
  flex: 1;
}

.color-test-label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  color: #6e6e73;
}

body.dark-mode .color-test-label {
  color: #999;
}

.color-test-input-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.color-test-result {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  padding: 1rem;
  background: #fafafa;
  border-radius: 8px;
}

body.dark-mode .color-test-result {
  background: #333;
}

.color-test-swatch {
  width: 100%;
  height: 50px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
  border: 1px solid #d2d2d7;
}

body.dark-mode .color-test-swatch {
  border-color: #555;
}

.color-test-metrics {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: center;
}

.color-test-metric-label {
  font-size: 0.75rem;
  color: #6e6e73;
  margin-right: 0.5rem;
}

body.dark-mode .color-test-metric-label {
  color: #999;
}

.color-test-metric-value {
  font-size: 0.875rem;
  font-weight: 600;
}

.custom-color-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.form-input {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  background-color: #ffffff;
  color: #1d1d1f;
  flex: 1;
  min-width: 0;
  font-family: monospace;
}

body.dark-mode .form-input {
  background-color: #2c2c2c;
  color: #e0e0e0;
  border-color: #555;
}

.form-input:focus {
  outline: none;
  border-color: #0066cc;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

body.dark-mode .form-input:focus {
  border-color: #3399ff;
  box-shadow: 0 0 0 3px rgba(51, 153, 255, 0.2);
}

.custom-color-preview {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid #d2d2d7;
  background-color: transparent;
}

body.dark-mode .custom-color-preview {
  border-color: #555;
}

/* Color Converter */
.color-converter-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.color-converter-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.color-converter-row .form-input {
  flex: 1;
  min-width: 0;
}

.color-converter-row .edit-role-select {
  width: auto;
}

.color-converter-result {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  background-color: #f5f5f7;
  border-radius: 6px;
  font-size: 0.75rem;
  color: #6e6e73;
  min-height: 28px;
}

body.dark-mode .color-converter-result {
  background-color: #3a3a3a;
  color: #bbb;
}

.color-converter-preview {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.1);
  display: none;
}

body.dark-mode .color-converter-preview {
  border-color: rgba(255, 255, 255, 0.15);
}

.color-converter-preview.visible {
  display: block;
}

.color-converter-value {
  font-family: monospace;
  font-size: 0.75rem;
  word-break: break-all;
}

/* Edit Footer */
.edit-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding-top: 1.5rem;
  border-top: 1px solid #e5e5e7;
}

body.dark-mode .edit-footer {
  border-top-color: #444;
}

.edit-footer-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ==========================================
   Layout adjustments when preview panel is open
   ========================================== */

/* Hide the Tools sidebar when the preview panel is open */
body.preview-panel-open .edit-layout-right {
  display: none;
}

/* Shift the edit container to the left to make room for the 780px preview panel */
body.preview-panel-open .edit-container {
  margin-right: 800px; /* 780px panel + 20px breathing room */
  margin-left: 1rem;
  max-width: none;
  transition: margin 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* When preview is open, stack left sidebar above center card */
body.preview-panel-open .edit-layout {
  flex-direction: column;
}

body.preview-panel-open .edit-layout-left {
  width: 100%;
  position: static;
}

body.preview-panel-open .edit-roles-grid {
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

/* Smooth transition back when panel closes */
.edit-container {
  transition: margin 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              max-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Responsive */
@media (max-width: 1100px) {
  .edit-layout {
    flex-direction: column;
  }

  .edit-layout-left,
  .edit-layout-right {
    width: 100%;
    position: static;
  }

  .edit-roles-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }

  .color-test-container {
    flex-direction: row;
    align-items: center;
  }

  .color-test-inputs {
    flex-direction: row;
  }

  .color-test-result {
    flex-direction: row;
    align-items: center;
  }
}

@media (max-width: 768px) {
  .edit-container {
    padding: 1.5rem 1rem 3rem;
  }

  .edit-card {
    padding: 1.25rem;
  }

  .edit-swatches-row {
    justify-content: center;
  }

  .edit-swatch {
    width: 100px;
    height: 90px;
  }

  .edit-roles-grid {
    grid-template-columns: 1fr;
  }

  .wcag-table {
    font-size: 0.75rem;
  }

  .color-test-container {
    flex-direction: column;
    align-items: stretch;
  }

  .color-test-inputs {
    flex-direction: column;
  }
}

html {
  zoom: 0.9;
}