/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --danger-color: #ef4444;
  --danger-hover: #dc2626;
  --text-color: #1f2937;
  --text-light: #6b7280;
  --border-color: #e5e7eb;
  --bg-color: #f9fafb;
  --bg-light: #f3f4f6;
  --white: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius: 0.5rem;
  --radius-sm: 0.375rem;
  --transition: all 0.2s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--bg-color);
  min-height: 100vh;
}

/* Login Page */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background: linear-gradient(135deg, #f9fafb 0%, #eef2ff 100%);
}

.login-card {
  background-color: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  text-align: center;
  border: 1px solid var(--border-color);
}

.login-icon {
  width: 3.5rem;
  height: 3.5rem;
  background-color: var(--primary-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
}

.lock-icon {
  color: var(--primary-color);
  width: 1.75rem;
  height: 1.75rem;
}

.login-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-color);
}

.login-subtitle {
  color: var(--text-light);
  margin-bottom: 2rem;
}

.login-form {
  text-align: left;
}

.form-group {
  margin-bottom: 1.5rem;
}

.password-input {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  transition: var(--transition);
  background-color: var(--bg-light);
}

.password-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
  background-color: var(--white);
}

.error-message {
  color: var(--danger-color);
  font-size: 0.875rem;
  margin-top: 0.5rem;
  min-height: 1.25rem;
  font-weight: 500;
}

.login-button {
  width: 100%;
  padding: 0.875rem;
  background-color: var(--primary-color);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.login-button:hover {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

/* Editor Page */
.editor-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--bg-color);
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background-color: var(--white);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.editor-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-color);
}

.instructions-button {
  padding: 0.5rem 1rem;
  background-color: var(--primary-light);
  color: var(--primary-color);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.instructions-button:hover {
  background-color: var(--primary-color);
  color: var(--white);
}

.editor-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.canvas-area {
  flex: 1;
  padding: 1.5rem;
  background-color: var(--bg-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.canvas-container {
  background-color: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  max-height: calc(100vh - 130px);
}

#canvas-wrapper {
  position: relative;
  overflow: hidden;
  width: 800px;
  height: 800px;
}

#editor-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.tools-panel {
  width: 340px;
  border-left: 1px solid var(--border-color);
  background-color: var(--white);
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: -2px 0 5px rgba(0, 0, 0, 0.03);
}

.tabs {
  flex: 1;
}

.tabs-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.tab-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 0.5rem;
  background-color: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-light);
}

.tab-button:hover {
  background-color: var(--primary-light);
  color: var(--primary-color);
}

.tab-button.active {
  background-color: var(--primary-color);
  color: var(--white);
  border-color: var(--primary-color);
  box-shadow: var(--shadow-sm);
}

.tab-button .tab-icon {
  width: 1.25rem;
  height: 1.25rem;
}

.tab-button.active .tab-icon {
  color: var(--white);
}

.tab-content {
  display: none;
  margin-bottom: 1.5rem;
  background-color: var(--bg-light);
  padding: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-color);
}

.text-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  transition: var(--transition);
  background-color: var(--white);
}

.text-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.control-group {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1rem 0;
  padding: 0.75rem;
  background-color: var(--white);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.control-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background-color: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-light);
}

.control-button:hover {
  background-color: var(--primary-light);
  color: var(--primary-color);
}

.control-button.active {
  background-color: var(--primary-color);
  color: var(--white);
  border-color: var(--primary-color);
  box-shadow: var(--shadow-sm);
}

.control-button.active .control-icon {
  color: var(--white);
}

.color-picker-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
}

.color-input {
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
  border: 2px solid var(--border-color);
}

.color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-input::-webkit-color-swatch {
  border: none;
  border-radius: var(--radius-sm);
}

.slider-container {
  margin: 1rem 0;
  padding: 0.75rem;
  background-color: var(--white);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.slider {
  width: 100%;
  height: 0.5rem;
  background-color: var(--bg-light);
  border-radius: 1rem;
  outline: none;
  -webkit-appearance: none;
  margin-top: 0.5rem;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 1.25rem;
  height: 1.25rem;
  background-color: var(--primary-color);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.file-input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  background-color: var(--white);
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.875rem;
  background-color: var(--primary-color);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.primary-button:hover {
  background-color: var(--primary-hover);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.danger-button {
  width: 100%;
  padding: 0.875rem;
  background-color: var(--danger-color);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 0.75rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.danger-button:hover {
  background-color: var(--danger-hover);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.action-buttons {
  margin-top: auto;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.editor-footer {
  padding: 0.75rem;
  background-color: var(--white);
  border-top: 1px solid var(--border-color);
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-light);
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}

.modal.active {
  display: flex;
  animation: fadeIn 0.3s ease;
}

.modal-content {
  background-color: var(--white);
  padding: 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--text-color);
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.instructions-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.section-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.instruction-list {
  list-style-type: none;
  padding-left: 0.5rem;
}

.instruction-list li {
  margin-bottom: 0.75rem;
  padding-left: 1.5rem;
  position: relative;
}

.instruction-list li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--primary-color);
  font-weight: bold;
}

.modal-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-light);
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

/* Heading styles */
.heading-size-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.heading-size-value {
  font-weight: bold;
  color: var(--primary-color);
}

/* Button icon styles */
.button-icon {
  width: 1rem;
  height: 1rem;
}

/* File upload styling */
.file-upload-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius);
  background-color: var(--white);
  cursor: pointer;
  transition: var(--transition);
}

