/* ==========================================================================
   CSS Custom Properties (Variables)
   ========================================================================== */
:root {
  /* Light Theme Colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #e2e8f0;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  
  /* Accent Colors */
  --accent-primary: #3b82f6;
  --accent-primary-hover: #2563eb;
  --accent-secondary: #10b981;
  --accent-danger: #ef4444;
  --accent-warning: #f59e0b;
  
  /* Interactive Colors */
  --border-light: #e2e8f0;
  --border-medium: #cbd5e1;
  --shadow-light: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  --shadow-medium: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-large: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  
  /* Table specific */
  --cell-hidden: #94a3b8;
  --cell-hidden-hover: #64748b;
  --cell-revealed: #ffffff;
  --cell-revealed-text: #1e293b;
  --cell-revealed-border: #e2e8f0;
  --cell-hover: #f1f5f9;
  
  /* Timer colors */
  --timer-bg: #e2e8f0;
  --timer-progress: linear-gradient(90deg, #3b82f6, #6366f1, #8b5cf6);
}

/* Dark Theme */
[data-theme="dark"] {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  
  --border-light: #334155;
  --border-medium: #475569;
  --shadow-light: 0 1px 3px 0 rgba(0, 0, 0, 0.3);
  --shadow-medium: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-large: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
  
  --cell-hidden: #475569;
  --cell-hidden-hover: #334155;
  --cell-revealed: #1e293b;
  --cell-revealed-text: #f1f5f9;
  --cell-revealed-border: #475569;
  --cell-hover: #334155;
  --timer-bg: #334155;
}

/* ==========================================================================
   Base Styles
   ========================================================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: all 0.3s ease;
  min-height: 100vh;
}

/* ==========================================================================
   Layout
   ========================================================================== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  text-align: center;
  margin-bottom: 3rem;
  position: relative;
}

header h1 {
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent-primary);
  margin-bottom: 0.5rem;
  text-shadow: var(--shadow-light);
}

header p {
  font-size: 1.2rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.controls {
  position: absolute;
  top: 0;
  right: 0;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

footer {
  text-align: center;
  padding-top: 2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 2rem;
}

/* Impressum footer links and layout */
.impressum p {
  margin: 0;
  color: var(--text-secondary);
}

.impressum a {
  color: var(--accent-primary);
  text-decoration: none;
  margin: 0 0.4rem;
}

.impressum a:hover {
  text-decoration: underline;
}

.impressum a:focus-visible {
  outline: 2px dashed var(--accent-primary);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  background: none;
  font-family: inherit;
}

.btn.primary {
  background: var(--accent-primary);
  color: white;
  box-shadow: var(--shadow-medium);
}

.btn.primary:hover {
  background: var(--accent-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-large);
}

.btn.secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
}

.btn.secondary:hover {
  background: var(--bg-tertiary);
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ==========================================================================
   Upload Section
   ========================================================================== */
.upload-section {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 400px;
}

.upload-area {
  background: var(--bg-secondary);
  border: 2px dashed var(--border-medium);
  border-radius: 1rem;
  padding: 3rem;
  text-align: center;
  transition: all 0.3s ease;
  max-width: 500px;
  width: 100%;
}

.upload-area:hover {
  border-color: var(--accent-primary);
  background: var(--bg-tertiary);
}

.upload-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.upload-area h3 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.upload-area p {
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

/* ==========================================================================
   Configuration Section
   ========================================================================== */
.config-section {
  display: flex;
  justify-content: center;
}

.config-panel {
  background: var(--bg-secondary);
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: var(--shadow-medium);
  max-width: 600px;
  width: 100%;
}

.config-panel h3 {
  margin-bottom: 1.5rem;
  color: var(--text-primary);
  text-align: center;
}

.config-row {
  margin-bottom: 1.5rem;
}

.config-row label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  color: var(--text-primary);
}

.config-row input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  accent-color: var(--accent-primary);
}

.config-row input[type="range"] {
  flex: 1;
  margin: 0 1rem;
  accent-color: var(--accent-primary);
}

.config-row select {
  padding: 0.5rem;
  border: 1px solid var(--border-medium);
  border-radius: 0.25rem;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 1rem;
}

#time-display {
  min-width: 3rem;
  font-weight: 600;
  color: var(--accent-primary);
}

/* ==========================================================================
   Table Section
   ========================================================================== */
.table-section {
  flex: 1;
}

.table-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding: 1rem;
  background: var(--bg-secondary);
  border-radius: 0.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.timer-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-weight: 500;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#zoom-level {
  min-width: 4rem;
  text-align: center;
  font-weight: 600;
  color: var(--accent-primary);
  background: var(--bg-primary);
  padding: 0.5rem;
  border-radius: 0.25rem;
  border: 1px solid var(--border-medium);
}

.table-container {
  background: var(--bg-secondary);
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: var(--shadow-medium);
}

.timer-bar {
  height: 0.5rem;
  background: var(--timer-bg);
  position: relative;
  overflow: hidden;
}

.timer-progress {
  height: 100%;
  background: var(--timer-progress);
  width: 100%;
  transition: width linear;
  border-radius: 0 0.25rem 0.25rem 0;
}

