* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --background: #fafafa;
  --foreground: #171717;
  --card: #ffffff;
  --card-foreground: #171717;
  --primary: #2563eb;
  --primary-foreground: #ffffff;
  --secondary: #f5f5f5;
  --secondary-foreground: #171717;
  --muted: #f5f5f5;
  --muted-foreground: #737373;
  --border: #e5e5e5;
  --correction: #2563eb;
  --radius: 0.5rem;
}

body {
  font-family: 'Noto Sans Arabic', Arial, sans-serif;
  background-color: var(--background);
  color: var(--foreground);
  min-height: 100vh;
  line-height: 1.6;
}

/* Header */
.header {
  background: linear-gradient(135deg, var(--primary) 0%, #1d4ed8 100%);
  color: white;
  padding: 2rem 1rem;
  text-align: center;
}

.header-content {
  max-width: 800px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.logo-icon {
  width: 48px;
  height: 48px;
  background: rgba(255,255,255,0.2);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-icon svg {
  width: 28px;
  height: 28px;
}

.logo h1 {
  font-size: 2rem;
  font-weight: 700;
}

.header p {
  opacity: 0.9;
  font-size: 1.1rem;
}

/* Main Container */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Card */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  overflow: hidden;
}

/* Input Section */
.input-section {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.input-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.input-label {
  font-weight: 600;
  color: var(--foreground);
}

.char-count {
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.textarea {
  width: 100%;
  min-height: 150px;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1.1rem;
  line-height: 1.8;
  resize: vertical;
  direction: rtl;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

/* Action Buttons */
.actions-section {
  padding: 1rem 1.5rem;
  background: var(--muted);
  border-bottom: 1px solid var(--border);
}

.actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .actions-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.action-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.05);
}

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

.action-btn.active {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.1);
}

.action-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-icon.correct { background: #dbeafe; color: #2563eb; }
.action-icon.reformulate { background: #dcfce7; color: #16a34a; }
.action-icon.translate { background: #fef3c7; color: #d97706; }
.action-icon.tashkil { background: #f3e8ff; color: #9333ea; }

.action-btn span:last-child {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--foreground);
}

/* Translation Options */
.translation-options {
  display: none;
  padding: 1rem 1.5rem;
  background: var(--muted);
  border-bottom: 1px solid var(--border);
}

.translation-options.visible {
  display: block;
}

.translation-label {
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  color: var(--foreground);
}

.language-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.lang-btn {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  transition: all 0.2s;
}

.lang-btn:hover {
  border-color: var(--primary);
}

.lang-btn.selected {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Result Section */
.result-section {
  padding: 1.5rem;
  display: none;
}

.result-section.visible {
  display: block;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.result-title {
  font-weight: 600;
  color: var(--foreground);
}

.copy-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  transition: all 0.2s;
}

.copy-btn:hover {
  background: var(--muted);
}

.result-content {
  padding: 1.5rem;
  background: var(--muted);
  border-radius: var(--radius);
  font-size: 1.1rem;
  line-height: 2;
  min-height: 100px;
}

/* Corrected Word */
.corrected-word {
  color: var(--correction);
  text-decoration: underline;
  text-decoration-style: wavy;
  text-underline-offset: 4px;
  cursor: help;
  position: relative;
}

/* Tooltip */
.tooltip {
  position: absolute;
  bottom: 100%;
  right: 0;
  transform: none;
  background: var(--foreground);
  color: white;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  white-space: nowrap;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  margin-bottom: 8px;
  min-width: 260px;
  max-width: 420px;
  white-space: normal;
  text-align: right;
  direction: rtl;
}

.tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 50%;
  transform: translateX(50%);
  border: 6px solid transparent;
  border-top-color: var(--foreground);
}

.corrected-word:hover .tooltip {
  opacity: 1;
  visibility: visible;
}

.tooltip-original {
  text-decoration: line-through;
  opacity: 0.7;
}

.tooltip-arrow {
  margin: 0 0.25rem;
}

.tooltip-corrected {
  color: #93c5fd;
}

.tooltip-rule {
  display: block;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(255,255,255,0.2);
  font-size: 0.8rem;
  opacity: 0.9;
}

/* Loading */
.loading {
  display: none;
  padding: 2rem;
  text-align: center;
}

.loading.visible {
  display: block;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  color: var(--muted-foreground);
}

/* Footer */
.footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--muted-foreground);
  font-size: 0.875rem;
}

/* Features */
.features {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-top: 2rem;
}

@media (min-width: 640px) {
  .features {
    grid-template-columns: repeat(4, 1fr);
  }
}

.feature {
  text-align: center;
  padding: 1.5rem 1rem;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.feature-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 0.75rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.feature h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.feature p {
  font-size: 0.875rem;
  color: var(--muted-foreground);
}
