/**
 * أوراد البنفسج (AWRAD VIOLET) - Brand & Theme Studio Comprehensive Styles
 * css/studio.css
 */

/* ==================== THEME STUDIO FULLSCREEN WRAPPER ==================== */
.theme-editor-wrapper {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background-color: #F8F9FA;
  overflow: hidden;
  font-family: 'Cairo', 'Tajawal', system-ui, sans-serif;
}

/* Dark Mode Studio Theme Interface */
.theme-editor-wrapper.dark-studio {
  background-color: #0F0F12;
  color: #F3F4F6;
}

.theme-editor-wrapper.dark-studio .theme-editor-topbar {
  background-color: #18181D;
  border-color: #2D2D35;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.theme-editor-wrapper.dark-studio .studio-icon-btn {
  background: #18181D;
  color: #9CA3AF;
  border-color: #2D2D35;
}

.theme-editor-wrapper.dark-studio .studio-icon-btn:hover:not(:disabled) {
  background: #22222A;
  color: #F3F4F6;
  border-color: #3E3E48;
}

.theme-editor-wrapper.dark-studio .studio-icon-btn.active {
  background: #7A1C6B;
  color: #ffffff;
  border-color: #7A1C6B;
}

.theme-editor-wrapper.dark-studio .theme-editor-sidebar {
  background-color: #18181D;
  border-color: #2D2D35;
}

.theme-editor-wrapper.dark-studio .studio-accordion-item {
  background-color: #18181D;
  border-color: #2D2D35;
}

.theme-editor-wrapper.dark-studio .studio-accordion-header {
  color: #F3F4F6;
}

.theme-editor-wrapper.dark-studio .studio-accordion-header:hover {
  background-color: #22222A;
}

.theme-editor-wrapper.dark-studio .studio-accordion-header.active {
  background-color: #2A1D2B;
}

.theme-editor-wrapper.dark-studio .studio-accordion-content {
  background-color: #18181D;
  border-color: #2D2D35;
}

/* ==================== SMART STUDIO TOPBAR ==================== */
.theme-editor-topbar {
  height: 56px;
  background-color: #ffffff;
  border-bottom: 1px solid #eeeeee;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  z-index: 1010;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.studio-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  color: #4B5563;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.studio-icon-btn:hover:not(:disabled) {
  background: #F3F4F6;
  color: #111827;
  border-color: #E5E7EB;
}

.studio-icon-btn.active {
  background: #7A1C6B;
  color: #ffffff;
  border-color: #7A1C6B;
}

.studio-icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.device-switch-btn {
  padding: 0.35rem 0.65rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s ease;
  background: #ffffff;
  color: #4A4A4A;
  border: 1px solid #E5E7EB;
  cursor: pointer;
}

.device-switch-btn:hover {
  background: #FAF2F8;
  color: #7A1C6B;
  border-color: #E5A9D3;
}

.device-switch-btn.active {
  background: #7A1C6B;
  color: #ffffff;
  border-color: #7A1C6B;
}

.theme-mode-switch-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  cursor: pointer;
  border: 1px solid #E5E7EB;
  background: #ffffff;
  padding: 0;
}

.undo-redo-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid #E5E7EB;
  color: #4B5563;
  font-size: 0.75rem;
  transition: all 0.15s ease;
  cursor: pointer;
}

.undo-redo-btn:hover:not(:disabled) {
  background: #F3F4F6;
  color: #111827;
  border-color: #D1D5DB;
}

.undo-redo-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ==================== STUDIO BODY & SIDEBAR ==================== */
.theme-editor-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
  height: calc(100dvh - 56px);
}

.theme-editor-sidebar {
  width: 320px;
  min-width: 320px;
  max-width: 320px;
  background-color: #ffffff;
  border-left: 1px solid #eeeeee;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 1005;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.02);
}

/* Accordion Component */
.studio-accordion-item {
  border-bottom: 1px solid #F0DFEC;
  background: #ffffff;
  transition: background-color 0.2s ease;
}

.studio-accordion-header {
  width: 100%;
  padding: 0.9rem 1.15rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: right;
  transition: all 0.2s ease;
}

.studio-accordion-header:hover {
  background-color: #FAF9FB;
}

.studio-accordion-header.active {
  background-color: #FAF2F8;
}

.studio-accordion-header.active .accordion-chevron {
  transform: rotate(180deg);
  color: #7A1C6B;
}

.accordion-chevron {
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 0.75rem;
  color: #9CA3AF;
}

.studio-accordion-content {
  padding: 1.15rem;
  background-color: #ffffff;
  border-top: 1px solid #F7E8F3;
  display: none;
}

.studio-accordion-content.open {
  display: block;
  animation: studioSlideDown 0.25s ease-out;
}

