/* ══════════════════════════════════════════════════════════════════════════════
   HIGH CONTRAST EXCEL 365 DESIGN SYSTEM (MAXIMUM TEXT READABILITY)
   ══════════════════════════════════════════════════════════════════════════════ */

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

:root {
  --excel-primary: #107c41;
  --excel-primary-hover: #0b582e;
  --excel-primary-light: #dff6dd;
  --excel-accent: #047857;
  --excel-blue: #0284c7;
  
  --excel-bg-light: #ffffff;
  --excel-header-bg: #e2e8f0;
  --excel-border-light: #cbd5e1;
  --excel-gridline-light: #cbd5e1;
  --excel-text-dark: #0f172a;

  --excel-font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --excel-mono: 'JetBrains Mono', 'Consolas', monospace;
}

/* 1. POWER PIVOT MAIN CONTAINER */
.power-pivot-wrapper {
  display: flex;
  flex-direction: column;
  height: auto;
  min-height: calc(100vh - 200px);
  background: #ffffff;
  color: #0f172a;
  font-family: var(--excel-font);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  border: 1.5px solid var(--excel-border-light);
  margin-top: 0 !important;
  position: relative;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* 2. EXCEL 365 GREEN RIBBON TOOLBAR */
.excel-ribbon-bar {
  background: linear-gradient(180deg, #107c41 0%, #0b582e 100%);
  border-bottom: 2px solid #073b1e;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  user-select: none;
  color: #ffffff;
}

.excel-ribbon-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  flex-wrap: wrap;
  gap: 8px;
}

.excel-app-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 800;
  color: #ffffff;
}

.btn-ribbon-header-primary {
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 800;
  color: #ffffff;
  background: linear-gradient(135deg, #059669, #047857);
  border: 1px solid #34d399;
  border-radius: 5px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.btn-ribbon-header-primary:hover {
  background: linear-gradient(135deg, #107c41, #059669);
  transform: translateY(-1px);
}

.btn-ribbon-header-secondary {
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.btn-ribbon-header-secondary:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: #ffffff;
}

.excel-ribbon-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 8px 0;
}

.excel-tab-btn {
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 700;
  color: #ecfdf5;
  background: transparent;
  border: none;
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.excel-tab-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.2);
}

.excel-tab-btn.active {
  color: #064e3b;
  background: #ffffff;
  font-weight: 800;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.2);
}

.excel-ribbon-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  overflow-x: auto;
  background: #ffffff;
  border-bottom: 1px solid var(--excel-border-light);
}

.excel-tool-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-right: 8px;
  border-right: 1px solid var(--excel-border-light);
}

.excel-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 4px;
  background: #f1f5f9;
  border: 1px solid #94a3b8;
  color: #0f172a;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.excel-action-btn:hover {
  background: #dff6dd;
  color: #064e3b;
  border-color: #107c41;
}

/* 3. EXCEL FORMULA BAR */
.excel-formula-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: #f1f5f9;
  border-bottom: 1px solid var(--excel-border-light);
  font-size: 11px;
}

.excel-cell-address {
  width: 50px;
  padding: 2px 4px;
  background: #ffffff;
  border: 1px solid #94a3b8;
  border-radius: 3px;
  color: #064e3b;
  font-weight: 900;
  text-align: center;
  font-family: var(--excel-mono);
  font-size: 11px;
}

.excel-fx-btn {
  font-weight: 900;
  font-style: italic;
  color: #107c41;
  font-size: 13px;
  cursor: pointer;
  padding: 0 4px;
  user-select: none;
}

.excel-formula-input {
  flex: 1;
  padding: 2px 8px;
  background: #ffffff;
  border: 1px solid #94a3b8;
  border-radius: 3px;
  color: #0f172a;
  font-family: var(--excel-mono);
  font-size: 11px;
  font-weight: 600;
}

/* 4. MAIN WORKSPACE (GRID + FIELDS PANEL) */
.pivot-main-workspace {
  display: flex;
  flex: 1;
  min-height: 480px;
  position: relative;
  overflow: visible;
}

/* 5. HIGH-CONTRAST LIGHT EXCEL GRID CANVAS (PURE BLACK TEXT) */
.excel-grid-viewport {
  flex: 1;
  overflow: auto;
  min-height: 450px;
  max-height: calc(100vh - 220px);
  position: relative;
  background: #ffffff;
  color: #000000 !important;
  -webkit-overflow-scrolling: touch;
}

.excel-sheet-table {
  border-collapse: collapse;
  table-layout: fixed;
  width: max-content;
  font-size: 11px;
  line-height: 1.2;
  color: #000000 !important;
}

.excel-sheet-table * {
  color: #000000 !important;
}

/* Headers: Columns (A, B, C...) & Rows (1, 2, 3...) */
.excel-col-header {
  background: #e2e8f0;
  color: #000000 !important;
  font-weight: 800;
  text-align: center;
  border: 1px solid #cbd5e1;
  padding: 3px 6px;
  position: sticky;
  top: 0;
  z-index: 5;
  user-select: none;
  min-width: 65px;
  box-sizing: border-box;
  font-size: 10.5px;
}

