﻿/* ==========================
   SORA CARE LABEL STUDIO
   Premium Japanese skincare style
========================== */

:root {
  --bg: #f5ede4;
  --card: #fcfaf7;
  --card-soft: #f9f3ea;
  --text: #2f241f;
  --muted: #7b6f65;
  --border: #e4d8c9;
  --accent: #9b7147;
  --accent-soft: #efe2d0;
  --shadow: 0 14px 36px rgba(74, 51, 31, 0.08);
  --shadow-soft: 0 8px 20px rgba(74, 51, 31, 0.05);
  --label-width-mm: 50mm;
  --label-height-mm: 70mm;
  --label-ratio: 50 / 70;
  --label-padding-mm: 2.2mm;
  --label-radius-mm: 1.8mm;
}

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

body {
  min-height: 100vh;
  font-family: "Inter", "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: none;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 350px) 1fr;
  min-height: 100vh;
  padding: 20px;
  gap: 18px;
}

.sidebar {
  padding: 18px 18px 20px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(155, 113, 71, 0.12);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.brand-block {
  margin-bottom: 12px;
  padding: 15px;
  border-radius: 16px;
  background: var(--card-soft);
  border: 1px solid rgba(155, 113, 71, 0.12);
}

.eyebrow {
  margin-bottom: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--accent);
}

.brand-block h1 {
  font-size: 1.7rem;
  letter-spacing: 0.14em;
  margin-bottom: 6px;
  font-family: "Cormorant Garamond", "Times New Roman", serif;
}

.intro {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.size-selector {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  padding: 10px 12px 12px;
  border-radius: 16px;
  background: var(--card-soft);
  border: 1px solid rgba(155, 113, 71, 0.12);
}

.size-selector h3 {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.size-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.size-option:hover {
  background: rgba(255, 255, 255, 0.94);
  transform: translateY(-1px);
}

.size-option input {
  accent-color: var(--accent);
}

.database-panel {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  padding: 10px 12px 12px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid rgba(155, 113, 71, 0.12);
}

.database-panel h3 {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.database-field {
  display: grid;
  gap: 6px;
}

.database-field span {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--muted);
}

.database-panel input,
.database-panel select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

.product-select {
  display: grid;
  gap: 6px;
  min-height: 112px;
  max-height: 150px;
  overflow-y: auto;
  border-radius: 12px;
  padding: 6px;
  background: var(--card-soft);
  border: 1px solid rgba(155, 113, 71, 0.1);
}

.product-select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(155, 113, 71, 0.12);
}

.product-option {
  width: 100%;
  border: 1px solid rgba(177, 137, 95, 0.16);
  border-radius: 10px;
  padding: 7px 8px;
  text-align: left;
  background: #fff;
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.35;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.product-option:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  background: #f6ebde;
}

.product-option.selected,
.product-option.active {
  background: #efe2d0;
  border-color: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8);
}

.product-option.empty {
  cursor: default;
  color: var(--muted);
  text-align: center;
}

.form-grid {
  display: grid;
  gap: 8px;
}

.field-section {
  border: 1px solid rgba(155, 113, 71, 0.12);
  border-radius: 14px;
  background: var(--card);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.field-section summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 12px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s ease;
}

.field-section summary:hover {
  background: #f7efe5;
}

.field-section summary::-webkit-details-marker {
  display: none;
}

.field-section summary::before {
  content: "▶";
  color: var(--accent);
  font-size: 0.8rem;
  transition: transform 0.2s ease;
}

.field-section[open] summary::before {
  content: "▼";
}

.field-section[open] summary {
  border-bottom: 1px solid rgba(177, 137, 95, 0.14);
}

.section-content {
  display: grid;
  gap: 8px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  padding: 0 12px;
  transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.25s ease;
}

.field-section[open] .section-content {
  max-height: 320px;
  opacity: 1;
  padding: 10px 12px 12px;
}

.form-grid label {
  display: grid;
  gap: 5px;
}

.form-grid span {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
}

.form-grid input,
.form-grid textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 11px;
  background: #fff;
  color: var(--text);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.03);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.form-grid textarea {
  min-height: 86px;
  resize: vertical;
}

.form-grid input:focus,
.form-grid textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(177, 137, 95, 0.16);
  transform: translateY(-1px);
}

