/* Critical CSS is loaded in the head */
@tailwind base;
@tailwind components;
@tailwind utilities;

/* System font stack as fallback */
@font-face {
  font-family: 'Tajawal';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: local('Tajawal'), local('Tajawal-Regular'),
       url('/fonts/tajawal-v9-latin-regular.woff2') format('woff2'),
       url('/fonts/tajawal-v9-latin-regular.woff') format('woff');
}

@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: local('Poppins'), local('Poppins-Regular'),
       url('/fonts/poppins-v20-latin-regular.woff2') format('woff2'),
       url('/fonts/poppins-v20-latin-regular.woff') format('woff');
}

/* Base styles */
:root {
  --primary-color: #1c3f6e;
  --secondary-color: #f5f5f5;
  --accent-color: #e67e22;
  --text-color: #333;
  --light-text: #666;
  --border-color: #e0e0e0;
  --success-color: #2ecc71;
  --error-color: #e74c3c;
  --warning-color: #f39c12;
  --info-color: #3498db;
  --bg-light: #f9f9f9;
  --bg-white: #ffffff;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --transition: all 0.3s ease;
  --border-radius: 8px;
  --max-width: 1200px;
  --header-height: 70px;
  --footer-height: 60px;
}

/* Optimize font rendering */
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  box-sizing: border-box;
}

/* Base typography */
html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  width: 100%;
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
}

/* RTL/LTR support */
html[dir="rtl"] { direction: rtl; }
html[dir="ltr"] { direction: ltr; }

/* Body styles */
body {
  font-family: 'Tajawal', 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--bg-light);
  overflow-x: hidden;
  width: 100%;
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Images */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Links */
a {
  color: var(--primary-color);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  text-decoration: underline;
}

/* Buttons */
button {
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
}

/* Focus styles for accessibility */
:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* Custom scrollbar - only for WebKit browsers */
@media (hover: hover) and (pointer: fine) {
  ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
  }

  ::-webkit-scrollbar-track {
    background: #f1f1f1;
  }

  ::-webkit-scrollbar-thumb {
    background: #bc2649;
    border-radius: 4px;
  }

  ::-webkit-scrollbar-thumb:hover {
    background: #a91f3f;
  }
}

/* Print styles */
@media print {
  *,
  *::before,
  *::after {
    background: transparent !important;
    color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  a,
  a:visited {
    text-decoration: underline;
  }

  a[href]::after {
    content: " (" attr(href) ")";
  }

  abbr[title]::after {
    content: " (" attr(title) ")";
  }

  pre,
  blockquote {
    page-break-inside: avoid;
  }

  thead {
    display: table-header-group;
  }

  tr,
  img {
    page-break-inside: avoid;
  }

  img {
    max-width: 100% !important;
  }

  p,
  h2,
  h3 {
    orphans: 3;
    widows: 3;
  }

  h2,
  h3 {
    page-break-after: avoid;
  }
}

/* Smooth animations */
* {
  transition: all 0.3s ease;
}

/* Custom gradient backgrounds */
.gradient-bg {
  background: linear-gradient(135deg, #bc2649 0%, #a91f3f 100%);
}

/* Custom shadows */
.custom-shadow {
  box-shadow: 0 20px 25px -5px rgba(188, 38, 73, 0.1), 0 10px 10px -5px rgba(188, 38, 73, 0.04);
}

/* Animation keyframes */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.animate-fadeInUp {
  animation: fadeInUp 0.6s ease-out;
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* RTL Support */
[dir="rtl"] .space-x-reverse > :not([hidden]) ~ :not([hidden]) {
  --tw-space-x-reverse: 1;
}

/* Custom button styles */
.btn-primary {
  @apply bg-[#bc2649] text-white px-6 py-3 rounded-lg font-medium hover:bg-[#a91f3f] transition-all duration-300 shadow-lg hover:shadow-xl transform hover:-translate-y-0.5;
}

.btn-secondary {
  @apply border-2 border-[#bc2649] text-[#bc2649] px-6 py-3 rounded-lg font-medium hover:bg-[#bc2649] hover:text-white transition-all duration-300;
}

/* Card hover effects */
.card-hover {
  @apply transition-all duration-300 hover:shadow-2xl hover:-translate-y-2;
}

/* Text selection */
::selection {
  background-color: #bc2649;
  color: white;
}

/* Focus styles */
input:focus, textarea:focus, select:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(188, 38, 73, 0.1);
}

/* Loading animation */
.loading {
  @apply animate-spin rounded-full h-8 w-8 border-b-2 border-[#bc2649];
}

/* Responsive text */
@media (max-width: 640px) {
  h1 {
    font-size: 2rem;
  }
  h2 {
    font-size: 1.75rem;
  }
  h3 {
    font-size: 1.5rem;
  }
}