/**
 * Long Division Grid Component Styles
 * 
 * Styles for the long division visualization component
 * with support for multiple interactive modes.
 */

/* ===== BASE CONTAINER ===== */

.long-division-grid {
  position: relative;
  font-family: 'Courier New', Courier, monospace;
}

/* ===== ROW STYLES ===== */

.div-row {
  display: flex;
  align-items: center;
}

.div-quotient-row {
  margin-bottom: 4px;
}

.div-bracket-row {
  align-items: stretch;
}

.div-subtract-row {
  margin-top: 4px;
}

.div-difference-row {
  margin-top: 2px;
}

.div-remainder-row {
  margin-top: 10px;
}

/* ===== CELL STYLES ===== */

.div-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  border-radius: 4px;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.div-cell-quotient {
  color: #E91E63;
  background-color: rgba(233, 30, 99, 0.1);
}

.div-cell-dividend {
  color: #4ECDC4;
  background-color: rgba(78, 205, 196, 0.1);
}

.div-cell-divisor {
  color: #FF6B6B;
  background-color: rgba(255, 107, 107, 0.1);
}

.div-cell-working {
  color: #9C27B0;
  background-color: rgba(156, 39, 176, 0.1);
}

.div-cell-remainder {
  color: #FF9800;
  background-color: rgba(255, 152, 0, 0.1);
}

/* ===== BRACKET STYLES ===== */

.div-bracket {
  position: relative;
}

.div-divisor-container {
  display: flex;
  align-items: center;
}

.div-dividend-container {
  display: flex;
  align-items: center;
}

/* ===== LINE STYLES ===== */

.div-line {
  background-color: #333;
}

/* ===== INPUT STYLES ===== */

.div-cell-input,
.div-cell-practice,
.div-cell-guided-active {
  outline: none;
  text-align: center;
  font-family: inherit;
}

.div-cell-input:focus,
.div-cell-practice:focus,
.div-cell-guided-active:focus {
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.3);
}

/* ===== SPOTINCORRECT MODE ===== */

.long-division-grid[data-mode="spotIncorrect"] .div-cell {
  cursor: pointer;
}

