/* 
   Shadcn Neutral Design Tokens & CSS Utilities
   Clean, crisp, readable Light Neutral aesthetic across public portal and admin dashboard
*/

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Noto+Sans+Arabic:wght@400;500;600;700&display=swap');

:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 240 10% 3.9%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 240 5.9% 10%;
  --radius: 0.5rem;
}

* {
  border-color: hsl(var(--border));
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

[dir="rtl"] * {
  font-family: 'Noto Sans Arabic', 'Inter', sans-serif;
}

body {
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: hsl(var(--background));
}
::-webkit-scrollbar-thumb {
  background: hsl(var(--muted-foreground) / 0.3);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--muted-foreground) / 0.5);
}

/* Glassmorphism Header */
.glass-header {
  background-color: hsl(var(--background) / 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid hsl(var(--border));
}

/* Card Surface */
.shadcn-card {
  background-color: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.2s ease;
}

.shadcn-card:hover {
  border-color: hsl(var(--ring) / 0.4);
}

/* Buttons */
.btn-shadcn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  transition: all 0.15s ease;
  cursor: pointer;
}

.btn-primary {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}
.btn-primary:hover {
  opacity: 0.9;
}

.btn-outline {
  border: 1px solid hsl(var(--border));
  background-color: transparent;
  color: hsl(var(--foreground));
}
.btn-outline:hover {
  background-color: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

.btn-ghost {
  background-color: transparent;
  color: hsl(var(--foreground));
}
.btn-ghost:hover {
  background-color: hsl(var(--accent));
  color: hsl(var(--accent-foreground));
}

/* Badges */
.badge-shadcn {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  border: 1px solid hsl(var(--border));
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  transition: colors 0.15s ease;
}

.badge-primary {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.badge-secondary {
  background-color: hsl(var(--secondary));
  color: hsl(var(--secondary-foreground));
}

.badge-outline {
  border-color: hsl(var(--border));
  color: hsl(var(--foreground));
}

/* Form Controls */
.input-shadcn {
  display: flex;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid hsl(var(--input));
  background-color: hsl(var(--background));
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-shadcn:focus {
  outline: none;
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

/* Article Prose & CKEditor Typography Engine */
.article-prose,
.ck-content {
  font-size: 1rem;
  line-height: 1.7;
  color: hsl(var(--foreground));
}

.article-prose p,
.ck-content p {
  margin-bottom: 1.25rem;
}

.article-prose h1,
.ck-content h1 {
  font-size: 1.875rem;
  font-weight: 800;
  margin-top: 2rem;
  margin-bottom: 1rem;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.article-prose h2,
.ck-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 1.75rem;
  margin-bottom: 0.875rem;
  line-height: 1.35;
  letter-spacing: -0.015em;
}

.article-prose h3,
.ck-content h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.article-prose h4,
.ck-content h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

/* Unordered & Ordered Lists */
.article-prose ul,
.ck-content ul {
  list-style-type: disc !important;
  padding-left: 1.5rem !important;
  margin-bottom: 1.25rem !important;
}

.article-prose ol,
.ck-content ol {
  list-style-type: decimal !important;
  padding-left: 1.5rem !important;
  margin-bottom: 1.25rem !important;
}

.article-prose li,
.ck-content li {
  margin-bottom: 0.35rem !important;
}

/* Blockquotes */
.article-prose blockquote,
.ck-content blockquote {
  border-left: 4px solid hsl(var(--primary)) !important;
  padding: 0.75rem 1.25rem !important;
  font-style: italic !important;
  background-color: hsl(var(--muted) / 0.5) !important;
  border-radius: 0 0.5rem 0.5rem 0 !important;
  color: hsl(var(--muted-foreground)) !important;
  margin: 1.5rem 0 !important;
}

/* CKEditor Tables & Full 4-Sided Grid Border Styles */
.article-prose figure.table,
.ck-content figure.table {
  width: 100% !important;
  margin: 1.5rem 0 !important;
  overflow-x: auto !important;
}

.article-prose table,
.ck-content table,
.article-prose figure.table table,
.ck-content figure.table table {
  width: 100% !important;
  border-collapse: collapse !important;
  border-spacing: 0 !important;
  margin: 1.5rem 0 !important;
  border: 1px solid #9ca3af !important; /* Solid outer 4-sided table border */
  border-left: 1px solid #9ca3af !important;
  border-right: 1px solid #9ca3af !important;
  border-top: 1px solid #9ca3af !important;
  border-bottom: 1px solid #9ca3af !important;
}

.article-prose th,
.ck-content th,
.article-prose figure.table th,
.ck-content figure.table th {
  background-color: #f3f4f6 !important;
  color: #111827 !important;
  font-weight: 700 !important;
  padding: 0.75rem 1rem !important;
  border: 1px solid #9ca3af !important; /* Full 4-sided header cell borders */
  border-left: 1px solid #9ca3af !important;
  border-right: 1px solid #9ca3af !important;
  border-top: 1px solid #9ca3af !important;
  border-bottom: 1px solid #9ca3af !important;
  text-align: left !important;
}

.article-prose td,
.ck-content td,
.article-prose figure.table td,
.ck-content figure.table td {
  padding: 0.75rem 1rem !important;
  border: 1px solid #9ca3af !important; /* Full 4-sided data cell borders */
  border-left: 1px solid #9ca3af !important;
  border-right: 1px solid #9ca3af !important;
  border-top: 1px solid #9ca3af !important;
  border-bottom: 1px solid #9ca3af !important;
  color: var(--foreground);
  vertical-align: top !important;
}

/* Inline Styles & Typography Preservation (Font Weight, Size, Colors, Alignment) */
.article-prose strong,
.ck-content strong,
.article-prose b,
.ck-content b {
  font-weight: 700 !important;
}

.article-prose em,
.ck-content em,
.article-prose i,
.ck-content i {
  font-style: italic !important;
}

.article-prose u,
.ck-content u {
  text-decoration: underline !important;
}

.article-prose s,
.ck-content s,
.article-prose strike,
.ck-content strike {
  text-decoration: line-through !important;
}

/* Font Size Utility Classes */
.article-prose .text-tiny,
.ck-content .text-tiny { font-size: 0.75em !important; }
.article-prose .text-small,
.ck-content .text-small { font-size: 0.875em !important; }
.article-prose .text-big,
.ck-content .text-big { font-size: 1.25em !important; }
.article-prose .text-huge,
.ck-content .text-huge { font-size: 1.75em !important; }

/* Text Alignments */
.article-prose .text-left,
.ck-content .text-left { text-align: left !important; }
.article-prose .text-center,
.ck-content .text-center { text-align: center !important; }
.article-prose .text-right,
.ck-content .text-right { text-align: right !important; }
.article-prose .text-justify,
.ck-content .text-justify { text-align: justify !important; }

.article-prose tr:nth-child(even),
.ck-content tr:nth-child(even) {
  background-color: #f9fafb !important;
}

/* Medium-Style Code Block & Inline Code */
.article-prose pre,
.ck-content pre {
  background-color: #1e1e2e !important;
  color: #cdd6f4 !important;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.875rem;
  line-height: 1.6;
  padding: 1.25rem 1.5rem;
  border-radius: 0.75rem;
  overflow-x: auto;
  margin: 1.75rem 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.article-prose pre code,
.ck-content pre code {
  background: transparent !important;
  color: inherit !important;
  padding: 0 !important;
  font-size: inherit !important;
  border: none !important;
  box-shadow: none !important;
}

.article-prose code,
.ck-content code {
  background-color: hsl(var(--muted));
  color: hsl(var(--foreground));
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.85em;
  padding: 0.2rem 0.4rem;
  border-radius: 0.25rem;
  border: 1px solid hsl(var(--border));
}

[dir="rtl"] .article-prose blockquote,
[dir="rtl"] .ck-content blockquote {
  border-left: none !important;
  border-right: 4px solid hsl(var(--primary)) !important;
  padding-left: 0 !important;
  padding-right: 1.25rem !important;
}

/* Reading Progress Bar */
#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, hsl(var(--primary)), hsl(var(--ring)));
  z-index: 100;
  width: 0%;
  transition: width 0.1s linear;
}

/* Search Modal Overlay */
.search-modal {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 999;
  align-items: flex-start;
  justify-content: center;
  padding-top: 5rem;
}

.search-modal.active {
  display: flex;
}
