/* Lumina Notes — Craft-Inspired Aesthetic Stylesheet */
:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "PingFang TC", "Microsoft JhengHei", sans-serif;
  --font-serif: 'Newsreader', 'Georgia', "Songti TC", "Noto Serif TC", serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  color: #1e293b;
  background: #f1f5f9;
  overflow: hidden;
  user-select: none;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* ==================== AURORA FROSTED GLASS APP LOGO ICON ==================== */
.lumina-aurora-app-icon {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 18%, rgba(52, 211, 153, 0.92) 0%, transparent 58%),
    radial-gradient(circle at 85% 22%, rgba(56, 189, 248, 0.92) 0%, transparent 58%),
    radial-gradient(circle at 80% 85%, rgba(244, 114, 182, 0.9) 0%, transparent 60%),
    radial-gradient(circle at 20% 82%, rgba(129, 140, 248, 0.95) 0%, transparent 60%),
    linear-gradient(135deg, #a5f3fc 0%, #c4b5fd 50%, #fbcfe8 100%);
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow:
    0 6px 16px -3px rgba(56, 189, 248, 0.38),
    0 2px 6px -1px rgba(129, 140, 248, 0.28),
    inset 0 1.5px 2.5px rgba(255, 255, 255, 0.92),
    inset 0 -1px 2px rgba(255, 255, 255, 0.45);
}

.lumina-aurora-app-icon::before {
  content: '';
  position: absolute;
  inset: 2px;
  border-radius: 9px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.52) 0%, rgba(255, 255, 255, 0.14) 55%, rgba(255, 255, 255, 0.32) 100%);
  backdrop-filter: blur(8px) saturate(190%);
  -webkit-backdrop-filter: blur(8px) saturate(190%);
  border: 0.5px solid rgba(255, 255, 255, 0.65);
  pointer-events: none;
}

.lumina-aurora-app-icon > span,
.lumina-aurora-app-icon > svg {
  position: relative;
  z-index: 2;
  color: #ffffff;
  filter: drop-shadow(0 1px 3px rgba(15, 23, 42, 0.28));
}

/* ==================== APP SHELL LIGHT / DARK MODE ==================== */
body.theme-light {
  background: #f1f5f9;
  color: #1e293b;
}

