@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@600;700;800&family=Inter:wght@400;500;600;700&family=Nunito:wght@600;700;800&display=swap');

:root {
  --primary-accent: #8f7fe0;
  --primary-accent-hover: #7c6dd8;
  --primary-gradient: linear-gradient(135deg, #a9a0f0 0%, #8f7fe0 100%);
  --secondary-bg: rgba(255, 255, 255, 0.75);
  --text-dark: #3d3856;
  --text-muted: #7c7893;
  --glass-bg: rgba(255, 255, 255, 0.6);
  --glass-border: 1px solid rgba(255, 255, 255, 0.65);
  --glass-shadow: 0 8px 32px rgba(99, 91, 166, 0.12);
  --pill-radius: 999px;
  --card-radius: 28px;
}

.theme-dark {
  --text-dark: #f0edff;
  --text-muted: #bcb6d5;
  --glass-bg: rgba(35, 31, 53, 0.82);
  --glass-border: 1px solid rgba(194, 184, 255, 0.16);
  --glass-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  color: var(--text-dark);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text-dark);
  background-color: #f6f5fa;
  overflow-x: hidden;
}

/* Disable native browser image ghosting */
img {
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Heading Typography */
h1, h2, h3, h4, .heading {
  font-family: 'Baloo 2', 'Nunito', sans-serif;
}

/* Background animated mesh gradient */
.app-bg-wrapper {
  position: relative;
  min-height: 100vh;
  padding: 24px 16px 80px;
  background:
    radial-gradient(circle at 15% 20%, #dce9fb 0%, transparent 45%),
    radial-gradient(circle at 85% 15%, #f3e1f7 0%, transparent 45%),
    radial-gradient(circle at 50% 90%, #fce9e1 0%, transparent 50%),
    #f6f5fa;
}

.theme-dark.app-bg-wrapper {
  background:
    radial-gradient(circle at 15% 20%, rgba(83, 69, 144, 0.36) 0%, transparent 42%),
    radial-gradient(circle at 85% 15%, rgba(94, 52, 124, 0.28) 0%, transparent 42%),
    radial-gradient(circle at 50% 90%, rgba(43, 73, 116, 0.24) 0%, transparent 48%),
    #181524;
}

.theme-dark .glass-card,
.theme-dark .editor-tool-rail,
.theme-dark .editor-sub-sidebar {
  background: var(--glass-bg);
  border-color: rgba(194, 184, 255, 0.16);
}

.theme-dark .header-container h1,
.theme-dark .header-container p,
.theme-dark .sub-sidebar-header h4,
.theme-dark .tool-rail-button,
.theme-dark .sub-sidebar-close-btn,
.theme-dark .footer-highlight {
  color: var(--text-dark) !important;
}

.theme-dark .tool-rail-button:hover,
.theme-dark .sub-sidebar-close-btn:hover {
  background: rgba(169, 160, 240, 0.18);
  color: #d9d3ff !important;
}

.theme-dark .tool-rail-button.active {
  color: #ffffff !important;
}

.theme-dark .bubble-button-secondary {
  background: rgba(143, 127, 224, 0.22);
  border-color: rgba(194, 184, 255, 0.3);
  color: #f0edff;
}

.theme-dark .bubble-button-secondary:hover:not(:disabled) {
  background: rgba(143, 127, 224, 0.34);
}

.theme-dark .editor-sub-sidebar input:not([type="range"]):not([type="color"]),
.theme-dark .editor-sub-sidebar textarea,
.theme-dark .editor-sub-sidebar select {
  background: rgba(255, 255, 255, 0.1) !important;
  color: #f0edff !important;
  border-color: rgba(194, 184, 255, 0.3) !important;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid rgba(143, 127, 224, 0.28);
  border-radius: var(--pill-radius);
  background: rgba(255, 255, 255, 0.7);
  color: #57536b;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.theme-dark .theme-toggle {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(194, 184, 255, 0.26);
  color: #f0edff;
}

.theme-toggle:hover {
  transform: translateY(-1px);
}
.share-dropdown {
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}

/* Canva-Style Editor Workspace Layout */
.editor-workspace-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 12px;
}

@media (min-width: 900px) {
  .editor-workspace-layout {
    display: grid;
    grid-template-columns: auto auto 1fr;
    gap: 16px;
    align-items: start;
    height: calc(100vh - 120px);
  }

  /* When the settings drawer is closed, the canvas takes the remaining space */
  .editor-workspace-layout.drawer-closed {
    grid-template-columns: auto 1fr;
  }
}

/* Slim Tool Rail (Far Left) */
.editor-tool-rail {
  display: flex;
  flex-direction: row;
  gap: 8px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 20px;
  padding: 8px;
  box-shadow: 0 4px 20px rgba(99, 91, 166, 0.08);
}

@media (min-width: 900px) {
  .editor-tool-rail {
    flex-direction: column;
    width: 84px;
    height: 100%;
    align-items: center;
    padding: 14px 6px;
  }
}

.tool-rail-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 6px;
  border-radius: 16px;
  border: 1px solid transparent;
  background: transparent;
  color: #57536b;
  cursor: pointer;
  width: 100%;
  transition: all 180ms ease;
}

.tool-rail-button:hover {
  background: rgba(143, 127, 224, 0.12);
  color: #7c6dd8;
}

.tool-rail-button.active {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(143, 127, 224, 0.35);
}

.tool-rail-label {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.1;
}

.tool-rail-badge {
  font-size: 10px;
  font-weight: 600;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 72px;
}

/* Expandable Sub-Sidebar Drawer */
.editor-sub-sidebar {
  background: var(--glass-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--card-radius);
  padding: 16px;
  width: 100%;
  display: flex;
  flex-direction: column;
  animation: fadeIn 200ms ease-out;
}

@media (min-width: 900px) {
  .editor-sub-sidebar {
    width: 360px;
    height: 100%;
    overflow-y: auto;
  }

  .editor-sub-sidebar::-webkit-scrollbar {
    width: 5px;
  }
  .editor-sub-sidebar::-webkit-scrollbar-thumb {
    background: rgba(143, 127, 224, 0.3);
    border-radius: 999px;
  }
}

.sub-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.sub-sidebar-close-btn {
  border: none;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #7c7893;
  transition: background 150ms ease;
}

.sub-sidebar-close-btn:hover {
  background: rgba(0, 0, 0, 0.12);
  color: #3d3856;
}

.sub-sidebar-content {
  flex: 1;
}

/* Main Canvas Viewport (Zero-scroll) */
.editor-canvas-viewport {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  overflow-y: auto;
}

.editor-canvas-viewport::-webkit-scrollbar {
  width: 6px;
}
.editor-canvas-viewport::-webkit-scrollbar-thumb {
  background: rgba(143, 127, 224, 0.3);
  border-radius: 999px;
}

/* Frosted glass card */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: var(--card-radius);
  transition: all 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Pill Buttons */
.bubble-pill-inactive {
  padding: 8px 18px;
  border-radius: var(--pill-radius);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(143, 127, 224, 0.25);
  background: rgba(143, 127, 224, 0.12);
  color: #57536b;
  cursor: pointer;
  transition: all 180ms ease;
  user-select: none;
}

.bubble-pill-inactive:hover {
  background: rgba(143, 127, 224, 0.2);
  transform: translateY(-1px);
}

.bubble-pill-active {
  padding: 8px 18px;
  border-radius: var(--pill-radius);
  font-size: 13px;
  font-weight: 700;
  border: 1px solid rgba(143, 127, 224, 0.4);
  background: var(--primary-gradient);
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(143, 127, 224, 0.35);
  transition: all 180ms ease;
  user-select: none;
}

.bubble-button-primary {
  border: none;
  border-radius: var(--pill-radius);
  background: var(--primary-gradient);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(143, 127, 224, 0.38);
  cursor: pointer;
  transition: all 200ms ease;
}

.bubble-button-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(143, 127, 224, 0.48);
}

.bubble-button-primary:active:not(:disabled) {
  transform: scale(0.97);
}

.bubble-button-accent {
  border: none;
  border-radius: var(--pill-radius);
  background: linear-gradient(135deg, #7c6dd8 0%, #6353c7 100%);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 6px 18px rgba(99, 83, 199, 0.35);
  cursor: pointer;
  transition: all 200ms ease;
}

.bubble-button-accent:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(99, 83, 199, 0.45);
}

.bubble-button-secondary {
  border: 1px solid rgba(143, 127, 224, 0.25);
  border-radius: var(--pill-radius);
  background: rgba(143, 127, 224, 0.12);
  color: var(--text-dark);
  font-weight: 600;
  cursor: pointer;
  transition: all 180ms ease;
}

.bubble-button-secondary:hover:not(:disabled) {
  background: rgba(143, 127, 224, 0.2);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(143, 127, 224, 0.18);
}

.bubble-button-secondary:active:not(:disabled) {
  transform: scale(0.97);
}

.bubble-button-danger {
  border: 1px solid rgba(229, 91, 91, 0.2);
  border-radius: var(--pill-radius);
  background: rgba(229, 91, 91, 0.08);
  color: #d14343;
  font-weight: 600;
  cursor: pointer;
  transition: all 180ms ease;
}

.bubble-button-danger:hover {
  background: rgba(229, 91, 91, 0.15);
}

/* Modal styles */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(61, 56, 86, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 200ms ease-out;
}

.modal-content {
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 250ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Photo editor: keep the rendered result in view while its settings scroll separately. */
.crop-modal-content {
  width: min(1160px, 94vw);
  max-width: none;
  padding: 24px;
  overflow: hidden;
}

.crop-modal-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 20px;
  height: min(680px, calc(90vh - 112px));
}

.crop-modal-preview {
  margin-bottom: 0 !important;
  min-height: 0 !important;
  max-height: none !important;
  height: 100%;
  overflow: hidden;
}

.crop-modal-preview canvas {
  max-height: calc(min(680px, 90vh - 112px) - 48px) !important;
}

.crop-modal-inspector {
  min-height: 0;
  overflow-y: auto;
  padding: 2px 8px 2px 2px;
}

.crop-modal-tabs {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  gap: 6px;
  padding: 0 0 14px;
  background: transparent;
}

.crop-modal-tab {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid rgba(143, 127, 224, 0.3);
  border-radius: 10px;
  background: rgba(143, 127, 224, 0.12);
  color: #57536b;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.crop-modal-tab.active {
  border: 2px solid #8f7fe0;
  background: rgba(143, 127, 224, 0.15);
  color: #6f5ec7;
}

.crop-modal-inspector::-webkit-scrollbar { width: 6px; }
.crop-modal-inspector::-webkit-scrollbar-thumb {
  background: rgba(143, 127, 224, 0.35);
  border-radius: 999px;
}

.crop-modal-actions {
  position: sticky;
  bottom: 0;
  z-index: 1;
  padding: 14px 0 2px;
  background: transparent;
}

.theme-dark .crop-modal-actions {
  background: rgba(35, 31, 53, 0.9);
}

@media (max-width: 760px) {
  .crop-modal-content {
    width: 94vw;
    max-height: 92vh;
    padding: 20px;
    overflow-y: auto;
  }

  .crop-modal-workspace {
    display: flex;
    flex-direction: column;
    height: auto;
  }

  .crop-modal-preview {
    height: min(48vh, 420px);
    min-height: 300px !important;
  }

  .crop-modal-preview canvas {
    max-height: calc(min(48vh, 420px) - 48px) !important;
  }

  .crop-modal-inspector {
    overflow: visible;
    padding: 0;
  }

  .crop-modal-actions {
    position: static;
  }
}

/* Interactive Sheet Preview Cell Overlay */
.sheet-preview-cell-overlay:hover {
  border-color: #8f7fe0 !important;
  background: rgba(143, 127, 224, 0.12) !important;
}

.sheet-preview-cell-overlay:hover .cell-gear-btn {
  opacity: 1 !important;
}

/* Spinner animation */
.spinner {
  animation: spin 1s linear infinite;
}

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

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

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==========================================================================
   Skeleton Screen & Shimmer Animation System
   ========================================================================== */

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

@keyframes skeleton-pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.96);
  }
}