.table-wrapper {
  overflow: auto;
  max-height: 70vh;
  transform-origin: top left;
  transition: transform 0.3s ease;
}

.table-wrapper.zoomed {
  overflow: auto;
  max-height: 70vh;
}

/* ==========================================================================
   Table Styles
   ========================================================================== */
#data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
}

/* Font size classes */
.font-small #data-table { font-size: 0.8rem; }
.font-medium #data-table { font-size: 1rem; }
.font-large #data-table { font-size: 1.2rem; }
.font-extra-large #data-table { font-size: 1.4rem; }

#data-table th,
#data-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
  position: relative;
  min-width: 120px;
  max-width: 200px;
  overflow: hidden;
  word-wrap: break-word;
  outline: none;
  transition: all 0.2s ease;
}

/* Keyboard navigation highlight */
#data-table td.keyboard-focus {
  box-shadow: 0 0 0 3px var(--accent-primary);
  z-index: 5;
}

#data-table th {
  background: var(--bg-tertiary);
  font-weight: 600;
  color: var(--text-primary);
  position: sticky;
  top: 0;
  z-index: 10;
}

#data-table tbody tr:hover {
  background: var(--cell-hover);
}

/* Cell states */
.cell-hidden {
  background: var(--cell-hidden) !important;
  color: transparent !important;
  cursor: pointer;
  position: relative;
  border: 2px solid white;
  transition: all 0.2s ease;
}

.cell-hidden::before {
  content: '👁️';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.2rem;
  opacity: 0.8;
}

.cell-hidden:hover {
  background: var(--cell-hidden-hover) !important;
}

.cell-hidden:hover::before {
  opacity: 1;
  font-size: 1.4rem;
}

.cell-revealed {
  background: var(--cell-revealed) !important;
  color: var(--cell-revealed-text) !important;
  border: 1px solid var(--cell-revealed-border) !important;
  animation: reveal 0.3s ease-out;
  font-weight: 500;
  position: relative;
}

.cell-revealing {
  animation: pulse 0.5s ease-in-out infinite alternate;
}

/* Individual cell timer ring */
.cell-timer-ring {
  position: absolute;
  bottom: 3px;
  right: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  z-index: 10;
  pointer-events: none;
}

.cell-timer-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.cell-timer-ring .timer-background {
  fill: none;
  stroke: #e2e8f0;
  stroke-width: 2;
}

.cell-timer-ring .timer-progress {
  fill: none;
  stroke: #64748b;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 35.4;
  stroke-dashoffset: 35.4;
  transition: stroke-dashoffset linear;
}

/* Dark theme timer colors */
[data-theme="dark"] .cell-timer-ring .timer-background {
  stroke: #475569;
}

[data-theme="dark"] .cell-timer-ring .timer-progress {
  stroke: #94a3b8;
}

/* Hide header when in table mode */
.table-mode header {
  display: none;
}

.table-mode main {
  padding-top: 0;
}

/* ==========================================================================
   Theme Toggle
   ========================================================================== */
#theme-toggle {
  border: 1px solid var(--border-medium);
}

.theme-icon {
  font-size: 1.2rem;
}

/* ==========================================================================
   Instructions
   ========================================================================== */
.instructions {
  text-align: center;
  padding: 1.5rem;
  background: var(--bg-secondary);
  border-radius: 0.5rem;
  margin-top: 1rem;
}

/* ==========================================================================
   Shortcuts Overlay
   ========================================================================== */
.shortcuts-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.shortcuts-content {
  background: var(--bg-primary);
  border-radius: 1rem;
  padding: 2rem;
  max-width: 800px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-large);
  border: 1px solid var(--border-medium);
}

.shortcuts-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.shortcuts-header h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: 1.5rem;
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0.25rem;
  border-radius: 0.25rem;
  transition: all 0.2s ease;
}

.btn-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.shortcut-group h4 {
  margin: 0 0 1rem 0;
  color: var(--accent-primary);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  border-radius: 0.5rem;
  transition: background 0.2s ease;
}

.shortcut-item:hover {
  background: var(--bg-secondary);
}

.shortcut-item kbd {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border-medium);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  white-space: nowrap;
}

.instructions p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes reveal {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.5s ease-out;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }
  
  header h1 {
    font-size: 2rem;
  }
  
  .controls {
    position: static;
    margin-top: 1rem;
  }
  
  .upload-area {
    padding: 2rem;
  }
  
  .config-panel {
    padding: 1.5rem;
  }
  
  .table-controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  #data-table th,
  #data-table td {
    padding: 0.5rem;
    min-width: 80px;
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  header h1 {
    font-size: 1.5rem;
  }
  
  .btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }
  
  #data-table th,
  #data-table td {
    padding: 0.4rem;
    min-width: 60px;
    font-size: 0.8rem;
  }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
  .upload-section,
  .config-section,
  .table-controls,
  .instructions,
  footer {
    display: none;
  }
  
  .cell-hidden {
    background: #f0f0f0 !important;
  }
  
  .cell-hidden::before {
    display: none;
  }
}
