:root {
  /* Unique Teal & Purple Theme */
  --bg-primary: #0f1a27;
  --bg-secondary: #1a2a3a;
  --bg-tertiary: #243447;
  --bg-accent: #2a3d55;
  
  --text-primary: #e3f2fd;
  --text-secondary: #b3e5fc;
  --text-dim: #81d4fa;
  --text-accent: #4fc3f7;
  
  --border-primary: #37474f;
  --border-accent: #4fc3f7;
  --border-focus: #80deea;
  
  --accent-teal: #4db6ac;
  --accent-purple: #9575cd;
  --accent-cyan: #4fc3f7;
  --accent-pink: #f48fb1;
  --accent-green: #81c784;
  --accent-orange: #ffb74d;
  --accent-red: #e57373;
  --accent-yellow: #fff176;
  
  --gradient-primary: linear-gradient(135deg, #1a2a3a 0%, #243447 100%);
  --gradient-accent: linear-gradient(135deg, #4db6ac 0%, #4fc3f7 100%);
  --gradient-header: linear-gradient(135deg, #2a3d55 0%, #37474f 100%);
  
  --shadow-glow: 0 0 30px rgba(79, 195, 247, 0.15);
  --shadow-soft: 0 8px 25px rgba(15, 26, 39, 0.5);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Geist Mono', monospace;
  background: var(--gradient-primary);
  color: var(--text-primary);
  line-height: 1.4;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.terminal {
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: 0px;
  box-shadow: var(--shadow-soft), var(--shadow-glow);
  max-width: 1400px;
  width: 100%;
  overflow: hidden;
}

.terminal-header {
  background: var(--gradient-header);
  border-bottom: 1px solid var(--border-accent);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Add to your styles.css */
.terminal-btn {
  min-width: 80px;
}

/* Style for active VIEW button */
.terminal-btn.active {
  background: var(--accent-purple);
  border-color: var(--accent-purple);
  color: var(--bg-primary);
  /* Ensure contrast */
}

.terminal-btn.active:hover {
  background: var(--accent-pink);
  border-color: var(--accent-pink);
  color: var(--bg-primary);
}

.window-controls {
  display: flex;
  gap: 8px;
}

.control {
  width: 12px;
  height: 12px;
  border-radius: 0px;
  display: inline-block;
  background: var(--border-primary);
  transition: all 0.3s ease;
}

.control.close { background: var(--accent-red); }
.control.minimize { background: var(--accent-orange); }
.control.maximize { background: var(--accent-green); }

.control:hover {
  transform: scale(1.1);
}

.title-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.prompt {
  color: var(--accent-cyan);
  text-shadow: 0 0 10px rgba(79, 195, 247, 0.5);
}

.title {
  color: var(--text-primary);
  letter-spacing: 0.5px;
  font-weight: 700;
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.cursor {
  color: var(--accent-cyan);
  animation: blink 1s infinite;
  text-shadow: 0 0 8px rgba(79, 195, 247, 0.7);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.terminal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-primary);
}

.app-title {
  color: var(--text-secondary);
  font-size: 1.1em;
  font-weight: 400;
  letter-spacing: 0.5px;
}

.status-bar {
  display: flex;
  gap: 12px;
}

.status-item {
  background: var(--bg-tertiary);
  padding: 4px 8px;
  border-radius: 0px;
  font-size: 0.8em;
  color: var(--accent-cyan);
  border: 1px solid var(--border-primary);
  transition: all 0.3s ease;
}

.status-item:hover {
  border-color: var(--accent-cyan);
  transform: translateY(-1px);
}

.spreadsheet-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
  max-height: 300px;
  /* Limit total height */
}

.info-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 0px;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
}

.info-panel:hover {
  border-color: var(--accent-teal);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.info-header {
  background: var(--bg-accent);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-primary);
  flex-shrink: 0;
  /* Prevent header from shrinking */
}

.info-title {
  color: var(--accent-teal);
  font-weight: 600;
  font-size: 1em;
}

.info-content {
  padding: 16px;
  overflow-y: auto;
  /* Make content scrollable */
  flex-grow: 1;
  /* Take remaining space */
  max-height: 250px;
}

/* Scrollbar styling for both panels */
.info-content::-webkit-scrollbar {
  width: 6px;
}

.info-content::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

.info-content::-webkit-scrollbar-thumb {
  background: var(--accent-teal);
  border-radius: 0px;
}

.info-content::-webkit-scrollbar-thumb:hover {
  background: var(--accent-cyan);
}

.function-list,
.reference-guide {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.function-item,
.ref-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-primary);
  transition: all 0.3s ease;
}

.function-item:hover,
.ref-item:hover {
  background: var(--bg-accent);
  padding-left: 8px;
  padding-right: 8px;
  margin: 0 -8px;
}

.function-item:last-child,
.ref-item:last-child {
  border-bottom: none;
}

.function-name, .ref-example {
  color: var(--accent-purple);
  font-weight: 600;
  font-size: 0.9em;
}

.function-desc, .ref-desc {
  color: var(--text-dim);
  font-size: 0.8em;
}

.spreadsheet-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 0px;
    padding: 20px;
    overflow: auto;
    max-height: 500px;
    transition: all 0.3s ease;
    width: fit-content;
    /* Add this line */
    margin: 0 auto;
    /* Center it */
}

.spreadsheet-container:hover {
  border-color: var(--accent-cyan);
}

.spreadsheet-grid {
    display: grid;
    grid-template-columns: 50px repeat(10, 120px);
    grid-template-rows: 35px repeat(99, 35px);
    gap: 1px;
    background: var(--border-primary);
    border: 1px solid var(--border-primary);
    width: fit-content;
    /* Add this line */
}

/* Empty top-left corner (A0) */
.spreadsheet-grid>*:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
    background: var(--bg-accent);
    border: 1px solid var(--border-primary);
}

