/* Curated Virtual Closet - New Design */
:root {
  --primary: #9d9082;
  --primary-dark: #7d7064;
  --primary-light: #b8a99a;
  --secondary: #a8998a;
  --accent: #8b7355;
  --bg: #f5f2ee;
  --bg-card: #c4b8aa;
  --bg-card-inner: #d4c9bc;
  --text: #5c5248;
  --text-light: #7a6f63;
  --text-muted: #9a8f83;
  --border: #c4b8aa;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
  --radius: 16px;
  --radius-sm: 12px;
  --radius-lg: 24px;
  --nav-height: 70px;
}

/* Dark Mode */
:root.dark {
  --bg: #2c2720;
  --bg-card: #3d362e;
  --bg-card-inner: #4a423a;
  --text: #e8e2dc;
  --text-light: #c8c0b8;
  --text-muted: #9a928a;
  --border: #4a423a;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Helvetica Neue', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: calc(var(--nav-height) + 20px);
  -webkit-font-smoothing: antialiased;
}

/* App Container */
.app-container {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px;
  padding-bottom: calc(var(--nav-height) + 32px);
}

/* Header */
.app-header {
  text-align: center;
  padding: 24px 16px 32px;
  margin: -20px -16px 24px -16px;
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: 0.15em;
  color: var(--text);
  margin-bottom: 8px;
}

.app-header h1 i {
  display: none;
}

.app-header .subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 12px 0;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 1000;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.65rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-item i {
  font-size: 1.3rem;
  margin-bottom: 2px;
}

.nav-item.active {
  color: var(--text);
}

.nav-item:active {
  transform: scale(0.95);
}

/* Page Headers */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.page-header h2 {
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
}

.page-header h2 i {
  display: none;
}

.page-description {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 20px;
}

/* Buttons */
.add-btn {
  background: var(--bg-card);
  color: var(--text);
  border: none;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 400;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.add-btn:hover {
  background: var(--primary);
  color: white;
}

.submit-btn {
  width: 100%;
  background: var(--primary);
  color: white;
  border: none;
  padding: 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 400;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 16px;
}

.submit-btn:hover:not(:disabled) {
  background: var(--primary-dark);
}

.submit-btn:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

.danger-btn {
  width: 100%;
  background: #c4a494;
  color: white;
  border: none;
  padding: 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.2s;
}

.danger-btn:hover {
  background: #b89484;
}

.action-btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 400;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.action-btn:hover {
  background: var(--bg-card);
}

.action-btn.danger {
  color: #c4a494;
  border-color: #c4a494;
}

/* HOME Page - Virtual Try-On */
.home-page {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.try-on-section {
  background: transparent;
}

.try-on-section h2 {
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 20px;
  color: var(--text);
}

.try-on-section h2 i {
  display: none;
}

.selection-grid {
  display: flex;
  align-items: stretch;
  gap: 16px;
  margin-bottom: 24px;
}

.selection-card {
  flex: 1;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
}

.selection-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.selection-card:active {
  transform: scale(0.98);
}

.selection-label {
  font-size: 0.7rem;
  color: var(--text);
  margin-bottom: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.selection-preview {
  flex: 1;
  min-height: 180px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-card-inner);
  display: flex;
  align-items: center;
  justify-content: center;
}

.selection-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.selection-preview .placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  padding: 20px;
  text-align: center;
}

.selection-preview .placeholder i {
  font-size: 2.5rem;
  opacity: 0.6;
}

.selection-preview .placeholder span {
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

.selection-preview .placeholder .label {
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-light);
  margin-bottom: 4px;
}

.selection-name {
  font-size: 0.8rem;
  font-weight: 400;
  margin-top: 10px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.plus-icon {
  font-size: 1.5rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  padding: 0 8px;
}

.try-on-btn {
  width: 100%;
  background: var(--primary);
  color: white;
  border: none;
  padding: 18px;
  border-radius: var(--radius-lg);
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s;
}

.try-on-btn i {
  display: none;
}

.try-on-btn:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.try-on-btn:disabled {
  background: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* Result Section */
.result-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
}

.result-section h3 {
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 16px;
  color: var(--text);
}

.result-section h3 i {
  display: none;
}

.result-container {
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 16px;
}

.result-container img {
  width: 100%;
  height: auto;
}

.result-actions {
  display: flex;
  gap: 12px;
}

.result-actions .action-btn {
  flex: 1;
  justify-content: center;
}

/* Favorites Section */
.favorites-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
}

.favorites-section h3 {
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 16px;
  color: var(--text);
}

.favorites-section h3 i {
  display: none;
}

.favorites-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.favorite-item {
  aspect-ratio: 3/4;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
}

.favorite-item:hover {
  transform: scale(1.03);
}

.favorite-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(92, 82, 72, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(4px);
}

.loading-content {
  text-align: center;
  color: white;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-content p {
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.loading-sub {
  font-size: 0.8rem;
  opacity: 0.7;
}

/* Models Page */
.models-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.model-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
}

.model-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.model-image {
  aspect-ratio: 3/4;
  overflow: hidden;
  background: var(--bg-card-inner);
}

.model-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.model-info {
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.model-name {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--text);
}

.delete-model-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s;
}

.delete-model-btn:hover {
  color: #c4a494;
  background: rgba(196, 164, 148, 0.1);
}

/* Closet Page */
.category-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}

