/**
 * Speed Reading App - Kindle-Compatible CSS
 * No Flexbox/Grid - using table-cell and inline-block
 */

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
  background: #fff;
  color: #000;
  overflow: hidden;
}

/* Home page container */
.home-container {
  display: table;
  width: 100%;
  height: 100%;
}

.home-content {
  display: table-cell;
  vertical-align: middle;
  text-align: center;
  padding: 20px;
}

.app-title {
  font-size: 2.5em;
  font-weight: 700;
  margin-bottom: 40px;
  color: #000;
}

/* Input mode tabs */
.mode-tabs {
  margin-bottom: 30px;
}

.mode-tab {
  display: inline-block;
  padding: 12px 24px;
  margin: 0 5px;
  background: #f0f0f0;
  border: 2px solid #ddd;
  cursor: pointer;
  font-size: 1em;
  font-weight: 500;
  transition: all 0.2s;
}

.mode-tab:hover {
  background: #e8e8e8;
}

.mode-tab.active {
  background: #000;
  color: #fff;
  border-color: #000;
}

.mode-tab.disabled {
  background: #f5f5f5;
  color: #999;
  border-color: #ddd;
  cursor: not-allowed;
}

.mode-tab.disabled:hover {
  background: #f5f5f5;
}

/* Server warning banner - B&W for e-ink */
.server-warning {
  display: none;
  background: #f5f5f5;
  border: 2px solid #000;
  color: #000;
  padding: 10px 15px;
  margin-bottom: 20px;
  font-size: 0.9em;
  text-align: center;
}

.server-warning.visible {
  display: block;
}

.server-warning .warning-icon {
  margin-right: 8px;
}

/* Input areas */
.input-area {
  max-width: 600px;
  margin: 0 auto 30px;
  min-height: 200px;
}

.input-mode {
  display: none;
}

.input-mode.active {
  display: block;
}

/* Paste text mode */
#pasteText {
  width: 100%;
  height: 250px;
  padding: 15px;
  font-size: 1em;
  font-family: inherit;
  border: 2px solid #ddd;
  resize: vertical;
}

#pasteText:focus {
  outline: none;
  border-color: #000;
}

/* Upload file mode */
.file-upload-area {
  padding: 40px;
  border: 2px dashed #ddd;
  text-align: center;
}

.file-input-wrapper {
  display: inline-block;
  margin-bottom: 15px;
}

#fileInput {
  display: none;
}

.file-button {
  display: inline-block;
  padding: 12px 30px;
  background: #000;
  color: #fff;
  cursor: pointer;
  font-size: 1em;
  font-weight: 500;
  border: none;
}

.file-button:hover {
  background: #333;
}

.file-info {
  margin-top: 15px;
  font-size: 1em;
  color: #666;
}

/* Code input mode */
#codeInput {
  width: 100%;
  padding: 15px;
  font-size: 1.2em;
  font-family: inherit;
  border: 2px solid #ddd;
  text-align: center;
  letter-spacing: 0.2em;
}

#codeInput:focus {
  outline: none;
  border-color: #000;
}

.code-hint {
  margin-top: 15px;
  font-size: 0.9em;
  color: #666;
}

/* Success message - B&W style */
.success-message {
  display: none;
  max-width: 600px;
  margin: 20px auto;
  padding: 25px;
  background: #f5f5f5;
  border: 2px solid #000;
  text-align: center;
}

.success-message.visible {
  display: block;
}

.success-icon {
  font-size: 3em;
  color: #000;
  margin-bottom: 10px;
}

.success-text {
  font-size: 1.4em;
  font-weight: 600;
  color: #000;
  margin-bottom: 15px;
}

.success-code {
  font-size: 1.5em;
  font-weight: 700;
  color: #000;
  margin-bottom: 10px;
  letter-spacing: 0.15em;
}

.success-code span {
  background: #fff;
  padding: 5px 15px;
  border: 2px solid #000;
}

.success-link {
  font-size: 1em;
  color: #000;
  margin-bottom: 15px;
  word-break: break-all;
}

.success-link a {
  color: #000;
  text-decoration: underline;
}

.success-hint {
  font-size: 0.9em;
  color: #333;
  margin-top: 15px;
}

.start-reading-btn {
  display: inline-block;
  margin-top: 20px;
  padding: 15px 40px;
  background: #000;
  color: #fff;
  font-size: 1.1em;
  font-weight: 600;
  border: none;
  cursor: pointer;
}

.start-reading-btn:hover {
  background: #333;
}

/* Start button */
.start-button {
  display: inline-block;
  padding: 15px 50px;
  background: #000;
  color: #fff;
  font-size: 1.2em;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.start-button:hover {
  background: #333;
}

.start-button:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Error message - B&W style */
.error-message {
  display: none;
  max-width: 600px;
  margin: 20px auto;
  padding: 15px;
  background: #f5f5f5;
  border: 2px solid #000;
  color: #000;
  font-weight: 500;
  text-align: center;
}

.error-message.visible {
  display: block;
}

/* Loading spinner */
.loading {
  display: none;
  margin: 20px auto;
  text-align: center;
  font-size: 1.2em;
  color: #666;
}

.loading.visible {
  display: block;
}

/* Reader page */
.reader-container {
  display: table;
  width: 100%;
  height: 100%;
  position: relative;
}

.reader-content {
  display: table-cell;
  vertical-align: middle;
  text-align: center;
}

/* Word display */
#wordDisplay {
  font-size: 4vw;
  font-weight: 700;
  color: #000;
  letter-spacing: 0.05em;
  padding: 20px;
  min-height: 100px;
}

