/* SmartCalc Pro — UI & UX styles (light / dark) */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap');
html { scroll-behavior: smooth; }
body {
  font-family: 'Cairo', sans-serif;
  background: linear-gradient(to bottom, #f8fafc 0%, #f1f5f9 100%);
  color: #334155;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

/* الحاويات (cards) */
main, .tab-content, #shiftResults, .card, .bg-white {
  background: #fff !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05) !important;
  border-radius: 1rem !important;
  border: 1px solid #e2e8f0 !important;
  color: #334155 !important;
}

/* التبويبات */
.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

.dark, html.dark {
  background: #0f172a !important;
  color: #e2e8f0 !important;
}
.dark main, .dark .tab-content, .dark #shiftResults, .dark .card, .dark .bg-white {
  background: #1e293b !important;
  color: #e2e8f0 !important;
  border: 1px solid #334155 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18) !important;
}

/* النصوص */
body, html { color: #334155; }
.text-primary { color: #2563eb !important; }
.text-secondary, .text-gray-500 { color: #64748b !important; }
.text-title, h1, h2, h3 { color: #1e293b !important; }
.dark .text-title, .dark h1, .dark h2, .dark h3 { color: #f1f5f9 !important; }
.dark .text-primary { color: #3b82f6 !important; }
.dark .text-secondary, .dark .text-gray-500 { color: #94a3b8 !important; }

/* العناوين */
h1, h2, h3 {
  font-size: 1.875rem; /* text-3xl */
  font-weight: bold;
  margin-bottom: 1.25rem;
  color: #1e293b;
}
.dark h1, .dark h2, .dark h3 { color: #f1f5f9; }

/* الحقول */
.input-field, .denomination-input {
  padding: 0.75rem;
  border-radius: 0.5rem;
  background: #f1f5f9;
  color: #1e293b;
  border: 1px solid #cbd5e1;
  font-size: 1.08rem;
  transition: background 0.2s, color 0.2s, border 0.2s;
}
.input-field:focus, .denomination-input:focus {
  background: #fff;
  color: #1e293b;
  border-color: #2563eb;
}
.dark .input-field, .dark .denomination-input {
  background: #1e293b !important;
  color: #f8fafc !important;
  border: 1px solid #475569 !important;
}
.dark .input-field:focus, .dark .denomination-input:focus {
  background: #334155 !important;
  color: #fff !important;
  border-color: #3b82f6 !important;
}

/* الأزرار */
.btn, .btn-calc {
  transition: all 0.2s ease-in-out;
  transform: scale(1);
  border-radius: 0.5rem;
  font-weight: 600;
  box-shadow: none;
  border: none;
}
.btn:hover, .btn-calc:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}
.btn.bg-primary, .btn-calc.bg-primary {
  background: #3b82f6 !important;
  color: #fff !important;
}
.btn.bg-primary:hover, .btn-calc.bg-primary:hover {
  background: #60a5fa !important;
}
.dark .btn.bg-primary, .dark .btn-calc.bg-primary {
  background: #3b82f6 !important;
  color: #fff !important;
}
.dark .btn.bg-primary:hover, .dark .btn-calc.bg-primary:hover {
  background: #60a5fa !important;
}

/* التبويبات */
.tab-btn {
  border-radius: 0.75rem 0.75rem 0 0;
  margin: 0 0.25rem;
  padding: 0.75rem 1.5rem;
  font-size: 1.1rem;
  background: #f1f5f9;
  color: #2563eb;
  border: none;
  border-bottom: 2px solid transparent;
  transition: background 0.2s, color 0.2s, border 0.2s;
}
.tab-btn.active {
  background: #fff;
  color: #2563eb;
  border-bottom: 3px solid #2563eb;
  font-weight: 700;
  box-shadow: 0 2px 8px 0 #0001;
}
.dark .tab-btn {
  background: #1e293b !important;
  color: #3b82f6 !important;
}
.dark .tab-btn.active {
  background: #1e293b !important;
  color: #60a5fa !important;
  border-bottom: 3px solid #60a5fa !important;
}

/* Footer */
footer, .footer {
  text-align: center;
  font-size: 0.95rem;
  color: #64748b;
  padding: 1.25rem 0 0.5rem 0;
  background: transparent;
}
footer .text-primary { color: #2563eb !important; font-weight: 600; }
.dark footer, .dark .footer {
  color: #94a3b8 !important;
}
.dark footer .text-primary { color: #3b82f6 !important; }

/* تحسينات عامة */
.text-lg { font-size: 1.25rem !important; }
.text-xl { font-size: 1.5rem !important; }
.text-xs { font-size: 0.75rem !important; }
.text-sm { font-size: 0.9rem !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.font-bold { font-weight: 700 !important; }
.font-semibold { font-weight: 600 !important; }
.font-mono { font-family: 'Cairo', monospace, sans-serif !important; }
.rounded-xl { border-radius: 1rem !important; }
.rounded-2xl { border-radius: 1.5rem !important; }
.shadow-xl { box-shadow: 0 4px 32px 0 #0002 !important; }
.shadow-lg { box-shadow: 0 2px 8px 0 #0001 !important; }

/* تحسينات للهوامش والتباعد */
.mb-4 { margin-bottom: 1.5rem !important; }
.mt-2 { margin-top: 0.75rem !important; }
.mt-1 { margin-top: 0.25rem !important; }
.py-4 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
.p-3 { padding: 1rem !important; }
.p-2 { padding: 0.5rem !important; }
.gap-3 { gap: 0.75rem !important; }
.flex { display: flex !important; }
.items-center { align-items: center !important; }
.justify-between { justify-content: space-between !important; }

/* تحسينات للدوائر والأيقونات */
.rounded-full { border-radius: 9999px !important; }

/* أزرار إعادة التهيئة */
.reset-btn {
  position: relative;
  z-index: 10;
}
.clear-both {
  clear: both;
}

/* حقول الإدخال */
.input-field {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid #d1d5db;
  border-radius: 0.5rem;
  background: #f9fafb;
  color: #374151;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.input-field:focus {
  outline: none;
  border-color: #2563eb;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.dark .input-field {
  background: #374151;
  border-color: #4b5563;
  color: #e5e7eb;
}

.dark .input-field:focus {
  background: #4b5563;
  border-color: #3b82f6;
}

/* الأزرار */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font-weight: 600;
  text-align: center;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  font-size: 0.875rem;
  line-height: 1.25rem;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* أزرار الحاسبة */
.btn-calc {
  min-height: 3rem;
  font-size: 1.125rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.btn-calc:hover {
  transform: scale(1.05);
}

.btn-calc:active {
  transform: scale(0.95);
}

/* الألوان الأساسية */
.text-primary {
  color: #2563eb !important;
}

.bg-primary {
  background-color: #2563eb !important;
}

.border-primary {
  border-color: #2563eb !important;
}

.hover\:bg-blue-600:hover {
  background-color: #1d4ed8 !important;
}

.bg-accent {
  background-color: #0ea5e9 !important;
}

.text-accent {
  color: #0ea5e9 !important;
}

/* التخطيط والشبكة */
.grid {
  display: grid;
}

.grid-cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

.grid-cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.gap-3 {
  gap: 0.75rem;
}

.gap-4 {
  gap: 1rem;
}

.gap-6 {
  gap: 1.5rem;
}

.space-y-2 > * + * {
  margin-top: 0.5rem;
}

.space-y-3 > * + * {
  margin-top: 0.75rem;
}

.space-y-4 > * + * {
  margin-top: 1rem;
}

.space-y-6 > * + * {
  margin-top: 1.5rem;
}

/* الحشو والهامش */
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.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; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }

/* ألوان الخلفية */
.bg-red-500 { background-color: #ef4444; }
.bg-yellow-500 { background-color: #eab308; }
.bg-green-500 { background-color: #10b981; }
.bg-blue-500 { background-color: #3b82f6; }
.bg-gray-300 { background-color: #d1d5db; }
.bg-gray-100 { background-color: #f3f4f6; }
.bg-gray-200 { background-color: #e5e7eb; }
.bg-gray-700 { background-color: #374151; }
.bg-white { background-color: #ffffff; }

/* ألوان النص */
.text-white { color: #ffffff; }
.text-gray-800 { color: #1f2937; }
.text-gray-200 { color: #e5e7eb; }
.text-gray-500 { color: #6b7280; }
.text-gray-400 { color: #9ca3af; }
.text-red-500 { color: #ef4444; }
.text-green-500 { color: #10b981; }
.text-blue-600 { color: #2563eb; }
.text-yellow-600 { color: #d97706; }
.text-green-600 { color: #059669; }

/* أحجام الخط */
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }

/* أوزان الخط */
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-mono { font-family: ui-monospace, SFMono-Regular, Monaco, monospace; }

/* الحواف */
.rounded-md { border-radius: 0.375rem; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-2xl { border-radius: 1rem; }

/* الظلال */
.shadow-xl { box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); }

/* الإخفاء */
.hidden { display: none !important; }

/* الموضع */
.float-right { float: right; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* التحولات */
.transition-all { transition: all 0.3s ease; }
.hover\:scale-105:hover { transform: scale(1.05); }
.hover\:bg-red-600:hover { background-color: #dc2626; }
.hover\:bg-green-600:hover { background-color: #059669; }
.hover\:bg-yellow-600:hover { background-color: #d97706; }
.hover\:bg-gray-400:hover { background-color: #9ca3af; }

/* التخطيط */
.w-full { width: 100%; }
.w-10 { width: 2.5rem; }
.w-12 { width: 3rem; }
.h-6 { height: 1.5rem; }
.h-10 { height: 2.5rem; }
.h-12 { height: 3rem; }
.min-h-screen { min-height: 100vh; }
.min-height-3rem { min-height: 3rem; }
.max-h-40 { max-height: 10rem; }

/* التموضع */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.overflow-y-auto { overflow-y: auto; }
.overflow-x-auto { overflow-x: auto; }

/* الحدود */
.border { border-width: 1px; }
.border-2 { border-width: 2px; }
.border-b-2 { border-bottom-width: 2px; }
.border-gray-200 { border-color: #e5e7eb; }
.border-gray-600 { border-color: #4b5563; }
.border-gray-700 { border-color: #374151; }

/* الأحجام التخصصية */
.col-span-2 { grid-column: span 2 / span 2; }

/* الحالات التفاعلية */
.cursor-pointer { cursor: pointer; }
.user-select-none { user-select: none; }

/* التموضع النسبي */
.relative { position: relative; }
.absolute { position: absolute; }
.sticky { position: sticky; }
.top-0 { top: 0; }
.z-10 { z-index: 10; }

/* الحاويات */
.container { 
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

@media (min-width: 640px) {
  .container { max-width: 640px; }
  .sm\:px-4 { padding-left: 1rem; padding-right: 1rem; }
  .sm\:text-sm { font-size: 0.875rem; }
}

@media (min-width: 768px) {
  .container { max-width: 768px; }
  .md\:grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .container { max-width: 1024px; }
}

@media (min-width: 1280px) {
  .container { max-width: 1280px; }
}

/* إضافات للوضع المظلم */
.dark .bg-gray-800 { background-color: #1f2937 !important; }
.dark .bg-gray-700 { background-color: #374151 !important; }
.dark .bg-gray-600 { background-color: #4b5563 !important; }
.dark .text-gray-200 { color: #e5e7eb !important; }
.dark .text-gray-400 { color: #9ca3af !important; }
.dark .border-gray-600 { border-color: #4b5563 !important; }
.dark .border-gray-700 { border-color: #374151 !important; }

/* ألوان إضافية للخلفية */
.bg-red-500\/10 { background-color: rgba(239, 68, 68, 0.1); }
.bg-green-500\/10 { background-color: rgba(16, 185, 129, 0.1); }
.bg-blue-500\/10 { background-color: rgba(59, 130, 246, 0.1); }
.bg-yellow-500\/10 { background-color: rgba(234, 179, 8, 0.1); }
.bg-accent\/10 { background-color: rgba(14, 165, 233, 0.1); }

/* تحسينات خاصة لتقرير الوردية */
.shift-result-card {
  animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ألوان إضافية للوضع المظلم */
.dark .bg-red-50 { background-color: rgba(239, 68, 68, 0.1) !important; }
.dark .bg-green-50 { background-color: rgba(16, 185, 129, 0.1) !important; }
.dark .bg-blue-50 { background-color: rgba(59, 130, 246, 0.1) !important; }
.dark .bg-yellow-50 { background-color: rgba(234, 179, 8, 0.1) !important; }

.dark .text-red-400 { color: #f87171 !important; }
.dark .text-green-400 { color: #4ade80 !important; }
.dark .text-blue-400 { color: #60a5fa !important; }
.dark .text-yellow-400 { color: #facc15 !important; }
.bg-blue-500\/10 { background-color: rgba(59, 130, 246, 0.1); }
.bg-yellow-500\/10 { background-color: rgba(234, 179, 8, 0.1); }
.bg-yellow-50 { background-color: #fefce8; }
.bg-green-50 { background-color: #f0fdf4; }
.bg-blue-50 { background-color: #eff6ff; }
.bg-yellow-100 { background-color: #fef3c7; }
.bg-yellow-700 { background-color: #a16207; }
.bg-yellow-200 { background-color: #fde68a; }

/* ألوان الوضع المظلم */
.dark .bg-yellow-900\/30 { background-color: rgba(120, 53, 15, 0.3); }
.dark .bg-yellow-900\/20 { background-color: rgba(120, 53, 15, 0.2); }
.dark .bg-green-900\/20 { background-color: rgba(20, 83, 45, 0.2); }
.dark .bg-blue-900\/20 { background-color: rgba(30, 58, 138, 0.2); }
.dark .bg-gray-700\/50 { background-color: rgba(55, 65, 81, 0.5); }

/* ألوان نص إضافية */
.text-yellow-700 { color: #a16207; }
.text-yellow-200 { color: #fde68a; }
.text-yellow-400 { color: #facc15; }
.text-green-400 { color: #4ade80; }
.text-blue-400 { color: #60a5fa; }

/* إضافات تفاعلية */
.hover\:bg-gray-200:hover { background-color: #e5e7eb; }
.hover\:bg-gray-700:hover { background-color: #374151; }
.hover\:shadow-xl:hover { box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); }
.hover\:shadow-2xl:hover { box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); }

/* تحسينات إضافية */
.whitespace-nowrap { white-space: nowrap; }
.truncate { 
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* إضافات التخطيط */
.flex-grow { flex-grow: 1; }
.mt-auto { margin-top: auto; }

/* إضافات الحدود */
.border-b { border-bottom-width: 1px; }

/* إضافات الحشو */
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }

/* إضافات الخط */
.font-cairo { font-family: 'Cairo', sans-serif; }

/* تحسينات للموبايل */
@media (max-width: 640px) {
  .btn-calc {
    min-height: 3.5rem;
    font-size: 1rem;
  }
  
  .grid-cols-4 {
    gap: 0.5rem;
  }
  
  .px-2 {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  
  .text-2xl {
    font-size: 1.25rem;
  }
  
  .p-6 {
    padding: 1rem;
  }
  
  .gap-6 {
    gap: 1rem;
  }
  
  .md\:grid-cols-2 {
    grid-template-columns: 1fr;
  }
}

/* إضافات أخيرة للوضع المظلم */
.dark .hover\:bg-gray-200:hover { background-color: #4b5563 !important; }
.dark .hover\:bg-gray-700:hover { background-color: #374151 !important; }

/* تحسينات للروابط */
a {
  color: #2563eb;
  text-decoration: none;
  transition: color 0.2s;
}
a:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

/* الطباعة */
@media print {
  body, html { background: #fff !important; color: #000 !important; }
  .dark, .dark * { background: #fff !important; color: #000 !important; }
  header, nav, footer, .tab-btn, .btn, .shadow-xl, .shadow-lg { display: none !important; }
  main, .tab-content, #shiftResults { box-shadow: none !important; background: #fff !important; color: #000 !important; border-radius: 0 !important; padding: 0 !important; }
}

/* Responsive */
@media (max-width: 600px) {
  main, .tab-content, #shiftResults {
    padding: 1rem 0.5rem;
    border-radius: 1rem;
  }
  .btn, .tab-btn {
    font-size: 1rem;
    padding: 0.5rem 1rem;
  }
  .input-field, .denomination-input {
    font-size: 1rem;
    padding: 0.5rem;
  }
}

/* Anti-flash safeguard: keep <body> dark when <html>.dark is set before <body> parses.
   (core.js also adds .dark to <body> once the DOM is ready.) */
html.dark body { background: #0f172a !important; color: #e2e8f0 !important; }
