/* ==========================================================================
   IDOffice Styles (DOCX, PPTX, XLSX)
   Light & Dark Theme Harmonized Floating Window
   ========================================================================== */

/* Badges */
.badge-docx {
  background: rgba(59, 130, 246, 0.2);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.35);
}
.badge-xlsx {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.35);
}
.badge-pptx {
  background: rgba(249, 115, 22, 0.2);
  color: #f97316;
  border: 1px solid rgba(249, 115, 22, 0.35);
}

body.theme-light .badge-docx {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}
body.theme-light .badge-xlsx {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}
body.theme-light .badge-pptx {
  background: #fff7ed;
  color: #c2410c;
  border-color: #fed7aa;
}

.office-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 4px;
  line-height: 1.2;
}

.office-mini-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

/* Docs 2-Pane Split View */
.docs-split-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 128px);
  width: 100%;
}

.docs-list-column {
  width: 380px;
  min-width: 300px;
  max-width: 440px;
  border-right: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-surface, #111827);
  flex-shrink: 0;
}

body.theme-light .docs-list-column {
  background: #f8fafc;
  border-right-color: #e2e8f0;
}

.docs-preview-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-main, #0b0f17);
  position: relative;
}

body.theme-light .docs-preview-pane {
  background: #ffffff;
}

.docs-preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-dim, #94a3b8);
  gap: 12px;
  padding: 24px;
  text-align: center;
}

.docs-preview-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.docs-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  background: var(--bg-card, #1e293b);
  flex-shrink: 0;
}

body.theme-light .docs-preview-header {
  background: #f1f5f9;
  border-bottom-color: #e2e8f0;
}

.docs-preview-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.doc-card.active {
  background: rgba(59, 130, 246, 0.12) !important;
  border-color: #3b82f6 !important;
}

body.theme-light .doc-card.active {
  background: #eff6ff !important;
  border-color: #3b82f6 !important;
}

/* Floating Window Container for Office */
.office-float-win {
  min-width: 520px;
  min-height: 420px;
  width: 960px;
  height: 680px;
  max-width: 98vw;
  max-height: calc(100vh - 12px);
  z-index: 105;
}

.office-header-save-btn {
  padding: 4px 10px;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  margin-right: 6px;
}

.office-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: var(--bg-surface, #111827);
}

body.theme-light .office-body {
  background: #f8fafc;
}

/* Docs Dropdown Creation Menu in Sidebar */
.docs-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 260px;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

body.theme-light .docs-dropdown-menu {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.15);
}

.docs-dropdown-menu.hidden {
  display: none !important;
}

.docs-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  background: transparent;
  border: none;
  color: var(--text-main, #f1f5f9);
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all 0.15s ease;
}

.docs-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

body.theme-light .docs-dropdown-item:hover {
  background: #f1f5f9;
}

.docs-dropdown-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
}

.docs-dropdown-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main, #f1f5f9);
}

body.theme-light .docs-dropdown-title {
  color: #0f172a;
}

