/* ==========================================================================
   Microsoft Word-Style Visual Equation Editor Styles
   ========================================================================== */

.word-equation-editor {
  background: #ffffff;
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 4px 18px rgba(99, 102, 241, 0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.word-equation-editor:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15), 0 8px 24px rgba(99, 102, 241, 0.12);
}

/* Word-Like Equation Ribbon (Header & Tabs) */
.equation-ribbon {
  background: linear-gradient(180deg, #f8faff 0%, #eef2ff 100%);
  border-bottom: 2px solid var(--border);
  padding: 0.75rem 1rem 0.5rem;
}

.ribbon-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.ribbon-title-box {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.ribbon-logo {
  font-family: var(--font-fun);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  background: #ffffff;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(99, 102, 241, 0.2);
}

.ribbon-title {
  font-family: var(--font-fun);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.ribbon-tools {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.btn-ribbon-action {
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 0.3rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.775rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s ease;
}

.btn-ribbon-action:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-hover);
}

.btn-ribbon-danger {
  color: #dc2626 !important;
  border-color: #fca5a5 !important;
  background: #fff5f5 !important;
}

.btn-ribbon-danger:hover {
  background: #fee2e2 !important;
  border-color: #ef4444 !important;
}

.btn-dismiss-keyboard {
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fca5a5;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s ease;
}

.btn-dismiss-keyboard:hover {
  background: #fecaca;
  transform: translateY(-1px);
}


/* Ribbon Tabs */
.ribbon-tabs-nav {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 0.25rem;
}

.ribbon-tabs-nav::-webkit-scrollbar {
  display: none;
}

.ribbon-tab-btn {
  background: none;
  border: none;
  padding: 0.35rem 0.75rem;
  font-family: var(--font-sans);
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-full);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.ribbon-tab-btn:hover {
  color: var(--primary);
  background: rgba(99, 102, 241, 0.08);
}

.ribbon-tab-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
}

/* Ribbon Tools Content Bar */
.ribbon-shelf {
  background: #ffffff;
  border-bottom: 1.5px solid var(--border);
  padding: 0.6rem 0.85rem;
  min-height: 54px;
  display: flex;
  align-items: center;
  overflow-x: auto;
}

.ribbon-buttons-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: nowrap;
}

/* Individual Structure / Symbol Buttons */
.btn-struct-tool {
  background: #ffffff;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.3rem 0.55rem;
  min-width: 44px;
  height: 40px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-size: 0.85rem;
  color: var(--text-main);
  user-select: none;
  flex-shrink: 0;
}

.btn-struct-tool:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 3px 8px rgba(99, 102, 241, 0.15);
}

.btn-struct-tool:active {
  transform: translateY(0);
}

.btn-struct-tool .struct-symbol {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  line-height: 1;
}

.btn-struct-tool .struct-name {
  font-size: 0.65rem;
  color: var(--text-light);
  margin-top: 1px;
}

/* Visual Equation Canvas (Interactive Word-Like <math-field>) */
.word-canvas-wrapper {
  background: #ffffff;
  padding: 1.25rem 1.5rem;
  position: relative;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* MathLive Web Component Styling */
math-field.word-math-canvas {
  width: 100%;
  font-size: 1.5rem;
  min-height: 60px;
  padding: 0.65rem 0.85rem;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  background: #fbfcfe;
  color: #1e1b4b;
  outline: none;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
}

math-field.word-math-canvas:focus-within {
  background: #ffffff;
  border: 2px solid var(--primary);
  border-style: solid;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.1);
}

/* Fallback textarea if web component is loading */
.word-math-fallback {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 1.15rem;
  padding: 0.65rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  min-height: 60px;
  resize: vertical;
}

/* Canvas Hint Bar */
.canvas-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.775rem;
  color: var(--text-muted);
}

.word-shortcut-hints {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.shortcut-badge {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-main);
  font-weight: 600;
}

/* LaTeX Source Toggle Drawer */
.latex-drawer {
  background: #1e1b4b;
  color: #ffffff;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.latex-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--sky);
  font-weight: 700;
}

.latex-source-code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #f1f5f9;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  width: 100%;
  resize: vertical;
  min-height: 48px;
}
