/* ========== Estilos Gerais ========== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

.page-header {
  text-align: center;
  margin-bottom: 3rem;
}

.page-header h1 {
  font-size: 2.5rem;
  color: #023e8a;
  margin-bottom: 0.5rem;
}

.page-header p {
  font-size: 1.1rem;
  color: #6c757d;
}

.tool-card {
  background: white;
  border-radius: 16px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.tool-card h2 {
  color: #023e8a;
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
}

/* ========== Color Picker ========== */
.color-picker-container {
  display: grid;
  /* duas colunas: preview à esquerda (fixa) + controles à direita (flex) */
  grid-template-columns: 200px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.color-display {
  display: flex;
  gap: 2rem;
  align-items: center;
}

.color-preview {
  width: 200px;
  height: 200px;
  border-radius: 12px;
  background: #3B82F6;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: 3px solid #e0e0e0;
}

.color-info {
  flex: 1;
}

.color-code {
  font-size: 2rem;
  font-weight: 700;
  color: #023e8a;
  margin-bottom: 1rem;
  font-family: 'Courier New', monospace;
}

.color-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.copy-btn, .random-btn, .favorite-btn {
  background: linear-gradient(135deg, #0077b6, #00a8e8);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Ensure buttons don't wrap their content and use box-sizing for JS width adjustments */
.color-actions button {
  white-space: nowrap;
  box-sizing: border-box;
  transition: width 120ms ease;
  /* allow flex-based sizing by default */
  flex: 1 1 auto;
  min-width: 0;
}

.copy-btn:hover, .random-btn:hover, .favorite-btn:hover {
  transform: translateY(-2px);
}

.random-btn {
  background: linear-gradient(135deg, #28a745, #20c997);
}

.favorite-btn {
  background: linear-gradient(135deg, #dc3545, #e74c3c);
}

/* Botão Gradiente Aleatório (magenta) */
.random-grad-btn {
  background: linear-gradient(135deg, #ff00c8, #9b00ff);
  color: white;
  border: none;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.random-grad-btn:hover { transform: translateY(-2px); }

/* ========== Cores Favoritas ========== */
.favorites-controls {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.clear-favorites-btn {
  background: #dc3545;
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background 0.3s;
}

.clear-favorites-btn:hover {
  background: #c82333;
}

.favorites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 1rem;
}

.favorite-item {
  background: white;
  border: 2px solid #e0e0e0;
  padding: 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
}

.favorite-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-color: #0077b6;
}

.favorite-color-preview {
  width: 100%;
  height: 60px;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  border: 2px solid #e0e0e0;
}

.favorite-color-code {
  text-align: center;
  font-family: 'Courier New', monospace;
  font-weight: 700;
  font-size: 0.9rem;
  color: #023e8a;
  margin-bottom: 0.5rem;
}

.delete-favorite-btn {
  width: 100%;
  background: #dc3545;
  color: white;
  border: none;
  padding: 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.3s;
}

.delete-favorite-btn:hover {
  background: #c82333;
}

.picker-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  /* posicionar abaixo do preview e das ações (ocupar as duas colunas) */
  grid-column: 1 / -1;
}
.picker-controls .input-group {
  display: flex;
  flex-direction: column;
}
.picker-controls .input-group:first-child {
  /* HEX: 30% maior que os demais */
  flex: 1.3 1 0;
}
.picker-controls .input-group:not(:first-child) {
  /* R/G/B com mesma proporção entre si */
  flex: 1 1 0;
}
.picker-controls .input-group label::after {
  content: ':';
  margin-left: 4px;
}
.picker-controls .input-group input {
  width: 100%;
  box-sizing: border-box;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.input-group label {
  font-weight: 600;
  color: #023e8a;
}

.input-group input {
  padding: 0.75rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1rem;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.3s ease;
}

.input-group input:focus {
  outline: none;
  border-color: #0077b6;
}

.input-group select {
  padding: 0.75rem !important;
  border: 2px solid #e0e0e0 !important;
  border-radius: 8px !important;
  font-size: 1rem !important;
  font-family: 'Inter', sans-serif !important;
  background: white !important;
  cursor: pointer;
  transition: border-color 0.3s ease;
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23023e8a' d='M10.293 3.293L6 7.586 1.707 3.293A1 1 0 00.293 4.707l5 5a1 1 0 001.414 0l5-5a1 1 0 10-1.414-1.414z'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 0.75rem center !important;
  background-size: 12px !important;
  padding-right: 2.5rem !important;
}

.input-group select:focus {
  outline: none;
  border-color: #0077b6;
}

.input-group select:hover {
  border-color: #00a8e8;
}

/* Estilos globais para select (caso não esteja em input-group) */
select {
  padding: 0.75rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1rem;
  font-family: 'Inter', sans-serif;
  background: white;
  cursor: pointer;
  transition: border-color 0.3s ease;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23023e8a' d='M10.293 3.293L6 7.586 1.707 3.293A1 1 0 00.293 4.707l5 5a1 1 0 001.414 0l5-5a1 1 0 10-1.414-1.414z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 12px;
  padding-right: 2.5rem;
}

select:focus {
  outline: none;
  border-color: #0077b6;
}

select:hover {
  border-color: #00a8e8;
}

.sliders {
  display: grid;
  gap: 1.5rem;
  /* garantir que os sliders ocupem toda a largura da área do picker abaixo
     dos elementos anteriores (span das duas colunas) */
  grid-column: 1 / -1;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.slider-group label {
  font-weight: 600;
  color: #023e8a;
}

.slider {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  outline: none;
  background: #c0c0c0;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  border: 3px solid #0077b6;
  cursor: pointer;
}

.slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  border: 3px solid #0077b6;
  cursor: pointer;
}

.slider::-moz-range-track {
  background: #c0c0c0;
  height: 8px;
  border-radius: 4px;
}

.slider.red {
  background: linear-gradient(to right, #000, #f00);
}

.slider.green {
  background: linear-gradient(to right, #000, #0f0);
}

.slider.blue {
  background: linear-gradient(to right, #000, #00f);
}

/* ========== Conversor ========== */
.converter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.format-box {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.format-box label {
  font-weight: 600;
  color: #023e8a;
}

.input-with-copy {
  display: flex;
  gap: 0.5rem;
}

.input-with-copy input {
  flex: 1;
  padding: 0.75rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  background: #f8f9fa;
}

.input-with-copy button {
  background: #0077b6;
  color: white;
  border: none;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  cursor: pointer;
}

/* ========== Ajustes ========== */
.adjustment-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.adjust-btn {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  padding: 1rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.shades-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.shade-item {
  aspect-ratio: 1;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ========== Paletas ========== */
.palette-controls {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.palette-btn {
  background: #0077b6;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.palette-display {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
}

.palette-color {
  aspect-ratio: 1;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.palette-color span {
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.875rem;
  font-family: 'Courier New', monospace;
}

/* ========== WCAG ========== */
.wcag-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.color-pair {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.color-input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.color-input-wrapper {
  display: flex;
  gap: 0.5rem;
}

.color-input-wrapper input[type="color"] {
  width: 60px;
  height: 50px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.color-input-wrapper input[type="text"] {
  flex: 1;
  padding: 0.75rem;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
}

.check-btn {
  background: linear-gradient(135deg, #0077b6, #00a8e8);
  color: white;
  border: none;
  padding: 1rem 2rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 1.1rem;
  cursor: pointer;
  align-self: flex-start;
}

.contrast-result {
  padding: 1.5rem;
  border-radius: 8px;
  border: 2px solid #e0e0e0;
  background: #f8f9fa;
}

.contrast-ratio {
  font-size: 2rem;
  font-weight: 700;
  color: #023e8a;
  margin-bottom: 1rem;
}

.wcag-level {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  margin: 0.5rem 0;
}

.wcag-level.pass {
  color: #28a745;
}

.wcag-level.fail {
  color: #dc3545;
}

/* ========== Export ========== */
.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.export-box {
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 1.5rem;
}

.export-box h3 {
  color: #023e8a;
  margin-bottom: 1rem;
}

.export-box pre {
  background: #f8f9fa;
  padding: 1rem;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  overflow-x: auto;
  margin-bottom: 1rem;
}

.export-box button {
  background: #0077b6;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
}

/* ========== Gradientes ========== */
.gradient-preview {
  width: 100%;
  height: 400px;
  border-radius: 12px;
  background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.preview-controls {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.export-svg-btn {
  background: linear-gradient(135deg, #28a745, #20c997);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.export-svg-btn:hover {
  transform: translateY(-2px);
}

.gradient-favorites-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.favorite-gradient-item {
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}

.favorite-gradient-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-color: #0077b6;
}

.favorite-gradient-preview {
  width: 100%;
  height: 120px;
  border-radius: 8px 8px 0 0;
}

.favorite-gradient-item .delete-favorite-btn {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: #dc3545;
  color: white;
  border: none;
  padding: 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.3s;
  border-radius: 0 0 6px 6px;
}

.favorite-gradient-item .delete-favorite-btn:hover {
  background: #c82333;
}

.gradient-type-selector {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
}

.type-btn {
  flex: 1;
  background: #f8f9fa;
  border: 2px solid #e0e0e0;
  padding: 1rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.type-btn.active {
  background: linear-gradient(135deg, #0077b6, #00a8e8);
  color: white;
  border-color: #0077b6;
}

.controls-section {
  margin-bottom: 2rem;
}

.color-stops-section {
  margin-top: 2rem;
}

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

.add-color-btn {
  background: #28a745;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}

.color-stops-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.color-stop-item {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 8px;
}

.color-stop-item input[type="color"] {
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.color-stop-item input[type="range"] {
  flex: 1;
}

.color-stop-item button {
  background: #dc3545;
  color: white;
  border: none;
  padding: 0.75rem;
  border-radius: 8px;
  cursor: pointer;
}

.presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}

.preset-btn {
  background: white;
  border: 2px solid #e0e0e0;
  padding: 1rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: transform 0.2s;
}

.preset-btn:hover {
  transform: translateY(-4px);
}

.preset-preview {
  width: 100%;
  height: 80px;
  border-radius: 8px;
}

.preset-btn span {
  font-weight: 600;
  text-align: center;
}

.preset-btn span small {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: #6c757d;
  margin-top: 0.25rem;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .color-display {
    flex-direction: column;
  }
  
  .color-preview {
    width: 100%;
    height: 150px;
  }
  
  .picker-controls {
    grid-template-columns: 1fr 1fr;
  }
}

/* Mobile: stack action buttons full width for easy tapping */
@media (max-width: 768px) {
  .color-actions {
    flex-direction: column;
  }
  .color-actions button {
    width: 100% !important;
    flex: 0 0 auto !important;
  }
}

/* Força tamanho fixo em desktop para evitar sobrescritas acidentais */
@media (min-width: 769px) {
  .color-preview {
    width: 200px !important;
    height: 200px !important;
    min-width: 200px !important;
    flex: 0 0 200px !important;
  }
  .color-picker-container {
    grid-template-columns: 200px 1fr !important;
  }
}

/* Ajustes específicos para os color stops em mobile: colocar preview + hex
   em uma linha, e o slider + lixeira em outra linha para melhor usabilidade */
@media (max-width: 700px) {
  .color-stop-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    gap: 8px;
    align-items: center;
  }
  .color-stop-item > input[type="color"] {
    grid-column: 1;
    grid-row: 1;
    width: 48px;
    height: 36px;
    padding: 0;
  }
  .color-stop-item > input[type="text"] {
    grid-column: 2;
    grid-row: 1;
    width: 100%;
    padding: 0.5rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    box-sizing: border-box;
  }
  .color-stop-item > span {
    grid-column: 3;
    grid-row: 1;
    justify-self: start;
    white-space: nowrap;
  }
  .color-stop-item > input[type="range"] {
    grid-column: 1 / 3;
    grid-row: 2;
    width: 100%;
  }
  .color-stop-item > button {
    grid-column: 3;
    grid-row: 2;
    justify-self: end;
  }
}
