/* CSS Variables */
:root {
  --bg: #ffffff;
  --fg: #111827;
  --muted: #6b7280;
  --brand: #667eea;
  --brand-dark: #764ba2;
  --border: #e5e7eb;
  --accent: #00d4ae;
  --error: #ef4444;
  --success: #10b981;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: var(--fg);
  line-height: 1.6;
  padding: 20px;
  min-height: 100vh;
}

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

/* Header */
.header {
  text-align: center;
  color: white;
  margin-bottom: 40px;
}

.header-icon {
  font-size: 3.5rem;
  margin-bottom: 20px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

h1 {
  font-size: 3rem;
  color: white;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.subtitle {
  font-size: 1.2rem;
  opacity: 0.9;
  color: white;
}

/* Main Card */
.main-card {
  background: white;
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  margin-bottom: 30px;
}

/* Mode Indicator */
.mode-indicator {
  text-align: center;
  margin-bottom: 30px;
  padding: 16px 24px;
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.1),
    rgba(118, 75, 162, 0.1)
  );
  border-radius: 50px;
  font-weight: 600;
  color: var(--brand);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 2px solid rgba(102, 126, 234, 0.2);
}

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

/* Converter Container */
.converter-container {
  display: flex;
  flex-direction: column;
  gap: 30px;
  margin-bottom: 40px;
}

.input-section,
.output-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--fg);
  font-size: 1.1rem;
}

.section-header i {
  color: var(--brand);
  font-size: 1.3rem;
}

.section-header h3 {
  font-weight: 600;
}

.textarea-wrapper {
  position: relative;
}

textarea {
  width: 100%;
  min-height: 220px;
  padding: 20px;
  border: 2px solid var(--border);
  border-radius: 12px;
  font-family: Consolas, Monaco, "Courier New", monospace;
  font-size: 14px;
  resize: vertical;
  transition: all 0.3s ease;
  line-height: 1.6;
}

textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

textarea::placeholder {
  color: var(--muted);
}

textarea[readonly] {
  background-color: #f9fafb;
}

.char-counter {
  position: absolute;
  bottom: 12px;
  right: 16px;
  font-size: 0.85rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.9);
  padding: 4px 8px;
  border-radius: 4px;
  pointer-events: none;
}

/* Screen Reader Only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Buttons */
.input-actions,
.output-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

button {
  padding: 12px 24px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

button i {
  font-size: 1rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: white;
  border: none;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:focus {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.btn-secondary {
  background-color: white;
  color: var(--fg);
  border: 2px solid var(--border);
}

.btn-secondary:hover {
  background-color: #f9fafb;
  border-color: var(--brand);
  transform: translateY(-2px);
}

.btn-secondary:active {
  transform: translateY(0);
}

.btn-secondary:focus {
  outline: 2px solid var(--muted);
  outline-offset: 2px;
}

/* Toggle Button */
.toggle-section {
  display: flex;
  justify-content: center;
  align-items: center;
}

.btn-toggle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: white;
  font-size: 24px;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3);
}

.btn-toggle:hover {
  transform: rotate(180deg) scale(1.1);
  box-shadow: 0 12px 24px rgba(102, 126, 234, 0.4);
}

.btn-toggle:active {
  transform: rotate(180deg) scale(1.05);
}

.btn-toggle:focus {
  outline: 3px solid rgba(102, 126, 234, 0.5);
  outline-offset: 3px;
}

/* Error Message */
.error-message {
  color: var(--error);
  font-size: 14px;
  min-height: 20px;
  padding: 8px 0;
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: white;
  padding: 16px 32px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  z-index: 1000;
  box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Info Cards */
.info-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.info-card {
  background: white;
  border-radius: 16px;
  padding: 30px;
  text-align: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.info-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

.info-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 20px;
  background: linear-gradient(
    135deg,
    rgba(102, 126, 234, 0.1),
    rgba(118, 75, 162, 0.1)
  );
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.info-icon i {
  font-size: 1.8rem;
  color: var(--brand);
}

.info-card h3 {
  font-size: 1.2rem;
  margin-bottom: 10px;
  color: var(--fg);
}

.info-card p {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Footer */
.footer {
  background: white;
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.usage-guide h2 {
  font-size: 1.5rem;
  margin-bottom: 30px;
  color: var(--fg);
  display: flex;
  align-items: center;
  gap: 12px;
}

.usage-guide h2 i {
  color: var(--brand);
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 24px;
  margin-bottom: 30px;
}

.guide-item {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.guide-number {
  min-width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.guide-item p {
  color: var(--muted);
  line-height: 1.6;
  padding-top: 6px;
}

.footer-links {
  text-align: center;
  padding-top: 30px;
  border-top: 1px solid var(--border);
}

.footer-links a {
  color: var(--brand);
  text-decoration: none;
  font-weight: 500;
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
}

.footer-links a:hover {
  color: var(--brand-dark);
  gap: 12px;
}

/* Responsive Design */
@media (max-width: 768px) {
  body {
    padding: 12px;
  }

  h1 {
    font-size: 2rem;
  }

  .header-icon {
    font-size: 2.5rem;
  }

  .main-card,
  .footer {
    padding: 24px;
  }

  textarea {
    min-height: 180px;
    font-size: 13px;
  }

  .btn-toggle {
    width: 56px;
    height: 56px;
    font-size: 20px;
  }

  button {
    padding: 10px 20px;
    font-size: 13px;
  }

  .info-cards {
    grid-template-columns: 1fr;
  }

  .guide-grid {
    grid-template-columns: 1fr;
  }

  .converter-container {
    gap: 20px;
  }
}

/* Accessibility - High Contrast Mode */
@media (prefers-contrast: high) {
  :root {
    --border: #666666;
  }

  textarea {
    border-width: 3px;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
