/**
 * Typographic Grid Tool - Styles
 */

/* CSS Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2a2a2a;
  --bg-tertiary: #3a3a3a;
  --text-primary: #ffffff;
  --text-secondary: #cccccc;
  --accent: #4a9eff;
  --accent-hover: #6ab0ff;
  --border: #444444;
  --shadow: rgba(0, 0, 0, 0.5);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
}

/* App Container */
.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Canvas Container */
.canvas-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  overflow: auto;
  padding: 20px;
}

#typo-grid-canvas {
  display: block;
  box-shadow: 0 10px 40px var(--shadow);
  border-radius: 4px;
}

/* Controls Container */
.controls-container {
  width: 380px;
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  transition: transform 0.3s ease;
}

.controls-container.hidden {
  transform: translateX(100%);
}

/* Controls Panel */
.controls-panel h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.control-section {
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.control-section:last-child {
  border-bottom: none;
}

.control-section h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 15px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

/* Control Group */
.control-group {
  margin-bottom: 16px;
}

.control-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.control-group input[type="text"],
.control-group input[type="url"],
.control-group select {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 13px;
  transition: border-color 0.2s;
}

.control-group input[type="text"]:focus,
.control-group input[type="url"]:focus,
.control-group select:focus {
  outline: none;
  border-color: var(--accent);
}

.control-group input[type="range"] {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  outline: none;
  -webkit-appearance: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s;
}

.control-group input[type="range"]::-webkit-slider-thumb:hover {
  background: var(--accent-hover);
}

.control-group input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s;
}

.control-group input[type="range"]::-moz-range-thumb:hover {
  background: var(--accent-hover);
}

.control-group input[type="color"] {
  width: 100%;
  height: 40px;
  padding: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}

/* Info Text */
.info-text {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
  line-height: 1.5;
}

/* Buttons */
button {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent);
  color: white;
  width: 100%;
  margin-bottom: 10px;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(74, 158, 255, 0.3);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  width: 100%;
  margin-bottom: 10px;
}

.btn-secondary:hover {
  background: var(--border);
}

/* Actions Section */
.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Gradient Editor */
.gradient-editor {
  background: var(--bg-secondary);
  padding: 15px;
  border-radius: 6px;
  margin-top: 10px;
}

.gradient-type-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

.gradient-type-selector label {
  flex: 1;
  min-width: 70px;
  text-align: center;
}

.gradient-type-selector input[type="radio"] {
  display: none;
}

.gradient-type-selector span {
  display: block;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.gradient-type-selector input[type="radio"]:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.gradient-preview {
  margin-bottom: 15px;
}

.preview-box {
  width: 100%;
  height: 80px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: #fff;
}

.gradient-controls {
  margin-top: 15px;
}

/* Color Stops */
.color-stops-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

.color-stop {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
}

.stop-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stop-controls input[type="range"] {
  flex: 1;
}

.stop-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stop-color-row input[type="color"] {
  width: 50px;
  height: 30px;
  padding: 2px;
}

.stop-color-row input[type="range"] {
  flex: 1;
}

.stop-position-label,
.stop-opacity-label {
  font-size: 11px;
  color: var(--text-secondary);
  min-width: 35px;
  text-align: right;
}

.remove-stop {
  width: 24px;
  height: 24px;
  padding: 0;
  background: rgba(255, 59, 48, 0.2);
  color: #ff3b30;
  border-radius: 3px;
  font-size: 18px;
  line-height: 1;
}

.remove-stop:hover {
  background: rgba(255, 59, 48, 0.4);
}

/* Mesh Grid */
.mesh-grid {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.mesh-point {
  aspect-ratio: 1;
}

.mesh-point input[type="color"] {
  width: 100%;
  height: 100%;
  border-radius: 4px;
}

/* Effect Checkboxes Grid */
.effect-checkboxes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.effect-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 12px;
}

.effect-checkbox:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent);
}

