/* ===== CSS VARIABLES FOR EASY CUSTOMIZATION ===== */
:root {
  /* GX-120B Calculator Colors */
  --calculator-bg: #C8C8C8; /* Silver background for main body */
  --calculator-top-bg: #2c3e50; /* Dark top section */
  --calculator-border: #A0A0A0;
  
  /* Display Colors (Dark top section) */
  --display-bg: #1a1a1a;
  --display-border: #333;
  --display-text: #ffffff; /* White text on dark background */
  --display-font-size: 2rem;
  
  /* Button Sizes */
  --button-size: 60px;
  --button-size-half: 30px; /* Half height for scientific function keys */
  --button-font-size: 1rem;
  
  /* Toggle Colors */
  --toggle-bg: #34495e;
  --toggle-text: #ecf0f1;
  --toggle-active: #3498db;
  
  /* Memory Colors */
  --memory-btn-bg: #e74c3c;
  
  /* FX-80 Scientific Calculator Colors */
  --fx80-scientific-function: #696564; /* Same as M+ key from basic calculator */
  --fx80-operation-function: #3D3D3D; /* Same as 0 key from basic calculator */
  --fx80-operation-clear-bg: #3D3D3D; /* Same as 0 key background */
  --fx80-operation-clear-text: #BF7D46; /* Orange text like AC key */
}

/* ===== GLOBAL STYLES ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Arial', sans-serif;
  background: transparent; /* Transparent background */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

/* ===== CALCULATOR CONTAINER ===== */
.calculator-container {
  background: var(--calculator-bg); /* Silver background */
  border-radius: 15px;
  padding: 0; /* Remove padding to create distinct sections */
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  border: 2px solid var(--calculator-border);
  max-width: 400px;
  width: 100%;
  overflow: hidden; /* Ensure rounded corners work properly */
}

/* ===== HEADER SECTION (Dark Top Area) ===== */
.calculator-header {
  background: var(--calculator-top-bg); /* Dark background for top section */
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  flex-wrap: wrap;
  gap: 10px;
  border-bottom: 2px solid var(--calculator-border);
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  width: 40px;
  height: 40px;
  border-radius: 8px;
}

.title-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.calculator-title {
  color: white;
  font-size: 1.2rem;
  font-weight: bold;
  margin: 0;
}

.mode-subtitle {
  color: var(--toggle-active);
  font-size: 0.8rem;
  font-weight: normal;
  opacity: 0.9;
}

/* ===== MODE TOGGLE ===== */
.mode-toggle {
  position: relative;
}

.mode-btn {
  background: var(--toggle-bg);
  color: var(--toggle-text);
  border: none;
  border-radius: 20px;
  padding: 8px 15px;
  font-size: 0.9rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  min-width: 80px;
}

.mode-btn:hover {
  background: var(--toggle-active);
  transform: translateY(-1px);
}

.toggle-indicator {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  background: var(--toggle-active);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ===== SOUND TOGGLE ===== */
.sound-btn {
  background: var(--toggle-bg);
  color: var(--toggle-text);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sound-btn:hover {
  background: var(--toggle-active);
}

.sound-btn.active {
  background: var(--toggle-active);
}

.sound-icon {
  font-size: 1.2rem;
}

/* ===== CALCULATOR BODY (Silver Area) ===== */
.calculator-body {
  background: var(--calculator-bg); /* Silver background */
  padding: 20px;
}

/* ===== DISPLAY SECTION (Dark Area) ===== */
.display-section {
  background: var(--calculator-top-bg); /* Dark background for display area */
  margin: -20px -20px 20px -20px; /* Extend to edges */
  padding: 20px;
  border-bottom: 2px solid var(--calculator-border);
}

.display-container {
  position: relative;
  background: var(--display-bg);
  border-radius: 8px;
  padding: 15px;
  border: 2px solid var(--display-border);
}

.display {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--display-text);
  font-size: var(--display-font-size);
  font-family: 'Courier New', monospace;
  text-align: right;
  outline: none;
  cursor: pointer;
  letter-spacing: 2px;
  font-weight: bold;
}

.display::placeholder {
  color: var(--display-text);
  opacity: 0.7;
}

.display-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 0.8rem;
}

