﻿:root {
  --background: 35 30% 96%;
  --foreground: 25 20% 12%;
  --card: 0 0% 100%;
  --card-foreground: 25 20% 12%;
  --primary: 24 80% 50%;
  --primary-foreground: 0 0% 100%;
  --secondary: 30 20% 92%;
  --secondary-foreground: 25 20% 20%;
  --muted: 30 15% 93%;
  --muted-foreground: 25 10% 45%;
  --accent: 30 40% 93%;
  --accent-foreground: 24 80% 40%;
  --destructive: 0 84% 60%;
  --destructive-foreground: 0 0% 100%;
  --border: 30 15% 86%;
  --input: 30 15% 86%;
  --radius: 0.75rem;

  --gradient-primary: linear-gradient(135deg, hsl(24, 80%, 45%), hsl(30, 85%, 60%));
  --gradient-hero: linear-gradient(135deg, hsl(25, 70%, 22%) 0%, hsl(28, 80%, 45%) 60%, hsl(35, 85%, 55%) 100%);
  --gradient-card: linear-gradient(145deg, hsl(0, 0%, 100%), hsl(30, 20%, 97%));
  --shadow-primary: 0 8px 24px -4px hsl(24 80% 50% / 0.25);
}

.dark {
  --background: 25 20% 8%;
  --foreground: 30 15% 92%;
  --card: 25 18% 11%;
  --card-foreground: 30 15% 92%;
  --primary: 28 75% 55%;
  --primary-foreground: 0 0% 100%;
  --secondary: 25 18% 18%;
  --secondary-foreground: 30 15% 85%;
  --muted: 25 18% 16%;
  --muted-foreground: 25 10% 55%;
  --accent: 28 35% 20%;
  --accent-foreground: 28 75% 70%;
  --destructive: 0 62% 45%;
  --destructive-foreground: 0 0% 100%;
  --border: 25 15% 20%;
  --input: 25 15% 20%;
}

body {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: 'Segoe UI', 'Cairo', 'Noto Sans Arabic', sans-serif;
  direction: rtl;
}

.layout-wrap {
  max-width: 80rem;
  margin-inline: auto;
  padding-inline: 1rem;
}

.surface {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 1rem;
  box-shadow: 0 4px 16px -2px hsl(25 30% 20% / 0.1);
}

.section-title {
  font-size: 1.75rem;
  line-height: 1.2;
  font-weight: 800;
  color: hsl(var(--foreground));
}

.section-subtitle {
  margin-top: .5rem;
  font-size: .95rem;
  color: hsl(var(--muted-foreground));
}

.gradient-primary { background: var(--gradient-primary); }
.gradient-hero { background: var(--gradient-hero); }
.gradient-card { background: var(--gradient-card); }
.shadow-primary-glow { box-shadow: var(--shadow-primary); }

.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }
.scrollbar-hide::-webkit-scrollbar { display: none; }

.line-clamp-2 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.line-clamp-3 {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  border-radius: 0.75rem;
  padding: 0.5rem 1rem;
  transition: all .2s;
}
.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.btn-primary:hover { opacity: .9; }
.btn-secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}
.btn-secondary:hover { filter: brightness(.97); }
.btn-destructive {
  background: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}
.btn-destructive:hover { opacity: .9; }

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  border: 1px solid hsl(var(--input));
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  border-radius: 0.75rem;
  padding: 0.6rem .9rem;
  font-size: 0.875rem;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 4px hsl(var(--primary) / 0.16);
}

.prose-content {
  font-size: 1.15rem;
  line-height: 2.05;
  color: hsl(var(--foreground));
}

/* Responsive Design & RTL Enhancements */

.theme-toggle:hover {
  background: hsl(var(--accent));
}

/* RTL Specific Styles */
* {
  text-align: right;
}