.workspace {
  padding: 8px 4px 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.toolbar button {
  padding: 8px 14px;
  border-radius: 999px;
  background: #2f241f;
  color: #fffdf9;
  box-shadow: 0 8px 18px rgba(47, 36, 31, 0.12);
}

.toolbar button:hover {
  background: #3c3129;
}

.toolbar button:disabled,
.toolbar button.is-busy {
  opacity: 0.7;
  cursor: wait;
  transform: none;
  box-shadow: none;
}

.preview-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-card {
  width: min(100%, 500px);
  padding: 14px;
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
  border: 1px solid rgba(155, 113, 71, 0.1);
}

.label-preview {
  position: relative;
  width: min(100%, calc(var(--label-width-mm) * 2.8));
  max-width: calc(var(--label-width-mm) * 3.6);
  aspect-ratio: var(--label-ratio);
  margin: 0 auto;
  padding: 2.2mm 1.8mm;
  border-radius: 1.8mm;
  background: #fcfaf7;
  border: 0.1mm solid rgba(155, 113, 71, 0.18);
  display: flex;
  flex-direction: column;
  gap: 0.8mm;
  overflow: hidden;
  box-shadow: inset 0 0.2mm 0 rgba(255,255,255,0.8);
}

.label-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35mm;
  position: relative;
  z-index: 1;
}

.brand-mark {
  font-size: clamp(0.82rem, 1.4vw, 1.1rem);
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-family: "Cormorant Garamond", "Times New Roman", serif;
  text-align: center;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: clamp(0.58rem, 0.9vw, 0.72rem);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

.label-badge {
  margin-top: 0.25mm;
  padding: 0.3mm 1.2mm;
  border: 0.1mm solid rgba(177, 137, 95, 0.28);
  background: rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  font-size: clamp(0.52rem, 0.78vw, 0.66rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  text-align: center;
}

.divider {
  height: 1px;
  width: 100%;
  background: rgba(155, 113, 71, 0.16);
  position: relative;
  z-index: 1;
}

.label-preview h2 {
  font-size: clamp(0.84rem, 1.18vw, 1rem);
  margin-top: 0.2mm;
  position: relative;
  z-index: 1;
  font-family: "Cormorant Garamond", "Times New Roman", serif;
  line-height: 1.18;
  text-align: center;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.label-preview h3 {
  font-size: clamp(0.62rem, 0.86vw, 0.74rem);
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  position: relative;
  z-index: 1;
  line-height: 1.2;
}

.preview-text {
  color: #433b35;
  font-size: clamp(0.64rem, 0.9vw, 0.8rem);
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  position: relative;
  z-index: 1;
  letter-spacing: 0.01em;
}

.meta-grid {
  margin-top: auto;
  display: grid;
  gap: 0.45mm;
  padding-top: 0.6mm;
  position: relative;
  z-index: 1;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 3mm;
  font-size: clamp(0.56rem, 0.8vw, 0.68rem);
  border-bottom: 0.1mm solid rgba(177, 137, 95, 0.14);
  padding-bottom: 0.5mm;
}

.meta-row span {
  color: var(--muted);
  font-weight: 600;
}

.meta-row strong {
  font-weight: 700;
  text-align: right;
  overflow-wrap: anywhere;
}

.status-bar {
  display: flex;
  justify-content: flex-end;
  padding: 2px 2px 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 999px;
  background: #f7efe5;
  border: 1px solid rgba(155, 113, 71, 0.12);
  color: var(--muted);
  font-size: 0.86rem;
  box-shadow: var(--shadow-soft);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #5aa96f;
  box-shadow: 0 0 0 3px rgba(90, 169, 111, 0.14);
}

.status-bar[data-state="saved"] .status-dot {
  background: #b1895f;
  box-shadow: 0 0 0 3px rgba(177, 137, 95, 0.14);
}

.status-bar[data-state="exported"] .status-dot {
  background: #7d8a68;
  box-shadow: 0 0 0 3px rgba(125, 138, 104, 0.14);
}

.status-bar[data-state="printed"] .status-dot {
  background: #4f6b7a;
  box-shadow: 0 0 0 3px rgba(79, 107, 122, 0.14);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .sidebar {
    border-right: 1px solid rgba(177, 137, 95, 0.14);
  }

  .workspace {
    padding: 6px 2px 4px;
  }
}

@page {
  size: 50mm 70mm;
  margin: 0;
}

@media print {
  html,
  body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    background: #fff !important;
  }

  body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff !important;
  }

  .app-shell {
    display: block !important;
    padding: 0;
    margin: 0;
    background: transparent !important;
  }

  .sidebar,
  .toolbar,
  .status-bar {
    display: none !important;
  }

  .workspace {
    padding: 0;
    margin: 0;
    display: block;
  }

  .preview-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    width: var(--label-width-mm);
    height: var(--label-height-mm);
  }

  .preview-card {
    width: var(--label-width-mm);
    height: var(--label-height-mm);
    padding: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    border: none;
  }

  .label-preview {
    width: var(--label-width-mm);
    height: var(--label-height-mm);
    max-width: none;
    max-height: none;
    box-sizing: border-box;
    margin: 0;
    padding: var(--label-padding-mm);
    border-radius: var(--label-radius-mm);
    border: 0.1mm solid rgba(177, 137, 95, 0.25);
    box-shadow: none;
    background: radial-gradient(circle at top, #fffdf8 0%, #fbf2e5 60%, #f5ebdb 100%);
  }

  .label-preview::before {
    background-size: 1.6mm 1.6mm;
  }
}
