@import url('https://fonts.googleapis.com/css2?family=Readex+Pro:wght@200..700&display=swap');
:root {
  --primary-purple: #6F1283;
  --primary-teal: #006E7F;
  --cyan: #45C3E9;
  --bg-color: #F4F8F9;
  --text-dark: #333333;
  --text-light: #777777;
  --white: #FFFFFF;
  --error: #E53E3E;
  --border-radius-lg: 24px;
  --border-radius-md: 12px;
  --border-radius-sm: 8px;
  --transition: all 0.3s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Readex Pro', system-ui, sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* =========================================
   Login Page Styles
========================================= */
.login-page {
  justify-content: center;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.bg-shape {
  position: absolute;
  z-index: 0;
  border-radius: 50%;
  opacity: 0.1;
}

.shape-1 {
  width: 700px;
  height: 700px;
  background: linear-gradient(135deg, var(--primary-purple) 0%, rgba(111, 18, 131,0.3) 100%);
  top: -250px;
  right: -250px;
  filter: blur(40px);
  opacity: 0.5;
}

.shape-2 {
  width: 500px;
  height: 500px;
  background: linear-gradient(135deg, var(--primary-teal) 0%, rgba(0, 110, 127,0.3) 100%);
  bottom: -150px;
  left: -150px;
  filter: blur(40px);
  opacity: 0.5;
}

.login-wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  padding: 2rem;
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2rem;
  gap: 1rem;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.logo-main {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-purple);
}

.logo-sub {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--primary-teal);
}

.brand-logo {
  height: 60px;
  width: auto;
  object-fit: contain;
}

.login-card {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--border-radius-lg);
  padding: 3rem 2rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.login-card-header {
  text-align: center;
  margin-bottom: 2.5rem;
}

.login-card-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary-purple);
  margin-bottom: 0.5rem;
}

.login-card-header p {
  color: var(--text-light);
  font-size: 0.95rem;
}

.input-group {
  margin-bottom: 1.5rem;
}

.input-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--primary-purple);
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  right: 1rem;
  color: var(--text-light);
  display: flex;
}

.input-wrap input {
  width: 100%;
  /* Padding: top right bottom left */
  padding: 1rem 3rem 1rem 1rem; 
  border: 2px solid #E2E8F0;
  border-radius: var(--border-radius-md);
  font-size: 1rem;
  transition: var(--transition);
  background-color: #F8FAFC;
}

#password {
  padding-left: 3rem; /* Extra padding on the left for the eye icon */
}

.input-wrap input:focus {
  outline: none;
  border-color: var(--primary-teal);
  background-color: var(--white);
}

.toggle-pass {
  position: absolute;
  left: 1rem;
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  display: flex;
  padding: 0.2rem;
}

.toggle-pass:hover {
  color: var(--primary-teal);
}

.error-msg {
  background-color: #FEF2F2;
  color: var(--error);
  padding: 0.75rem 1rem;
  border-radius: var(--border-radius-md);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid #FECACA;
}

.btn-login {
  width: 100%;
  padding: 1rem;
  background-color: var(--primary-purple);
  color: var(--white);
  border: none;
  border-radius: var(--border-radius-md);
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: var(--transition);
  margin-top: 1rem;
}

.btn-login:hover {
  background-color: #2c2559;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(111, 18, 131, 0.2);
}

