/* UTM Visualizer v6.0 - Elegant Professional Design */

:root {
  --primary: #1c1c1c;
  --secondary: #2c2c2c;
  --accent: #8b7355;
  --accent-light: #a08b70;
  --gold: #c9a962;
  --cream: #f5f3ef;
  --white: #ffffff;
  --text: #333333;
  --text-light: #666666;
  --text-muted: #999999;
  --border: #e0dcd5;
  --border-dark: #ccc5ba;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.12);
  --radius: 4px;
  --radius-lg: 8px;
  --transition: all 0.2s ease;
}

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

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  font-weight: 400;
}

.app {
  max-width: 800px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--white);
  box-shadow: var(--shadow-lg);
}

/* Header */
.header {
  text-align: center;
  padding: 32px 24px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
}

.logo {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.02em;
}

.tagline {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-top: 4px;
}

/* Main Content */
.main {
  flex: 1;
  padding: 0 24px 32px;
}

/* Sections */
.section {
  padding: 28px 0;
  border-bottom: 1px solid var(--border);
}

.section:last-of-type {
  border-bottom: none;
}

.section-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--primary);
  margin-bottom: 6px;
}

.section-desc {
  font-size: 0.8125rem;
  color: var(--text-light);
  margin-bottom: 20px;
}

/* Materials List */
.materials-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.material-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: var(--cream);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: var(--transition);
}

.material-item:hover {
  border-color: var(--border-dark);
}

.material-image-wrapper {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

.material-upload {
  width: 100%;
  height: 100%;
  border: 2px dashed var(--border-dark);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--white);
  overflow: hidden;
}

.material-upload:hover {
  border-color: var(--accent);
  background: #faf9f7;
}

.material-upload.has-image {
  border: 1px solid var(--border-dark);
}

.material-upload-icon {
  font-size: 1.5rem;
  color: var(--text-muted);
  font-weight: 300;
}

.material-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius);
}

.material-preview.hidden {
  display: none;
}

.material-delete {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--white);
  border: none;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.material-delete.hidden { display: none !important; }
.material-delete:not(.hidden) {
  display: flex;
}

.material-delete:hover {
  background: #c9302c;
}

.material-input {
  flex: 1;
  min-width: 0;
}

.material-input input {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.875rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--text);
  transition: var(--transition);
}

.material-input input:focus {
  outline: none;
  border-color: var(--accent);
}

.material-input input::placeholder {
  color: var(--text-muted);
}

/* Empty material slot */
.material-item.empty {
  opacity: 0.7;
  border-style: dashed;
}

.material-item.empty:hover {
  opacity: 1;
}

/* Space Input */
.space-input {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.space-image-upload {
  width: 100%;
}

.space-upload-area {
  position: relative;
  width: 100%;
  height: 140px;
  border: 2px dashed var(--border-dark);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--cream);
  overflow: hidden;
}

.space-upload-area:hover {
  border-color: var(--accent);
  background: #faf9f7;
}

.space-upload-area.has-image {
  border: 1px solid var(--border-dark);
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.upload-icon {
  font-size: 1.75rem;
  color: var(--text-muted);
  font-weight: 300;
}

.upload-text {
  font-size: 0.8125rem;
  color: var(--text-light);
}

.upload-hint {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.space-preview {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.space-preview.hidden {
  display: none;
}

.upload-placeholder.hidden {
  display: none !important;
}

.remove-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: var(--white);
  border: none;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 10;
}

.remove-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

.remove-btn.hidden {
  display: none;
}

.space-description textarea {
  width: 100%;
  min-height: 100px;
  padding: 14px 16px;
  font-size: 0.875rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--white);
  color: var(--text);
  resize: vertical;
  transition: var(--transition);
  line-height: 1.5;
}

.space-description textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.space-description textarea::placeholder {
  color: var(--text-muted);
}

/* Generate Button */
.generate-section {
  padding: 24px 0;
  text-align: center;
}

.btn-generate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 48px;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  min-width: 260px;
}

.btn-generate:hover:not(:disabled) {
  background: var(--secondary);
}

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

.btn-generate.generating {
  background: var(--accent);
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Results */
.results-section {
  padding-top: 0;
}

.results-section.hidden {
  display: none;
}

.results-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.result-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--white);
  transition: all 0.4s ease;
}

.result-image {
  width: 100%;
  display: block;
}

.result-meta {
  padding: 12px 16px;
  font-size: 0.75rem;
  color: var(--text-light);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.result-timestamp {
  color: var(--text-muted);
}

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

.result-action {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.75rem;
  font-family: inherit;
  padding: 4px;
  transition: var(--transition);
}

.result-action:hover {
  color: var(--accent-light);
}

/* ═══════════════════════════════════════════════════════════════
   LOADING CARD - Elegant inline loading state
   ═══════════════════════════════════════════════════════════════ */

.loading-card {
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #faf9f7 0%, #f5f3ef 100%);
}

.loading-card-content {
  text-align: center;
  padding: 32px;
}

.loading-visual {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
}

.loading-ring {
  position: absolute;
  inset: 0;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1.5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.loading-ring.delay-1 {
  inset: 8px;
  border-top-color: var(--gold);
  animation-delay: 0.15s;
  animation-duration: 1.8s;
}

.loading-ring.delay-2 {
  inset: 16px;
  border-top-color: var(--accent-light);
  animation-delay: 0.3s;
  animation-duration: 2.1s;
}

.loading-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 20px;
  color: var(--accent);
  animation: pulse 2s ease-in-out infinite;
}

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

@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
}

.loading-text {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.125rem;
  color: var(--primary);
  margin-bottom: 4px;
}

.loading-subtext {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Expanding animation when image is ready */
.loading-card.expanding {
  animation: cardExpand 0.4s ease-out forwards;
}

@keyframes cardExpand {
  0% { min-height: 180px; }
  100% { min-height: 300px; }
}

.result-card.result-ready {
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0.5; }
  to { opacity: 1; }
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 24px;
  text-align: center;
  background: var(--cream);
}

.footer p {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1rem;
  color: var(--primary);
}

.footer-address {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.6875rem !important;
  color: var(--text-muted) !important;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 4px;
}

/* Responsive */
@media (min-width: 600px) {
  .space-input {
    flex-direction: row;
  }
  
  .space-image-upload {
    width: 200px;
    flex-shrink: 0;
  }
  
  .space-upload-area {
    height: 160px;
  }
  
  .space-description textarea {
    min-height: 160px;
  }
}

/* Safe area for notched phones */
@supports (padding-top: env(safe-area-inset-top)) {
  .header {
    padding-top: calc(32px + env(safe-area-inset-top));
  }
  
  .footer {
    padding-bottom: calc(24px + env(safe-area-inset-bottom));
  }
}