.memory-indicator {
  color: var(--memory-btn-bg);
  font-weight: bold;
}

.angle-mode-indicator {
  color: var(--toggle-active);
  font-weight: bold;
  font-size: 0.75rem;
  background: rgba(52, 152, 219, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--toggle-active);
}

.hidden {
  display: none !important;
}

/* ===== BUTTON GRID (Silver Area) ===== */
.button-grid {
  display: flex;
  flex-direction: column;
  gap: 7px; /* REDUCED from 15px to 7px for tighter spacing between sections */
  margin-bottom: 15px;
  background: var(--calculator-bg); /* Ensure silver background */
}

/* Grid layouts for different modes */
.grid-simple {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(5, var(--button-size));
  gap: 10px;
}

.grid-scientific {
  /* This will be handled by the individual section grids */
}

.grid-conversion {
  /* This will be handled by the individual section grids */
}

/* ===== SCIENTIFIC CALCULATOR SPECIFIC GRIDS ===== */

/* Scientific Functions Grid (4×6) - UPDATED from 3×6 */
.scientific-functions-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(4, var(--button-size-half));
  gap: 6px;
}

/* Section Separator - NO LONGER NEEDED since we control spacing via button-grid gap */
.section-separator {
  height: 0px; /* Set to 0 since spacing is now controlled by button-grid gap */
  background: transparent;
}

/* Operational Functions Grid (4×5) */
.operational-functions-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(4, var(--button-size));
  gap: 8px;
}

/* Empty space for grid alignment */
.empty-space {
  background: transparent;
  border: none;
}

/* ===== CONVERSION CALCULATOR SPECIFIC GRIDS ===== */

/* Conversion Categories Grid (4×6) */
.conversion-categories-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(4, var(--button-size-half));
  gap: 6px;
}

/* ===== BUTTON STYLES ===== */
.btn {
  border: none;
  border-radius: 8px;
  font-size: var(--button-font-size);
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
  border: 1px solid #999; /* Add subtle border for definition */
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
}

.btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Button type styles - GX-120B Color Groups (Basic Calculator) */
.btn-number {
  background: #3D3D3D;
  color: white;
  border: 1px solid #555;
}

.btn-number:hover {
  background: #4D4D4D;
}

.btn-operator {
  background: #696564;
  color: white;
  border: 1px solid #777;
}

.btn-operator:hover {
  background: #797574;
}

.btn-clear {
  background: #BF7D46;
  color: white;
  border: 1px solid #AA6A33;
}

.btn-clear:hover {
  background: #CF8D56;
}

.btn-function {
  background: #696564;
  color: white;
  border: 1px solid #777;
}

.btn-function:hover {
  background: #797574;
}

.btn-memory {
  background: #696564;
  color: white;
  border: 1px solid #777;
}

.btn-memory:hover {
  background: #797574;
}

.btn-equals {
  background: #696564;
  color: white;
  border: 1px solid #777;
}

.btn-equals:hover {
  background: #797574;
}

/* ===== FX-80 SCIENTIFIC CALCULATOR BUTTON STYLES ===== */

/* Scientific function keys (top 4 rows) - Same color as M+ key */
.btn-scientific-function {
  background: var(--fx80-scientific-function);
  color: white;
  border: 1px solid #777;
  font-size: 0.65rem; /* Smaller font for half-height buttons */
  line-height: 1.1;
}

.btn-scientific-function:hover {
  background: #797574;
}

/* Operation function keys (bottom 4 rows) - Same color as 0 key */
.btn-operation-function {
  background: var(--fx80-operation-function);
  color: white;
  border: 1px solid #555;
}

.btn-operation-function:hover {
  background: #4D4D4D;
}

/* Operation clear keys (AC, C) - Same background as 0 key but orange text */
.btn-operation-clear {
  background: var(--fx80-operation-clear-bg);
  color: var(--fx80-operation-clear-text);
  border: 1px solid #555;
}