.effect-checkbox input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.effect-checkbox span {
  text-transform: capitalize;
  user-select: none;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .app-container {
    flex-direction: column;
  }

  .controls-container {
    width: 100%;
    height: 50vh;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .controls-container.hidden {
    transform: translateY(100%);
  }

  .canvas-container {
    height: 50vh;
  }
}

@media (max-width: 768px) {
  .controls-container {
    height: 60vh;
  }

  .canvas-container {
    height: 40vh;
    padding: 10px;
  }

  .controls-panel h2 {
    font-size: 16px;
  }

  .control-section h3 {
    font-size: 13px;
  }
}

/* Scrollbar Styling */
.controls-container::-webkit-scrollbar {
  width: 8px;
}

.controls-container::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

.controls-container::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

.controls-container::-webkit-scrollbar-thumb:hover {
  background: var(--border);
}

/* Loading State */
.loading {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 14px;
  color: var(--text-secondary);
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.control-section {
  animation: fadeIn 0.3s ease-out;
}

/* Accordion Styles */
.accordion-section {
  margin-bottom: 15px;
  padding-bottom: 0;
  border-bottom: none;
}

.accordion-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 15px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.accordion-header:hover {
  background: var(--bg-tertiary);
  border-color: var(--accent);
}

.accordion-header.expanded {
  border-radius: 6px 6px 0 0;
  border-bottom-color: transparent;
  background: var(--bg-tertiary);
}

.accordion-icon {
  font-size: 10px;
  color: var(--text-secondary);
  transition: transform 0.2s ease;
  width: 12px;
}

.accordion-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.accordion-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--accent);
  color: white;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.accordion-content {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.3s ease;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 0 15px;
}

.accordion-content.expanded {
  max-height: 2000px;
  opacity: 1;
  padding: 15px;
}

/* Nested accordions (effects categories) */
.effects-subsection {
  margin-bottom: 10px;
}

.effects-subsection .accordion-header {
  background: var(--bg-tertiary);
  border-color: var(--border);
  padding: 10px 12px;
}

.effects-subsection .accordion-header:hover {
  background: var(--border);
}

.effects-subsection .accordion-header.expanded {
  background: var(--border);
}

.effects-subsection .accordion-content {
  background: var(--bg-tertiary);
  border-color: var(--border);
}

.effects-subsection .accordion-title {
  font-size: 12px;
}

/* Effect category sections (deepest level) */
.effect-category-section {
  margin-bottom: 8px;
}

.effect-category-section .accordion-header {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.1);
  padding: 8px 10px;
}

.effect-category-section .accordion-header:hover {
  background: rgba(255, 255, 255, 0.06);
}

.effect-category-section .accordion-header.expanded {
  background: rgba(255, 255, 255, 0.06);
}

.effect-category-section .accordion-content {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.1);
}

.effect-category-section .accordion-title {
  font-size: 11px;
  text-transform: capitalize;
}

.effect-category-section .accordion-badge {
  min-width: 16px;
  height: 16px;
  font-size: 10px;
}

/* Effects settings (always visible) */
.effects-settings {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
}

/* Gradient editors in accordions */
.accordion-content .gradient-editor {
  margin-top: 0;
}

/* Export Modal */
.export-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease-out;
}

.export-modal.hidden {
  display: none;
}

