/* ==========================================================================
   FACTOR & FACTORIAL CALCULATOR STYLESHEET - CALCULATOR ARCHIVE
   Pixel-perfect match to clone reference images:
   - Image 1: Quick Factorial Calculator (n!) Modal & Engine
   - Image 2: Factor Calculator with 120 default, green Calculate button,
              sidebar search bar & Math Calculators card
   - High-DPI Factor Tree SVG, Factorial Canvas Chart, History & Print Suite
   ========================================================================== */

:root {
  --fac-primary-blue: #0844a4;
  --fac-header-blue: #2c5f88;
  --fac-header-dark: #1f4366;
  --fac-green: #3d7a22;
  --fac-green-hover: #32661c;
  --fac-gray-btn: #888888;
  --fac-gray-btn-hover: #737373;
  --fac-card-bg: #eeeeee;
  --fac-card-border: #cccccc;
  --fac-input-border: #7f9db9;
  --fac-res-bg: #eef8ea;
  --fac-res-border: #c3e6cb;
  --fac-res-dark: #134e15;
  --fac-text: #333333;
  --fac-font: Arial, Helvetica, sans-serif;
}

/* Page Wrapper */
.fac-page-wrapper {
  max-width: 1000px;
  margin: 0 auto;
  padding: 12px 16px 50px;
  font-family: var(--fac-font);
  color: var(--fac-text);
  box-sizing: border-box;
}

/* Top Utility Toolbar */
.fac-top-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.fac-tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  font-size: 12px;
  color: #334155;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.fac-tool-btn:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

.fac-tool-btn.primary {
  background: #2b5a88;
  border-color: #244b72;
  color: #ffffff;
}

.fac-tool-btn.primary:hover {
  background: #1e4265;
}

.fac-badge {
  display: inline-block;
  padding: 1px 6px;
  background: #e2e8f0;
  color: #334155;
  font-size: 11px;
  font-weight: bold;
  border-radius: 10px;
}

.fac-tool-btn.primary .fac-badge {
  background: #ffffff;
  color: #2b5a88;
}

/* Breadcrumbs matching Image 2 */
.fac-breadcrumbs {
  font-size: 11.5px;
  color: var(--fac-primary-blue);
  margin-bottom: 6px;
}

.fac-breadcrumbs a {
  color: var(--fac-primary-blue);
  text-decoration: underline;
}

.fac-breadcrumbs a:hover {
  color: #002277;
}

.fac-breadcrumbs .sep {
  color: #555555;
  margin: 0 4px;
}

.fac-breadcrumbs .current {
  color: #333333;
}

/* Page Heading & Subtitle matching Image 2 */
.fac-main-heading {
  font-size: 24px;
  font-weight: bold;
  color: var(--fac-primary-blue);
  margin: 0 0 6px 0;
  line-height: 1.2;
}

.fac-subtitle {
  font-size: 13px;
  color: #333333;
  margin: 0 0 16px 0;
  line-height: 1.45;
}

/* 2-Column Layout matching Image 2 */
.fac-main-layout {
  display: flex;
  gap: 28px;
  align-items: flex-start;
}

.fac-content-col {
  flex: 1;
  min-width: 0;
}

.fac-sidebar-col {
  width: 270px;
  flex-shrink: 0;
}

/* Dual Mode Tabs (Factor Calculator vs Factorial Calculator n!) */
.fac-mode-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 0;
}

.fac-tab-btn {
  padding: 8px 18px;
  background: #e4ebf2;
  border: 1px solid #cbd5e1;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  font-size: 13px;
  font-weight: bold;
  color: #2c5f88;
  cursor: pointer;
  transition: all 0.15s ease;
}

.fac-tab-btn:hover {
  background: #d8e3ed;
}

.fac-tab-btn.active {
  background: #eeeeee;
  border-color: #cccccc;
  border-bottom: 1px solid #eeeeee;
  color: #0844a4;
  position: relative;
  z-index: 2;
  margin-bottom: -1px;
}

/* Main Calculator Input Card (Exact Clone of Image 2) */
.fac-calc-card {
  background: #eeeeee;
  border: 1px solid #cccccc;
  border-radius: 2px;
  padding: 18px 20px;
  margin-bottom: 24px;
  box-sizing: border-box;
}