.btn-operation-clear:hover {
  background: #4D4D4D;
}

/* Conversion category buttons */
.btn-conversion-category {
  background: var(--fx80-scientific-function);
  color: white;
  border: 1px solid #777;
  font-size: 0.65rem;
  line-height: 1.1;
  text-align: center;
  padding: 4px;
}

.btn-conversion-category:hover {
  background: #797574;
}

.btn-conversion-category.active {
  background: var(--toggle-active);
  border-color: #2980b9;
}

/* Conversion function buttons */
.btn-conversion-function {
  background: var(--fx80-scientific-function);
  color: white;
  border: 1px solid #777;
  font-size: 0.65rem;
  line-height: 1.1;
}

.btn-conversion-function:hover {
  background: #797574;
}

/* Empty button space */
.btn-empty {
  background: transparent;
  border: none;
}

/* Special button sizes */
.btn-wide {
  grid-column: span 2;
}

.btn-tall {
  grid-row: span 2;
}

/* ===== CONVERSION PANEL ===== */
.conversion-panel {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 15px;
  margin-top: 15px;
  backdrop-filter: blur(10px);
}

.conversion-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
  align-items: center;
}

.unit-selector {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 5px;
  background: var(--display-bg);
  color: var(--display-text);
  font-size: 0.9rem;
}

/* Swap button styling */
.swap-btn {
  background: var(--fx80-scientific-function);
  color: white;
  border: none;
  border-radius: 5px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
  min-width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.swap-btn:hover {
  background: #797574;
  transform: scale(1.1);
}

.convert-btn {
  background: var(--toggle-active);
  color: white;
  border: none;
  border-radius: 5px;
  padding: 8px 15px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.2s ease;
}

.convert-btn:hover {
  background: #2980b9;
  transform: translateY(-1px);
}

.conversion-categories {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.category-btn {
  background: var(--toggle-bg);
  color: var(--toggle-text);
  border: none;
  border-radius: 5px;
  padding: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s ease;
}

.category-btn:hover {
  background: var(--toggle-active);
}

.category-btn.active {
  background: var(--toggle-active);
  color: white;
}

/* ===== SIMPLE FOOTER ===== */
.footer-text {
  margin-top: 20px;
  text-align: center;
  color: #2c3e50;
  font-size: 0.9rem;
  line-height: 1.4;
}

.footer-small {
  font-size: 0.75rem;
  opacity: 0.7;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 480px) {
  .calculator-container {
    max-width: 350px;
  }
  
  :root {
    --button-size: 50px;
    --button-size-half: 25px;
    --button-font-size: 0.9rem;
    --display-font-size: 1.5rem;
  }
  
  .calculator-header {
    padding: 10px 15px;
  }
  
  .calculator-title {
    font-size: 1rem;
  }
  
  .mode-subtitle {
    font-size: 0.7rem;
  }
  
  .mode-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
    min-width: 70px;
  }
  
  .btn-scientific-function {
    font-size: 0.55rem;
  }
  
  .btn-conversion-category {
    font-size: 0.55rem;
  }
  
  .btn-conversion-function {
    font-size: 0.55rem;
  }
  
  .footer-text {
    font-size: 0.8rem;
  }
  
  .footer-small {
    font-size: 0.7rem;
  }
  
  .conversion-categories {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
  
  .category-btn {
    font-size: 0.7rem;
    padding: 6px;
  }
  
  .swap-btn {
    min-width: 35px;
    padding: 6px 10px;
  }
}

@media (max-width: 360px) {
  :root {
    --button-size: 45px;
    --button-size-half: 22px;
    --button-font-size: 0.8rem;
    --display-font-size: 1.3rem;
  }
  
  .calculator-container {
    max-width: 320px;
  }
  
  .btn-scientific-function {
    font-size: 0.5rem;
  }
  
  .btn-conversion-category {
    font-size: 0.5rem;
  }
  
  .btn-conversion-function {
    font-size: 0.5rem;
  }
  
  .footer-text {
    font-size: 0.75rem;
  }
  
  .footer-small {
    font-size: 0.65rem;
  }
}