/* Fintech-style app shell — RTL sidebar layout */

.app-layout {
  display: flex;
  min-height: 100vh;
  background: #f1f5f9;
  direction: rtl;
}

.app-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: #ffffff;
  border-left: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1040;
  transition: transform 0.25s ease;
  box-shadow: -2px 0 12px rgba(15, 23, 42, 0.04);
}

.app-sidebar-brand {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid #f1f5f9;
}

.app-sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: #1e293b;
}

.app-sidebar-brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.1rem;
}

.app-sidebar-brand-text h1 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.3;
}

.app-sidebar-brand-text span {
  font-size: 0.75rem;
  color: #64748b;
}

.app-sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
}

.app-sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.25rem;
  border-radius: 10px;
  color: #475569;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.app-sidebar-link i {
  width: 20px;
  text-align: center;
  font-size: 0.95rem;
  opacity: 0.85;
}

.app-sidebar-link:hover {
  background: #f8fafc;
  color: #6366f1;
}

.app-sidebar-link.active {
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

.app-sidebar-link.active i {
  opacity: 1;
}

.app-sidebar-footer {
  padding: 1rem;
  border-top: 1px solid #f1f5f9;
}

.app-main {
  flex: 1;
  margin-right: 260px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-topbar {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 1030;
}

.app-topbar-start {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.app-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: #94a3b8;
  margin: 0;
  padding: 0;
  list-style: none;
  flex-wrap: wrap;
}

.app-breadcrumb li + li::before {
  content: "/";
  margin-left: 0.35rem;
  color: #cbd5e1;
}

.app-breadcrumb a {
  color: #64748b;
  text-decoration: none;
}

.app-breadcrumb a:hover {
  color: #6366f1;
}

.app-page-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
}

.app-topbar-center {
  flex: 1;
  max-width: 420px;
  min-width: 180px;
}

.app-search-form {
  position: relative;
}

.app-search-input {
  width: 100%;
  padding: 0.55rem 2.5rem 0.55rem 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
  font-size: 0.875rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.app-search-input:focus {
  outline: none;
  border-color: #a5b4fc;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
  background: #fff;
}

.app-search-icon {
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
}

.app-topbar-end {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.app-user-chip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.35rem 0.65rem;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

.app-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.85rem;
  overflow: hidden;
  flex-shrink: 0;
}

.app-user-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

.app-user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1e293b;
  line-height: 1.2;
}

.app-user-role {
  font-size: 0.72rem;
  color: #64748b;
}

.app-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  position: relative;
  transition: all 0.15s ease;
}

.app-icon-btn:hover {
  background: #f8fafc;
  color: #6366f1;
  border-color: #c7d2fe;
}

.app-icon-btn .notification-badge {
  position: absolute;
  top: -4px;
  left: -4px;
}

.app-content {
  flex: 1;
  padding: 1.25rem 1.5rem 2rem;
  overflow-x: hidden;
}

.app-sidebar-toggle {
  display: none;
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  color: #475569;
}

.app-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 1035;
}

/* KPI cards */
.dashboard-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.dashboard-kpi-card {
  background: #fff;
  border-radius: 16px;
  padding: 1.15rem 1.25rem;
  border: 1px solid #f1f5f9;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.dashboard-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
  color: inherit;
}

.dashboard-kpi-card--inactive {
  opacity: 0.72;
}

.dashboard-kpi-card--inactive .dashboard-kpi-value {
  color: #94a3b8;
  font-size: 1.35rem;
}

.dashboard-kpi-label {
  font-size: 0.82rem;
  color: #64748b;
  margin-bottom: 0.35rem;
}

.dashboard-kpi-value {
  font-size: 1.65rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.2;
}

.dashboard-kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 0.35rem;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
}

.dashboard-kpi-trend.up {
  color: #059669;
  background: #ecfdf5;
}

.dashboard-kpi-trend.down {
  color: #dc2626;
  background: #fef2f2;
}

.dashboard-kpi-trend.neutral {
  color: #64748b;
  background: #f1f5f9;
}

