/* 
   ICARE Application Documentation Styling
   Modern Medical Slate & Teal Design System
   Supports LTR (English) & RTL (Arabic) natively
*/

:root {
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  
  /* Color Palette */
  --primary: #0f766e;      /* Deep Teal */
  --primary-hover: #0d9488;
  --secondary: #10b981;    /* Mint Green */
  --bg-main: #ffffff;
  --bg-alt: #f8fafc;       /* Slate 50 */
  --text-main: #0f172a;    /* Slate 900 */
  --text-muted: #475569;   /* Slate 600 */
  --border: #e2e8f0;       /* Slate 200 */
  --header-bg: rgba(255, 255, 255, 0.85);
  --sidebar-bg: #f8fafc;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Layout Dimensions */
  --header-height: 64px;
  --sidebar-width: 280px;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Header */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background-color: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  transition: var(--transition);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-logo {
  width: 32px;
  height: 32px;
}

.brand-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.025em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.lang-toggle {
  background-color: var(--bg-alt);
  border: 1px solid var(--border);
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  transition: var(--transition);
}

.lang-toggle:hover {
  background-color: var(--border);
  color: var(--text-main);
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-main);
  cursor: pointer;
}

/* Base Layout (RTL & LTR) */
.layout {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

/* Sidebar Menu */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  position: fixed;
  top: var(--header-height);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  padding: 32px 16px;
  z-index: 90;
  transition: var(--transition);
}

/* RTL Specific Sidebar Overrides */
html[dir="rtl"] .sidebar {
  left: auto;
  right: 0;
  border-right: none;
  border-left: 1px solid var(--border);
}

.menu-group {
  margin-bottom: 24px;
}

.menu-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  padding: 0 12px;
}

.menu-list {
  list-style: none;
}

.menu-item a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.925rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.menu-item a:hover {
  background-color: rgba(15, 118, 110, 0.05);
  color: var(--primary);
}

.menu-item.active a {
  background-color: var(--primary);
  color: #ffffff;
}

/* Main Content Area */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 40px 48px;
  max-width: 1200px;
  transition: var(--transition);
}

html[dir="rtl"] .main-content {
  margin-left: 0;
  margin-right: var(--sidebar-width);
}

/* Page Typographical Content */
h1 {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 12px;
  letter-spacing: -0.025em;
}

h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 36px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary);
  margin-top: 24px;
  margin-bottom: 12px;
}

p {
  color: var(--text-muted);
  margin-bottom: 16px;
  font-size: 1rem;
}

.lead {
  font-size: 1.125rem;
  color: var(--text-main);
}

/* Lists */
ul, ol {
  margin-bottom: 16px;
  padding-left: 24px;
  color: var(--text-muted);
}

html[dir="rtl"] ul, html[dir="rtl"] ol {
  padding-left: 0;
  padding-right: 24px;
}

li {
  margin-bottom: 8px;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 24px;
  font-size: 0.925rem;
}

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

html[dir="rtl"] th, html[dir="rtl"] td {
  text-align: right;
}

th {
  background-color: var(--bg-alt);
  font-weight: 700;
  color: var(--text-main);
}

tr:hover {
  background-color: rgba(248, 250, 252, 0.6);
}

/* Alerts / Callouts */
.alert {
  padding: 16px;
  border-left: 4px solid var(--primary);
  background-color: var(--bg-alt);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 24px;
}

html[dir="rtl"] .alert {
  border-left: none;
  border-right: 4px solid var(--primary);
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.alert-title {
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-main);
}

.alert-info {
  border-color: #0284c7;
  background-color: #f0f9ff;
}

.alert-warning {
  border-color: #d97706;
  background-color: #fffbeb;
}

/* Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.card {
  background-color: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--primary);
}

/* Accordions for Modules */
.accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 16px;
}

.accordion-header {
  background-color: var(--bg-alt);
  padding: 16px 20px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  transition: var(--transition);
}

.accordion-header:hover {
  background-color: rgba(15, 118, 110, 0.03);
}

.accordion-header::after {
  content: '▼';
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: var(--transition);
}

.accordion.open .accordion-header::after {
  transform: rotate(180deg);
}

.accordion-content {
  display: none;
  padding: 20px;
  background-color: var(--bg-main);
  border-top: 1px solid var(--border);
}

.accordion.open .accordion-content {
  display: block;
}

/* Mermaid Diagrams styling */
.mermaid-container {
  background-color: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  margin: 24px 0;
  overflow-x: auto;
  display: flex;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  position: relative;
  cursor: zoom-in;
  transition: var(--transition);
}

.mermaid-container:hover {
  border-color: var(--primary);
  background-color: rgba(15, 118, 110, 0.02);
  box-shadow: var(--shadow-md);
}

.mermaid {
  background-color: transparent !important;
  width: 100%;
}

.mermaid svg {
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
}

/* Enlarge Badge */
.mermaid-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background-color: rgba(15, 118, 110, 0.9);
  color: #ffffff;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 20px;
  pointer-events: none;
  opacity: 0;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 4px;
}

html[dir="rtl"] .mermaid-badge {
  right: auto;
  left: 12px;
}

.mermaid-container:hover .mermaid-badge {
  opacity: 1;
}

/* Modal Overlay */
.diagram-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 40px;
  cursor: zoom-out;
  animation: fadeIn 0.2s ease-out;
}

.diagram-modal.open {
  display: flex;
}

.diagram-modal-content {
  background-color: var(--bg-main);
  border-radius: var(--radius-md);
  padding: 32px;
  width: 90vw;
  max-height: 90vh;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  cursor: default;
  position: relative;
  animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.diagram-modal-content svg {
  width: 100% !important;
  max-width: 100% !important;
  max-height: 75vh;
  height: auto !important;
}

.diagram-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 1.75rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  transition: var(--transition);
}

html[dir="rtl"] .diagram-modal-close {
  right: auto;
  left: 12px;
}

.diagram-modal-close:hover {
  color: var(--primary);
  transform: rotate(90deg);
}

/* Code Snippets */
pre, code {
  font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
  font-size: 0.9rem;
}

code {
  background-color: var(--bg-alt);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
}

pre {
  background-color: #1e293b;
  color: #f8fafc;
  padding: 16px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: 24px;
}

pre code {
  background: none;
  color: inherit;
  padding: 0;
}

/* Footer */
.footer {
  margin-top: 48px;
  border-top: 1px solid var(--border);
  padding-top: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Responsive Overrides */
@media (max-width: 768px) {
  .mobile-menu-btn {
    display: block;
  }
  
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-md);
  }
  
  html[dir="rtl"] .sidebar {
    transform: translateX(100%);
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 24px 16px;
  }
}

/* Image Zoom Lightbox Styles */
.main-content img:not(.logo-img):not(.nav-logo) {
  cursor: zoom-in;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
}

.main-content img:not(.logo-img):not(.nav-logo):hover {
  transform: scale(1.015);
  box-shadow: var(--shadow-md);
}

