/* Essential CSS Framework - Production Ready */
/* This file provides core styling to reduce dependency on Tailwind CDN */

:root {
  --color-primary: #3b82f6;
  --color-primary-hover: #2563eb;
  --color-secondary: #6b7280;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-gray-50: #f9fafb;
  --color-gray-100: #f3f4f6;
  --color-gray-200: #e5e7eb;
  --color-gray-300: #d1d5db;
  --color-gray-400: #9ca3af;
  --color-gray-500: #6b7280;
  --color-gray-600: #4b5563;
  --color-gray-700: #374151;
  --color-gray-800: #1f2937;
  --color-gray-900: #111827;
}

[data-theme="dark"] {
  --color-bg-primary: #111827;
  --color-bg-secondary: #1f2937;
  --color-text-primary: #f9fafb;
  --color-text-secondary: #d1d5db;
  --color-border: #374151;
}

[data-theme="light"] {
  --color-bg-primary: #ffffff;
  --color-bg-secondary: #f9fafb;
  --color-text-primary: #111827;
  --color-text-secondary: #6b7280;
  --color-border: #e5e7eb;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* RTL Support */
[dir="rtl"] {
  font-family: "Cairo", ui-sans-serif, system-ui, -apple-system, sans-serif;
}

/* Layout Components */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-center {
  justify-content: center;
}

.justify-between {
  justify-content: space-between;
}

.space-x-3 > * + * {
  margin-left: 0.75rem;
}

[dir="rtl"] .space-x-3 > * + * {
  margin-left: 0;
  margin-right: 0.75rem;
}

.space-y-4 > * + * {
  margin-top: 1rem;
}

.space-y-6 > * + * {
  margin-top: 1.5rem;
}

/* Grid */
.grid {
  display: grid;
}

.grid-cols-1 {
  grid-template-columns: repeat(1, minmax(0, 1fr));
}

.gap-6 {
  gap: 1.5rem;
}

@media (min-width: 768px) {
  .md\\:grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .lg\\:grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .lg\\:w-1-2 {
    width: 50%;
  }
}

/* Typography */
.text-sm {
  font-size: 0.875rem;
}

.text-lg {
  font-size: 1.125rem;
}

.text-xl {
  font-size: 1.25rem;
}

.text-2xl {
  font-size: 1.5rem;
}

.text-3xl {
  font-size: 1.875rem;
}

.text-4xl {
  font-size: 2.25rem;
}

.font-medium {
  font-weight: 500;
}

.font-semibold {
  font-weight: 600;
}

.font-bold {
  font-weight: 700;
}

.text-center {
  text-align: center;
}

/* Colors */
.text-white {
  color: #ffffff;
}

.text-gray-400 {
  color: var(--color-gray-400);
}

.text-gray-500 {
  color: var(--color-gray-500);
}

.text-gray-600 {
  color: var(--color-gray-600);
}

.text-gray-900 {
  color: var(--color-gray-900);
}

.bg-white {
  background-color: #ffffff;
}

.bg-gray-50 {
  background-color: var(--color-gray-50);
}

.bg-gray-100 {
  background-color: var(--color-gray-100);
}

.bg-gray-800 {
  background-color: var(--color-gray-800);
}

.bg-gray-900 {
  background-color: var(--color-gray-900);
}

.bg-blue-500 {
  background-color: var(--color-primary);
}

.bg-blue-600 {
  background-color: var(--color-primary-hover);
}

.bg-red-500 {
  background-color: var(--color-danger);
}

.bg-green-500 {
  background-color: var(--color-success);
}

/* Dark Mode */
[data-theme="dark"] .dark\\:bg-gray-800 {
  background-color: var(--color-gray-800);
}

[data-theme="dark"] .dark\\:bg-gray-900 {
  background-color: var(--color-gray-900);
}

[data-theme="dark"] .dark\\:text-white {
  color: #ffffff;
}

[data-theme="dark"] .dark\\:text-gray-100 {
  color: var(--color-gray-100);
}

[data-theme="dark"] .dark\\:text-gray-400 {
  color: var(--color-gray-400);
}

[data-theme="dark"] .dark\\:border-gray-700 {
  border-color: var(--color-gray-700);
}

/* Forms */
.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  background-color: var(--color-bg-secondary);
  color: var(--color-text-primary);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--color-text-secondary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 0.5rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

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

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

.btn-danger {
  background-color: var(--color-danger);
  color: white;
}

.btn-danger:hover {
  background-color: #dc2626;
}

/* Cards */
.card {
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Utilities */
.min-h-screen {
  min-height: 100vh;
}

.w-full {
  width: 100%;
}

.h-full {
  height: 100%;
}

.p-4 {
  padding: 1rem;
}

.p-6 {
  padding: 1.5rem;
}

.p-8 {
  padding: 2rem;
}

.px-4 {
  padding-left: 1rem;
  padding-right: 1rem;
}

.px-6 {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.py-2 {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.py-3 {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
}

.py-4 {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.py-8 {
  padding-top: 2rem;
  padding-bottom: 2rem;
}

.mb-2 {
  margin-bottom: 0.5rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

.mb-6 {
  margin-bottom: 1.5rem;
}

.mb-8 {
  margin-bottom: 2rem;
}

.mt-8 {
  margin-top: 2rem;
}

.rounded-lg {
  border-radius: 0.5rem;
}

.rounded-xl {
  border-radius: 0.75rem;
}

.rounded-full {
  border-radius: 9999px;
}

.shadow-sm {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.shadow-xl {
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.border {
  border-width: 1px;
  border-color: var(--color-border);
}

.border-b {
  border-bottom-width: 1px;
  border-bottom-color: var(--color-border);
}

.transition-colors {
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.duration-200 {
  transition-duration: 200ms;
}

.duration-300 {
  transition-duration: 300ms;
}

.hover\\:bg-gray-200:hover {
  background-color: var(--color-gray-200);
}

.hover\\:bg-blue-600:hover {
  background-color: var(--color-primary-hover);
}

.hover\\:bg-red-600:hover {
  background-color: #dc2626;
}

/* Responsive */
.hidden {
  display: none;
}

@media (min-width: 1024px) {
  .lg\\:hidden {
    display: none;
  }

  .lg\\:flex {
    display: flex;
  }
}

/* Focus states */
.focus\\:ring-2:focus {
  box-shadow: 0 0 0 2px var(--color-primary);
}

.focus\\:border-blue-500:focus {
  border-color: var(--color-primary);
}

/* Animation */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background-color: var(--color-gray-100);
}

[data-theme="dark"] .custom-scrollbar::-webkit-scrollbar-track {
  background-color: var(--color-gray-800);
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background-color: var(--color-gray-400);
  border-radius: 3px;
}

[data-theme="dark"] .custom-scrollbar::-webkit-scrollbar-thumb {
  background-color: var(--color-gray-600);
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-gray-500);
}

[data-theme="dark"] .custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-gray-500);
}

/* Positioning */
.relative {
  position: relative;
}

.absolute {
  position: absolute;
}

.fixed {
  position: fixed;
}

.top-4 {
  top: 1rem;
}

.right-4 {
  right: 1rem;
}

.left-4 {
  left: 1rem;
}

.left-3 {
  left: 0.75rem;
}

.top-3\.5 {
  top: 0.875rem;
}

.z-10 {
  z-index: 10;
}

.z-50 {
  z-index: 50;
}

/* Icon sizing */
.w-4 {
  width: 1rem;
}

.h-4 {
  height: 1rem;
}

.w-5 {
  width: 1.25rem;
}

.h-5 {
  height: 1.25rem;
}

.w-8 {
  width: 2rem;
}

.h-8 {
  height: 2rem;
}

.w-12 {
  width: 3rem;
}

.h-12 {
  height: 3rem;
}

.w-16 {
  width: 4rem;
}

.h-16 {
  height: 4rem;
}

.w-24 {
  width: 6rem;
}

.h-24 {
  height: 6rem;
}

/* Overflow */
.overflow-hidden {
  overflow: hidden;
}

.overflow-y-auto {
  overflow-y: auto;
}

.max-h-96 {
  max-height: 24rem;
}

/* Flexbox utilities */
.flex-shrink-0 {
  flex-shrink: 0;
}

.flex-wrap {
  flex-wrap: wrap;
}

/* Max width */
.max-w-md {
  max-width: 28rem;
}

.max-w-sm {
  max-width: 24rem;
}

.max-w-7xl {
  max-width: 80rem;
}

/* Transform */
.transform {
  transform: translateX(var(--tw-translate-x, 0)) translateY(var(--tw-translate-y, 0)) rotate(var(--tw-rotate, 0))
    skewX(var(--tw-skew-x, 0)) skewY(var(--tw-skew-y, 0)) scaleX(var(--tw-scale-x, 1)) scaleY(var(--tw-scale-y, 1));
}

.rtl\\:rotate-180[dir="rtl"] {
  transform: rotate(180deg);
}

/* Backdrop effects */
.backdrop-blur-sm {
  backdrop-filter: blur(4px);
}

/* Opacity */
.opacity-90 {
  opacity: 0.9;
}

/* Line height */
.leading-tight {
  line-height: 1.25;
}

/* Special gradient background */
.bg-gradient {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

[data-theme="dark"] .bg-gradient {
  background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
}