/* Reader controls - hidden when playing */
.reader-controls {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 15px;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid #ddd;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.reader.paused .reader-controls {
  opacity: 1;
  visibility: visible;
}

.reader.playing .reader-controls {
  opacity: 0;
  visibility: hidden;
}

/* Speed controls */
.speed-control {
  display: inline-block;
  margin: 0 20px;
  vertical-align: middle;
}

.speed-display {
  display: inline-block;
  font-size: 1.2em;
  font-weight: 600;
  margin: 0 10px;
  min-width: 80px;
}

.speed-button {
  display: inline-block;
  width: 35px;
  height: 35px;
  background: #000;
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1.2em;
  font-weight: 700;
  margin: 0 5px;
}

.speed-button:hover {
  background: #333;
}

/* Progress display */
.progress-display {
  display: none;
  font-size: 1.1em;
  color: #666;
  margin-top: 15px;
}

.reader.paused .progress-display {
  display: block;
}

/* Bottom controls */
.bottom-controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 15px;
  background: rgba(255, 255, 255, 0.95);
  border-top: 1px solid #ddd;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.reader.paused .bottom-controls {
  opacity: 1;
  visibility: visible;
}

.reader.playing .bottom-controls {
  opacity: 0;
  visibility: hidden;
}

/* Control buttons */
.control-button {
  display: inline-block;
  padding: 10px 20px;
  margin: 5px;
  background: #000;
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1em;
  font-weight: 500;
}

.control-button:hover {
  background: #333;
}

.control-button.primary {
  background: #000;
  padding: 12px 30px;
  font-size: 1.1em;
}

/* Chapter info */
.chapter-info {
  display: none;
  margin: 10px 0;
  font-size: 1.1em;
  font-weight: 600;
  color: #000;
}

.chapter-info.visible {
  display: block;
}

/* Chapter list */
.chapter-list {
  display: none;
  max-width: 600px;
  margin: 20px auto;
  text-align: left;
  max-height: 300px;
  overflow-y: auto;
  background: #f9f9f9;
  border: 2px solid #ddd;
  padding: 15px;
}

.chapter-list.visible {
  display: block;
}

.chapter-list-title {
  font-weight: 600;
  margin-bottom: 10px;
  font-size: 1.1em;
}

.chapter-item {
  padding: 10px;
  margin: 5px 0;
  cursor: pointer;
  background: #fff;
  border: 1px solid #ddd;
}

.chapter-item:hover {
  background: #f0f0f0;
}

.chapter-item.current {
  background: #000;
  color: #fff;
  font-weight: 600;
}

/* Completion screens */
.completion-screen {
  display: none;
}

.completion-screen.visible {
  display: table;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background: #fff;
  z-index: 1000;
}

.completion-content {
  display: table-cell;
  vertical-align: middle;
  text-align: center;
  padding: 40px 20px;
}

.completion-title {
  font-size: 2.5em;
  font-weight: 700;
  margin: 0 0 40px 0;
  text-align: center;
  line-height: 1.2;
}

.completion-stats {
  font-size: 1.3em;
  margin: 30px auto;
  color: #666;
  text-align: center;
  max-width: 400px;
  line-height: 1.6;
}

.completion-stats div {
  margin: 15px 0;
}

.completion-buttons {
  margin-top: 40px;
  text-align: center;
}

/* Paused indicator */
.paused-indicator {
  display: none;
  font-size: 1em;
  color: #666;
  margin-top: 10px;
}

.reader.paused .paused-indicator {
  display: block;
}

/* Completion message (inline) */
.completion-message {
  display: none;
  margin-top: 30px;
  text-align: center;
}

.completion-message.visible {
  display: block;
}

.completion-text {
  font-size: 1.5em;
  font-weight: 600;
  margin-bottom: 20px;
  color: #666;
}

.completion-stats-inline {
  font-size: 1.1em;
  color: #666;
  line-height: 1.8;
}

.completion-stats-inline div {
  margin: 8px 0;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .app-title {
    font-size: 1.8em;
    margin-bottom: 25px;
  }

  .mode-tab {
    display: block;
    margin: 5px auto;
    width: 90%;
    max-width: 300px;
  }

  #wordDisplay {
    font-size: 8vw;
  }

  .reader-controls {
    font-size: 0.9em;
  }

  .speed-control,
  .progress-display {
    display: block;
    margin: 10px auto;
  }

  .control-button {
    padding: 8px 15px;
    font-size: 0.9em;
  }
}

/* Utility classes */
.hidden {
  display: none !important;
}

.visible {
  display: block !important;
}