.export-modal-content {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 30px;
  min-width: 350px;
  max-width: 450px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.export-modal-content h3 {
  margin-bottom: 20px;
  font-size: 18px;
  color: var(--text-primary);
}

.progress-bar-container {
  width: 100%;
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 15px;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 4px;
  transition: width 0.1s ease-out;
}

.progress-text {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* Countdown Timer Styles */
.countdown-container {
  padding: 20px 0;
}

.countdown-container.hidden {
  display: none;
}

.countdown-number {
  font-size: 96px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  animation: countdownPulse 1s ease-in-out infinite;
}

.countdown-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 15px;
}

@keyframes countdownPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

/* Start Recording Button */
.btn-record {
  background: linear-gradient(135deg, #e53935, #c62828);
}

.btn-record:hover {
  background: linear-gradient(135deg, #f44336, #d32f2f);
}

/* Floating Recording Overlay - doesn't block interaction */
.recording-overlay {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.9);
  border: 2px solid #e53935;
  border-radius: 12px;
  padding: 15px 30px;
  z-index: 1001;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(229, 57, 53, 0.4);
}

.recording-overlay.hidden {
  display: none;
}

/* Countdown mode in overlay */
.overlay-countdown {
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlay-countdown.hidden {
  display: none;
}

.overlay-countdown-number {
  font-size: 64px;
  font-weight: 700;
  color: #e53935;
  line-height: 1;
  animation: countdownPulse 1s ease-in-out infinite;
}

/* Recording mode in overlay */
.overlay-recording {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.overlay-recording.hidden {
  display: none;
}

.recording-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.recording-dot {
  width: 14px;
  height: 14px;
  background: #e53935;
  border-radius: 50%;
  animation: recordingBlink 1s ease-in-out infinite;
}

.recording-label {
  font-size: 18px;
  font-weight: 700;
  color: #e53935;
  letter-spacing: 2px;
}

.recording-time {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  margin: 0;
}

@keyframes recordingBlink {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* Record Shortcut Hint */
.record-hint {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  z-index: 100;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.record-hint.hidden {
  opacity: 0;
}

.hint-key {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: monospace;
  font-weight: 600;
  color: var(--text-primary);
}

/* Frame Sequence Export Controls */
.frame-export-controls {
  background: var(--bg-secondary);
  padding: 15px;
  border-radius: 6px;
  margin-bottom: 15px;
}

.frame-export-controls .control-group {
  margin-bottom: 12px;
}

.frame-export-controls .control-group:last-child {
  margin-bottom: 0;
}

.frame-export-row {
  display: flex;
  gap: 10px;
}

.frame-export-row .control-group {
  flex: 1;
}

.frame-export-info {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* Font Selector Styles */
.font-selector {
  margin-bottom: 16px;
}

.font-selector > label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.font-selector .current-font-name {
  font-weight: 400;
  color: var(--accent);
  font-style: italic;
}

.font-source-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.font-source-tabs .tab {
  flex: 1;
  padding: 8px 10px;
  font-size: 11px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  margin: 0;
  width: auto;
}

.font-source-tabs .tab:hover {
  background: var(--border);
  color: var(--text-primary);
}

.font-source-tabs .tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.font-source-content {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
}

.font-source-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.font-source-group.hidden {
  display: none;
}

.font-search {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 12px;
}

.font-search:focus {
  outline: none;
  border-color: var(--accent);
}

.font-search::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}

.font-select {
  width: 100%;
  padding: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
}

.font-select:focus {
  outline: none;
  border-color: var(--accent);
}

.font-select option {
  padding: 6px 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.font-select option:hover,
.font-select option:focus {
  background: var(--accent);
  color: white;
}

/* Multi-line select for scrollable lists */
.font-select[size] {
  height: auto;
  min-height: 120px;
  max-height: 180px;
  overflow-y: auto;
}

.font-select[size] option {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.font-select[size] option:last-child {
  border-bottom: none;
}

.font-select[size] option:checked {
  background: var(--accent);
  color: white;
}

.font-url-name,
.font-url-input {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 12px;
}

.font-url-name:focus,
.font-url-input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-small {
  padding: 6px 12px;
  font-size: 11px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  width: auto;
  margin: 0;
}

.btn-small:hover {
  background: var(--accent-hover);
}

.btn-small:disabled {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  cursor: not-allowed;
}

.btn-full {
  width: 100%;
}

.font-divider {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
}

.info-text.small {
  font-size: 11px;
  margin-top: 6px;
}

.font-count {
  font-size: 11px;
  color: var(--text-secondary);
  margin-left: 4px;
}

/* Font List Container (for system fonts with preview) */
.font-list-container {
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.font-list-item {
  padding: 10px 12px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.15s ease;
}

.font-list-item:last-child {
  border-bottom: none;
}

.font-list-item:hover {
  background: var(--bg-tertiary);
  color: var(--accent);
}

.font-list-item.active {
  background: var(--accent);
  color: white;
}

/* Scrollbar for font list */
.font-list-container::-webkit-scrollbar {
  width: 6px;
}

.font-list-container::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

.font-list-container::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 3px;
}

.font-list-container::-webkit-scrollbar-thumb:hover {
  background: var(--border);
}

/* Font Variant Controls (Weight & Style) */
.font-variant-controls {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.font-variant-row {
  display: flex;
  gap: 12px;
}

.font-variant-control {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.font-variant-control label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
}

.font-variant-select {
  width: 100%;
  padding: 6px 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 11px;
  cursor: pointer;
}

.font-variant-select:focus {
  outline: none;
  border-color: var(--accent);
}

.font-variant-select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.font-variant-select option:disabled {
  color: var(--text-secondary);
  opacity: 0.5;
}

/* Variable Font Weight Slider */
.font-weight-slider {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-secondary);
  border-radius: 3px;
  outline: none;
  margin-top: 4px;
}

.font-weight-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.1s;
}

.font-weight-slider::-webkit-slider-thumb:hover {
  transform: scale(1.1);
}

.font-weight-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

.font-weight-control label {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.weight-value {
  font-weight: 600;
  color: var(--accent);
  font-size: 10px;
}
