/* ============================================================
   custom-order.css — Custom Order page (CaseRoom)
   Uses the shared design tokens from css/styles.css.
   ============================================================ */

.co-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4.5rem;
}

/* ---------- Hero ---------- */
.co-hero {
  text-align: center;
  margin-bottom: 2.5rem;
}

.co-title {
  font-family: var(--font-heading);
  font-size: clamp(1.9rem, 4vw, 3rem);
  font-weight: 800;
  letter-spacing: 0.5px;
}

.co-title span {
  color: var(--gray-400);
}

.co-subtitle {
  max-width: 620px;
  margin: 0.75rem auto 1.5rem;
  color: var(--gray-600);
  font-size: 1.05rem;
}

.co-steps {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem 2rem;
}

.co-step {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 500;
  font-size: 0.92rem;
  color: var(--gray-800);
}

.co-step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--black);
  color: var(--white);
  font-family: var(--font-heading);
  font-size: 0.8rem;
  font-weight: 700;
}

/* ---------- Layout ---------- */
.co-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 2rem;
  align-items: start;
}

.co-aside {
  display: grid;
  gap: 1.25rem;
  position: sticky;
  top: 1.5rem;
}

/* ---------- Cards ---------- */
.co-card {
  border: 1px solid var(--gray-200);
  border-radius: 14px;
  padding: 1.5rem;
  margin: 0;
  background: var(--white);
}

.co-form .co-card + .co-card {
  margin-top: 1.25rem;
}

.co-card-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 1.1rem;
  padding: 0 0 0.4rem;
  width: 100%;
  border-bottom: 2px solid var(--black);
  display: block;
}

/* ---------- Fields ---------- */
.co-field {
  margin-bottom: 1.1rem;
}

.co-field:last-child {
  margin-bottom: 0;
}

.co-label {
  display: block;
  font-weight: 600;
  font-size: 0.92rem;
  margin-bottom: 0.4rem;
  color: var(--gray-800);
}

.co-optional {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--gray-400);
}

.co-input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--black);
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.co-input:focus,
.co-dropdown:focus-within .co-input {
  outline: none;
  border-color: var(--black);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
}

.co-input.field-error {
  border-color: #c53030;
}

.co-textarea {
  resize: vertical;
  min-height: 84px;
}

.co-hint {
  font-size: 0.8rem;
  color: var(--gray-400);
  margin-top: 0.3rem;
}

.co-error {
  font-size: 0.82rem;
  color: #c53030;
  margin-top: 0.35rem;
  font-weight: 500;
}

/* ---------- Premium option ---------- */
.co-option {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 0.9rem 1rem;
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.co-option:hover {
  border-color: var(--gray-400);
}

.co-option input {
  margin-top: 0.25rem;
  accent-color: var(--black);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.co-option-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
}

.co-option-text small {
  color: var(--gray-600);
  font-size: 0.82rem;
}

.co-option-price {
  font-family: var(--font-heading);
  font-weight: 700;
  white-space: nowrap;
}

/* ---------- Model dropdown ---------- */
.co-dropdown {
  position: relative;
}

.co-select {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  text-align: left;
  cursor: pointer;
}

.co-select-chevron {
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.co-dropdown.open .co-select-chevron {
  transform: rotate(180deg);
}

.co-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 40;
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.14);
  overflow: hidden;
}

.co-dropdown-search {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: none;
  border-bottom: 1.5px solid var(--gray-200);
  font-family: var(--font);
  font-size: 0.92rem;
  outline: none;
}

.co-dropdown-list {
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.co-dropdown-group {
  padding: 0.45rem 0.85rem 0.2rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--gray-400);
  background: var(--gray-100);
}

.co-dropdown-option {
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  font-size: 0.92rem;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.co-dropdown-option:hover,
.co-dropdown-option.hovered {
  background: var(--gray-100);
}

.co-dropdown-option[aria-selected="true"] {
  background: var(--black);
  color: var(--white);
}

.co-dropdown-option .co-dropdown-other {
  color: var(--gray-400);
  font-style: italic;
  font-size: 0.8rem;
}

/* ---------- Upload zone ---------- */
.co-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1.8rem 1rem;
  border: 2px dashed var(--gray-400);
  border-radius: 12px;
  text-align: center;
  cursor: pointer;
  color: var(--gray-600);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.co-upload:hover,
.co-upload:focus-visible {
  border-color: var(--black);
  background: var(--gray-100);
}

.co-upload.dragover {
  border-color: var(--black);
  background: var(--gray-100);
}

.co-upload-title {
  font-weight: 600;
  color: var(--gray-800);
}

.co-upload-hint {
  font-size: 0.82rem;
  color: var(--gray-400);
}

/* ---------- Upload progress ---------- */
.co-upload-progress {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.8rem;
}

.co-progress-track {
  flex: 1;
  height: 8px;
  background: var(--gray-200);
  border-radius: 99px;
  overflow: hidden;
}

.co-progress-bar {
  height: 100%;
  width: 0;
  background: var(--black);
  border-radius: 99px;
  transition: width 0.15s linear;
}

.co-upload-status {
  font-size: 0.82rem;
  font-weight: 600;
  min-width: 42px;
  text-align: right;
}

/* ---------- Upload thumb ---------- */
.co-upload-thumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-top: 0.8rem;
  padding: 0.6rem;
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
}

.co-upload-thumb img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--gray-200);
}

.co-upload-thumb-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
  min-width: 0;
}

.co-upload-thumb-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--gray-800);
  word-break: break-all;
  max-width: 220px;
}

