/* Simulator Apps Styles */

.page-simulator-apps {
  min-height: 100vh;
  background: white;
  padding: 24px;
  font-family:"Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
  color:#000;
  --t-text-primary:#000;
  --t-text-secondary:#000;
  --t-text-muted:#000;
}

.apps-header {
  max-width: 1200px;
  margin: 0 auto 14px;
  text-align: center;
}

.apps-title {
  font-size: 32px;
  font-weight: 800;
  color: #1b1b23;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.apps-subtitle {
  font-size: 16px;
  color: #464554;
  max-width: 600px;
  margin: 0 auto;
  line-height: 1.5;
}

.apps-shell {
  max-width: 1200px;
  margin: 0 auto;
}

/* Toolbar */
.apps-toolbar {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 8px 12px;
  display: flex;
  width: 100%;
  max-width: 100%;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  box-shadow: 0 4px 24px rgba(27, 27, 35, 0.06);
  border: 1px solid rgba(118, 117, 134, 0.1);
  flex-wrap: wrap;
}

.apps-toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.apps-toolbar-label {
  font-size: 11px;
  font-weight: 700;
  color: #767586;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.apps-toolbar-btn {
  height: 36px;
  min-width: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #1b1b23;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.apps-toolbar-btn:hover {
  background: rgba(70, 72, 212, 0.08);
}

.apps-toolbar-btn.active {
  background: white;
  box-shadow: 0 2px 8px rgba(27, 27, 35, 0.12);
  color: #4648d4;
}

.apps-toolbar-btn.size-btn {
  padding: 0 14px;
}

/* Alignment buttons */
.apps-toolbar-btn.align-btn {
  width: 36px;
  min-width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid #cfd4e6;
  background: var(--t-card-bg);
  color: #4f5d7c;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.apps-toolbar-btn.align-btn:hover {
  background: #eef2ff;
  border-color: #9aa9e6;
  color: #2f418c;
  transform: translateY(-1px);
}

.apps-toolbar-btn.align-btn.active {
  background: #dde6ff;
  border-color: #6380e8;
  color: #2840a0;
  box-shadow: 0 4px 12px rgba(70, 72, 212, 0.22);
}

.apps-toolbar-btn.bold-btn.active {
  background: #dde6ff;
  border: 1px solid #6380e8;
  color: #2840a0;
  box-shadow: 0 4px 12px rgba(70, 72, 212, 0.22);
}

.apps-toolbar-btn.align-btn:focus-visible {
  outline: none;
  border-color: #5375e0;
  box-shadow: 0 0 0 3px rgba(83, 117, 224, 0.22);
}

.apps-toolbar-btn.align-btn .align-glyph {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  width: 18px;
  height: 16px;
}

.apps-toolbar-btn.align-btn .align-line {
  display: block;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}

.apps-toolbar-btn.align-left .line-1,
.apps-toolbar-btn.align-left .line-3 {
  width: 18px;
}

.apps-toolbar-btn.align-left .line-2 {
  width: 13px;
}

.apps-toolbar-btn.align-left .line-4 {
  width: 10px;
}

.apps-toolbar-btn.align-center .line-1,
.apps-toolbar-btn.align-center .line-3 {
  width: 18px;
  margin: 0 auto;
}

.apps-toolbar-btn.align-center .line-2 {
  width: 13px;
  margin: 0 auto;
}

.apps-toolbar-btn.align-center .line-4 {
  width: 10px;
  margin: 0 auto;
}

.apps-toolbar-btn.align-right .line-1,
.apps-toolbar-btn.align-right .line-3 {
  width: 18px;
  margin-left: auto;
}

.apps-toolbar-btn.align-right .line-2 {
  width: 13px;
  margin-left: auto;
}

.apps-toolbar-btn.align-right .line-4 {
  width: 10px;
  margin-left: auto;
}

.bold-icon {
  font-weight: 700;
  font-size: 16px;
}

.apps-toolbar-btn .material-symbols-outlined {
  font-size: 20px;
}

