/* AlHaseen Insurance System - Global Styles */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&display=swap');

:root {
  --primary: #212f80;
  --primary-light: #eef0fb;
  --accent: #ee272d;
  --accent-light: #fef2f2;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ee272d;
  --info: #3b82f6;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --surface: #ffffff;
  --background: #eef1f8;
  --border: #e2e8f0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --font: 'Cairo', 'Inter', sans-serif;
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 68px;
  --navbar-height: 56px;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font);
  background: var(--background);
  color: var(--text-primary);
  direction: rtl;
  text-align: right;
  line-height: 1.6;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ============================================
   ARABIC FONT OVERRIDE - Force Cairo everywhere
   ============================================ */
*:lang(ar),
[dir="rtl"] *,
body, body * {
  font-family: 'Cairo', 'Inter', sans-serif !important;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #c1c8d6;
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: #a0a8b8;
}

/* Selection */
::selection {
  background: var(--primary);
  color: #fff;
}

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

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font);
  font-weight: 700;
  color: var(--text-primary);
}

/* ============================================
   RESPONSIVE - Mobile First Approach
   ============================================ */

/* ---- Tablet (max-width: 1024px) ---- */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 68px;
  }
  
  /* Force sidebar collapsed on tablet */
  app-sidebar,
  [class*="sidebar"] {
    width: var(--sidebar-collapsed-width) !important;
  }
  
  /* Adjust main content padding */
  .home-layout,
  [class*="home-layout"] {
    padding-right: var(--sidebar-collapsed-width) !important;
  }
  
  .home-content,
  [class*="home-content"] {
    padding: 0.75rem !important;
  }
}

/* ---- Mobile (max-width: 768px) ---- */
@media (max-width: 768px) {
  html {
    font-size: 14px;
  }
  
  /* Hide sidebar completely on mobile */
  app-sidebar,
  [class*="sidebar"]:not(.sidebar-mobile-open) {
    transform: translateX(100%);
    position: fixed !important;
    z-index: 9999 !important;
    width: 260px !important;
    transition: transform 0.3s ease;
  }
  
  /* Show sidebar when toggled */
  app-sidebar.mobile-open,
  .sidebar-mobile-open {
    transform: translateX(0) !important;
  }
  
  /* Remove sidebar padding from main content */
  .home-layout,
  [class*="home-layout"] {
    padding-right: 0 !important;
    padding-top: var(--navbar-height) !important;
  }
  
  .home-content,
  [class*="home-content"] {
    padding: 0.5rem !important;
  }
  
  /* Navbar adjustments */
  app-navbar,
  [class*="navbar"] {
    padding: 0 0.5rem !important;
  }
  
  /* Tables responsive */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  
  /* Cards stack vertically */
  .stat-cards,
  .dashboard-cards,
  [class*="stat-card"],
  [class*="grid"] {
    grid-template-columns: 1fr !important;
  }
  
  /* Forms full width */
  .form-group,
  .form-row,
  [class*="form-row"] {
    flex-direction: column !important;
  }
  
  .form-group > *,
  .form-row > *,
  [class*="form-row"] > * {
    width: 100% !important;
    min-width: 0 !important;
  }
  
  /* Modals full screen on mobile */
  .modal-content,
  [class*="modal-content"],
  .cdk-overlay-pane {
    width: 95vw !important;
    max-width: 95vw !important;
    margin: 0 auto !important;
  }
  
  /* Buttons stack on mobile */
  .btn-group,
  .action-buttons,
  [class*="btn-group"] {
    flex-wrap: wrap !important;
    gap: 0.5rem !important;
  }
}

/* ---- Small Mobile (max-width: 480px) ---- */
@media (max-width: 480px) {
  html {
    font-size: 13px;
  }
  
  .home-content,
  [class*="home-content"] {
    padding: 0.25rem !important;
  }
  
  /* Hide breadcrumbs on very small screens */
  .breadcrumbs,
  [class*="breadcrumb"] {
    display: none !important;
  }
  
  /* Stack everything */
  .flex-row,
  [class*="flex-row"] {
    flex-direction: column !important;
  }
}

/* ---- Overlay for mobile sidebar ---- */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9998;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideRight {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-primary { color: var(--primary) !important; }
.text-accent { color: var(--accent) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }
.text-muted { color: var(--text-muted) !important; }

.bg-primary { background: var(--primary) !important; }
.bg-accent { background: var(--accent) !important; }
.bg-success { background: var(--success) !important; }

.font-bold { font-weight: 700 !important; }
.font-extrabold { font-weight: 800 !important; }

/* Touch-friendly targets */
button, a, .clickable, [role="button"] {
  min-height: 44px;
  min-width: 44px;
}

/* Smooth transitions */
a, button, input, select, textarea {
  transition: all 0.2s ease;
}

/* Better input styling for mobile */
input, select, textarea {
  font-size: 16px !important; /* Prevents zoom on iOS */
  font-family: var(--font) !important;
}

@media (min-width: 769px) {
  input, select, textarea {
    font-size: 14px !important;
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
  body {
    background: #fff;
    color: #000;
  }
  .no-print,
  app-sidebar,
  app-navbar,
  [class*="sidebar"],
  [class*="navbar"] {
    display: none !important;
  }
  .home-layout,
  [class*="home-layout"] {
    padding: 0 !important;
  }
}