/* Letter headers A (position 2) */
.spreadsheet-grid>*:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
    background: var(--bg-accent);
    text-align: center;
    line-height: 35px;
    color: var(--accent-purple);
    font-weight: 600;
    border: 1px solid var(--border-primary);
}

/* Letter headers B-J (positions 3-11) */
.spreadsheet-grid>*:nth-child(3) {
    grid-column: 3;
    grid-row: 1;
}

.spreadsheet-grid>*:nth-child(4) {
    grid-column: 4;
    grid-row: 1;
}

.spreadsheet-grid>*:nth-child(5) {
    grid-column: 5;
    grid-row: 1;
}

.spreadsheet-grid>*:nth-child(6) {
    grid-column: 6;
    grid-row: 1;
}

.spreadsheet-grid>*:nth-child(7) {
    grid-column: 7;
    grid-row: 1;
}

.spreadsheet-grid>*:nth-child(8) {
    grid-column: 8;
    grid-row: 1;
}

.spreadsheet-grid>*:nth-child(9) {
    grid-column: 9;
    grid-row: 1;
}

.spreadsheet-grid>*:nth-child(10) {
    grid-column: 10;
    grid-row: 1;
}

.spreadsheet-grid>*:nth-child(11) {
    grid-column: 11;
    grid-row: 1;
}

/* Style all letter headers */
.spreadsheet-grid>*:nth-child(n+2):nth-child(-n+11) {
    background: var(--bg-accent);
    text-align: center;
    vertical-align: middle;
    line-height: 35px;
    color: var(--accent-purple);
    font-family: 'Geist Mono', monospace;
    font-size: 0.8em;
    font-weight: 600;
    border: 1px solid var(--border-primary);
    transition: all 0.3s ease;
}

.spreadsheet-grid>*:nth-child(n+2):nth-child(-n+11):hover {
    background: var(--accent-purple);
    color: var(--bg-primary);
}

/* Number labels row 1 (position 12) */
.spreadsheet-grid>*:nth-child(12) {
    grid-column: 1;
    grid-row: 2;
}