.file-upload-container:hover {
  border-color: var(--primary-color);
  background-color: var(--primary-light);
}

.file-upload-icon {
  color: var(--primary-color);
  width: 2.5rem;
  height: 2.5rem;
  margin-bottom: 1rem;
}

.file-upload-text {
  font-size: 0.875rem;
  color: var(--text-light);
  text-align: center;
}

.file-upload-input {
  display: none;
}

/* Layer Panel Styles */
.layer-panel {
  width: 340px;
  border-left: 1px solid var(--border-color);
  background-color: var(--white);
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: -2px 0 5px rgba(0, 0, 0, 0.03);
}

.layer-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.layer-panel-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-color);
}

.layer-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
  min-height: 100px;
}

.layer-item {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  background-color: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: move;
  transition: var(--transition);
  position: relative;
}

.layer-item.selected {
  background-color: var(--primary-light);
  border-color: var(--primary-color);
}

.layer-item:hover {
  border-color: var(--primary-color);
}

.layer-thumbnail {
  width: 40px;
  height: 40px;
  background-color: var(--white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 0.75rem;
  overflow: hidden;
}

.layer-thumbnail img {
  max-width: 100%;
  max-height: 100%;
}

.layer-thumbnail-icon {
  color: var(--text-light);
}

.layer-info {
  flex: 1;
}

.layer-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-color);
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.layer-type {
  font-size: 0.75rem;
  color: var(--text-light);
}

.layer-visibility {
  margin-left: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  transition: var(--transition);
}

.layer-visibility:hover {
  color: var(--primary-color);
}

.layer-visibility.hidden {
  color: var(--text-light);
  opacity: 0.5;
}

.layer-drag-placeholder {
  border: 2px dashed var(--primary-color);
  background-color: var(--primary-light);
  opacity: 0.5;
  height: 60px;
  border-radius: var(--radius-sm);
}

/* Save/Load Panel Styles */
.save-load-panel {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.save-load-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.save-button, .load-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.save-button {
  background-color: var(--primary-light);
  color: var(--primary-color);
  border: 1px solid var(--primary-color);
}

.save-button:hover {
  background-color: var(--primary-color);
  color: var(--white);
}

.load-button {
  background-color: var(--bg-light);
  color: var(--text-color);
  border: 1px solid var(--border-color);
}

.load-button:hover {
  background-color: var(--bg-color);
  border-color: var(--text-color);
}

/* Saved Projects Modal */
.saved-projects-modal {
  max-width: 500px;
}

.saved-projects-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1rem 0;
  max-height: 300px;
  overflow-y: auto;
}

.saved-project-item {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  background-color: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.saved-project-item:hover {
  background-color: var(--primary-light);
  border-color: var(--primary-color);
}

.saved-project-thumbnail {
  width: 60px;
  height: 60px;
  background-color: var(--white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  margin-right: 1rem;
  overflow: hidden;
}

.saved-project-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.saved-project-info {
  flex: 1;
}

.saved-project-name {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.saved-project-date {
  font-size: 0.75rem;
  color: var(--text-light);
}

.saved-project-actions {
  display: flex;
  gap: 0.5rem;
}

.saved-project-action {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-light);
  transition: var(--transition);
  padding: 0.25rem;
}

.saved-project-action:hover {
  color: var(--primary-color);
}

.saved-project-action.delete:hover {
  color: var(--danger-color);
}

.no-saved-projects {
  text-align: center;
  padding: 2rem;
  color: var(--text-light);
}

/* Save Project Modal */
.save-project-form {
  margin: 1rem 0;
}

.save-project-form .form-group {
  margin-bottom: 1rem;
}

.save-project-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Tabs for main content */
.main-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1rem;
}

.main-tab {
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-light);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}

.main-tab:hover {
  color: var(--primary-color);
}

.main-tab.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

.main-tab-content {
  display: none;
}

.main-tab-content.active {
  display: block;
}

/* File upload dragover state */
.file-upload-dragover {
  border-color: var(--primary-color);
  background-color: var(--primary-light);
}

/* No layers message */
.no-layers-message {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-light);
  font-size: 0.875rem;
  background-color: var(--bg-light);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-color);
}

/* Responsive layout adjustments */
@media (max-width: 1024px) {
  .editor-content {
    flex-direction: column;
  }
  
  .tools-panel, .layer-panel {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border-color);
  }
}

/* Background Removal Styles */
.bg-removal-container {
  margin-top: 1.5rem;
  padding: 1.25rem;
  background-color: var(--bg-light);
  border-radius: var(--radius);
  border: 1px solid var(--border-color);
}

.bg-removal-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-color);
}

.bg-removal-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.color-preview-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.color-preview {
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: #FFFFFF;
}

#selected-color-hex {
  font-family: monospace;
  font-size: 0.875rem;
  color: var(--text-color);
}

#pick-color-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem;
  font-size: 0.75rem;
}

#pick-color-btn.active {
  background-color: var(--primary-color);
  color: var(--white);
}

.slider-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

#tolerance-value {
  font-weight: 600;
  color: var(--primary-color);
}

#apply-bg-removal-btn {
  margin-top: 1rem;
}