/* Mobile Navigation Improvements */
@media (max-width: 768px) {
  .section-title {
    font-size: 1.5rem;
  }
  
  .section-subtitle {
    font-size: 0.875rem;
  }
  
  /* Better spacing on mobile */
  .layout-wrap {
    padding-inline: 0.75rem;
  }
  
  /* Hero section mobile optimization */
  section.gradient-hero {
    padding-top: 3rem;
    padding-bottom: 3rem;
  }
  
  section.gradient-hero h1 {
    font-size: 1.75rem !important;
  }
  
  section.gradient-hero p {
    font-size: 0.95rem !important;
  }
  
  /* Card grid improvements for mobile */
  .grid-cols-1 {
    gap: 1rem !important;
  }
  
  /* Form elements better sizing */
  .form-input,
  .form-select,
  .form-textarea {
    font-size: 1rem; /* Prevents zoom on iOS */
    padding: 0.75rem 1rem;
  }
  
  /* Button full width on very small screens */
  .btn {
    min-width: 100px;
  }
}

/* Tablet optimizations */
@media (min-width: 768px) and (max-width: 1024px) {
  .section-title {
    font-size: 1.65rem;
  }
  
  .grid-cols-2 {
    gap: 1.25rem;
  }
}

/* Large screen optimizations */
@media (min-width: 1280px) {
  .layout-wrap {
    padding-inline: 2rem;
  }
}

/* Print styles */
@media print {
  body {
    background: white !important;
    color: black !important;
  }
  
  .no-print {
    display: none !important;
  }
}

/* Accessibility improvements */
:focus-visible {
  outline: 2px solid hsl(var(--primary));
  outline-offset: 2px;
}

/* Smooth scrolling */
html {
  scroll-behavior: smooth;
}

/* Prevent horizontal scroll */
body {
  overflow-x: hidden;
}

/* Better touch targets for mobile */
@media (max-width: 768px) {
  a, button {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Larger tap targets for navigation */
  nav a {
    padding: 0.75rem 1rem;
  }
}

/* Safe area padding for modern iPhones */
.safe-area-pb {
  padding-bottom: env(safe-area-inset-bottom);
}

/* RTL Enhancements */
[dir="rtl"] {
  text-align: right;
}

[dir="rtl"] .flex-row {
  flex-direction: row;
}

[dir="rtl"] .ms-auto {
  margin-inline-start: auto;
  margin-inline-end: 0;
}

[dir="rtl"] .me-auto {
  margin-inline-end: auto;
  margin-inline-start: 0;
}

/* Ensure proper RTL spacing in grids */
[dir="rtl"] .grid {
  direction: rtl;
}

/* Fix icon spacing in RTL */
[dir="rtl"] .flex.items-center.gap-1,
[dir="rtl"] .flex.items-center.gap-2,
[dir="rtl"] .flex.items-center.gap-3 {
  gap: 0.25rem;
}

/* Improve Arabic text rendering */
p, h1, h2, h3, h4, h5, h6, span, div {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Better line height for Arabic */
.lang-ar {
  line-height: 1.8;
}

/* Fix table RTL */
[dir="rtl"] table {
  direction: rtl;
  text-align: right;
}

/* Form elements RTL */
[dir="rtl"] input,
[dir="rtl"] textarea,
[dir="rtl"] select {
  direction: rtl;
  text-align: right;
}

/* Placeholder RTL */
[dir="rtl"] ::placeholder {
  text-align: right;
}

/* Dashboard/Admin tables responsive */
table {
  font-size: 0.875rem;
}

@media (max-width: 768px) {
  table {
    font-size: 0.75rem;
  }
  
  /* Make tables horizontally scrollable on mobile */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Card hover effects better on mobile */
@media (hover: none) {
  .group:hover .group-hover\:scale-105 {
    transform: none;
  }
  
  .group:hover .group-hover\:-translate-y-1 {
    transform: none;
  }
}

/* Better form layout on mobile */
@media (max-width: 640px) {
  form input[type="email"],
  form input[type="password"],
  form input[type="text"],
  form textarea,
  form select {
    width: 100%;
  }
  
  form button[type="submit"],
  form button[type="button"] {
    width: 100%;
  }
}

/* Improve reading experience */
.prose {
  max-width: 65ch;
  margin-left: auto;
  margin-right: auto;
}

/* Sticky headers for tables */
thead th {
  position: sticky;
  top: 0;
  background: hsl(var(--card));
  z-index: 10;
}

/* Smooth transitions */
* {
  transition-property: background-color, border-color, color, fill, stroke;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 150ms;
}

/* Reduce motion preference */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Mobile menu animations */
#mobileMenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-in-out;
}

#mobileMenu:not(.hidden) {
  max-height: 500px;
}