.btn-login.loading {
  background-color: #a09dc4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

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

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

.shake {
  animation: shake 0.5s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.login-footer-note {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.login-version {
  text-align: center;
  margin-top: 2rem;
  color: var(--text-light);
  font-size: 0.8rem;
}

/* =========================================
   Dashboard Styles
========================================= */
.dashboard-header {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.3);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.avatar {
  width: 40px;
  height: 40px;
  background-color: var(--primary-teal);
  color: var(--white);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.2rem;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--primary-purple);
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-light);
}

.btn-logout {
  background: none;
  border: 1px solid #E2E8F0;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-sm);
  color: var(--error);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
}

.btn-logout:hover {
  background-color: #FEF2F2;
  border-color: #FECACA;
}

.btn-manage-users {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  background: linear-gradient(135deg, var(--primary-purple) 0%, #470C54 100%);
  color: var(--white);
  border-radius: var(--border-radius-sm);
  font-weight: 700;
  font-size: 0.88rem;
  text-decoration: none;
  border: none;
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(111, 18, 131, 0.2);
}
.btn-manage-users:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(111, 18, 131, 0.35);
}

/* Welcome greeting banner — "أهلًا {name} · {jobTitle}" */
.welcome-greeting {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  background: linear-gradient(135deg, rgba(111, 18, 131, 0.08) 0%, rgba(0, 110, 127, 0.08) 100%);
  border: 1px solid rgba(111, 18, 131, 0.12);
  border-radius: var(--border-radius-md);
  padding: 0.85rem 1.25rem;
  margin: 0 0 1.25rem;
  font-size: 1.05rem;
}
.welcome-greeting .greet-hello {
  font-weight: 700;
  color: var(--primary-purple);
}
.welcome-greeting .greet-name {
  font-weight: 800;
  color: var(--text-dark);
}
.welcome-greeting .greet-sep {
  color: var(--text-light);
  margin: 0 0.25rem;
}
.welcome-greeting .greet-job {
  color: var(--primary-teal);
  font-weight: 600;
  font-size: 0.95rem;
}

.dashboard-main {
  padding: 3rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.dashboard-title-area {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.welcome-section {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 2rem 2.5rem;
  border-radius: var(--border-radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
  margin-bottom: 4rem;
  color: #4A5568;
  line-height: 1.8;
  font-size: 1.1rem;
}

.welcome-section p {
  margin-bottom: 1rem;
}

.welcome-section p:last-child {
  margin-bottom: 0;
}

.welcome-section strong {
  color: var(--primary-purple);
  font-weight: 700;
}

.welcome-section .highlight {
  color: var(--primary-teal);
  font-weight: 700;
  font-size: 1.15rem;
  margin-top: 1.5rem;
}

.dashboard-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary-purple);
}

/* Cortex hero logo — centered on the dashboard */
.dashboard-title-area.cortex-hero {
  justify-content: center;
}
.cortex-hero .dashboard-title { margin: 0; text-align: center; }
.cortex-hero-logo {
  display: block;
  margin: 0.5rem auto 0;
  width: min(460px, 78%);
  height: auto;
}

.title-line-container {
  flex-grow: 1;
  display: flex;
  align-items: center;
  margin-right: 2rem;
}

.title-line {
  height: 2px;
  background-color: #E2E8F0;
  flex-grow: 1;
  margin-left: 1rem;
}

.title-dots {
  display: flex;
  gap: 0.2rem;
}

.dot {
  width: 8px;
  height: 8px;
  background-color: var(--primary-purple);
}
.dot:nth-child(2) { background-color: var(--primary-teal); }
.dot:nth-child(3) { background-color: var(--primary-purple); }

.cards-container {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.project-card {
  width: 250px;
  min-height: 380px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 2px solid var(--primary-teal);
  border-radius: 40px;
  border-bottom-left-radius: 125px; /* Perfect half circle for 250px width */
  border-bottom-right-radius: 125px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  position: relative;
  text-decoration: none;
  transition: var(--transition);
  padding: 2.5rem 1.5rem 4rem 1.5rem;
  text-align: center;
}

.project-card:hover {
  transform: translateY(-10px);
  box-shadow: 0 20px 30px rgba(0, 110, 127, 0.15);
}

.card-title {
  color: var(--primary-teal);
  font-weight: 700;
  font-size: 1.25rem;
  line-height: 1.4;
  margin-top: 0;
  margin-bottom: 1rem;
  min-height: 4rem; /* Fixed min-height so descriptions align properly */
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-desc {
  font-size: 0.95rem;
  color: #4A5568;
  line-height: 1.6;
  margin: 0;
  font-weight: 600;
}

.card-icon-wrapper {
  position: absolute;
  bottom: -20px;
  width: 80px;
  height: 80px;
  background-color: var(--primary-purple);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-teal);
  border: 4px solid var(--white);
  transition: var(--transition);
}

.project-card:hover .card-icon-wrapper {
  transform: scale(1.15) rotate(5deg);
  background-color: var(--primary-teal);
  color: var(--white);
  box-shadow: 0 0 20px rgba(0, 110, 127, 0.4);
}

/* Specific adjustments for smaller screens */
@media (max-width: 1200px) {
  .cards-container {
    gap: 1rem;
  }
  .project-card {
    width: 180px;
    height: 280px;
  }
  .card-title {
    font-size: 1rem;
  }
}

@media (max-width: 768px) {
  .cards-container {
    justify-content: center;
  }
  .project-card {
    margin-bottom: 2rem;
  }
  .dashboard-header {
    flex-direction: column;
    gap: 1rem;
  }
}

.dashboard-footer {
  text-align: center;
  padding: 1.5rem 2rem;
  margin-top: auto;
  color: var(--white);
  font-size: 0.95rem;
  background-color: var(--primary-purple);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
}
/* =========================================
   Tool Page Styles
========================================= */
.tool-page-body {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tool-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  background-color: #f0f2f5;
}

.tool-sidebar {
  width: 300px;
  background: var(--white);
  border-left: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  transition: var(--transition);
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid #eee;
}

.btn-back {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary-purple);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  transition: var(--transition);
}

.btn-back:hover {
  transform: translateX(5px);
}

.sidebar-title {
  font-size: 1.1rem;
  color: var(--text-dark);
  font-weight: 700;
}

.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.menu-item {
  padding: 0.75rem 1rem;
  border-radius: var(--border-radius-md);
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #4a5568;
  font-weight: 600;
  font-size: 0.9rem;
}

.menu-item:hover, .menu-item.active {
  background-color: rgba(0, 110, 127, 0.1);
  color: var(--primary-teal);
}

.tool-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-color);
  position: relative;
}

