/* Basic Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Nunito', sans-serif;
  transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease;
}

:root {
  --primary: #084A69;
  --text-light: #333;
  --text-dark: #f1f5f9;
  --bg-light: #fff;
  --bg-dark: #1e293b;
  --border-light: #e2e8f0;
  --border-dark: #4a5568;
}

body {
  background: linear-gradient(135deg, #83a8df, #c3cfe2);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  transition: background 0.5s ease;
}

body.dark-mode {
  background: linear-gradient(135deg, #2c3e50, #4a6491);
}

.container {
  background-color: var(--bg-light);
  border-radius: 1rem;
  padding: 2rem;
  width: 100%;
  max-width: 900px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  transition: all 0.5s ease;
}

body.dark-mode .container {
  background-color: var(--bg-dark);
  color: var(--text-dark);
}

h1 {
  text-align: center;
  margin-bottom: 1.5rem;
  color: var(--text-light);
  position: relative;
  padding-bottom: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

body.dark-mode h1 {
  color: var(--text-dark);
}

h1::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 50%;
  height: 3px;
  background-color: var(--primary);
  border-radius: 2px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  justify-content: center;
  align-items: center;
}

.btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.8rem 1.5rem;
  border-radius: 50px;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  letter-spacing: 0.5px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(8, 74, 105, 0.3);
}

.btn:active {
  transform: translateY(0);
}

#save-btn {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--text-light);
}

body.dark-mode #save-btn {
  color: var(--text-dark);
}

#save-btn:hover {
  background: var(--primary);
  color: white;
}

.theme-toggle {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: var(--bg-light);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.5s ease;
  font-size: 1.1rem;
}

body.dark-mode .theme-toggle {
  background: var(--bg-dark);
  color: var(--text-dark);
}

.scheme-selector {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.scheme-btn {
  padding: 0.5rem 1rem;
  border-radius: 30px;
  border: 2px solid var(--primary);
  background: transparent;
  cursor: pointer;
  color: var(--text-light);
  transition: all 0.3s ease;
  font-weight: 600;
  font-size: 0.9rem;
}

.scheme-btn.active {
  background: var(--primary);
  color: white;
  border-color: transparent;
}

body.dark-mode .scheme-btn {
  color: var(--text-dark);
}

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

.color-box {
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
  position: relative;
  transition: all 0.3s ease;
}

.color-box.copied {
  animation: pulse 0.5s ease;
}

.color-box:hover {
  transform: translateY(-5px);
}

.color {
  height: 120px;
  cursor: pointer;
  position: relative;
  transition: background-color 0.5s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.lock-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
  opacity: 0;
  color: #fff;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.7);
  transition: opacity 0.3s ease;
}

.color-box:hover .lock-btn {
  opacity: 1;
}

.lock-btn.locked {
  opacity: 1;
  background: rgba(0, 0, 0, 0.4);
}

.contrast-label {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(0,0,0,0.3);
  color: white;
  padding: 0.2rem 0.5rem;
  border-radius: 20px;
  font-size: 0.7rem;
  display: none;
}

.show-contrast .contrast-label {
  display: block;
}

.contrast-good {
  background: rgba(40, 167, 69, 0.8);
}

.contrast-bad {
  background: rgba(220, 53, 69, 0.8);
}

.color-info {
  background-color: var(--bg-light);
  padding: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--text-light);
  transition: all 0.5s ease;
}

body.dark-mode .color-info {
  background-color: #2d3748;
  color: var(--text-dark);
}

.hex-value {
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
}

.copy-btn {
  cursor: pointer;
  color: #64748b;
  transition: color 0.2s;
}

.copy-btn:hover {
  color: var(--primary);
}

.saved-palettes {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-light);
  transition: all 0.5s ease;
}

body.dark-mode .saved-palettes {
  border-top: 1px solid var(--border-dark);
}

.saved-palettes h2 {
  margin-bottom: 1rem;
  text-align: center;
  font-weight: 700;
}

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

.saved-palette {
  border: 1px solid var(--border-light);
  border-radius: 0.5rem;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: all 0.3s ease;
}

body.dark-mode .saved-palette {
  border-color: var(--border-dark);
}

.saved-palette:hover {
  transform: translateY(-3px);
}

.saved-colors {
  display: flex;
  height: 50px;
}

.saved-color {
  flex: 1;
}

.saved-palette p {
  text-align: center;
  padding: 0.5rem;
  font-size: 0.8rem;
  margin: 0;
  background-color: var(--bg-light);
  color: var(--text-light);
  transition: all 0.5s ease;
  font-weight: 600;
}

body.dark-mode .saved-palette p {
  background-color: #2d3748;
  color: var(--text-dark);
}

.saved-palette .delete-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e53e3e;
  opacity: 0;
  transition: opacity 0.3s ease;
  font-size: 0.9rem;
}

.saved-palette:hover .delete-btn {
  opacity: 1;
}

.export-options {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.export-btn {
  background: #e2e8f0;
  border: none;
  padding: 0.5rem 1.2rem;
  border-radius: 30px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text-light);
  transition: all 0.3s ease;
  font-weight: 600;
}

body.dark-mode .export-btn {
  background: #4a5568;
  color: var(--text-dark);
}

.export-btn:hover {
  background: var(--primary);
  color: white;
  transform: translateY(-2px);
}

.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #48bb78;
  color: white;
  padding: 0.8rem 1.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  transform: translateX(110%);
  transition: transform 0.3s ease, opacity 0.3s ease;
  opacity: 0;
  z-index: 1000;
  font-weight: 600;
}

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

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

@media (max-width: 768px) {
  .palette-container {
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  }
  .controls {
    flex-direction: column;
  }
  .export-btn {
    padding: 0.5rem 1rem;
  }
}

/* Adaptive Design */
@media (max-width: 768px) {
  body {
    padding: 10px;
    display: block;
  }
  
  .container {
    padding: 1.2rem;
    border-radius: 12px;
    max-width: 100%;
    margin: 0 auto;
  }
  
  h1 {
    font-size: 1.6rem;
    margin-bottom: 1.2rem;
    padding-bottom: 0.4rem;
  }
  
  .controls {
    flex-direction: column;
    gap: 0.8rem;
    margin-bottom: 1.2rem;
  }
  
  .btn {
    width: 100%;
    padding: 0.9rem;
    font-size: 1rem;
    justify-content: center;
    border-radius: 10px;
  }
  
  .scheme-selector {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }
  
  .scheme-btn {
    padding: 0.6rem 0.5rem;
    font-size: 0.85rem;
    text-align: center;
    border-radius: 8px;
    white-space: nowrap;
  }
  
  .palette-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
  }
  
  .color {
    height: 130px;
    border-radius: 8px;
  }
  
  .color-info {
    padding: 0.6rem;
    font-size: 0.85rem;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
  }
  
  .hex-value {
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70px;
  }
  
  .export-options {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 10px;
    justify-content: flex-start;
    -webkit-overflow-scrolling: touch;
  }
  
  .export-btn {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    flex: 0 0 auto;
    border-radius: 8px;
  }
  
  .saved-palettes {
    margin-top: 1.5rem;
    padding-top: 1rem;
  }
  
  .saved-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
  }
  
  .saved-colors {
    height: 40px;
  }
  
  .saved-palette p {
    font-size: 0.8rem;
    padding: 0.5rem;
  }
  
  .theme-toggle {
    top: 0.8rem;
    right: 0.8rem;
    width: 36px;
    height: 36px;
    font-size: 1rem;
    background: rgba(255,255,255,0.8);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  }
  
  body.dark-mode .theme-toggle {
    background: rgba(30, 41, 59, 0.8);
  }
  
  .notification {
    top: 10px;
    left: 5%;
    right: 5%;
    width: 90%;
    text-align: center;
    padding: 0.8rem;
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 1rem;
  }
  
  h1 {
    font-size: 1.4rem;
    padding-top: 0.5rem;
  }
  
  h1::after {
    width: 70%;
  }
  
  .btn {
    padding: 0.8rem;
  }
  
  .scheme-selector {
    grid-template-columns: 1fr;
  }
  
  .palette-container {
    grid-template-columns: 1fr;
  }
  
  .color {
    height: 150px;
  }
  
  .export-options {
    gap: 0.4rem;
  }
  
  .export-btn {
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
  }
  
  .saved-container {
    grid-template-columns: 1fr;
  }
  
  .saved-palette p {
    padding: 0.6rem;
  }
  
  .theme-toggle {
    top: 0.5rem;
    right: 0.5rem;
  }
}

/* Horizontal orientation */
@media (max-width: 768px) and (orientation: landscape) {
  .container {
    max-width: 95%;
    padding: 1rem;
  }
  
  .controls {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .btn {
    flex: 1 0 45%;
    min-width: 0;
  }
  
  #generate-btn, #save-btn {
    order: -1;
  }
  
  .scheme-selector {
    grid-template-columns: repeat(3, 1fr);
    order: 1;
    width: 100%;
    margin-top: 0.5rem;
  }
  
  .palette-container {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .saved-container {
    grid-template-columns: repeat(2, 1fr);
  }
}