body.theme-light .craft-glass-sidebar {
  background: rgba(241, 245, 249, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid rgba(226, 232, 240, 0.9);
}

body.theme-light .craft-glass-middle {
  background: rgba(248, 250, 252, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid rgba(226, 232, 240, 0.9);
}

body.theme-light .craft-glass-header {
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
}

body.theme-light .craft-glass-inspector {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid rgba(226, 232, 240, 0.9);
}

/* Dark Mode App Shell */
body.theme-dark {
  background: #0b0f19;
  color: #f1f5f9;
}

body.theme-dark .craft-glass-sidebar {
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
}

body.theme-dark .craft-glass-middle {
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
}

body.theme-dark .craft-glass-header {
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
}

body.theme-dark .craft-glass-inspector {
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
}

/* Dark Mode Adaptive Elements inside Shell, Cards, Inspector, and Default Canvas */
body.theme-dark .text-slate-900,
body.theme-dark .text-slate-800 {
  color: #f1f5f9 !important;
}

body.theme-dark .text-slate-700,
body.theme-dark .text-slate-600 {
  color: #cbd5e1 !important;
}

body.theme-dark .text-slate-500,
body.theme-dark .text-slate-400 {
  color: #94a3b8 !important;
}

body.theme-dark .bg-white,
body.theme-dark .bg-white\/85,
body.theme-dark .bg-white\/80,
body.theme-dark .bg-white\/75,
body.theme-dark .bg-white\/70,
body.theme-dark .bg-white\/60 {
  background-color: rgba(30, 41, 59, 0.88) !important;
  color: #f1f5f9 !important;
}

body.theme-dark .bg-slate-50,
body.theme-dark .bg-slate-50\/80,
body.theme-dark .bg-slate-100,
body.theme-dark .bg-slate-100\/80,
body.theme-dark .bg-slate-200\/70 {
  background-color: rgba(30, 41, 59, 0.72) !important;
  color: #e2e8f0 !important;
}

body.theme-dark .border-slate-200,
body.theme-dark .border-slate-200\/90,
body.theme-dark .border-slate-200\/80,
body.theme-dark .border-slate-200\/70,
body.theme-dark .border-slate-100,
body.theme-dark .border-white\/80,
body.theme-dark .border-white\/70,
body.theme-dark .border-white\/60 {
  border-color: rgba(255, 255, 255, 0.1) !important;
}

body.theme-dark .backdrop-clean-white {
  background: linear-gradient(180deg, #0b0f19 0%, #111827 100%);
  color: #f8fafc;
}

body.theme-dark .craft-paper-sheet {
  background: rgba(17, 24, 39, 0.92);
  border-color: rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
  box-shadow:
    0 24px 60px -12px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(255, 255, 255, 0.06);
}

body.theme-dark #slash-menu-popover,
body.theme-dark #block-action-popover,
body.theme-dark #modal-content {
  background-color: #1e293b !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  color: #f1f5f9 !important;
}

/* Custom subtle scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(100, 116, 139, 0.55);
}

/* 6 Craft Page Backdrop Themes */
.backdrop-clean-white {
  background: linear-gradient(180deg, #f1f5f9 0%, #f8fafc 100%);
  color: #0f172a;
}
.backdrop-warm-sand {
  background: radial-gradient(circle at 20% 10%, #fdf6e9 0%, #f5ebe0 55%, #ede0d4 100%);
  color: #292524;
}
.backdrop-aurora-glass {
  background:
    radial-gradient(at 10% 14%, rgba(129, 140, 248, 0.34) 0px, transparent 50%),
    radial-gradient(at 88% 20%, rgba(244, 114, 182, 0.3) 0px, transparent 50%),
    radial-gradient(at 50% 85%, rgba(52, 211, 153, 0.25) 0px, transparent 55%),
    radial-gradient(at 25% 65%, rgba(167, 139, 250, 0.22) 0px, transparent 50%),
    linear-gradient(135deg, #e0e7ff 0%, #fce7f3 50%, #d1fae5 100%);
  color: #0f172a;
}
.backdrop-midnight-slate {
  background:
    radial-gradient(at 20% 15%, rgba(99, 102, 241, 0.25) 0px, transparent 50%),
    radial-gradient(at 80% 80%, rgba(168, 85, 247, 0.2) 0px, transparent 50%),
    linear-gradient(160deg, #090d16 0%, #111827 55%, #1e1b4b 100%);
  color: #f8fafc;
}
.backdrop-forest-mist {
  background:
    radial-gradient(at 15% 20%, rgba(16, 185, 129, 0.2) 0px, transparent 50%),
    radial-gradient(at 85% 75%, rgba(20, 184, 166, 0.18) 0px, transparent 50%),
    linear-gradient(150deg, #ecfdf5 0%, #f0fdfa 55%, #e6f4ea 100%);
  color: #064e3b;
}
.backdrop-sunset-glow {
  background:
    radial-gradient(at 20% 15%, rgba(251, 146, 60, 0.24) 0px, transparent 50%),
    radial-gradient(at 85% 30%, rgba(244, 63, 94, 0.2) 0px, transparent 50%),
    linear-gradient(145deg, #fff7ed 0%, #fff1f2 55%, #fef3c7 100%);
  color: #431407;
}

/* Paper Sheet inside Backdrop */
.craft-paper-sheet {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow:
    0 20px 50px -12px rgba(15, 23, 42, 0.08),
    0 4px 16px -2px rgba(15, 23, 42, 0.04);
  border-radius: 24px;
  transition: all 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: text;
}

.backdrop-warm-sand .craft-paper-sheet {
  background: rgba(255, 252, 245, 0.95);
  border-color: rgba(231, 220, 204, 0.8);
}

.backdrop-midnight-slate .craft-paper-sheet {
  background: rgba(17, 24, 39, 0.88);
  border-color: rgba(255, 255, 255, 0.1);
  color: #f1f5f9;
  box-shadow:
    0 24px 60px -12px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(255, 255, 255, 0.06);
}

/* 8 Curated Cover Gradients */
.cover-aurora-mesh {
  background: linear-gradient(125deg, #4f46e5 0%, #9333ea 45%, #ec4899 85%, #fb7185 100%);
}
.cover-sunset-silk {
  background: linear-gradient(125deg, #f97316 0%, #f43f5e 52%, #a855f7 100%);
}
.cover-ocean-breeze {
  background: linear-gradient(125deg, #0284c7 0%, #06b6d4 50%, #34d399 100%);
}
.cover-emerald-forest {
  background: linear-gradient(135deg, #065f46 0%, #059669 50%, #a7f3d0 100%);
}
.cover-midnight-cosmos {
  background: radial-gradient(circle at 75% 25%, #6366f1 0%, #312e81 42%, #090d16 100%);
}
.cover-royal-velvet {
  background: linear-gradient(135deg, #3b0764 0%, #7e22ce 50%, #f472b6 100%);
}
.cover-golden-hour {
  background: linear-gradient(135deg, #d97706 0%, #f59e0b 48%, #fde68a 100%);
}
.cover-minimal-slate {
  background: linear-gradient(135deg, #334155 0%, #64748b 55%, #cbd5e1 100%);
}

/* Font style classes */
.font-style-sans {
  font-family: var(--font-sans);
}
.font-style-serif {
  font-family: var(--font-serif);
}
.font-style-mono {
  font-family: var(--font-mono);
}

/* Editable block styling */
.block-row {
  position: relative;
  border-radius: 12px;
  transition: background-color 0.15s ease, transform 0.15s ease;
}
.block-row:hover {
  background-color: rgba(148, 163, 184, 0.08);
}
.block-row.dragging {
  opacity: 0.45;
  transform: scale(0.99);
}
.block-row.drag-over {
  box-shadow: 0 -2px 0 0 #6366f1;
}

.block-handle {
  opacity: 0;
  transition: opacity 0.15s ease;
}
.block-row:hover .block-handle {
  opacity: 1;
}

.block-input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  color: inherit;
  font-family: inherit;
  line-height: 1.65;
  padding: 0;
  margin: 0;
}

/* Craft Subpage Card Animations */
.craft-subpage-card {
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
}
.craft-subpage-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px -8px rgba(15, 23, 42, 0.12);
}

/* Drilldown Page Animation */
@keyframes pageDrillIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.animate-page-in {
  animation: pageDrillIn 0.24s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Mobile Bottom Navigation (Desktop Hidden, Mobile Fixed Bar) */
#mobile-bottom-nav {
  display: none;
}

.block-row:focus-within .block-handle {
  opacity: 1;
}

@media (max-width: 768px) {
  body {
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
  }

  /* Hide non-active panes on mobile */
  body[data-mobile-active="folders"] #middle-pane,
  body[data-mobile-active="folders"] #main-canvas-pane {
    display: none !important;
  }
  body[data-mobile-active="folders"] #sidebar-pane {
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    padding-bottom: 78px !important;
  }

  body[data-mobile-active="list"] #sidebar-pane,
  body[data-mobile-active="list"] #main-canvas-pane {
    display: none !important;
  }
  body[data-mobile-active="list"] #middle-pane {
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    padding-bottom: 78px !important;
  }

  body[data-mobile-active="editor"] #sidebar-pane,
  body[data-mobile-active="editor"] #middle-pane,
  body[data-mobile-active="editor"] #style-inspector-panel {
    display: none !important;
  }
  body[data-mobile-active="editor"] #main-canvas-pane {
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  body[data-mobile-active="editor"] #main-canvas-scroll {
    padding: 12px 10px 88px 10px !important;
  }

  body[data-mobile-active="inspector"] #sidebar-pane,
  body[data-mobile-active="inspector"] #middle-pane,
  body[data-mobile-active="inspector"] #main-canvas-scroll {
    display: none !important;
  }
  body[data-mobile-active="inspector"] #main-canvas-pane {
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  body[data-mobile-active="inspector"] #style-inspector-panel {
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    padding-bottom: 78px !important;
  }

  /* Mobile Top Header Bar */
  header.craft-glass-header {
    padding: 8px 12px !important;
    gap: 8px !important;
    overflow-x: auto;
  }
  #top-header-actions {
    overflow-x: auto;
    max-width: 64vw;
    padding-bottom: 2px;
  }
  #top-header-actions button {
    white-space: nowrap;
    padding: 5px 9px !important;
  }

  /* Mobile Craft Paper Sheet */
  .craft-paper-sheet {
    border-radius: 18px !important;
  }
  .craft-paper-sheet .px-10 {
    padding-left: 1.15rem !important;
    padding-right: 1.15rem !important;
  }

  /* Touch-friendly controls on mobile */
  .block-handle,
  .subpage-style-switcher {
    opacity: 1 !important;
  }

  /* Floating popovers fit mobile screen */
  #slash-menu-popover,
  #block-action-popover {
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    max-width: calc(100vw - 24px) !important;
  }

  /* Mobile Bottom Navigation Bar */
  #mobile-bottom-nav {
    display: flex;
    align-items: center;
    justify-content: space-around;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(62px + env(safe-area-inset-bottom, 0px));
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px)) 8px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid rgba(226, 232, 240, 0.9);
    box-shadow: 0 -8px 24px -6px rgba(15, 23, 42, 0.08);
    z-index: 45;
  }

  body.theme-dark #mobile-bottom-nav {
    background: rgba(15, 23, 42, 0.92);
    border-top: 1px solid rgba(51, 65, 85, 0.85);
    box-shadow: 0 -8px 24px -6px rgba(2, 6, 23, 0.6);
  }

  .mobile-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 6px 4px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    transition: all 0.15s ease;
  }

  .mobile-nav-btn.is-active {
    color: #4f46e5;
    background: rgba(99, 102, 241, 0.12);
    font-weight: 700;
  }

  body.theme-dark .mobile-nav-btn {
    color: #94a3b8;
  }

  body.theme-dark .mobile-nav-btn.is-active {
    color: #a5b4fc;
    background: rgba(99, 102, 241, 0.24);
  }

  .mobile-nav-fab {
    width: 42px;
    height: 42px;
    margin: 0 4px;
    border-radius: 14px;
    background: linear-gradient(135deg, #34d399 0%, #38bdf8 35%, #6366f1 70%, #f472b6 100%);
    color: #ffffff;
    font-size: 20px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px -3px rgba(99, 102, 241, 0.45);
    flex-shrink: 0;
  }

  #toast-banner {
    bottom: 76px !important;
    right: 16px !important;
    left: 16px !important;
    text-align: center;
  }
}

/* Print / PDF Export Styles */
@media print {
  body {
    overflow: visible !important;
    background: #ffffff !important;
    color: #0f172a !important;
  }
  .no-print {
    display: none !important;
  }
  #main-canvas-scroll {
    overflow: visible !important;
    height: auto !important;
    padding: 0 !important;
  }
  .craft-paper-sheet {
    box-shadow: none !important;
    border: none !important;
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 12px !important;
    background: #ffffff !important;
    color: #0f172a !important;
  }
}