@keyframes studioSlideDown {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==================== PREVIEW CANVAS & DEVICE FRAMES ==================== */
.theme-editor-preview {
  flex: 1;
  background-color: #EAEEF3;
  background-image: radial-gradient(#D1D5DB 1px, transparent 1px);
  background-size: 20px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow: auto;
  position: relative;
  transition: all 0.3s ease;
}

.theme-preview-frame {
  background-color: #ffffff;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12);
  border-radius: 1.25rem;
  overflow: hidden;
  transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1), height 0.35s cubic-bezier(0.16, 1, 0.3, 1), border-radius 0.35s ease;
  border: 4px solid #ffffff;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.theme-preview-frame.desktop {
  width: 100%;
  max-width: 1200px;
  height: 100%;
  border-radius: 0.85rem;
}

.theme-preview-frame.tablet {
  width: 768px;
  height: 95%;
  border-radius: 1.75rem;
  border: 10px solid #2D3748;
}

.theme-preview-frame.mobile {
  width: 375px;
  height: 95%;
  border-radius: 2.25rem;
  border: 12px solid #1F2937;
}

.theme-preview-frame.dark-mode-active {
  background-color: #121214;
  border-color: #2D3748;
}

.preview-address-bar {
  height: 32px;
  background: #F3F4F6;
  border-bottom: 1px solid #E5E7EB;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.75rem;
  font-size: 0.7rem;
  color: #6B7280;
  user-select: none;
}

/* ==================== RESIZE HANDLES & DIMENSION BADGE ==================== */
.te-selection-overlay {
  position: absolute;
  pointer-events: none;
  border: 2px dashed #7A1C6B;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.8), 0 4px 15px rgba(122, 28, 107, 0.2);
  z-index: 1050;
  transition: all 0.05s ease-out;
}

.te-selection-overlay.active {
  pointer-events: auto;
}

.te-resize-handle {
  position: absolute;
  width: 11px;
  height: 11px;
  background: #7A1C6B;
  border: 2px solid #ffffff;
  border-radius: 3px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  pointer-events: auto;
  z-index: 1060;
}

.te-resize-handle.tl { top: -6px; left: -6px; cursor: nwse-resize; }
.te-resize-handle.tr { top: -6px; right: -6px; cursor: nesw-resize; }
.te-resize-handle.bl { bottom: -6px; left: -6px; cursor: nesw-resize; }
.te-resize-handle.br { bottom: -6px; right: -6px; cursor: nwse-resize; }
.te-resize-handle.tm { top: -6px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.te-resize-handle.bm { bottom: -6px; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.te-resize-handle.ml { top: 50%; left: -6px; transform: translateY(-50%); cursor: ew-resize; }
.te-resize-handle.mr { top: 50%; right: -6px; transform: translateY(-50%); cursor: ew-resize; }

.te-dim-indicator {
  position: absolute;
  top: -30px;
  right: 0;
  background: #1F2937;
  color: #ffffff;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 0.4rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  white-space: nowrap;
  z-index: 1070;
  direction: ltr;
}

/* ==================== INTERACTIVE MOTION CANVAS ==================== */
.motion-drag-canvas {
  touch-action: none;
  user-select: none;
}

.motion-drag-puck {
  box-shadow: 0 4px 15px rgba(122, 28, 107, 0.35);
  transition: transform 0.05s ease-out;
}

/* Cubic-Bezier SVG Canvas */
.bezier-editor-box {
  background: #FAF9FB;
  border: 1px solid #F0DFEC;
  border-radius: 1rem;
  padding: 1rem;
}

.bezier-svg-canvas {
  width: 100%;
  height: 160px;
  background: #ffffff;
  border: 1px solid #E5E7EB;
  border-radius: 0.75rem;
  overflow: visible;
  touch-action: none;
}

.bezier-handle-point {
  cursor: grab;
  transition: r 0.15s ease;
}

.bezier-handle-point:hover {
  r: 8px;
}

.bezier-handle-point:active {
  cursor: grabbing;
  r: 9px;
}

/* ==================== DIRECT EDIT & HOVER INDICATORS ==================== */
.direct-edit-hover {
  outline: 2px dashed #7A1C6B !important;
  outline-offset: 2px !important;
  cursor: pointer !important;
  position: relative !important;
}

.direct-text-editing {
  outline: 2px solid #7A1C6B !important;
  background-color: rgba(250, 242, 248, 0.6) !important;
  border-radius: 4px !important;
  padding: 2px 4px !important;
  cursor: text !important;
}

/* Drop Indicator Line for Section Reordering */
.section-drop-indicator {
  height: 4px;
  background-color: #7A1C6B;
  border-radius: 2px;
  box-shadow: 0 0 10px rgba(122, 28, 107, 0.5);
  margin: 4px 0;
  transition: all 0.15s ease;
}

/* ==================== LIVE SECTION DRAG & DROP TOOLBAR (IFRAME) ==================== */
.store-section-wrapper {
  position: relative;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.store-section-wrapper.direct-edit-section {
  outline: 2px dashed rgba(122, 28, 107, 0.45) !important;
  outline-offset: -2px;
}

.store-section-wrapper.direct-edit-section:hover {
  outline: 2.5px solid #7A1C6B !important;
}

.store-section-wrapper.section-dragging {
  opacity: 0.35 !important;
  transform: scale(0.985);
}

.section-drag-drop-line {
  height: 4px;
  background: #7A1C6B;
  box-shadow: 0 0 10px rgba(122, 28, 107, 0.8);
  border-radius: 9999px;
  margin: 6px 0;
  pointer-events: none;
  animation: pulseDropLine 1s infinite alternate;
}

@keyframes pulseDropLine {
  from { opacity: 0.6; transform: scaleY(1); }
  to { opacity: 1; transform: scaleY(1.4); }
}

.section-live-toolbar {
  position: absolute;
  top: 8px;
  right: 12px;
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid #E5A9D3;
  padding: 4px 10px;
  border-radius: 9999px;
  box-shadow: 0 4px 14px rgba(122, 28, 107, 0.18);
  font-family: 'Cairo', 'Tajawal', sans-serif;
  user-select: none;
}

.section-live-toolbar .section-name-tag {
  font-size: 11px;
  font-weight: 800;
  color: #7A1C6B;
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: grab;
}

.section-live-toolbar .section-name-tag:active {
  cursor: grabbing;
}

.section-live-toolbar .section-action-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: #7A1C6B;
  background: #FAF2F8;
  border: 1px solid #E5A9D3;
  cursor: pointer;
  transition: all 0.15s ease;
}

.section-live-toolbar .section-action-btn:hover {
  background: #7A1C6B;
  color: #ffffff;
}

/* Draggable Section Item in Sidebar */
.studio-section-drag-item {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.studio-section-drag-item.dragging {
  opacity: 0.5;
  border: 2px dashed #7A1C6B;
}

/* Color Swatch Picker */
.color-swatch-picker {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: none;
  cursor: pointer;
  width: 38px;
  height: 38px;
  border-radius: 0.75rem;
  padding: 0;
  background: transparent;
}

.color-swatch-picker::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-swatch-picker::-webkit-color-swatch {
  border: 2px solid #ffffff;
  border-radius: 0.75rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* Custom Scrollbars */
.theme-editor-sidebar::-webkit-scrollbar {
  width: 6px;
}

.theme-editor-sidebar::-webkit-scrollbar-track {
  background: #FAF9FB;
}

.theme-editor-sidebar::-webkit-scrollbar-thumb {
  background: #E5A9D3;
  border-radius: 3px;
}

.theme-editor-sidebar::-webkit-scrollbar-thumb:hover {
  background: #7A1C6B;
}

/* ==================== PWA INSTALL BUTTON ==================== */
.pwa-install-btn {
  background: linear-gradient(135deg, #7e22ce 0%, #6b21a8 50%, #581c87 100%) !important;
  color: #ffffff !important;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
  animation: pwaPulse 3.5s infinite ease-in-out;
}

.pwa-install-btn:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 6px 18px rgba(107, 33, 168, 0.45) !important;
}

@keyframes pwaPulse {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(107, 33, 168, 0.25);
  }
  50% {
    box-shadow: 0 6px 18px rgba(107, 33, 168, 0.45);
  }
}

/* ==================== PHASE 3 STUDIO UTILITIES ==================== */
.studio-thumb-preview {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #E5A9D3;
  background-color: #FAF2F8;
}

.studio-range-slider {
  width: 100%;
  accent-color: #7A1C6B;
  height: 6px;
  border-radius: 4px;
  background: #E5A9D3;
  cursor: pointer;
}

.studio-segmented-btn {
  padding: 0.35rem 0.65rem;
  font-size: 11px;
  font-weight: 700;
  border-radius: 8px;
  border: 1px solid #E5A9D3;
  background: #ffffff;
  color: #4A4A4A;
  transition: all 0.2s ease;
  cursor: pointer;
  text-align: center;
}

.studio-segmented-btn.active, .studio-segmented-btn:hover {
  background: #7A1C6B;
  color: #ffffff;
  border-color: #7A1C6B;
  box-shadow: 0 2px 6px rgba(122, 28, 107, 0.25);
}

.studio-gift-card-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #ffffff;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  transition: all 0.3s ease;
}

.studio-preset-card {
  border: 1px solid #F0DFEC;
  border-radius: 14px;
  padding: 0.75rem;
  background: #ffffff;
  transition: all 0.2s ease;
  cursor: pointer;
}

.studio-preset-card:hover {
  border-color: #7A1C6B;
  box-shadow: 0 4px 14px rgba(122, 28, 107, 0.12);
  transform: translateY(-1px);
}

.studio-swatch-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.direct-text-editing {
  outline: 2px dashed #7A1C6B !important;
  outline-offset: 4px !important;
  background-color: rgba(229, 169, 211, 0.2) !important;
  border-radius: 4px;
}

.direct-edit-hover:hover {
  outline: 1.5px dashed #C59B27;
  outline-offset: 2px;
  cursor: pointer;
}