/* Change document button */
.apps-toolbar-group-right {
  margin-left: 4px;
}

.apps-toolbar-group-timer {
  margin-left: auto;
  gap: 8px;
  align-items: baseline;
}

.apps-toolbar-timer-label {
  font-size: 11px;
  font-weight: 700;
  color: #767586;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.apps-toolbar-timer-value {
  font-size: 22px;
  line-height: 1;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  color: #1b1b23;
  font-variant-numeric: tabular-nums;
}

.apps-toolbar-btn.change-doc-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0;
  width: 36px;
  min-width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(70, 72, 212, 0.08);
  color: #2563eb;
  font-weight: 700;
  border: 1px solid rgba(37, 99, 235, 0.18);
}

.apps-toolbar-btn.change-doc-btn:hover {
  background: rgba(37, 99, 235, 0.16);
  border-color: rgba(37, 99, 235, 0.28);
  transform: translateY(-1px);
}

.change-doc-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  line-height: 0;
}

.change-doc-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}

.change-doc-text {
  font-size: 13px;
}

[data-theme="dark"] .apps-toolbar-btn.change-doc-btn {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.2);
  color: #e5e7eb;
}

[data-theme="dark"] .apps-toolbar-btn.change-doc-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
}

/* Editor Layout */
.apps-editor {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.apps-paper {
  flex: 1;
  min-width: 0;
}

.apps-paper,
.apps-paper * {
  box-sizing: border-box;
}

.apps-toolbar-doc-top {
  margin-bottom: 10px;
}

/* Document Paper */
.apps-document {
  background: white;
  border-radius: 28px;
  box-shadow: none;
  border: 1px solid rgba(99, 128, 232, 0.26);
  padding: 24px 28px 34px;
  min-height: 800px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.8;
  color: #9CA3AF;
  position: relative;
  transition: font-size 0.2s ease;
  overflow: hidden;
}

.apps-document::before {
  content: none;
}

.apps-paper:hover .apps-document::before {
  opacity: 0.3;
}

.doc-line {
  min-height: 1.8em;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.doc-line.align-right {
  text-align: right;
}

.doc-line.align-center {
  text-align: center;
}

.doc-line.align-left {
  text-align: left;
}

/* Document alignment modes */
.apps-document.align-left-mode .doc-line:not(.align-right):not(.align-center) {
  text-align: left;
}

.apps-document.align-center-mode .doc-line:not(.align-right):not(.align-left) {
  text-align: center;
}

.apps-document.align-right-mode .doc-line:not(.align-left):not(.align-center) {
  text-align: right;
}

.doc-char {
  color: #9CA3AF;
  transition: color 0.1s ease;
  position: relative;
}

.intro-typing .doc-char:not(.typed):not(.wrong):not(.active) {
  opacity: 0;
  transform: translateY(6px);
  filter: blur(1.5px);
  animation: intro-typing-reveal 0.32s ease-out forwards;
  animation-delay: var(--intro-delay, 0s);
}

.intro-typing .doc-char.space:not(.typed):not(.wrong):not(.active)::before {
  opacity: 0;
  animation: intro-space-reveal 0.32s ease-out forwards;
  animation-delay: var(--intro-delay, 0s);
}

/* Space characters - show as en-space with subtle background */
.doc-char.space {
  background: transparent;
}

/* Show subtle dot for untyped spaces */
.doc-char.space:not(.typed)::before {
  content: '·';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  color: #d1d5db;
  font-size: 0.7em;
  pointer-events: none;
}

/* Hide dot when space is typed */
.doc-char.space.typed::before {
  display: none;
}

.doc-char.typed {
  color: #1b1b23;
}

.doc-char.wrong {
  color: #ba1a1a;
  background: rgba(186, 26, 26, 0.1);
  border-radius: 2px;
}

.doc-char.bold,
.doc-line.bold-line .doc-char {
  font-weight: 700;
}

/* Active cursor - visible on all characters including spaces */
.doc-char.active {
  background: rgba(70, 72, 212, 0.08);
}

.doc-char.active::after {
  content: '';
  position: absolute;
  left: 0;
  top: 10%;
  bottom: 10%;
  width: 2px;
  background: #4648d4;
  animation: cursor-blink 1s step-end infinite;
}

/* Space-specific cursor adjustments */
.doc-char.space.active {
  background: rgba(70, 72, 212, 0.15);
  border-radius: 2px;
}

/* Enter character (line break indicator) */
.doc-char.enter-char {
  color: #d1d5db;
  font-size: 0.9em;
  margin-left: 2px;
  opacity: 0.6;
}

.doc-char.enter-char.typed {
  color: #1b1b23;
  opacity: 0.3;
}

.doc-char.enter-char.wrong {
  color: #ba1a1a;
  opacity: 1;
}

/* Empty line styling - just uses the regular enter-char */

/* Empty line styling */
.doc-line.empty-line {
  min-height: 1.15em;
  position: relative;
}

@keyframes cursor-blink {
  50% {
    opacity: 0;
  }
}

@keyframes intro-typing-reveal {
  from {
    opacity: 0;
    transform: translateY(6px);
    filter: blur(1.5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes intro-space-reveal {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Individual bold characters are styled via .doc-char.bold class */
/* The bold button state only affects toolbar indicator, not the document */

/* Character needs bold but user hasn't enabled bold mode */
.doc-char.needs-bold {
  background: rgba(186, 26, 26, 0.15) !important;
  border-radius: 2px;
}

/* Bold button pulse when bold is required */
@keyframes pulse-bold {
  0%, 100% { 
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(186, 26, 26, 0.4);
  }
  50% { 
    transform: scale(1.05);
    box-shadow: 0 0 0 8px rgba(186, 26, 26, 0);
  }
}

.bold-btn.pulse-required {
  animation: pulse-bold 0.5s ease;
  background: rgba(186, 26, 26, 0.1) !important;
  border: 1px solid #ba1a1a;
}

/* Alignment button pulse animation */
.align-btn.pulse-required {
  animation: pulse-bold 0.5s ease;
  background: rgba(186, 26, 26, 0.1) !important;
  border: 1px solid #ba1a1a;
}

/* Alignment error indicator */
.doc-char.needs-align {
  background: rgba(186, 26, 26, 0.15) !important;
  border-radius: 2px;
}

/* Bold enabled but not needed - turn off bold button */
.doc-char.bold-unneeded {
  background: rgba(186, 26, 26, 0.15) !important;
  border-radius: 2px;
}

/* Auto-skip characters (signature lines) */
.doc-char.auto-skip {
  color: #1b1b23;
  opacity: 0.5;
  background: transparent;
}

/* Hidden Input */
.apps-hidden-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
}

/* Stats Panel */
.apps-stats {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.apps-stat-card {
  background: white;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 4px 16px rgba(27, 27, 35, 0.06);
  border: 1px solid rgba(118, 117, 134, 0.08);
}

.apps-stat-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #767586;
  display: block;
  margin-bottom: 8px;
}

.apps-stat-label.primary {
  color: #4648d4;
}

.apps-stat-label.error {
  color: #ba1a1a;
}

.apps-stat-label.secondary {
  color: #575992;
}

.apps-stat-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.apps-stat-value {
  font-size: 40px;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  color: #1b1b23;
  line-height: 1;
  letter-spacing: -0.02em;
}

.apps-stat-value.error-value {
  color: #ba1a1a;
}

.apps-stat-unit {
  font-size: 14px;
  font-weight: 500;
  color: #767586;
}

.duration-row {
  gap: 8px;
}

.time-icon {
  color: #575992;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

/* Progress bar */
.apps-progress-bar {
  height: 6px;
  background: #e4e1ed;
  border-radius: 3px;
  margin-top: 12px;
  overflow: hidden;
}

.apps-progress-fill {
  height: 100%;
  background: #4648d4;
  border-radius: 3px;
  transition: width 0.3s ease;
  width: 0%;
}

/* Accuracy segments */
.apps-segments {
  display: flex;
  gap: 4px;
  margin-top: 12px;
}

.apps-segment {
  flex: 1;
  height: 6px;
  background: #e4e1ed;
  border-radius: 3px;
  transition: background 0.3s ease;
}

.apps-segment.active {
  background: #4648d4;
}

/* Frequent error */
.apps-frequent-error {
  font-size: 12px;
  color: #767586;
  margin-top: 12px;
  line-height: 1.5;
}

.frequent-error strong {
  font-weight: 600;
}

.frequent-error .correct-char {
  color: #4648d4;
}

/* Tip Card */
.apps-tip-card {
  background: #6063ee;
  border-radius: 16px;
  padding: 20px;
  color: white;
}

.apps-tip-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.apps-tip-title svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.apps-tip-text {
  font-size: 13px;
  line-height: 1.6;
  opacity: 0.9;
}

/* Modal */
.apps-modal {
  position: fixed;
  inset: 0;
  background: rgba(27, 27, 35, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fade-in 0.3s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.apps-modal-card {
  background: white;
  border-radius: 24px;
  padding: 40px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: 0 24px 80px rgba(27, 27, 35, 0.2);
  animation: slide-up 0.3s ease;
}

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

.apps-modal-title {
  font-size: 24px;
  font-weight: 800;
  color: #1b1b23;
  margin-bottom: 8px;
}

.apps-modal-subtitle {
  font-size: 15px;
  color: #767586;
  margin-bottom: 24px;
}

.apps-modal-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.apps-metric {
  background: #f5f3ff;
  border-radius: 12px;
  padding: 16px;
}

.apps-metric-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #767586;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.apps-metric-value {
  font-size: 28px;
  font-weight: 800;
  color: #4648d4;
}

.apps-modal-btn {
  background: #4648d4;
  color: white;
  border: none;
  border-radius: 12px;
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.apps-modal-btn:hover {
  background: #3a3cb8;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(70, 72, 212, 0.3);
}

.apps-modal-btn-secondary {
  background: transparent;
  color: #6b6b75;
  border: 1px solid #e0e0e6;
  margin-top: 8px;
}

.apps-modal-btn-secondary:hover {
  background: #f5f5f7;
  border-color: #d0d0d8;
  color: #4648d4;
  box-shadow: none;
  transform: none;
}

[data-theme="dark"] .page-simulator-apps {
  background: transparent;
  color: #e2e8f0;
  --t-text-primary: #e2e8f0;
  --t-text-secondary: #cbd5e1;
  --t-text-muted: #94a3b8;
}

[data-theme="dark"] .apps-title {
  color: #e2e8f0;
}

[data-theme="dark"] .apps-subtitle {
  color: #94a3b8;
}

[data-theme="dark"] .apps-toolbar {
  background: rgba(28, 28, 27, 0.82);
  border-color: rgba(148, 163, 184, 0.24);
  box-shadow: none;
}

[data-theme="dark"] .apps-toolbar-label {
  color: #94a3b8;
}

[data-theme="dark"] .apps-toolbar-timer-label {
  color: #94a3b8;
}

[data-theme="dark"] .apps-toolbar-timer-value {
  color: #e2e8f0;
}

[data-theme="dark"] .apps-toolbar-btn {
  color: #cbd5e1;
}

[data-theme="dark"] .apps-toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .apps-toolbar-btn.active {
  background: rgba(255, 255, 255, 0.12);
  color: #e5e7eb;
  box-shadow: none;
}

[data-theme="dark"] .apps-toolbar-btn.bold-btn.active {
  border: 1px solid rgba(255, 255, 255, 0.24);
}

[data-theme="dark"] .apps-toolbar-btn.align-btn {
  border-color: rgba(148, 163, 184, 0.32);
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
  box-shadow: none;
}

[data-theme="dark"] .apps-toolbar-btn.align-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.3);
  color: #e5e7eb;
}

[data-theme="dark"] .apps-toolbar-btn.align-btn.active {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.32);
  color: #e5e7eb;
  box-shadow: none;
}

[data-theme="dark"] .apps-document {
  background: rgba(28, 28, 27, 0.86);
  box-shadow: none;
}

[data-theme="dark"] .apps-document::before {
  background: #60a5fa;
  opacity: 0.26;
}

[data-theme="dark"] .doc-char {
  color: rgba(148, 163, 184, 0.78);
}

[data-theme="dark"] .doc-char.typed,
[data-theme="dark"] .doc-char.auto-skip {
  color: #e2e8f0;
}

[data-theme="dark"] .doc-char.space:not(.typed)::before,
[data-theme="dark"] .doc-char.enter-char {
  color: rgba(148, 163, 184, 0.5);
}

[data-theme="dark"] .doc-char.enter-char.typed {
  color: #e2e8f0;
  opacity: 0.45;
}

[data-theme="dark"] .doc-char.active {
  background: rgba(59, 130, 246, 0.18);
}

[data-theme="dark"] .doc-char.active::after {
  background: #60a5fa;
}

[data-theme="dark"] .apps-stat-card {
  background: rgba(28, 28, 27, 0.82);
  border-color: rgba(148, 163, 184, 0.24);
  box-shadow: none;
}

[data-theme="dark"] .apps-stat-label,
[data-theme="dark"] .apps-stat-unit,
[data-theme="dark"] .apps-frequent-error {
  color: #94a3b8;
}

[data-theme="dark"] .apps-stat-label.primary,
[data-theme="dark"] .apps-stat-label.secondary,
[data-theme="dark"] .frequent-error .correct-char,
[data-theme="dark"] .time-icon {
  color: #93c5fd;
}

[data-theme="dark"] .apps-stat-value {
  color: #e2e8f0;
}

[data-theme="dark"] .apps-progress-bar,
[data-theme="dark"] .apps-segment {
  background: rgba(148, 163, 184, 0.2);
}

[data-theme="dark"] .apps-progress-fill,
[data-theme="dark"] .apps-segment.active {
  background: #60a5fa;
}

[data-theme="dark"] .apps-modal {
  background: rgba(2, 6, 23, 0.7);
}

[data-theme="dark"] .apps-modal-card {
  background: rgba(28, 28, 27, 0.96);
  border: 1px solid rgba(148, 163, 184, 0.24);
  box-shadow: none;
}

[data-theme="dark"] .apps-modal-title {
  color: #e2e8f0;
}

[data-theme="dark"] .apps-modal-subtitle,
[data-theme="dark"] .apps-metric-label {
  color: #94a3b8;
}

[data-theme="dark"] .apps-metric {
  background: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .apps-metric-value {
  color: #93c5fd;
}

[data-theme="dark"] .apps-modal-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #e5e7eb;
}

[data-theme="dark"] .apps-modal-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: none;
}

[data-theme="dark"] .apps-modal-btn-secondary {
  background: transparent;
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.32);
}

[data-theme="dark"] .apps-modal-btn-secondary:hover {
  background: rgba(148, 163, 184, 0.14);
  color: #e2e8f0;
  border-color: rgba(148, 163, 184, 0.44);
}

/* Responsive */
@media (max-width: 1024px) {
  .apps-editor {
    flex-direction: column;
  }
  
  .apps-stats {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .apps-stat-card {
    flex: 1;
    min-width: 200px;
  }
}

@media (max-width: 768px) {
  .page-simulator-apps {
    padding: 16px;
  }
  
  .apps-document {
    padding: 40px 30px;
    min-height: 600px;
  }
  
  .apps-toolbar {
    padding: 10px 14px;
    gap: 16px;
  }
  
  .apps-stats {
    flex-direction: column;
  }
  
  .apps-stat-card {
    min-width: unset;
  }
}

@media (max-width: 480px) {
  .apps-document {
    padding: 30px 20px;
  }
  
  .apps-title {
    font-size: 24px;
  }
}