.skeleton {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background-color: #ebe8f5;
}

.theme-dark .skeleton {
  background-color: rgba(255, 255, 255, 0.08);
}

.skeleton-shimmer {
  background: linear-gradient(
    90deg,
    #ebe8f5 0%,
    #ebe8f5 25%,
    #f8f7fc 45%,
    #ffffff 50%,
    #f8f7fc 55%,
    #ebe8f5 75%,
    #ebe8f5 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.theme-dark .skeleton-shimmer {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 0%,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.12) 45%,
    rgba(255, 255, 255, 0.18) 50%,
    rgba(255, 255, 255, 0.12) 55%,
    rgba(255, 255, 255, 0.05) 75%,
    rgba(255, 255, 255, 0.05) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.skeleton-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #8f7fe0;
  box-shadow: 0 0 10px rgba(143, 127, 224, 0.7);
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}

.sheet-skeleton-card {
  background: #ffffff;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(35, 31, 53, 0.14);
  border: 1px solid rgba(143, 127, 224, 0.15);
  transition: all 180ms ease;
}

.theme-dark .sheet-skeleton-card {
  background: #252037;
  border-color: rgba(194, 184, 255, 0.14);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

.skeleton-cell {
  border: 1px dashed rgba(143, 127, 224, 0.3);
  border-radius: 6px;
  background: rgba(143, 127, 224, 0.04);
  padding: 4px;
  box-sizing: border-box;
}

.theme-dark .skeleton-cell {
  border-color: rgba(194, 184, 255, 0.2);
  background: rgba(255, 255, 255, 0.02);
}