/* Number labels row 2 (position 23) */
.spreadsheet-grid>*:nth-child(23) {
    grid-column: 1;
    grid-row: 3;
}

/* Continue this pattern for all 99 rows... */

/* Style all number labels */
.spreadsheet-grid>.label.row-label {
    background: var(--bg-accent);
    text-align: center;
    vertical-align: middle;
    line-height: 35px;
    color: var(--accent-teal);
    font-family: 'Geist Mono', monospace;
    font-size: 0.8em;
    font-weight: 600;
    border: 1px solid var(--border-primary);
    transition: all 0.3s ease;
}

.spreadsheet-grid>.label.row-label:hover {
    background: var(--accent-teal);
    color: var(--bg-primary);
}

/* Input cells - we need to position each one individually */
/* Row 1 inputs */
.spreadsheet-grid>*:nth-child(13) {
    grid-column: 2;
    grid-row: 2;
}

/* A1 */
.spreadsheet-grid>*:nth-child(14) {
    grid-column: 3;
    grid-row: 2;
}

/* B1 */
.spreadsheet-grid>*:nth-child(15) {
    grid-column: 4;
    grid-row: 2;
}

/* C1 */
.spreadsheet-grid>*:nth-child(16) {
    grid-column: 5;
    grid-row: 2;
}

/* D1 */
.spreadsheet-grid>*:nth-child(17) {
    grid-column: 6;
    grid-row: 2;
}

/* E1 */
.spreadsheet-grid>*:nth-child(18) {
    grid-column: 7;
    grid-row: 2;
}

/* F1 */
.spreadsheet-grid>*:nth-child(19) {
    grid-column: 8;
    grid-row: 2;
}

/* G1 */
.spreadsheet-grid>*:nth-child(20) {
    grid-column: 9;
    grid-row: 2;
}

/* H1 */
.spreadsheet-grid>*:nth-child(21) {
    grid-column: 10;
    grid-row: 2;
}

/* I1 */
.spreadsheet-grid>*:nth-child(22) {
    grid-column: 11;
    grid-row: 2;
}

/* J1 */

/* Continue this pattern for all 99 rows... */

/* Style all input cells */
.spreadsheet-grid input {
    background: var(--bg-primary);
    border: none;
    border-radius: 0px;
    padding: 8px;
    color: var(--text-primary);
    font-family: 'Geist Mono', monospace;
    font-size: 0.8em;
    border: 1px solid var(--border-primary);
    transition: all 0.2s ease;
}

.spreadsheet-grid input:focus {
    outline: none;
    border-color: var(--accent-cyan);
    background: var(--bg-tertiary);
    box-shadow: 0 0 10px rgba(79, 195, 247, 0.3);
}

.spreadsheet-grid input:hover {
    border-color: var(--accent-teal);
    background: var(--bg-secondary);
}

/* Add cell selection styles */
.spreadsheet-grid input.selected {
  border-color: var(--accent-cyan);
  background: var(--bg-tertiary);
  box-shadow: 0 0 15px rgba(79, 195, 247, 0.4);
  position: relative;
}

.spreadsheet-grid input.selected::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border: 2px solid var(--accent-cyan);
  pointer-events: none;
}

/* Formula bar status colors */
.formula-status.ready {
  color: var(--accent-green);
  border-color: var(--accent-green);
}

.formula-status.applied {
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

.formula-status.error {
  color: var(--accent-red);
  border-color: var(--accent-red);
}

.formula-status.warning {
  color: var(--accent-orange);
  border-color: var(--accent-orange);
}

/* Alternative simpler approach - use auto placement but ensure no gaps */
.spreadsheet-grid {
    grid-auto-flow: dense;
    /* Fill all grid cells */
}

/* Hide any elements beyond our intended grid */
.spreadsheet-grid>*:nth-child(n+1101) {
    display: none;
}

.formula-bar {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 0px;
  transition: all 0.3s ease;
}

.formula-bar:hover {
  border-color: var(--accent-purple);
}

.formula-header {
  background: var(--bg-accent);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-primary);
}