.dashboard-kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.dashboard-kpi-icon.blue { background: #eff6ff; color: #2563eb; }
.dashboard-kpi-icon.green { background: #ecfdf5; color: #059669; }
.dashboard-kpi-icon.purple { background: #f5f3ff; color: #7c3aed; }
.dashboard-kpi-icon.orange { background: #fff7ed; color: #ea580c; }
.dashboard-kpi-icon.red { background: #fef2f2; color: #dc2626; }
.dashboard-kpi-icon.teal { background: #f0fdfa; color: #0d9488; }

/* Chart cards */
.dashboard-charts-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.dashboard-panel {
  background: #fff;
  border-radius: 16px;
  border: 1px solid #f1f5f9;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  overflow: hidden;
}

.dashboard-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #f1f5f9;
}

.dashboard-panel-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
}

.dashboard-panel-body {
  padding: 1rem 1.25rem 1.25rem;
}

.dashboard-period-select {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  background: #fff;
  color: #475569;
}

.dashboard-donut-wrap {
  position: relative;
  max-width: 220px;
  margin: 0 auto;
}

.dashboard-donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.dashboard-donut-center strong {
  font-size: 1.1rem;
  color: #1e293b;
}

.dashboard-donut-center span {
  font-size: 0.72rem;
  color: #94a3b8;
}

.dashboard-contract-countdown {
  text-align: center;
}

.dashboard-countdown-labels {
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.dashboard-countdown-value {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f766e;
  letter-spacing: 0.06em;
  direction: ltr;
  unicode-bidi: isolate;
}

/* Recent table */
.dashboard-recent-table {
  width: 100%;
  border-collapse: collapse;
}

.dashboard-recent-table th {
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #f1f5f9;
  text-align: right;
}

.dashboard-recent-table td {
  font-size: 0.85rem;
  color: #334155;
  padding: 0.75rem;
  border-bottom: 1px solid #f8fafc;
  vertical-align: middle;
}

.dashboard-recent-table tr:hover td {
  background: #f8fafc;
}

.status-pill {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.status-pill.success { background: #ecfdf5; color: #059669; }
.status-pill.warning { background: #fffbeb; color: #d97706; }
.status-pill.danger { background: #fef2f2; color: #dc2626; }
.status-pill.info { background: #eff6ff; color: #2563eb; }
.status-pill.muted { background: #f1f5f9; color: #64748b; }

.btn-details {
  font-size: 0.78rem;
  padding: 0.25rem 0.65rem;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #475569;
  text-decoration: none;
}

.btn-details:hover {
  background: #6366f1;
  border-color: #6366f1;
  color: #fff;
}

.dashboard-action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.dashboard-action-card {
  background: #fff;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  padding: 1.25rem;
  text-align: center;
  text-decoration: none;
  color: inherit;
  transition: all 0.15s ease;
}

.dashboard-action-card:hover {
  border-color: #a5b4fc;
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.12);
  transform: translateY(-2px);
  color: inherit;
}

.dashboard-action-card i {
  font-size: 1.75rem;
  color: #6366f1;
  margin-bottom: 0.65rem;
}

.dashboard-action-card h5 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.dashboard-action-card p {
  font-size: 0.8rem;
  color: #64748b;
  margin: 0;
}

/* Hide legacy navbar when shell active */
body.app-shell-active .navbar-enhanced,
body.app-shell-active .simple-footer {
  display: none !important;
}

body.app-shell-active .page-wrapper {
  min-height: 100vh;
}

body.app-shell-active main.container {
  padding: 0 !important;
  max-width: none !important;
}

.dashboard-donut-center span {
  font-size: 0.75rem;
  color: #64748b;
}

/* Case pipeline timeline (candidate dashboard) */
.dashboard-panel-body--timeline {
  padding-top: 0.75rem;
  padding-bottom: 1rem;
}

.case-pipeline {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.25rem;
}

.case-pipeline-track {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  min-width: max-content;
  gap: 0;
  padding: 0.25rem 0.25rem 0;
}

.case-pipeline-step {
  position: relative;
  flex: 0 0 7.5rem;
  max-width: 7.5rem;
  text-align: center;
  padding: 0 0.15rem;
}

.case-pipeline-node-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  height: 1.5rem;
  margin-bottom: 0.5rem;
}

.case-pipeline-node {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  background: #fff;
  position: relative;
  z-index: 2;
  flex-shrink: 0;
}

.case-pipeline-segment {
  position: absolute;
  top: 50%;
  left: calc(50% + 0.45rem);
  right: calc(-50% + 0.45rem);
  height: 2px;
  background: #e2e8f0;
  transform: translateY(-50%);
  z-index: 1;
}

.case-pipeline-label {
  font-size: 0.68rem;
  line-height: 1.35;
  color: #64748b;
  min-height: 2.6rem;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  text-wrap: balance;
}

.case-pipeline-date {
  font-size: 0.65rem;
  color: #94a3b8;
  margin-top: 0.15rem;
  direction: ltr;
  unicode-bidi: plaintext;
}

.case-pipeline-step.is-completed .case-pipeline-node {
  border-color: #14b8a6;
  background: #14b8a6;
}

.case-pipeline-step.is-completed .case-pipeline-segment {
  background: #14b8a6;
}

.case-pipeline-step.is-completed .case-pipeline-label {
  color: #0f766e;
  font-weight: 500;
}

.case-pipeline-step.is-completed .case-pipeline-date {
  color: #475569;
}

.case-pipeline-step.is-current .case-pipeline-node {
  width: 1rem;
  height: 1rem;
  border-color: #3b82f6;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.case-pipeline-step.is-current .case-pipeline-label {
  color: #1d4ed8;
  font-weight: 600;
}

.case-pipeline-step.is-current .case-pipeline-date {
  color: #2563eb;
  font-weight: 500;
}

.case-pipeline-step.is-pending .case-pipeline-node {
  border-color: #e2e8f0;
  background: #f8fafc;
}

.case-pipeline-step.is-pending .case-pipeline-label {
  color: #cbd5e1;
}

@media (max-width: 1200px) {
  .dashboard-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .dashboard-charts-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 992px) {
  .app-sidebar {
    transform: translateX(100%);
  }
  .app-sidebar.open {
    transform: translateX(0);
  }
  .app-sidebar-overlay.open {
    display: block;
  }
  .app-main {
    margin-right: 0;
  }
  .app-sidebar-toggle {
    display: inline-flex;
  }
  .app-user-details-text {
    display: none;
  }
}

@media (max-width: 576px) {
  .dashboard-kpi-grid {
    grid-template-columns: 1fr;
  }
  .app-content {
    padding: 1rem;
  }
  .app-topbar-center {
    order: 3;
    flex: 1 1 100%;
    max-width: none;
  }
}