.tool-top-bar {
  padding: 1rem 2rem;
  background: var(--white);
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tool-info h2 {
  font-size: 1.25rem;
  color: var(--primary-purple);
}

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.message {
  max-width: 80%;
  padding: 1rem 1.5rem;
  border-radius: 20px;
  line-height: 1.6;
  font-size: 0.95rem;
  position: relative;
}

.message.bot {
  align-self: flex-start;
  background-color: var(--white);
  color: var(--text-dark);
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.message.user {
  align-self: flex-end;
  background-color: var(--primary-purple);
  color: var(--white);
  border-bottom-left-radius: 4px;
}

.input-area {
  padding: 1.5rem 2rem;
  background: var(--white);
  border-top: 1px solid #eee;
}

.chat-input-wrap {
  display: flex;
  gap: 1rem;
  max-width: 1000px;
  margin: 0 auto;
}

.chat-input-wrap input {
  flex: 1;
  padding: 1rem 1.5rem;
  border: 2px solid #e2e8f0;
  border-radius: 30px;
  font-size: 1rem;
  outline: none;
  transition: var(--transition);
}

.chat-input-wrap input:focus {
  border-color: var(--primary-teal);
}

.btn-send {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: var(--primary-teal);
  color: var(--white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-send:hover {
  transform: scale(1.1);
  background-color: #3ca388;
}

/* Upload Area (for OCR / BD Assistant) */
.upload-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.upload-box {
  width: 100%;
  max-width: 600px;
  background: var(--white);
  border: 2px dashed var(--primary-teal);
  border-radius: var(--border-radius-lg);
  padding: 4rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.upload-box:hover {
  background-color: rgba(0, 110, 127, 0.05);
}

.upload-icon {
  margin-bottom: 1.5rem;
  color: var(--primary-teal);
}

.upload-text h3 {
  color: var(--primary-purple);
  margin-bottom: 0.5rem;
}

.upload-text p {
  color: var(--text-light);
}

@media (max-width: 768px) {
  .tool-sidebar {
    position: absolute;
    right: -300px;
    z-index: 1000;
    height: 100%;
  }
  .tool-sidebar.open {
    right: 0;
  }
}

.project-card.coming-soon {
  filter: grayscale(0.8);
  opacity: 0.7;
  cursor: default;
  border-color: #cbd5e0;
}

.project-card.coming-soon:hover {
  transform: none;
  box-shadow: none;
}

.badge-soon {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  background-color: #718096;
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  z-index: 10;
}

/* Cortex logo beside صَرح logo in headers */
.cortex-mark{height:72px;width:auto;vertical-align:middle;margin-inline-start:14px;padding-inline-start:16px;border-inline-start:2px solid rgba(0,28,32,0.15);}

/* =====================================================================
   LTR overrides — applied when the i18n engine switches the UI to English
   (sets <html dir="ltr">). These mirror the direction-specific rules above;
   everything else relies on flexbox / logical properties, which auto-flip.
   ===================================================================== */
html[dir="ltr"] body { text-align: left; }

/* Login inputs: icon and eye-toggle swap sides */
html[dir="ltr"] .input-icon { left: 1rem; right: auto; }
html[dir="ltr"] .input-wrap input { padding: 1rem 1rem 1rem 3rem; }
html[dir="ltr"] #password { padding-left: 3rem; padding-right: 3rem; }
html[dir="ltr"] .toggle-pass { right: 1rem; left: auto; }

/* "Upcoming Projects" title divider */
html[dir="ltr"] .title-line-container { margin-left: 2rem; margin-right: 0; }
html[dir="ltr"] .title-line { margin-right: 1rem; margin-left: 0; }

/* Tool sidebar divider moves to the right edge */
html[dir="ltr"] .tool-sidebar { border-left: none; border-right: 1px solid #e0e0e0; }

/* "Soon" badge corner */
html[dir="ltr"] .badge-soon { right: 1.5rem; left: auto; }