.excel-col-header span {
  color: #000000 !important;
  font-weight: 800;
}

.excel-row-header {
  background: #e2e8f0;
  color: #000000 !important;
  font-weight: 800;
  text-align: center;
  border: 1px solid #cbd5e1;
  padding: 3px 4px;
  position: sticky;
  left: 0;
  z-index: 6;
  user-select: none;
  width: 26px;
  box-sizing: border-box;
  font-size: 10.5px;
}

.excel-corner-header {
  background: #cbd5e1;
  position: sticky;
  top: 0;
  left: 0;
  z-index: 10;
  border: 1px solid #94a3b8;
  color: #000000 !important;
}

/* HIGH-CONTRAST DATA CELLS WITH PURE SOLID BLACK TEXT (#000000) */
.excel-data-cell {
  border: 1px solid #cbd5e1;
  padding: 3px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  outline: none;
  transition: background 0.1s ease;
  background: #ffffff;
  color: #000000 !important;
  font-size: 11px;
  font-weight: 600;
}

.excel-data-cell:nth-child(even) {
  background: #f8fafc;
}

.excel-data-cell.selected {
  outline: 2px solid #107c41 !important;
  outline-offset: -2px;
  background: #dff6dd !important;
  color: #000000 !important;
}

.excel-data-cell.numeric {
  text-align: right;
  font-family: var(--excel-mono);
  font-size: 11px;
  font-weight: 800;
  color: #000000 !important;
}

/* 6. RIGHT SIDE PIVOTTABLE FIELDS PANEL */
.pivot-fields-pane {
  width: 285px;
  background: #f8fafc;
  border-left: 1.5px solid var(--excel-border-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.pivot-fields-header {
  padding: 8px 12px;
  background: #107c41;
  border-bottom: 1px solid #0b582e;
  font-weight: 800;
  font-size: 12px;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pivot-fields-search {
  padding: 6px 10px;
  background: #ffffff;
  border-bottom: 1px solid var(--excel-border-light);
}

.pivot-fields-search input {
  width: 100%;
  padding: 4px 8px;
  border-radius: 4px;
  background: #ffffff;
  border: 1px solid #94a3b8;
  color: #0f172a;
  font-size: 11px;
  font-weight: 600;
  outline: none;
}

.pivot-fields-search input:focus {
  border-color: #107c41;
}

.pivot-fields-tree {
  flex: 1;
  min-height: 140px;
  max-height: 280px;
  overflow-y: auto;
  padding: 6px 10px;
  background: #ffffff;
  -webkit-overflow-scrolling: touch;
}

.pivot-table-group {
  margin-bottom: 6px;
}

.pivot-table-title {
  font-weight: 900;
  font-size: 11.5px;
  color: #064e3b;
  padding: 3px 0;
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  user-select: none;
}

.pivot-field-item {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  margin: 2px 0 2px 8px;
  border-radius: 4px;
  background: #f1f5f9;
  border: 1px dashed #94a3b8;
  color: #0f172a;
  font-size: 11px;
  font-weight: 600;
  cursor: grab;
  user-select: none;
  transition: all 0.15s ease;
}

.pivot-field-item:hover {
  background: #dff6dd;
  border-color: #107c41;
  color: #064e3b;
}

/* 7. 4 QUADRANTS DROP ZONES */
.pivot-dropzones-grid {
  height: 190px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 6px;
  padding: 6px;
  background: #e2e8f0;
  border-top: 1.5px solid var(--excel-border-light);
}

.pivot-dropzone-box {
  background: #ffffff;
  border: 1px dashed #94a3b8;
  border-radius: 5px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.15s ease;
}

.pivot-dropzone-box:hover {
  border-color: #107c41;
  background: #dff6dd;
}

.pivot-dropzone-title {
  font-size: 9.5px;
  font-weight: 900;
  text-transform: uppercase;
  color: #064e3b;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 3px;
  letter-spacing: 0.3px;
}

.pivot-dropzone-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 25px;
}

.pivot-tag-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 5px;
  background: linear-gradient(135deg, #047857, #065f46);
  color: #ffffff;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
}

.pivot-tag-chip select {
  background: rgba(0, 0, 0, 0.3);
  color: #ffffff;
  border: none;
  border-radius: 2px;
  font-size: 9px;
  padding: 1px 2px;
  margin-left: 2px;
  font-weight: 700;
}

.pivot-order-btn {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  border-radius: 2px;
  font-size: 8px;
  padding: 0 2px;
  cursor: pointer;
  line-height: 1;
}

.pivot-order-btn:hover:not(:disabled) {
  background: #ffffff;
  color: #047857;
}

/* REMOVE BUTTON FOR DROP ZONE FIELD CHIPS */
.pivot-chip-remove-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  min-width: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #ffffff;
  font-size: 9px;
  font-weight: 900;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.pivot-chip-remove-btn:hover {
  background: #ef4444;
  border-color: #ef4444;
  color: #ffffff;
  transform: scale(1.2);
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
}

/* 8. EXCEL STATUS BAR */
.excel-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 12px;
  background: #107c41;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  user-select: none;
}

.excel-status-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