.category-tab {
  flex-shrink: 0;
  background: var(--bg-card);
  border: none;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 0.75rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  color: var(--text);
}

.category-tab.active {
  background: var(--primary);
  color: white;
}

.clothes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.clothes-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: all 0.2s;
}

.clothes-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.clothes-image {
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--bg-card-inner);
}

.clothes-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.clothes-info {
  padding: 12px;
}

.clothes-name {
  font-weight: 400;
  font-size: 0.8rem;
  display: block;
  color: var(--text);
}

.clothes-category {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.delete-clothes-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(92, 82, 72, 0.6);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: all 0.2s;
}

.clothes-card:hover .delete-clothes-btn {
  opacity: 1;
}

.delete-clothes-btn:hover {
  background: rgba(196, 164, 148, 0.9);
}

/* Settings Page */
.settings-page {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.settings-page > h2 {
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.settings-page > h2 i {
  display: none;
}

.settings-section {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
}

.settings-section h3 {
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 12px;
  color: var(--text);
}

.settings-section h3 i {
  display: none;
}

.section-description {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 16px;
}

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--bg-card-inner);
}

.setting-item:last-child {
  border-bottom: none;
}

.setting-item span {
  font-size: 0.85rem;
  color: var(--text);
}

/* Switch Toggle */
.switch {
  position: relative;
  width: 50px;
  height: 28px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-card-inner);
  border-radius: 28px;
  transition: 0.3s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.3s;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(22px);
}

/* Language Select */
.language-select {
  padding: 8px 12px;
  border: 1px solid var(--bg-card-inner);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
  min-width: 120px;
}

.language-select:focus {
  outline: none;
  border-color: var(--primary);
}

/* Data Stats */
.data-stats {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.stat-item {
  flex: 1;
  text-align: center;
  padding: 16px 8px;
  background: var(--bg-card-inner);
  border-radius: var(--radius-sm);
}

.stat-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--primary);
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

/* API Guide */
.api-guide {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg-card-inner);
  border-radius: var(--radius-sm);
}

.api-guide h4 {
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 12px;
  color: var(--text);
}

.api-guide ol {
  padding-left: 20px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.api-guide li {
  margin-bottom: 8px;
}

.api-guide a {
  color: var(--primary);
}

/* API Key Input */
.api-key-input {
  display: flex;
  gap: 8px;
}

.api-key-input input {
  flex: 1;
}

.toggle-visibility {
  background: var(--bg-card-inner);
  border: 1px solid var(--bg-card-inner);
  padding: 0 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
}

/* Privacy Note */
.privacy-note {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--primary);
  margin-top: 8px;
}

.privacy-note i {
  font-size: 1rem;
}

/* Form Elements */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text);
  letter-spacing: 0.03em;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--bg-card-inner);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
}

.hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Upload Area */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-card-inner);
}

.upload-area:hover {
  border-color: var(--primary);
  background: var(--bg-card);
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.upload-placeholder i {
  font-size: 2rem;
}

.upload-placeholder span {
  font-size: 0.8rem;
}

.upload-preview {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius-sm);
}

/* Checkbox */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
}

.checkbox-label input {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(92, 82, 72, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--bg);
  border-radius: var(--radius);
  width: 100%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: var(--text);
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
}

.modal-body {
  padding: 20px;
}

/* Picker Modal */
.picker-modal {
  max-width: 500px;
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 20px;
}

.picker-item {
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.picker-item:hover {
  transform: scale(1.03);
}

.picker-item img {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
}

.picker-item span {
  display: block;
  font-size: 0.7rem;
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

/* Result Modal */
.result-modal {
  max-width: 500px;
}

.result-detail img {
  width: 100%;
  border-radius: var(--radius-sm);
}

.result-detail-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  padding: 0 20px 20px;
}

.result-detail-actions .action-btn {
  flex: 1;
  justify-content: center;
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 20px);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-card);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 3000;
  transition: transform 0.3s ease-out;
  font-size: 0.85rem;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast-success {
  border-left: 4px solid var(--primary);
}

.toast-success i {
  color: var(--primary);
}

.toast-error {
  border-left: 4px solid #c4a494;
}

.toast-error i {
  color: #c4a494;
}

.toast-info {
  border-left: 4px solid var(--primary);
}

.toast-info i {
  color: var(--primary);
}

/* Empty Message */
.empty-message {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
  grid-column: 1 / -1;
  font-size: 0.85rem;
}

/* Responsive */
@media (min-width: 768px) {
  .app-container {
    max-width: 600px;
  }

  .models-grid,
  .clothes-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .picker-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 1024px) {
  .app-container {
    max-width: 800px;
  }

  .bottom-nav {
    max-width: 500px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 20px 20px 0 0;
    border: 1px solid var(--border);
    border-bottom: none;
  }
}
