@import url('https://fonts.googleapis.com/css2?family=Samim:wght@400;700&family=Vazirmatn:wght@400;500;700&display=swap');

:root {
  --primary-color: #6366f1;
  --secondary-color: #8b5cf6;
  --accent-color: #ec4899;
  --light-color: #f0f9ff;
  --dark-color: #1e293b;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  --info-color: #06b6d4;
  --purple-light: #c7d2fe;
  --pink-light: #fbcfe8;
  --blue-light: #bfdbfe;
  --green-light: #bbf7d0;
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);

  /* Light mode colors */
  --bg-color: linear-gradient(135deg, #e0f2fe 0%, #f0f9ff 50%, #ede9fe 100%);
  --container-bg: white;
  --text-color: #1e293b;
  --card-bg: linear-gradient(135deg, #f8fafc, #f1f5f9);
  --card-hover-bg: rgba(99, 102, 241, 0.1);
  --border-color: #e2e8f0;
  --input-bg: #f8fafc;
  --steps-bg: linear-gradient(135deg, #f0f9ff, #e0f2fe);
  --formula-bg: linear-gradient(135deg, #f8fafc, #f1f5f9);
  --info-bg: linear-gradient(135deg, #dbeafe, #bfdbfe);
  --alert-danger-bg: linear-gradient(135deg, #fee2e2, #fecaca);
  --alert-success-bg: linear-gradient(135deg, #d1fae5, #a7f3d0);
  --key-point-root-bg: linear-gradient(135deg, #d1fae5, #a7f3d0);
  --key-point-vertex-bg: linear-gradient(135deg, #fef3c7, #fde68a);
  --key-point-intersection-bg: linear-gradient(135deg, #dbeafe, #bfdbfe);
  --plot-bg: #f8fafc;
  --grid-color: #f0f0f0;
}

/* Dark mode colors */
[data-theme="dark"] {
  --bg-color: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #1e293b 100%);
  --container-bg: #1e293b;
  --text-color: #f1f5f9;
  --card-bg: linear-gradient(135deg, #334155, #334155);
  --card-hover-bg: rgba(99, 102, 241, 0.2);
  --border-color: #334155;
  --input-bg: #334155;
  --steps-bg: linear-gradient(135deg, #334155, #1e293b);
  --formula-bg: linear-gradient(135deg, #334155, #1e293b);
  --info-bg: linear-gradient(135deg, #1e3a8a, #1e40af);
  --alert-danger-bg: linear-gradient(135deg, #7f1d1d, #991b1b);
  --alert-success-bg: linear-gradient(135deg, #064e3b, #065f46);
  --key-point-root-bg: linear-gradient(135deg, #064e3b, #065f46);
  --key-point-vertex-bg: linear-gradient(135deg, #78350f, #92400e);
  --key-point-intersection-bg: linear-gradient(135deg, #1e3a8a, #1e40af);
  --plot-bg: #334155;
  --grid-color: #475569;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Samim', 'Vazirmatn', sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  font-weight: 400;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden; /* Prevent horizontal scroll */
  width: 100%;
  max-width: 100vw;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect width="100" height="100" fill="none"/><path d="M0,0 L100,100 M100,0 L0,100" stroke="rgba(99, 102, 241, 0.05)" stroke-width="1"/></svg>');
  z-index: -1;
  pointer-events: none;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  overflow-x: hidden;
  width: 100%;
  box-sizing: border-box;
}

header {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  color: white;
  padding: 25px 0;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

header::after {
  content: '';
  position: absolute;
  bottom: -20px;
  right: 0;
  width: 100%;
  height: 40px;
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
  z-index: -1;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  position: relative;
  z-index: 1;
}

.logo {
  display: flex;
  align-items: center;
  gap: 15px;
}

.logo i {
  font-size: 2.5rem;
  background: rgba(255, 255, 255, 0.2);
  padding: 12px;
  border-radius: 50%;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.logo h1 {
  font-size: 2rem;
  font-weight: 700;
  font-family: 'Vazirmatn', sans-serif;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tagline p {
  font-size: 1.1rem;
  opacity: 0.9;
  font-weight: 500;
}

.theme-toggle {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.05);
}

.tabs {
  display: flex;
  background: var(--container-bg);
  border-radius: 16px 16px 0 0;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  margin-top: 30px;
  flex-wrap: wrap;
  position: relative;
}

.tab {
  flex: 1;
  padding: 18px 20px;
  text-align: center;
  cursor: pointer;
  background: var(--card-bg);
  border: none;
  font-size: 1.05rem;
  font-weight: 700;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 150px;
  font-family: 'Vazirmatn', sans-serif;
  position: relative;
  overflow: hidden;
  color: var(--text-color);
}

.tab::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 100%;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  transition: width 0.4s ease;
  z-index: -1;
}

.tab:hover::before {
  width: 100%;
}

.tab:hover {
  color: white;
}

.tab.active {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
}

.tab.active::before {
  width: 100%;
}

.tab i {
  font-size: 1.2rem;
}

.tab-content {
  display: none;
  background: var(--container-bg);
  padding: 30px;
  border-radius: 0 0 16px 16px;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.5s ease;
  overflow-x: hidden;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.tab-content.active {
  display: block;
}

.section-title {
  font-size: 2rem;
  margin-bottom: 25px;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 15px;
  font-weight: 700;
  font-family: 'Vazirmatn', sans-serif;
  position: relative;
}

.section-title i {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.input-group {
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  margin-bottom: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-color);
}

.input-group input, .input-group select {
  width: 100%;
  padding: 14px;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  font-size: 1rem;
  transition: var(--transition);
  font-family: 'Samim', sans-serif;
  background-color: var(--input-bg);
  color: var(--text-color);
}

.input-group input:focus, .input-group select:focus {
  border-color: var(--primary-color);
  outline: none;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
  background-color: var(--container-bg);
}

.btn {
  display: inline-block;
  padding: 14px 28px;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 700;
  transition: var(--transition);
  font-family: 'Vazirmatn', sans-serif;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 100%;
  background: rgba(255, 255, 255, 0.3);
  transition: width 0.4s ease;
}

.btn:hover::before {
  width: 100%;
}

.btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
  background: linear-gradient(135deg, #64748b, #475569);
}

.btn-success {
  background: linear-gradient(135deg, var(--success-color), #059669);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger-color), #dc2626);
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.9rem;
}

.graph-container {
  width: 100%;
  height: 500px;
  margin-top: 25px;
  border: 2px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--container-bg);
}

.steps-container {
  margin-top: 30px;
  padding: 25px;
  background: var(--steps-bg);
  border-radius: 16px;
  border-right: 5px solid var(--primary-color);
  box-shadow: var(--shadow);
}

.step {
  margin-bottom: 20px;
  padding: 20px;
  background: var(--container-bg);
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  position: relative;
  overflow: hidden;
}

.step::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 5px;
  height: 100%;
  background: linear-gradient(to bottom, var(--primary-color), var(--secondary-color));
}

.step.visible {
  opacity: 1;
  transform: translateY(0);
}

.step-title {
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--primary-color);
  font-size: 1.2rem;
}

.step-content {
  display: flex;
  align-items: center;
  gap: 15px;
}

.step-formula {
  font-size: 1.4rem;
  padding: 15px;
  background: var(--formula-bg);
  border-radius: 10px;
  font-family: 'Samim', 'Vazirmatn', sans-serif;
  font-weight: 500;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
  text-align: center;
  width: 100%;
  color: var(--text-color);
  direction: ltr;
  unicode-bidi: isolate;
  overflow-wrap: break-word;
  word-break: break-all;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 25px;
}

.control-group {
  flex: 1;
  min-width: 200px;
}

.slider-container {
  margin-top: 12px;
}

.slider {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--border-color);
  outline: none;
  -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.slider-value {
  display: inline-block;
  margin-right: 10px;
  font-weight: 700;
  min-width: 40px;
  color: var(--primary-color);
}

.info-box {
  background: var(--info-bg);
  border-right: 5px solid var(--info-color);
  padding: 20px;
  margin-bottom: 25px;
  border-radius: 0 12px 12px 0;
  font-size: 1.1rem;
  box-shadow: var(--shadow);
  color: var(--text-color);
}

.alert {
  padding: 18px;
  margin-bottom: 25px;
  border-radius: 12px;
  font-weight: 500;
  box-shadow: var(--shadow);
  color: var(--text-color);
}

.alert-danger {
  background: var(--alert-danger-bg);
  border: 1px solid #fca5a5;
  color: #b91c1c;
}

/* Fixed dark mode alert text visibility */
[data-theme="dark"] .alert-danger {
  background: var(--alert-danger-bg);
  color: #fca5a5; /* Lighter red text for dark mode */
  border: 1px solid #fca5a5;
}

.alert-success {
  background: var(--alert-success-bg);
  border: 1px solid #6ee7b7;
  color: #065f46;
}

.function-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 25px;
}

.function-card {
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  color: var(--text-color);
}

.function-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: -1;
}

.function-card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-color);
}

.function-card:hover::before {
  opacity: 0.1;
}

.function-card.active {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  border-color: var(--primary-color);
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
}

.function-card i {
  font-size: 2rem;
  margin-bottom: 12px;
  display: block;
}

.function-card div {
  font-weight: 700;
  font-family: 'Vazirmatn', sans-serif;
  font-size: 1.1rem;
}

.animation-controls {
  display: flex;
  gap: 15px;
  margin-top: 25px;
  flex-wrap: wrap;
}

.key-points {
  margin-top: 25px;
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
}

.key-point {
  padding: 12px 18px;
  border-radius: 30px;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.key-point:hover {
  transform: translateY(-3px);
}

.key-point.root {
  background: var(--key-point-root-bg);
  color: #065f46;
  border: 1px solid #6ee7b7;
}

.key-point.vertex {
  background: var(--key-point-vertex-bg);
  color: #92400e;
  border: 1px solid #fcd34d;
}

.key-point.intersection {
  background: var(--key-point-intersection-bg);
  color: #1e40af;
  border: 1px solid #93c5fd;
}

.key-point.x-intercept {
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  color: #1e40af;
  border: 1px solid #93c5fd;
}

.key-point.y-intercept {
  background: linear-gradient(135deg, #dcfce7, #bbf7d0);
  color: #166534;
  border: 1px solid #86efac;
}

.loader {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255,255,255,.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.hidden {
  display: none;
}

/* Line Manager Styles */
.line-manager {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 25px;
  box-shadow: var(--shadow);
}

.line-manager h3 {
  margin-bottom: 15px;
  color: var(--primary-color);
  font-size: 1.3rem;
}

.expression-input-container {
  display: flex;
  gap: 15px;
  margin-bottom: 20px;
  align-items: flex-end;
}

.expression-input {
  flex: 1;
  position: relative;
}

.expression-input input {
  width: 100%;
  padding: 14px 50px 14px 60px;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  font-size: 1.2rem;
  font-family: 'Samim', sans-serif;
  background-color: var(--input-bg);
  color: var(--text-color);
  transition: var(--transition);
  direction: ltr;
  text-align: left;
  unicode-bidi: plaintext;
}

.expression-input input:focus {
  border-color: var(--primary-color);
  outline: none;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
  background-color: var(--container-bg);
}

.expression-input input::placeholder {
  color: #999;
  opacity: 0.7;
  font-family: 'Vazirmatn', sans-serif;
  direction: rtl;
  text-align: right;
}

.expression-input .input-suffix {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--primary-color);
  font-weight: 700;
  font-size: 1.2rem;
  font-family: 'Vazirmatn', sans-serif;
  direction: rtl;
  z-index: 1;
}

.keyboard-toggle {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white;
  border: none;
  border-radius: 8px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.keyboard-toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.keyboard-toggle:active {
  transform: translateY(0);
}

/* Fixed Add Expression Button - Text Overflow and Visibility Issues */
.add-expression-btn {
  padding: 14px 20px; /* Reduced padding to prevent overflow */
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  color: white; /* Ensure white text for visibility */
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 700;
  transition: var(--transition);
  font-family: 'Vazirmatn', sans-serif;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap; /* Prevent text wrapping */
  overflow: hidden;
  text-overflow: ellipsis; /* Show ellipsis if text overflows */
  max-width: 180px; /* Set maximum width */
}

.add-expression-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
}

/* Dark mode button fixes */
[data-theme="dark"] .add-expression-btn {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: white; /* Ensure white text in dark mode */
}

.lines-list {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  max-height: none;
  overflow-y: visible;
}

.line-item {
  flex: 1 1 calc(50% - 15px);
  min-width: 250px;
  display: flex;
  flex-direction: column;
  background: var(--container-bg);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  border: 1px solid var(--border-color);
  transition: var(--transition);
  overflow: hidden;
}

.line-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.line-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  border-bottom: 1px solid var(--border-color);
}

.line-info {
  display: flex;
  align-items: center;
  gap: 15px;
  flex: 1;
}

.line-color-display {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.line-details {
  flex: 1;
}

.line-name {
  font-weight: 700;
  font-family: 'Samim', 'Vazirmatn', sans-serif;
  color: var(--text-color);
  font-size: 1.1rem;
  direction: ltr;
  unicode-bidi: isolate;
  text-align: left;
  background: var(--input-bg);
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
}

.line-type {
  font-size: 0.9rem;
  color: var(--primary-color);
  opacity: 0.8;
  margin-top: 3px;
}

.line-params {
  font-size: 0.85rem;
  color: var(--text-color);
  opacity: 0.7;
  margin-top: 3px;
}

.delete-line-btn {
  background: var(--danger-color);
  color: white;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.delete-line-btn:hover {
  background: #dc2626;
  transform: scale(1.1);
}

.line-intersections {
  padding: 15px;
  background: var(--info-bg);
  border-top: 1px solid var(--border-color);
}

.line-intersections h4 {
  font-size: 1rem;
  color: var(--info-color);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.line-intersections h4 i {
  font-size: 1rem;
}

.intersection-point {
  padding: 8px 12px;
  background: var(--container-bg);
  border-radius: 6px;
  margin-bottom: 8px;
  font-family: 'Vazirmatn', sans-serif;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.intersection-point .math-ltr {
  font-family: 'Samim', sans-serif;
  direction: ltr;
  unicode-bidi: isolate;
}

.intersection-point i {
  color: var(--info-color);
  font-size: 0.8rem;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-color);
  opacity: 0.7;
}

.empty-state i {
  font-size: 3rem;
  margin-bottom: 15px;
  color: var(--primary-color);
  opacity: 0.5;
}

.empty-state p {
  font-size: 1.1rem;
}

/* Virtual Keyboard Styles */
.virtual-keyboard {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 15px;
  margin-top: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  display: none;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 8px;
}

.keyboard-row:last-child {
  margin-bottom: 0;
}

.key-btn {
  background: var(--input-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  width: 50px;
  height: 50px;
  font-size: 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Samim', sans-serif;
  direction: ltr;
  unicode-bidi: isolate;
}

.key-btn:hover {
  background: var(--primary-color);
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.key-btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.key-btn[data-value="√"],
.key-btn[data-value="∛"],
.key-btn[data-value="×"],
.key-btn[data-value="÷"],
.key-btn[data-value="−"],
.key-btn[data-value="x"],
.key-btn[data-value="e"],
.key-btn[data-value="π"] {
  font-size: 1.4rem;
  font-weight: 700;
}

.key-btn#backspace {
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: white;
}

.key-btn#clear {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
}

.key-btn#backspace:hover, .key-btn#clear:hover {
  opacity: 0.9;
}

/* Math symbol styling */
.math-symbol {
  font-family: 'Samim', sans-serif;
  direction: ltr;
  unicode-bidi: isolate;
}

.math-ltr {
  direction: ltr;
  unicode-bidi: isolate;
  font-family: 'Samim', sans-serif;
}

/* Dark mode button fixes */
[data-theme="dark"] .btn {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: white;
}

[data-theme="dark"] .btn:hover {
  background: linear-gradient(135deg, #4338ca, #6d28d9);
}

[data-theme="dark"] .btn-secondary {
  background: linear-gradient(135deg, #475569, #334155);
}

[data-theme="dark"] .btn-success {
  background: linear-gradient(135deg, #059669, #047857);
}

[data-theme="dark"] .btn-danger {
  background: linear-gradient(135deg, #dc2626, #b91c1b);
}

[data-theme="dark"] .key-btn {
  background: var(--input-bg);
  color: var(--text-color);
  border-color: var(--border-color);
}

[data-theme="dark"] .key-btn:hover {
  background: var(--primary-color);
  color: white;
}

[data-theme="dark"] .virtual-keyboard {
  background: var(--card-bg);
  border-color: var(--border-color);
}

/* Dynamic Graphs Styles */
.function-formula {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 25px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
}

.function-formula h3 {
  margin-top: 0;
  margin-bottom: 15px;
  color: var(--primary-color);
  font-family: 'Vazirmatn', sans-serif;
}

.formula-display {
  font-size: 1.4rem;
  text-align: center;
  padding: 15px;
  background: var(--input-bg);
  border-radius: 8px;
  font-family: 'Samim', sans-serif;
}

.parameter-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 25px;
}

/* Modal Styles for Inspection Prevention */
.modal {
  display: none;
  position: fixed;
  z-index: 9999;
  right: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
}

.modal-content {
  background-color: var(--container-bg);
  margin: 15% auto;
  padding: 0;
  border-radius: 16px;
  width: 90%;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalSlideIn 0.4s ease;
}

@keyframes modalSlideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  background: linear-gradient(135deg, var(--danger-color), #dc2626);
  color: white;
  padding: 20px;
  text-align: center;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.5rem;
  font-family: 'Vazirmatn', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.modal-body {
  padding: 30px 20px;
  text-align: center;
}

.modal-body p {
  margin-bottom: 15px;
  font-size: 1.1rem;
  line-height: 1.6;
}

.modal-footer {
  padding: 20px;
  text-align: center;
  background-color: var(--input-bg);
}

.countdown-container {
  display: inline-block;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--danger-color), #dc2626);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  font-family: 'Vazirmatn', sans-serif;
  box-shadow: var(--shadow);
  animation: pulse 1s infinite;
}

/* About Me Section Styles */
#about {
  padding: 20px 0;
}

.about-content {
  display: flex;
  gap: 40px;
  align-items: flex-start;
  position: relative;
  z-index: 1;
}

.about-image {
  flex: 0 0 300px;
  position: relative;
  margin-right: 20px; /* فاصله از چپ برای ایجاد فاصله از راست */
}

.profile-image {
  width: 100%;
  height: auto;
  transition: transform 0.3s ease;
  cursor: pointer;
}

/* هاور ساده - فقط زوم کوچک */
.profile-image:hover {
  transform: scale(1.05);
}

/* حذف اوورلی کاملاً */
.image-overlay {
  display: none;
}

.about-info {
  flex: 1;
}

.about-name {
  font-size: 2.2rem;
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
  font-family: 'Vazirmatn', sans-serif;
  font-weight: 700;
}

.about-title {
  font-size: 1.2rem;
  color: var(--secondary-color);
  margin-bottom: 25px;
  font-family: 'Vazirmatn', sans-serif;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}

.about-title::before {
  content: '🎓';
  font-size: 1.5rem;
}

.about-description {
  margin-bottom: 30px;
  margin-left: 20px;
}

.about-description p {
  font-size: 1.1rem;
  line-height: 1.8;
  margin-bottom: 15px;
  color: var(--text-color);
  text-align: justify;
}

.about-interests {
  margin-bottom: 30px;
}

.about-interests h4 {
  font-size: 1.3rem;
  color: var(--primary-color);
  margin-bottom: 15px;
  font-family: 'Vazirmatn', sans-serif;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.about-interests h4::before {
  content: '⭐';
  font-size: 1.2rem;
}

.interests-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

.interest-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 15px;
  background: var(--card-bg);
  border-radius: 12px;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.interest-item:hover {
  transform: translateY(-5px);
  background: var(--card-hover-bg);
  border-color: var(--primary-color);
  box-shadow: 0 10px 20px rgba(99, 102, 241, 0.2);
}

.interest-item i {
  font-size: 1.5rem;
  color: var(--primary-color);
  width: 30px;
  text-align: center;
}

.interest-item span {
  font-weight: 600;
  color: var(--text-color);
  font-family: 'Vazirmatn', sans-serif;
}

.social-links {
  margin-bottom: 30px;
}

.social-links h4 {
  font-size: 1.3rem;
  color: var(--primary-color);
  margin-bottom: 15px;
  font-family: 'Vazirmatn', sans-serif;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.social-links h4::before {
  content: '🔗';
  font-size: 1.2rem;
}

.links-container {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
}

.social-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: 50px;
  text-decoration: none;
  color: white;
  font-weight: 700;
  font-family: 'Vazirmatn', sans-serif;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  position: relative;
  overflow: hidden;
}

.social-link::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 100%;
  background: rgba(255, 255, 255, 0.2);
  transition: width 0.3s ease;
}

.social-link:hover::before {
  width: 100%;
}

.social-link i {
  font-size: 1.2rem;
  z-index: 1;
}

.social-link span {
  z-index: 1;
}

.social-link.youtube {
  background: linear-gradient(135deg, #FF0000, #CC0000);
}

.social-link.website {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.social-link.github {
  background: linear-gradient(135deg, #24292e, #1a1e22);
}

.social-link.email {
  background: linear-gradient(135deg, var(--info-color), #0891B2);
}

.social-link:hover {
  transform: translateY(-5px) scale(1.05);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}


/* Mobile Responsiveness */
@media (max-width: 768px) {
  /* Prevent horizontal overflow */
  html, body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
    position: relative;
  }

  * {
    box-sizing: border-box;
  }

  .container {
    padding: 10px;
    max-width: 100%;
    margin: 0;
    width: 100%;
  }

  /* Header adjustments */
  .header-content {
    flex-direction: column;
    text-align: center;
    gap: 15px;
    padding: 0 10px;
  }

  .logo h1 {
    font-size: 1.5rem;
  }

  .tagline p {
    font-size: 1rem;
  }

  /* Tabs */
  .tabs {
    flex-direction: column;
    margin-top: 15px;
    border-radius: 16px;
    overflow: hidden;
  }

  .tab {
    min-width: 100%;
    padding: 12px 8px;
    border-bottom: 1px solid var(--border-color);
  }

  .tab:last-child {
    border-bottom: none;
  }

  /* Tab content */
  .tab-content {
    padding: 15px 10px;
    border-radius: 0 0 16px 16px;
    overflow-x: hidden;
  }

  /* Section titles */
  .section-title {
    font-size: 1.5rem;
  }

  .section-title i {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  /* Controls */
  .controls {
    flex-direction: column;
    gap: 15px;
  }

  .control-group {
    min-width: 100%;
  }

  /* Graph container */
  .graph-container {
    height: 300px;
    margin-top: 15px;
    overflow: hidden;
  }

  /* Function list */
  .function-list {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
  }

  .function-card {
    padding: 15px;
  }

  .function-card i {
    font-size: 1.5rem;
  }

  .function-card div {
    font-size: 1rem;
  }

  /* Line manager */
  .line-manager {
    padding: 15px;
  }

  .line-manager h3 {
    font-size: 1.1rem;
  }

  .expression-input-container {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .expression-input input {
    padding: 12px 45px 12px 55px;
    font-size: 1.1rem;
  }

  .expression-input .input-suffix {
    font-size: 1.1rem;
  }

  /* Line items */
  .line-item {
    flex: 1 1 100%;
    min-width: 100%;
  }

  .line-header {
    padding: 12px;
  }

  .line-name {
    font-size: 1rem;
  }

  .line-type, .line-params {
    font-size: 0.8rem;
  }

  /* Virtual keyboard */
  .virtual-keyboard {
    padding: 10px;
    max-width: 100%;
    overflow-x: hidden;
  }

  .key-btn {
    width: calc(20% - 4px);
    height: 45px;
    font-size: 1rem;
  }

  .key-btn[data-value="√"],
  .key-btn[data-value="∛"],
  .key-btn[data-value="×"],
  .key-btn[data-value="÷"],
  .key-btn[data-value="−"],
  .key-btn[data-value="x"],
  .key-btn[data-value="e"],
  .key-btn[data-value="π"] {
    font-size: 1.2rem;
  }

  /* Steps container */
  .steps-container {
    padding: 15px;
    overflow-x: hidden;
  }

  .step {
    padding: 15px;
  }

  .step-title {
    font-size: 1.1rem;
  }

  .step-formula {
    font-size: 1rem;
    padding: 12px;
    word-break: break-all;
    overflow-wrap: break-word;
  }

  /* Info box */
  .info-box {
    padding: 15px;
    font-size: 1rem;
  }

  /* Alert */
  .alert {
    padding: 15px;
    font-size: 0.9rem;
  }

  /* Key points */
  .key-points {
    gap: 10px;
  }

  .key-point {
    padding: 10px 15px;
    font-size: 0.9rem;
  }

  /* Parameter controls */
  .parameter-controls {
    flex-direction: column;
    gap: 15px;
  }

  /* Animation controls */
  .animation-controls {
    flex-direction: column;
    gap: 10px;
  }

  .animation-controls .btn {
    width: 100%;
  }

  /* Function formula */
  .function-formula {
    padding: 15px;
  }

  .function-formula h3 {
    font-size: 1.1rem;
  }

  .formula-display {
    font-size: 1.2rem;
    padding: 12px;
  }

  /* Slider */
  .slider {
    height: 6px;
  }

  .slider::-webkit-slider-thumb {
    width: 18px;
    height: 18px;
  }

  .slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
  }

  .slider-value {
    font-size: 0.9rem;
  }

  /* Modal */
  .modal-content {
    width: 95%;
    margin: 20% auto;
  }

  .modal-header h3 {
    font-size: 1.3rem;
  }

  .modal-body p {
    font-size: 1rem;
  }

  .countdown-container {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
  }

  /* Math expressions */
  .math-ltr {
    font-size: 0.9rem;
    word-break: break-all;
  }

  /* Add expression button mobile adjustments */
  .add-expression-btn {
    padding: 12px 16px;
    font-size: 0.9rem;
    max-width: 150px;
  }

  /* About section responsive */
  .about-content {
    flex-direction: column;
    gap: 30px;
  }
  
  .about-image {
    flex: 0 0 auto;
    align-self: center;
    max-width: 250px;
  }
  
  .about-name {
    font-size: 1.8rem;
    text-align: center;
  }
  
  .about-title {
    font-size: 1.1rem;
    text-align: center;
    justify-content: center;
  }
  
  .interests-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
  
  .links-container {
    justify-content: center;
  }
  
  .social-link {
    flex: 1 1 calc(50% - 15px);
    justify-content: center;
    min-width: 140px;
  }
  
  .about-quote p {
    font-size: 1rem;
  }
}

@media (max-width: 480px) {
  /* Very small screens */
  .container {
    padding: 5px;
  }

  .tab-content {
    padding: 10px 5px;
  }

  .graph-container {
    height: 250px;
  }

  .function-list {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .key-btn {
    width: calc(20% - 3px);
    height: 40px;
    font-size: 0.9rem;
  }

  .key-btn[data-value="√"],
  .key-btn[data-value="∛"],
  .key-btn[data-value="×"],
  .key-btn[data-value="÷"],
  .key-btn[data-value="−"],
  .key-btn[data-value="x"],
  .key-btn[data-value="e"],
  .key-btn[data-value="π"] {
    font-size: 1.1rem;
  }

  .step-formula {
    font-size: 0.9rem;
  }

  .math-ltr {
    font-size: 0.8rem;
  }

  .line-manager {
    padding: 10px;
  }

  .line-manager h3 {
    font-size: 1rem;
  }

  .expression-input input {
    padding: 10px 40px 10px 50px;
    font-size: 1rem;
  }

  .expression-input .input-suffix {
    font-size: 1rem;
  }

  .keyboard-toggle, .add-expression-btn {
    width: 35px;
    height: 35px;
    font-size: 0.9rem;
  }

  .add-expression-btn {
    padding: 10px 15px;
    max-width: 120px;
  }

  .virtual-keyboard {
    padding: 8px;
  }

  .line-header {
    padding: 10px;
  }

  .line-name {
    font-size: 0.9rem;
  }

  .line-type, .line-params {
    font-size: 0.75rem;
  }

  .line-intersections {
    padding: 10px;
  }

  .line-intersections h4 {
    font-size: 0.9rem;
  }

  .intersection-point {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .steps-container {
    padding: 12px;
  }

  .step {
    padding: 12px;
  }

  .step-title {
    font-size: 1rem;
  }

  .info-box {
    padding: 12px;
    font-size: 0.9rem;
  }

  .alert {
    padding: 12px;
    font-size: 0.85rem;
  }

  .function-formula {
    padding: 12px;
  }

  .function-formula h3 {
    font-size: 1rem;
  }

  .formula-display {
    font-size: 1.1rem;
    padding: 10px;
  }

  .slider-container {
    margin-top: 8px;
  }

  .slider {
    height: 5px;
  }

  .slider::-webkit-slider-thumb {
    width: 16px;
    height: 16px;
  }

  .slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
  }

  .modal-content {
    width: 98%;
    margin: 30% auto;
  }

  .modal-header {
    padding: 15px;
  }

  .modal-header h3 {
    font-size: 1.2rem;
  }

  .modal-body {
    padding: 20px 15px;
  }

  .modal-body p {
    font-size: 0.9rem;
  }

  .modal-footer {
    padding: 15px;
  }

  .countdown-container {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
  }

  /* About section very small screens */
  .social-link {
    flex: 1 1 100%;
  }
  
  .interest-item {
    padding: 12px;
  }
  
  .interest-item i {
    font-size: 1.3rem;
  }
  
  .about-name {
    font-size: 1.6rem;
  }
}