/* ==========================================================================
   MS WORD ONLINE (OFFICE 365 PRO) - MAIN DESIGN SYSTEM
   Fluent Design System, Rich Typography, Glassmorphism, Theme Tokens
   ========================================================================== */

:root {
  /* Microsoft Office 365 Brand Colors */
  --ms-word-blue: #185abd;
  --ms-word-dark-blue: #103f84;
  --ms-word-light-blue: #2b7cd3;
  --ms-word-ultralight-blue: #e8f1fc;
  --ms-word-accent: #0f6cbd;
  --ms-word-hover: #115ea3;

  /* Surfaces & Canvas */
  --bg-app: #f3f2f1;
  --bg-surface: #ffffff;
  --bg-subtle: #f8f9fa;
  --bg-hover: #edebe9;
  --bg-active: #e1dfdd;
  --bg-ribbon: #ffffff;
  --bg-canvas: #eaeaea;
  --bg-page: #ffffff;

  /* Borders & Dividers */
  --border-subtle: #edebe9;
  --border-default: #d1d5db;
  --border-strong: #8a8886;
  --border-focus: #185abd;

  /* Text Hierarchy */
  --text-primary: #201f1e;
  --text-secondary: #605e5c;
  --text-disabled: #a19f9d;
  --text-inverse: #ffffff;
  --text-link: #0f6cbd;

  /* Status Colors */
  --status-success: #107c41;
  --status-warning: #d83b01;
  --status-error: #a80000;
  --status-info: #0078d4;

  /* Typography */
  --font-family-ui: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
  --font-family-doc: 'Calibri', 'Aptos', 'Arial', 'Times New Roman', sans-serif;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.16);
  --shadow-page: 0 4px 24px rgba(0, 0, 0, 0.18), 0 1px 4px rgba(0, 0, 0, 0.12);
  --shadow-dropdown: 0 12px 36px rgba(0, 0, 0, 0.24), 0 2px 8px rgba(0, 0, 0, 0.14);

  /* Dimensions */
  --top-header-height: 48px;
  --ribbon-tabs-height: 38px;
  --ribbon-content-height: 92px;
  --ruler-height: 26px;
  --status-bar-height: 28px;
  
  /* Standard Page Dimensions (Letter: 816px x 1056px at 96 DPI / A4: 794px x 1123px) */
  --page-width: 816px;
  --page-height: 1056px;
  --page-padding-top: 96px;
  --page-padding-bottom: 96px;
  --page-padding-left: 96px;
  --page-padding-right: 96px;
  --page-gap: 32px;
  
  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-pill: 9999px;

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-family-ui);
  font-size: 13px;
  color: var(--text-primary);
  background-color: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
}

#app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* Top App Header / Title Bar */
.app-header {
  height: var(--top-header-height);
  background-color: var(--ms-word-blue);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  flex-shrink: 0;
  z-index: 5000;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-launcher-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.app-launcher-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.2px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.app-brand:hover {
  background-color: rgba(255, 255, 255, 0.15);
}

.app-logo-icon {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

/* Document Title & AutoSave Pill */
.document-meta-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: rgba(255, 255, 255, 0.14);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.25);
  transition: background var(--transition-fast);
}

.document-meta-box:focus-within,
.document-meta-box:hover {
  background-color: rgba(255, 255, 255, 0.25);
}

.doc-title-input {
  background: transparent;
  border: none;
  color: var(--text-inverse);
  font-weight: 600;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  min-width: 140px;
  max-width: 260px;
}

.doc-title-input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.save-status-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
  background: rgba(0, 0, 0, 0.22);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

.save-status-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #4ade80;
  display: inline-block;
  transition: background-color var(--transition-fast);
}

.save-status-indicator.saving {
  background-color: #facc15;
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

/* Quick Tools */
.quick-tools {
  display: flex;
  align-items: center;
  gap: 3px;
}

.quick-btn {
  background: transparent;
  border: none;
  color: var(--text-inverse);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast);
  position: relative;
}

.quick-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.quick-btn:active {
  background-color: rgba(255, 255, 255, 0.3);
}

.quick-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-bar-header {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  gap: 8px;
  width: 220px;
  transition: all var(--transition-fast);
}

.search-bar-header:focus-within {
  background: #ffffff;
  width: 280px;
  box-shadow: var(--shadow-sm);
}

.search-bar-header:focus-within input {
  color: var(--text-primary);
}

.search-bar-header:focus-within svg {
  stroke: var(--text-secondary);
}

.search-bar-header input {
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 12px;
  outline: none;
  width: 100%;
}

.search-bar-header input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.search-bar-header svg {
  width: 15px;
  height: 15px;
  stroke: #ffffff;
  flex-shrink: 0;
}

.btn-header-export {
  background-color: #ffffff;
  color: var(--ms-word-blue);
  border: none;
  font-weight: 600;
  font-size: 12px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-header-export:hover {
  background-color: #f0f4f9;
  box-shadow: var(--shadow-sm);
}

.btn-header-export svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
}

.user-avatar-pill {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #0f6cbd;
  border: 2px solid #ffffff;
  color: #ffffff;
  font-weight: 700;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

/* App Main Body Split View */
.app-workspace-body {
  display: flex;
  flex: 1;
  width: 100%;
  height: calc(100vh - var(--top-header-height) - var(--ribbon-tabs-height) - var(--ribbon-content-height) - var(--ruler-height) - var(--status-bar-height));
  position: relative;
  overflow: hidden;
}

/* Status Bar */
.app-status-bar {
  height: var(--status-bar-height);
  background-color: var(--ms-word-blue);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 11.5px;
  font-weight: 500;
  flex-shrink: 0;
  z-index: 5000;
  box-shadow: 0 -1px 3px rgba(0,0,0,0.1);
}

.status-left, .status-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.status-item:hover {
  background-color: rgba(255, 255, 255, 0.18);
}

.status-item svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
}

/* Zoom Controls */
.zoom-control-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.zoom-btn {
  background: transparent;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 2px;
}

.zoom-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.zoom-btn svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
}

.zoom-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.4);
  outline: none;
  cursor: pointer;
}

.zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.zoom-slider::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
  border: none;
}

/* Custom Context Menu */
#custom-context-menu {
  position: fixed;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-dropdown);
  padding: 6px;
  z-index: 100000;
  display: none;
  min-width: 180px;
}

#custom-context-menu.show {
  display: block;
}

/* Drawing Canvas Layer */
#drawing-canvas-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 15;
}

#drawing-canvas-layer.active {
  pointer-events: auto;
  cursor: crosshair;
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 40px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200000;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 400px;
  background: #ffffff;
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 500;
  border-left: 4px solid var(--ms-word-blue);
  animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: all 0.3s ease;
}

.toast.success { border-left-color: var(--status-success); }
.toast.warning { border-left-color: var(--status-warning); }
.toast.error   { border-left-color: var(--status-error); }

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #c8c6c4;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #979593;
}