.docs-dropdown-sub {
  font-size: 11px;
  color: var(--text-dim, #94a3b8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.theme-light .docs-dropdown-sub {
  color: #64748b;
}

/* Office Toolbar */
.office-layout {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.office-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 4px;
  padding: 6px 12px;
  background: var(--bg-surface, #1e293b);
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

body.theme-light .office-toolbar {
  background: #f1f5f9;
  border-bottom-color: #e2e8f0;
}

.btn-tb {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-main, #f1f5f9);
  padding: 4px 6px;
  min-width: 28px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

body.theme-light .btn-tb {
  color: #334155;
}

.btn-tb:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

body.theme-light .btn-tb:hover {
  background: #e2e8f0;
  border-color: #cbd5e1;
  color: #0f172a;
}

.btn-tb.active {
  background: rgba(59, 130, 246, 0.25) !important;
  border-color: rgba(59, 130, 246, 0.4) !important;
  color: #60a5fa !important;
}

body.theme-light .btn-tb.active {
  background: #dbeafe !important;
  border-color: #bfdbfe !important;
  color: #1d4ed8 !important;
}

.btn-tb-sm {
  min-width: 22px;
  height: 24px;
  padding: 2px 5px;
  font-size: 11px;
}

.btn-tb-text {
  font-weight: 500;
  font-size: 12px;
  padding: 4px 8px;
}

.tb-divider {
  width: 1px;
  height: 18px;
  background: var(--border-color, rgba(255, 255, 255, 0.12));
  margin: 0 4px;
  flex-shrink: 0;
}

body.theme-light .tb-divider {
  background: #cbd5e1;
}

.tb-select {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  color: var(--text-main, #f1f5f9);
  padding: 2px 6px;
  font-size: 12px;
  height: 28px;
  outline: none;
  cursor: pointer;
  flex-shrink: 0;
}

body.theme-light .tb-select {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}

.tb-style-select { width: 110px; }
.tb-font-select { width: 130px; }
.tb-zoom-select { width: 75px; }

.tb-size-stepper {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  height: 28px;
  padding: 0 2px;
  flex-shrink: 0;
}

body.theme-light .tb-size-stepper {
  background: #ffffff;
  border-color: #cbd5e1;
}

.tb-size-input {
  width: 32px;
  border: none;
  background: transparent;
  text-align: center;
  color: var(--text-main, #f1f5f9);
  font-size: 12px;
  font-weight: 600;
  outline: none;
  appearance: textfield;
  -moz-appearance: textfield;
}

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

body.theme-light .tb-size-input {
  color: #0f172a;
}

/* Ruler Styling */
.docx-ruler-wrapper {
  background: #1e293b;
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  display: flex;
  justify-content: center;
  padding: 0 24px;
  flex-shrink: 0;
  user-select: none;
}

body.theme-light .docx-ruler-wrapper {
  background: #f8fafc;
  border-bottom-color: #e2e8f0;
}

.docx-ruler {
  width: 100%;
  max-width: 800px;
  height: 20px;
  background: #ffffff;
  position: relative;
  display: flex;
  border-left: 1px solid #cbd5e1;
  border-right: 1px solid #cbd5e1;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.docx-ruler-track {
  width: 100%;
  height: 100%;
  display: flex;
  position: relative;
}

.ruler-unit {
  flex: 1;
  height: 100%;
  border-right: 1px solid #94a3b8;
  position: relative;
  font-size: 9px;
  font-family: Arial, sans-serif;
  color: #475569;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 2px;
}

.ruler-tick-sub {
  position: absolute;
  top: 0;
  left: 50%;
  width: 1px;
  height: 6px;
  background: #cbd5e1;
}

.ruler-marker-left {
  position: absolute;
  left: 56px;
  top: 0;
  width: 12px;
  height: 20px;
  cursor: ew-resize;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ruler-marker-right {
  position: absolute;
  right: 56px;
  top: 6px;
  width: 12px;
  height: 14px;
  cursor: ew-resize;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ruler-marker-triangle {
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #2563eb;
}

.ruler-marker-rect {
  width: 10px;
  height: 4px;
  background: #2563eb;
  margin-bottom: 2px;
}

/* Loading & Error States */
.office-loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
}

/* 1. DOCX Paper Styling */
.docx-paper-container {
  flex: 1;
  overflow: auto;
  padding: 24px;
  display: flex;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
}

body.theme-light .docx-paper-container {
  background: #e2e8f0;
}

.docx-paper {
  width: 100%;
  max-width: 800px;
  min-height: 960px;
  background: #ffffff;
  color: #1a1a1a;
  padding: 48px 56px;
  border-radius: 2px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  outline: none;
  font-family: Arial, sans-serif;
  line-height: 1.6;
  font-size: 14px;
  transform-origin: top center;
  transition: transform 0.15s ease;
}

body.theme-light .docx-paper {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.docx-paragraph {
  margin-bottom: 12px;
  min-height: 20px;
  outline: none;
}

.docx-paragraph:focus {
  background: rgba(59, 130, 246, 0.04);
}

/* Document Table Styling */
.docx-table-wrap {
  margin: 16px 0;
  position: relative;
  display: block;
}

.docx-table-actions {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
  opacity: 0.85;
}

.docx-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
  border: 1px solid #94a3b8;
}

.docx-table th, .docx-table td {
  border: 1px solid #cbd5e1;
  padding: 8px 12px;
  min-width: 60px;
  outline: none;
  font-size: 13px;
}

.docx-table th {
  background: #f1f5f9;
  font-weight: 600;
}

.docx-table td:focus, .docx-table th:focus {
  background: #eff6ff;
  border-color: #3b82f6;
}

/* 2. XLSX Spreadsheet Grid Styling */
.xlsx-toolbar {
  gap: 10px;
}

.xlsx-cell-pos {
  font-weight: 700;
  font-family: monospace;
  font-size: 13px;
  padding: 3px 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  color: #10b981;
  min-width: 44px;
  text-align: center;
}

body.theme-light .xlsx-cell-pos {
  background: #e2e8f0;
  color: #047857;
}

.xlsx-formula-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  padding: 4px 10px;
  color: var(--text-main, #f1f5f9);
  font-size: 13px;
  outline: none;
}

body.theme-light .xlsx-formula-input {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}

.xlsx-formula-input:focus {
  border-color: #10b981;
}

.xlsx-grid-container {
  flex: 1;
  overflow: auto;
  background: #0f141c;
}

body.theme-light .xlsx-grid-container {
  background: #f8fafc;
}

.xlsx-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.xlsx-corner, .xlsx-col-header, .xlsx-row-header {
  background: #1a2230;
  color: var(--text-dim, #94a3b8);
  font-weight: 600;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  user-select: none;
}

body.theme-light .xlsx-corner,
body.theme-light .xlsx-col-header,
body.theme-light .xlsx-row-header {
  background: #f1f5f9;
  color: #64748b;
  border-color: #e2e8f0;
}

.xlsx-col-header {
  min-width: 90px;
  padding: 5px 8px;
}

.xlsx-row-header {
  width: 42px;
  padding: 4px 6px;
}

.xlsx-cell {
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 4px 8px;
  color: var(--text-main, #e2e8f0);
  outline: none;
  min-width: 90px;
  height: 24px;
  white-space: nowrap;
}

body.theme-light .xlsx-cell {
  border-color: #e2e8f0;
  color: #1e293b;
  background: #ffffff;
}

.xlsx-cell:focus {
  outline: 2px solid #10b981;
  background: rgba(16, 185, 129, 0.12);
}

body.theme-light .xlsx-cell:focus {
  background: rgba(16, 185, 129, 0.08);
}

.xlsx-sheet-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: #141b27;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

body.theme-light .xlsx-sheet-tabs {
  background: #f1f5f9;
  border-top-color: #e2e8f0;
}

.xlsx-tab {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-dim, #94a3b8);
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}

body.theme-light .xlsx-tab {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #64748b;
}

.xlsx-tab.active {
  background: #10b981;
  color: #ffffff;
  font-weight: 700;
  border-color: #10b981;
}

.xlsx-tab-add {
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.25);
  color: var(--text-dim, #94a3b8);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}

body.theme-light .xlsx-tab-add {
  border-color: #cbd5e1;
  color: #64748b;
}

/* 3. PPTX Slide Deck Styling */
.pptx-stage {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.pptx-sidebar {
  width: 190px;
  background: rgba(0, 0, 0, 0.25);
  border-right: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

body.theme-light .pptx-sidebar {
  background: #f1f5f9;
  border-right-color: #e2e8f0;
}

.pptx-thumb {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: all 0.15s ease;
}

body.theme-light .pptx-thumb {
  background: #ffffff;
  border-color: #cbd5e1;
}

.pptx-thumb.active, .pptx-thumb:hover {
  background: rgba(249, 115, 22, 0.15);
  border-color: #f97316;
}

body.theme-light .pptx-thumb.active {
  background: #fff7ed;
  border-color: #f97316;
}

.pptx-thumb-num {
  font-weight: 700;
  font-size: 12px;
  color: #f97316;
}

.pptx-thumb-preview {
  font-size: 11px;
  color: var(--text-main, #f1f5f9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.theme-light .pptx-thumb-preview {
  color: #334155;
}

.pptx-canvas-wrap {
  flex: 1;
  overflow: auto;
  padding: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
}

body.theme-light .pptx-canvas-wrap {
  background: #e2e8f0;
}

.pptx-slide-canvas {
  width: 100%;
  max-width: 720px;
  aspect-ratio: 16 / 9;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  padding: 36px 44px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

body.theme-light .pptx-slide-canvas {
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.12);
}

.pptx-shape {
  width: 100%;
}

.pptx-textarea {
  width: 100%;
  border: 1px dashed transparent;
  outline: none;
  background: transparent;
  color: #1e293b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  resize: none;
  line-height: 1.5;
  transition: border-color 0.15s ease;
}

.pptx-textarea:focus {
  border-color: #f97316;
  border-radius: 4px;
  background: rgba(249, 115, 22, 0.04);
}

.pptx-title-shape .pptx-textarea {
  font-size: 22px;
  font-weight: 700;
  height: 48px;
}

.pptx-body-shape .pptx-textarea {
  font-size: 14px;
  height: 160px;
}