.fac-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.fac-input-field {
  width: 190px;
  height: 32px;
  padding: 4px 10px;
  background: #ffffff;
  border: 1px solid #7f9db9;
  border-radius: 2px;
  font-size: 15px;
  color: #222222;
  box-sizing: border-box;
  outline: none;
}

.fac-input-field:focus {
  border-color: #0844a4;
  box-shadow: 0 0 3px rgba(8, 68, 164, 0.4);
}

/* Calculate Button matching Image 2 (Green with right-pointing triangle) */
.fac-btn-calc {
  height: 32px;
  padding: 0 16px;
  background: #3c763d;
  background: linear-gradient(to bottom, #468847 0%, #35722c 100%);
  border: 1px solid #2d6624;
  border-radius: 2px;
  color: #ffffff;
  font-size: 13.5px;
  font-weight: bold;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  transition: all 0.15s ease;
}

.fac-btn-calc:hover {
  background: linear-gradient(to bottom, #3b743c 0%, #2b5e23 100%);
}

.fac-btn-calc .play-icon {
  font-size: 11px;
  display: inline-block;
  line-height: 1;
}

/* Clear Button matching Image 2 (Neutral Gray) */
.fac-btn-clear {
  height: 32px;
  padding: 0 14px;
  background: #999999;
  background: linear-gradient(to bottom, #a3a3a3 0%, #888888 100%);
  border: 1px solid #777777;
  border-radius: 2px;
  color: #ffffff;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.15s ease;
}

.fac-btn-clear:hover {
  background: linear-gradient(to bottom, #8e8e8e 0%, #757575 100%);
}

/* Quick Number Presets / Chips */
.fac-presets-row {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed #d1d5db;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12px;
  color: #555555;
}

.fac-preset-btn {
  padding: 2px 8px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  font-size: 11.5px;
  color: #0844a4;
  cursor: pointer;
}

.fac-preset-btn:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
}

/* Result Section & Panels */
.fac-result-container {
  margin-bottom: 28px;
}

.fac-res-header-box {
  background: #eef8ea;
  border: 1px solid #c3e6cb;
  border-radius: 3px;
  padding: 14px 18px;
  margin-bottom: 18px;
}

.fac-res-title {
  font-size: 18px;
  font-weight: bold;
  color: #134e15;
  margin: 0 0 8px 0;
}

.fac-res-highlight {
  font-size: 16px;
  color: #1b5e20;
  font-weight: bold;
  word-break: break-word;
  line-height: 1.5;
}

.fac-res-subtext {
  font-size: 13px;
  color: #2e7d32;
  margin-top: 4px;
}

/* Factor Information Grid */
.fac-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 768px) {
  .fac-info-grid {
    grid-template-columns: 1fr;
  }
}

.fac-info-card {
  background: #ffffff;
  border: 1px solid #dcdcdc;
  border-radius: 3px;
  padding: 14px 16px;
}

.fac-info-card-title {
  font-size: 14px;
  font-weight: bold;
  color: var(--fac-primary-blue);
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 6px;
  margin: 0 0 10px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fac-factor-pairs-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  font-size: 13px;
  color: #333333;
  font-family: Consolas, "Courier New", monospace;
}

.fac-pair-item {
  background: #f8fafc;
  padding: 4px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 2px;
}

/* Division Steps Ladder */
.fac-ladder-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.fac-ladder-table th,
.fac-ladder-table td {
  padding: 5px 8px;
  border: 1px solid #e2e8f0;
  text-align: left;
}

.fac-ladder-table th {
  background: #f1f5f9;
  font-weight: bold;
  color: #1e293b;
}

.fac-ladder-table tr:nth-child(even) {
  background: #f8fafc;
}

/* Properties Table */
.fac-prop-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.fac-prop-table td {
  padding: 6px 10px;
  border: 1px solid #e2e8f0;
}

.fac-prop-table td:first-child {
  font-weight: bold;
  background: #f8fafc;
  width: 45%;
  color: #334155;
}

.fac-prop-table tr:hover td {
  background-color: #f1f5f9;
}

/* Factor Tree Visualizer */
.fac-tree-card {
  background: #ffffff;
  border: 1px solid #dcdcdc;
  border-radius: 3px;
  padding: 16px;
  margin-bottom: 20px;
}

.fac-tree-svg-container {
  width: 100%;
  min-height: 220px;
  overflow-x: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #fafafa;
  border: 1px solid #eaeaea;
  border-radius: 3px;
  padding: 12px;
  box-sizing: border-box;
}

/* Factorial Section Styles */
.fac-factorial-box {
  background: #fbfbfb;
  border: 1px solid #e2e8f0;
  border-radius: 3px;
  padding: 16px;
  margin-bottom: 20px;
}

.fac-factorial-result-hero {
  background: #eef8ea;
  border: 1px solid #c3e6cb;
  border-radius: 4px;
  padding: 16px 20px;
  margin-bottom: 16px;
  text-align: center;
}

.fac-factorial-formula {
  font-size: 24px;
  font-weight: bold;
  color: #134e15;
  margin: 0 0 6px 0;
  word-break: break-all;
}

.fac-expansion-box {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  padding: 10px 14px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  color: #1e293b;
  line-height: 1.6;
  max-height: 120px;
  overflow-y: auto;
  word-break: break-all;
  margin-bottom: 14px;
}

/* Permutations & Combinations Sub-Tool */
.fac-subtool-card {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  padding: 12px 16px;
  margin-bottom: 16px;
}

.fac-subtool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Chart Canvas Container */
.fac-chart-card {
  background: #ffffff;
  border: 1px solid #dcdcdc;
  border-radius: 3px;
  padding: 16px;
  margin-bottom: 24px;
}

.fac-canvas-wrapper {
  position: relative;
  width: 100%;
  height: 240px;
}

.fac-canvas-wrapper canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* SIDEBAR MATCHING IMAGE 2 */
.fac-sidebar-search-box {
  display: flex;
  margin-bottom: 16px;
}

.fac-sidebar-search-input {
  flex: 1;
  height: 28px;
  padding: 4px 8px;
  background: #ffffff;
  border: 1px solid #7f9db9;
  border-right: none;
  font-size: 13px;
  outline: none;
  box-sizing: border-box;
}

.fac-sidebar-search-input:focus {
  border-color: #0844a4;
}

.fac-sidebar-search-btn {
  height: 28px;
  padding: 0 12px;
  background: #295a88;
  border: 1px solid #1f476d;
  color: #ffffff;
  font-size: 12.5px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.15s ease;
}

.fac-sidebar-search-btn:hover {
  background: #1c4266;
}

/* Sidebar Math Calculators Card matching Image 2 */
.fac-sidebar-card {
  border: 1px solid #2a5d8c;
  background: #ffffff;
  margin-bottom: 20px;
}

.fac-sidebar-card-header {
  background: #2a5d8c;
  color: #ffffff;
  font-weight: bold;
  font-size: 13px;
  padding: 6px 10px;
}

.fac-sidebar-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 8px 10px;
  gap: 4px 10px;
  font-size: 12px;
  border-bottom: 1px solid #cbd5e1;
}

.fac-sidebar-card-grid a {
  color: #0844a4;
  text-decoration: underline;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fac-sidebar-card-grid a:hover {
  color: #002277;
}

.fac-sidebar-card-grid .full-span {
  grid-column: 1 / -1;
}

.fac-sidebar-card-grid .more-link {
  grid-column: 1 / -1;
  text-align: right;
  font-weight: normal;
  color: #0844a4;
  margin-top: 4px;
}

.fac-sidebar-card-footer {
  background: #eef2f6;
  padding: 6px 10px;
  font-size: 11px;
  color: #0844a4;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
}

.fac-sidebar-card-footer a {
  color: #0844a4;
  text-decoration: underline;
}

.fac-sidebar-card-footer .sep {
  color: #94a3b8;
  margin: 0 3px;
}

/* ==========================================================================
   EXACT CLONE OF IMAGE 1: "Factorial Calculator (n!)" QUICK MODAL
   ========================================================================== */
.fac-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 99999;
  padding: 16px;
  box-sizing: border-box;
}

.fac-modal-backdrop.active {
  display: flex;
}

.fac-modal-dialog {
  width: 100%;
  max-width: 460px;
  background: #ffffff;
  border: 1px solid #002e5b;
  border-radius: 4px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  animation: facModalPop 0.18s ease-out;
}

@keyframes facModalPop {
  from { transform: scale(0.94); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.fac-modal-header {
  background: #003366;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #ffffff;
}

.fac-modal-title {
  font-size: 14.5px;
  font-weight: bold;
  letter-spacing: 0.2px;
}

.fac-modal-close-btn {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 18px;
  line-height: 1;
  font-weight: bold;
  cursor: pointer;
  padding: 0 4px;
  opacity: 0.85;
}

.fac-modal-close-btn:hover {
  opacity: 1;
}

.fac-modal-body {
  padding: 18px 20px 20px;
}

.fac-modal-group {
  margin-bottom: 14px;
}

.fac-modal-label {
  display: block;
  font-size: 13px;
  font-weight: bold;
  color: #333333;
  margin-bottom: 6px;
}

.fac-modal-input {
  width: 100%;
  height: 34px;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 3px;
  font-size: 15px;
  box-sizing: border-box;
  outline: none;
}

.fac-modal-input:focus {
  border-color: #0844a4;
  box-shadow: 0 0 3px rgba(8, 68, 164, 0.4);
}

.fac-modal-calc-btn {
  width: 100%;
  height: 38px;
  background: #2e7d32;
  border: 1px solid #1b5e20;
  border-radius: 3px;
  color: #ffffff;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.15s ease;
  margin-bottom: 16px;
}

.fac-modal-calc-btn:hover {
  background: #256d29;
}

.fac-modal-result-box {
  background: #eef8ea;
  border: 1px solid #c3e6cb;
  border-radius: 3px;
  padding: 14px 16px;
  text-align: center;
  font-size: 18px;
  font-weight: bold;
  color: #1b5e20;
  word-break: break-all;
}

/* History Drawer */
.fac-drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.4);
  display: none;
  z-index: 99998;
}

.fac-drawer-backdrop.active {
  display: block;
}

.fac-drawer {
  position: fixed;
  top: 0;
  right: -360px;
  width: 350px;
  max-width: 90vw;
  height: 100vh;
  background: #ffffff;
  box-shadow: -4px 0 15px rgba(0, 0, 0, 0.15);
  transition: right 0.25s ease;
  z-index: 99999;
  display: flex;
  flex-direction: column;
}

.fac-drawer.open {
  right: 0;
}

.fac-drawer-header {
  background: #2b5a88;
  color: #ffffff;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fac-drawer-header h3 {
  font-size: 15px;
  margin: 0;
}

.fac-drawer-close {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 18px;
  cursor: pointer;
}

.fac-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.fac-drawer-footer {
  padding: 12px 14px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 10px;
}

/* Print Report Modal */
.fac-print-modal-dialog {
  max-width: 720px;
}

/* Rich SEO, AEO & GEO Content Section */
.fac-seo-content {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid #e2e8f0;
  font-size: 13.5px;
  line-height: 1.65;
  color: #334155;
}

.fac-seo-content h2 {
  font-size: 19px;
  color: #0844a4;
  margin: 22px 0 10px 0;
  font-weight: bold;
}

.fac-seo-content h3 {
  font-size: 15.5px;
  color: #1e293b;
  margin: 16px 0 6px 0;
  font-weight: bold;
}

.fac-seo-content p {
  margin-bottom: 12px;
}

.fac-seo-content ul, .fac-seo-content ol {
  margin: 8px 0 14px 24px;
}

.fac-seo-content li {
  margin-bottom: 6px;
}

.fac-faq-item {
  margin-bottom: 14px;
  padding: 12px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
}

.fac-faq-question {
  font-weight: bold;
  font-size: 14px;
  color: #0844a4;
  margin-bottom: 6px;
}

.fac-faq-answer {
  font-size: 13px;
  color: #334155;
}

/* Print Styles */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }
  .site-header,
  .fac-top-toolbar,
  .fac-sidebar-col,
  .fac-mode-tabs,
  .fac-btn-clear,
  .fac-presets-row,
  .fac-drawer,
  .fac-modal-backdrop,
  .site-footer {
    display: none !important;
  }
  .fac-main-layout {
    display: block !important;
  }
  .fac-content-col {
    width: 100% !important;
  }
  .fac-calc-card {
    background: #ffffff !important;
    border: 1px solid #000000 !important;
  }
}

/* Responsive adjustments */
@media (max-width: 860px) {
  .fac-main-layout {
    flex-direction: column;
  }
  .fac-sidebar-col {
    width: 100%;
  }
}