.formula-title {
  color: var(--accent-pink);
  font-weight: 600;
  font-size: 1em;
}

.formula-status {
  color: var(--accent-green);
  font-size: 0.8em;
  background: rgba(129, 199, 132, 0.1);
  padding: 4px 8px;
  border-radius: 0px;
  border: 1px solid var(--accent-green);
}

.formula-input-container {
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.formula-prompt {
  color: var(--accent-cyan);
  font-weight: 600;
  font-size: 1em;
  text-shadow: 0 0 8px rgba(79, 195, 247, 0.5);
}

.formula-input {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: 0px;
  padding: 12px;
  color: var(--text-primary);
  font-family: 'Geist Mono', monospace;
  font-size: 0.9em;
  transition: all 0.3s ease;
}

.formula-input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px rgba(79, 195, 247, 0.2);
  background: var(--bg-tertiary);
}

.formula-input::placeholder {
  color: var(--text-dim);
  opacity: 0.7;
}

.terminal-btn {
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: 0px;
  padding: 12px 20px;
  color: var(--text-primary);
  font-family: 'Geist Mono', monospace;
  font-size: 0.9em;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.terminal-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(79, 195, 247, 0.2);
}

.terminal-btn.primary {
  background: var(--gradient-accent);
  border-color: var(--accent-cyan);
  color: var(--bg-primary);
  font-weight: 700;
}

.terminal-btn.primary:hover {
  background: linear-gradient(135deg, #4fc3f7 0%, #4db6ac 100%);
  border-color: var(--accent-teal);
  transform: translateY(-2px) scale(1.05);
}

.terminal-footer {
  background: var(--gradient-header);
  border-top: 1px solid var(--border-accent);
  padding: 12px 16px;
}

.footer-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.8em;
  color: var(--text-dim);
}

.stat {
  font-family: 'Geist Mono', monospace;
  transition: all 0.3s ease;
}

.stat:hover {
  color: var(--text-secondary);
  transform: translateY(-1px);
}

/* Responsive Design */
@media (max-width: 1200px) {
  .terminal-body {
    padding: 16px;
  }
  
  .spreadsheet-info {
    grid-template-columns: 1fr;
  }
  
  .spreadsheet-grid {
    grid-template-columns: 40px repeat(10, 100px);
    grid-template-rows: repeat(11, 32px);
  }
  
  .footer-stats {
    flex-direction: column;
    gap: 8px;
  }
}

@media (max-width: 768px) {
  body {
    padding: 10px;
  }
  
  .spreadsheet-grid {
    grid-template-columns: 35px repeat(5, 80px);
    grid-template-rows: repeat(11, 30px);
    font-size: 0.7em;
  }
  
  .formula-input-container {
    flex-direction: column;
    align-items: stretch;
  }
  
  .app-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--accent-teal);
  border-radius: 0px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-cyan);
}

.spreadsheet-grid input.range-selected {
  background: rgba(79, 195, 247, 0.1);
  border: 1px solid var(--accent-teal);
  position: relative;
}

.spreadsheet-grid input.range-selected::before {
  content: '';
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  bottom: -1px;
  border: 1px solid;
  border-image: linear-gradient(135deg, var(--accent-teal), var(--accent-cyan)) 1;
  pointer-events: none;
}

.spreadsheet-grid input.range-start {
  border-left: 3px solid var(--accent-green);
  border-top: 3px solid var(--accent-green);
}

.spreadsheet-grid input.range-end {
  border-right: 3px solid var(--accent-cyan);
  border-bottom: 3px solid var(--accent-cyan);
}
.spreadsheet-grid input.range-selected:hover {
  background: var(--accent-pink);
  border-color: var(--accent-purple);
}

/* Update the existing .selected style to work with range selection */
.spreadsheet-grid input.selected {
  border-color: var(--accent-cyan);
  background: var(--bg-tertiary);
  box-shadow: 0 0 15px rgba(79, 195, 247, 0.4);
  position: relative;
  z-index: 2;
  /* Ensure selected cell appears above range selection */
}