/* ---------- Quantity ---------- */
.co-qty {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.co-qty-btn {
  padding: 0.7rem 1rem;
  font-size: 1.05rem;
  line-height: 1;
  min-width: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.co-qty-input {
  width: 90px;
  text-align: center;
  appearance: textfield;
  -moz-appearance: textfield;
}

.co-qty-input::-webkit-inner-spin-button,
.co-qty-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.co-qty-hint {
  margin: 0 0 0 auto;
  white-space: nowrap;
}

/* ---------- Phone preview ---------- */
.co-preview-card {
  text-align: center;
}

.phone-preview {
  width: 360px;
  max-width: 100%;
  margin: 0 auto 1.1rem;
  /* Mockup container: contain everything, so neither the placeholder nor
     the uploaded design can bleed past the phone silhouette. */
  position: relative;
  overflow: hidden;
}

.phone-svg {
  display: block;
  width: 100%;
  height: auto;
}

/* Visibility for the SVG preview layers.
   NOTE: never rely on the `hidden` ATTRIBUTE for SVG elements — setting
   el.hidden = false does NOT remove the attribute in some browsers, so the
   layer stays display:none forever. Always toggle the .ph-hidden class. */
.phone-svg [hidden],
.phone-svg .ph-hidden {
  display: none;
}

.ph-base {
  fill: #0d0d0d;
}

/* Uploaded design layer — absolute over the mockup, beneath the camera
   cutout. Border-radius is respected via the #caseClip clip-path. */
#designImage {
  z-index: 5;
  pointer-events: none;
}

.ph-camera circle {
  fill: #050505;
}

.ph-box {
  fill: none;
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 1.5;
  stroke-dasharray: 6 5;
  opacity: 0.85;
}

.ph-icon {
  fill: none;
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.ph-label {
  fill: rgba(255, 255, 255, 0.92);
  font-family: var(--font-heading);
  font-size: 7px; /* ~18px when the phone renders at 360px wide */
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* Zoom / pan controls under the mockup — reuse .controls-label,
   .controls-row, .control-btn and .zoom-value from styles.css.
   Explicit [hidden] rule required: author display:flex would otherwise
   override the UA [hidden] { display: none }. */
.co-design-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  margin: 0 auto 1.1rem;
}

.co-design-controls[hidden] {
  display: none;
}

.co-design-controls .controls-row {
  justify-content: center;
}

.co-design-controls .control-btn {
  min-width: 44px;
  height: 44px;
  padding: 0;
}

.co-design-controls .zoom-value {
  min-width: 48px;
}

/* ---------- Preview info ---------- */
.co-preview-info {
  text-align: left;
}

.co-preview-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.9rem;
}

.co-preview-row dt {
  color: var(--gray-600);
}

.co-preview-row dd {
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}

.co-preview-premium {
  margin-top: 0.7rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #178b46;
  text-align: left;
}

/* ---------- Summary ---------- */
.co-summary-rows {
  display: grid;
  gap: 0.5rem;
}

.co-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.95rem;
  color: var(--gray-800);
}

.co-summary-row dt {
  color: var(--gray-600);
}

.co-summary-row dd {
  font-weight: 600;
}

.co-summary-total {
  margin-top: 0.6rem;
  padding-top: 0.8rem;
  border-top: 2px solid var(--black);
  font-family: var(--font-heading);
  font-size: 1.2rem;
}

.co-summary-total dt,
.co-summary-total dd {
  color: var(--black);
  font-weight: 700;
}

.co-summary-note {
  margin: 0.9rem 0;
  font-size: 0.8rem;
  color: var(--gray-400);
}

.co-submit {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
}

.co-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(255, 255, 255, 0.35);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: co-spin 0.7s linear infinite;
}

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

.co-summary-login {
  margin-top: 0.7rem;
  font-size: 0.82rem;
  color: #c53030;
  text-align: center;
  font-weight: 500;
}

/* ---------- Danger button (public variant) ---------- */
.btn-danger {
  border-color: #c53030;
  color: #c53030;
}

.btn-danger:hover {
  background: #c53030;
  color: var(--white);
}

/* ---------- Success modal ---------- */
.co-success {
  text-align: center;
  padding: 1rem 0 0.4rem;
}

.co-success-ring {
  width: 84px;
  height: 84px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: #178b46;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: co-pop 0.45s cubic-bezier(0.18, 0.89, 0.32, 1.28) both;
}

.co-success-ring svg {
  width: 44px;
  height: 44px;
  stroke: var(--white);
  stroke-width: 3.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.co-success-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.co-success-text {
  color: var(--gray-600);
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.co-success-order {
  display: inline-block;
  padding: 0.4rem 1rem;
  background: var(--gray-100);
  border-radius: 99px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1.1rem;
}

@keyframes co-pop {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .co-layout {
    grid-template-columns: 1fr;
  }

  .co-aside {
    position: static;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .co-page {
    padding: 1.75rem 1rem 3.5rem;
  }

  .co-steps {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }

  .co-aside {
    grid-template-columns: 1fr;
  }

  .phone-preview {
    width: 280px;
  }

  .co-qty-hint {
    margin-left: 0;
  }
}

@media (max-width: 480px) {
  .co-card {
    padding: 1.15rem;
  }

  .phone-preview {
    width: 240px;
  }
}

/* ---------- Live design swap micro-transitions ----------
   Hidden is toggled by JS via the .ph-hidden class (never the hidden
   attribute on SVG elements); removing the class restarts the CSS
   animation, giving a smooth fade-in for the user's upload/text. */
#designImage:not(.ph-hidden),
#designText:not(.ph-hidden),
#designPlaceholder:not(.ph-hidden),
.co-preview-premium:not([hidden]) {
  animation: co-design-in 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes co-design-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  #designImage:not(.ph-hidden),
  #designText:not(.ph-hidden),
  #designPlaceholder:not(.ph-hidden),
  .co-preview-premium:not([hidden]),
  .co-success-ring {
    animation: none !important;
  }
}