.long-division-grid[data-mode="spotIncorrect"] .div-cell:hover {
  transform: scale(1.05);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ===== BUTTON THEME (for spotIncorrect mode) ===== */

.div-cell-button-theme {
  background: linear-gradient(145deg, #FFD700, #E6C200);
  border: 2px solid #B8860B;
  border-radius: 8px;
  box-shadow: 
    4px 4px 8px rgba(0, 0, 0, 0.3),
    inset 1px 1px 2px rgba(255, 255, 255, 0.4),
    inset -1px -1px 2px rgba(0, 0, 0, 0.2);
  transition: all 0.1s ease;
  position: relative;
  transform: translateY(0);
}

.div-cell-button-theme:hover {
  background: linear-gradient(145deg, #FFE55C, #FFD700);
  box-shadow: 
    6px 6px 12px rgba(0, 0, 0, 0.4),
    inset 1px 1px 2px rgba(255, 255, 255, 0.5),
    inset -1px -1px 2px rgba(0, 0, 0, 0.3);
  transform: translateY(-1px);
}

.div-cell-button-theme:active {
  background: linear-gradient(145deg, #E6C200, #CCB000);
  box-shadow: 
    2px 2px 4px rgba(0, 0, 0, 0.3),
    inset 2px 2px 4px rgba(0, 0, 0, 0.2),
    inset -1px -1px 2px rgba(255, 255, 255, 0.1);
  transform: translateY(1px);
}

.div-cell-button-theme.selected {
  background: linear-gradient(145deg, #2196F3, #1976D2);
  color: black;
  box-shadow: 
    0 0 0 2px rgba(33, 150, 243, 0.8),
    4px 4px 8px rgba(0, 0, 0, 0.3),
    inset 1px 1px 2px rgba(255, 255, 255, 0.4),
    inset -1px -1px 2px rgba(0, 0, 0, 0.2);
}

.div-cell-button-theme.correct {
  background: linear-gradient(145deg, #4CAF50, #45A049);
  border-color: #2E7D32;
  box-shadow: 
    4px 4px 8px rgba(0, 0, 0, 0.3),
    inset 1px 1px 2px rgba(255, 255, 255, 0.3),
    inset -1px -1px 2px rgba(0, 0, 0, 0.2);
}

.div-cell-button-theme.incorrect {
  background: linear-gradient(145deg, #FF6B6B, #E53E3E);
  border-color: #D32F2F;
  box-shadow: 
    4px 4px 8px rgba(0, 0, 0, 0.3),
    inset 1px 1px 2px rgba(255, 255, 255, 0.3),
    inset -1px -1px 2px rgba(0, 0, 0, 0.2);
  animation: wiggle 0.5s ease-in-out;
}

.div-cell-button-theme.disabled {
  cursor: not-allowed;
  pointer-events: none;
  /* Keep original button theme appearance, just disable interaction */
}

.div-cell-button-theme.disabled:hover {
  /* No hover effects for disabled cells */
}

.div-cell-button-theme.disabled:active {
  /* No active effects for disabled cells */
}

/* Wiggle animation for incorrect drops */
@keyframes wiggle {
  0%, 100% { transform: translateX(0) rotate(0); }
  10% { transform: translateX(-5px) rotate(-2deg); }
  20% { transform: translateX(5px) rotate(2deg); }
  30% { transform: translateX(-5px) rotate(-2deg); }
  40% { transform: translateX(5px) rotate(2deg); }
  50% { transform: translateX(-5px) rotate(-2deg); }
  60% { transform: translateX(5px) rotate(2deg); }
  70% { transform: translateX(-5px) rotate(-2deg); }
  80% { transform: translateX(5px) rotate(2deg); }
  90% { transform: translateX(-5px) rotate(-2deg); }
  100% { transform: translateX(0) rotate(0); }
}

/* ===== PRACTICE MODE ===== */

.long-division-grid[data-mode="practice"] {
  border: 2px solid #2196F3;
}

.div-cell-practice {
  background-color: #F5F5F5;
  border: 2px dashed #9E9E9E;
}

.div-cell-practice:focus {
  border-color: #2196F3;
  background-color: white;
}

/* ===== GUIDED MODE ===== */

.long-division-grid[data-mode="guided"] {
  border: 2px solid #FFC107;
}

.div-cell-guided-active {
  background-color: #FFF9C4;
  border: 3px solid #FFC107;
  box-shadow: 0 0 10px rgba(255, 193, 7, 0.5);
  animation: guidedPulse 1.5s ease-in-out infinite;
}

.div-cell-wiggling {
  background-color: #FA8072;
  border: 3px solid #FF6B6B;
  box-shadow: 0 0 10px rgba(250, 128, 114, 0.5);
  animation: wiggle 1500ms ease-in-out;
}

.div-cell-hidden {
  background-color: transparent;
  border: 2px dashed #E0E0E0;
  color: transparent;
}

.div-guided-hint {
  animation: fadeIn 0.3s ease;
}

@keyframes guidedPulse {
  0%, 100% {
    box-shadow: 0 0 10px rgba(255, 193, 7, 0.5);
  }
  50% {
    box-shadow: 0 0 20px rgba(255, 193, 7, 0.8);
  }
}

/* ===== ANIMATION MODE ===== */

.long-division-grid[data-mode="animation"] {
  border: 2px solid #673AB7;
}

.div-cell-animation-hidden {
  background-color: transparent;
  border: 2px dashed #E0E0E0;
  color: transparent;
}

.div-animation-controls {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 15px;
}

.div-animation-controls button {
  transition: all 0.2s ease;
}

.div-animation-controls button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.div-animation-controls button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.div-animation-info {
  animation: fadeIn 0.3s ease;
}

@keyframes digitAppear {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes digitFade {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

/* ===== DRAGDROP MODE ===== */

.long-division-grid[data-mode="dragDrop"] {
  border: 2px solid #9C27B0;
}

.div-cell-dragdrop {
  transition: all 0.2s ease;
  position: relative;
}

.div-cell-dragdrop:hover {
  background-color: #E1F5FE;
  border-color: #0288D1;
}

.div-digit-tile {
  transition: all 0.2s ease;
  user-select: none;
}

.div-digit-tile:hover:not(:disabled) {
  transform: scale(1.1);
  box-shadow: 0 4px 8px rgba(33, 150, 243, 0.4);
  background-color: #BBDEFB;
}

.div-digit-tile:active:not(:disabled) {
  transform: scale(0.95);
}

.div-dragdrop-digit-bank {
  animation: fadeIn 0.3s ease;
}

.div-dragdrop-controls {
  margin-top: 15px;
}

.div-dragdrop-controls button {
  transition: all 0.2s ease;
}

.div-dragdrop-controls button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* ===== INPUT MODE ===== */

.long-division-grid[data-mode="input"] {
  border: 2px solid #4CAF50;
}

/* ===== COMMON ANIMATIONS ===== */

@keyframes fadeIn {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInUp {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== VALIDATION STATES ===== */

.div-cell-correct {
  background-color: #C8E6C9;
  border-color: #4CAF50;
}

.div-cell-incorrect {
  background-color: #FFCDD2;
  border-color: #F44336;
}

.div-cell-missed {
  background-color: #FFF9C4;
  border-color: #FFC107;
}

/* ===== COMPLETION MESSAGES ===== */

.div-complete-message {
  animation: fadeInUp 0.5s ease;
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */

@media (max-width: 768px) {
  .long-division-grid {
    padding: 10px;
  }
  
  .div-animation-controls {
    flex-wrap: wrap;
  }
  
  .div-dragdrop-digit-bank {
    padding: 10px;
  }
}

/* ===== THEME OVERRIDES ===== */

.long-division-grid.white-theme .div-cell {
  background-color: white;
  color: #333;
}

.long-division-grid.minimal-mode .div-cell {
  background-color: transparent;
  border: none;
}

.long-division-grid.minimal-mode .div-bracket {
  border-color: #333;
}

.long-division-grid.minimal-mode .div-line {
  background-color: #333;
}

/* ===== DARK THEME ===== */
/* Modern dark theme with teal quotient tiles and purple work tiles */

.long-division-grid.dark-theme {
  /* Dark blue gradient background with math texture effect */
  /* Background can be overridden by inline style from backgroundColor prop */
  /* background: linear-gradient(135deg, #0a1628 0%, #1a2a4a 50%, #0f1e3a 100%); */
  border-radius: 16px;
  padding: 32px;
  position: relative;
  overflow: hidden;
}

/* Subtle math texture overlay */
.long-division-grid.dark-theme::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(255,255,255,0.02) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.long-division-grid.dark-theme .div-main-content {
  position: relative;
  z-index: 1;
}

/* Number Tiles - Quotient (teal/green) */
.long-division-grid.dark-theme .div-cell-quotient {
  background: linear-gradient(145deg, #41BDA3, #1C8974);
  color: #FFFFFF;
  /* width: controlled by component */
  /* height: controlled by component */
  /* border-radius: controlled by component cellBorderRadius prop */  /* box-shadow: controlled by component cellBoxShadow prop */  border: none;
  font-weight: 700;
  /* font-size: controlled by component */
  font-family: 'Nunito', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Number Tiles - Work/Dividend/Remainder (purple) */
.long-division-grid.dark-theme .div-cell-dividend,
.long-division-grid.dark-theme .div-cell-working,
.long-division-grid.dark-theme .div-cell-remainder,
.long-division-grid.dark-theme .div-cell-bringDown {
  background: linear-gradient(145deg, #B27FCA, #8950A3);
  color: #FFFFFF;
  /* width: controlled by component */
  /* height: controlled by component */
  /* border-radius: controlled by component cellBorderRadius prop */  /* box-shadow: controlled by component cellBoxShadow prop */  border: none;
  font-weight: 700;
  /* font-size: controlled by component */
  font-family: 'Nunito', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Divisor - no background, just white text */
.long-division-grid.dark-theme .div-cell-divisor {
  background: transparent;
  color: #FFFFFF;
  border: none;
  box-shadow: none;
  font-weight: 700;
  /* font-size: controlled by component */
  font-family: 'Nunito', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Division Bracket - white stroke */
.long-division-grid.dark-theme .div-bracket-symbol div {
  border-color: #FFFFFF;
  /* border-width: controlled by component */}

/* Step Separator Lines */
.long-division-grid.dark-theme .div-line {
  background-color: rgba(255,255,255,0.85);
  /* height: controlled by component */  border-radius: 2px;
}

/* Helper equation text (6 × 3 = etc.) */
.long-division-grid.dark-theme .div-helper-text {
  color: rgba(255,255,255,0.45);
  /* font-size: controlled by component */  font-weight: 400;
  font-family: 'Nunito', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  margin-right: 12px;
  white-space: nowrap;
}

/* Bring-down arrow */
.long-division-grid.dark-theme .div-bring-down-arrow {
  stroke: rgba(170,170,170,0.65);
  /* stroke-width: controlled by component */  fill: none;
}

.long-division-grid.dark-theme .div-bring-down-arrow-head {
  fill: rgba(170,170,170,0.65);
}

/* Row spacing for dark theme */
.long-division-grid.dark-theme .div-row {
  margin-bottom: 10px;
}

.long-division-grid.dark-theme .div-quotient-row {
  margin-bottom: 8px;
}

.long-division-grid.dark-theme .div-subtract-row {
  margin-top: 10px;
}

.long-division-grid.dark-theme .div-difference-row {
  margin-top: 10px;
}

/* Active step highlight for dark theme */
.long-division-grid.dark-theme .div-cell-active {
  box-shadow: 0 6px 12px rgba(0,0,0,0.25), 0 0 20px rgba(65, 189, 163, 0.4);
  transform: scale(1.05);
}

/* Completed step dim for dark theme */
.long-division-grid.dark-theme .div-cell-completed {
  opacity: 0.7;
}

/* Remainder row styling */
.long-division-grid.dark-theme .div-remainder-row {
  margin-top: 20px;
}

.long-division-grid.dark-theme .div-remainder-row span {
  color: rgba(255,255,255,0.65);
  font-family: 'Nunito', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Final answer display for dark theme */
.long-division-grid.dark-theme .div-final-answer {
  background: linear-gradient(145deg, #1C8974, #156b5a);
  border: 2px solid #41BDA3;
  color: #FFFFFF;
  /* border-radius: controlled by component cellBorderRadius prop */  padding: 12px 24px;
  font-weight: 700;
  font-family: 'Nunito', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

