/* PersalOne Business — Shared Components */

/* ─── APP LAYOUT ─────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  min-height: 100vh;
  min-width: 1024px;
}

/* ─── SIDEBAR ────────────────────────────────────────────────── */
.sidebar {
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  background: var(--ps-white);
  border-right: 1px solid var(--ps-grey-100);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-header {
  padding: var(--sp-5) var(--sp-5);
  border-bottom: 1px solid var(--ps-grey-100);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  text-decoration: none;
}

.logo-img {
  height: 32px;
  width: auto;
  flex-shrink: 0;
}

.wordmark {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.wm-main {
  font-size: var(--text-lg);
  font-weight: var(--fw-bold);
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.wm-p, .wm-o { color: var(--ps-ocre); }
.wm-ersal, .wm-ne { color: var(--ps-green); }

.wm-business {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--ps-navy);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
  opacity: 0.7;
}

.sidebar-nav {
  flex: 1;
  padding: var(--sp-3) var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-section-label {
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--ps-grey-300);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: var(--sp-4) var(--sp-3) var(--sp-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  font-size: var(--text-base);
  font-weight: var(--fw-medium);
  color: var(--ps-grey-700);
  transition: background var(--t-fast), color var(--t-fast);
  border-left: 3px solid transparent;
  text-decoration: none;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity var(--t-fast);
}

.nav-item:hover {
  background: var(--ps-bg);
  color: var(--ps-green);
}

.nav-item:hover svg { opacity: 1; }

.nav-item.active {
  background: var(--ps-bg);
  color: var(--ps-green);
  border-left-color: var(--ps-green);
  font-weight: var(--fw-semibold);
}

.nav-item.active svg { opacity: 1; }

.sidebar-footer {
  padding: var(--sp-4) var(--sp-4);
  border-top: 1px solid var(--ps-grey-100);
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--r-full);
  background: var(--ps-green);
  color: white;
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--ps-navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: var(--text-xs);
  color: var(--ps-grey-300);
  font-weight: var(--fw-medium);
}

/* ─── TOPBAR ─────────────────────────────────────────────────── */
.topbar {
  grid-column: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-6);
  padding: 0 var(--sp-8);
  background: var(--ps-white);
  border-bottom: 1px solid var(--ps-grey-100);
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--topbar-h);
}

.topbar-search {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  background: var(--ps-bg);
  border: 1px solid var(--ps-grey-100);
  border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-4);
  width: 320px;
  transition: border-color var(--t-base);
}

.topbar-search:focus-within {
  border-color: var(--ps-green);
  background: var(--ps-white);
}

.topbar-search svg {
  width: 16px;
  height: 16px;
  color: var(--ps-grey-300);
  flex-shrink: 0;
}

.topbar-search input {
  border: none;
  background: transparent;
  font-size: var(--text-sm);
  color: var(--ps-grey-700);
  outline: none;
  width: 100%;
}

.topbar-search input::placeholder { color: var(--ps-grey-300); }

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.topbar-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ps-grey-700);
  transition: background var(--t-fast);
}

.topbar-btn:hover { background: var(--ps-bg); }

.topbar-btn svg { width: 20px; height: 20px; }

.topbar-btn .notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 16px;
  height: 16px;
  background: var(--ps-danger);
  color: white;
  font-size: 9px;
  font-weight: var(--fw-bold);
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--ps-white);
}

.topbar-company {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--ps-grey-700);
  padding: var(--sp-2) var(--sp-3);
  background: var(--ps-bg);
  border-radius: var(--r-md);
  border: 1px solid var(--ps-grey-100);
}

.topbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--r-full);
  background: var(--ps-green);
  color: white;
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid var(--ps-grey-100);
  transition: border-color var(--t-fast);
}

.topbar-avatar:hover { border-color: var(--ps-green); }

/* ─── MAIN CONTENT ───────────────────────────────────────────── */
.main {
  grid-column: 2;
  padding: var(--sp-8);
  overflow-y: auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-6);
}

.page-title {
  font-size: var(--text-2xl);
  font-weight: var(--fw-bold);
  color: var(--ps-navy);
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--ps-grey-300);
  margin-top: 2px;
}

/* ─── CARDS ──────────────────────────────────────────────────── */
.card {
  background: var(--ps-white);
  border: 1px solid var(--ps-grey-100);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
  box-shadow: var(--shadow-xs);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
}

.card-title {
  font-size: var(--text-base);
  font-weight: var(--fw-semibold);
  color: var(--ps-navy);
}

.card-label {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--ps-grey-300);
  letter-spacing: 0.01em;
}

/* ─── KPI CARDS ──────────────────────────────────────────────── */
.kpi-card {
  background: var(--ps-white);
  border: 1px solid var(--ps-grey-100);
  border-radius: var(--r-lg);
  padding: var(--sp-5) var(--sp-6);
  box-shadow: var(--shadow-xs);
  animation: fade-up 0.4s ease both;
}

.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--sp-4);
}

.kpi-icon svg { width: 20px; height: 20px; }

.kpi-icon.green { background: var(--ps-green-08); color: var(--ps-green); }
.kpi-icon.warning { background: var(--ps-warning-bg); color: var(--ps-warning); }
.kpi-icon.danger { background: var(--ps-danger-bg); color: var(--ps-danger); }
.kpi-icon.navy { background: rgba(27,42,74,0.08); color: var(--ps-navy); }

.kpi-value {
  font-size: var(--text-3xl);
  font-weight: var(--fw-heavy);
  color: var(--ps-navy);
  line-height: 1;
  letter-spacing: -0.02em;
}

.kpi-label {
  font-size: var(--text-sm);
  color: var(--ps-grey-300);
  margin-top: var(--sp-1);
  font-weight: var(--fw-medium);
}

.kpi-change {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  margin-top: var(--sp-2);
  padding: 2px var(--sp-2);
  border-radius: var(--r-full);
}

.kpi-change.up {
  color: var(--ps-success);
  background: var(--ps-success-bg);
}

.kpi-change.down {
  color: var(--ps-danger);
  background: var(--ps-danger-bg);
}

/* ─── BUTTONS ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  padding: 10px var(--sp-5);
  border-radius: var(--r-md);
  border: none;
  transition: all var(--t-base);
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
}

.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--ps-green);
  color: var(--ps-white);
}

.btn-primary:hover {
  background: var(--ps-green-light);
  box-shadow: 0 2px 8px rgba(40,86,51,0.25);
  transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: transparent;
  color: var(--ps-grey-700);
  border: 1px solid var(--ps-grey-300);
}

.btn-secondary:hover {
  background: var(--ps-bg);
  border-color: var(--ps-grey-700);
}

.btn-ghost {
  background: transparent;
  color: var(--ps-grey-700);
  padding: 6px var(--sp-3);
}

.btn-ghost:hover { background: var(--ps-bg); }

.btn-sm {
  font-size: var(--text-xs);
  padding: var(--sp-1) var(--sp-3);
  gap: var(--sp-1);
}

.btn-sm svg { width: 13px; height: 13px; }

.btn-lg {
  font-size: var(--text-md);
  padding: var(--sp-4) var(--sp-8);
}

/* ─── STATUS BADGES ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  padding: 3px var(--sp-3);
  border-radius: var(--r-full);
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-success {
  background: var(--ps-success-bg);
  color: var(--ps-success);
}
.badge-success::before { background: var(--ps-success); }

.badge-warning {
  background: var(--ps-warning-bg);
  color: var(--ps-warning);
}
.badge-warning::before { background: var(--ps-warning); }

.badge-danger {
  background: var(--ps-danger-bg);
  color: var(--ps-danger);
}
.badge-danger::before { background: var(--ps-danger); }

.badge-neutral {
  background: var(--ps-grey-100);
  color: var(--ps-grey-700);
}
.badge-neutral::before { background: var(--ps-grey-300); }

.badge-info {
  background: rgba(27,42,74,0.08);
  color: var(--ps-navy);
}
.badge-info::before { background: var(--ps-navy); }

/* ─── PROGRESS BARS ──────────────────────────────────────────── */
.progress-bar {
  height: 8px;
  border-radius: var(--r-full);
  background: var(--ps-grey-100);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--ps-green);
  transition: width 0.8s ease;
}

.progress-fill.warning { background: var(--ps-warning); }
.progress-fill.danger  { background: var(--ps-danger); }

/* ─── TABLES ─────────────────────────────────────────────────── */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

thead th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  color: var(--ps-grey-300);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--ps-grey-100);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--ps-grey-100);
  transition: background var(--t-fast);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--ps-bg); }

tbody td {
  padding: var(--sp-3) var(--sp-4);
  vertical-align: middle;
  color: var(--ps-grey-700);
}

.td-primary {
  font-weight: var(--fw-medium);
  color: var(--ps-navy);
}

.td-mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-xs);
  color: var(--ps-green);
  font-weight: var(--fw-medium);
}

/* ─── TABS ───────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--ps-grey-100);
  margin-bottom: var(--sp-6);
}

.tab-item {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--ps-grey-300);
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab-item:hover { color: var(--ps-green); }

.tab-item.active {
  color: var(--ps-green);
  border-bottom-color: var(--ps-green);
  font-weight: var(--fw-semibold);
}

/* ─── BREADCRUMB ─────────────────────────────────────────────── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--ps-grey-300);
  margin-bottom: var(--sp-4);
}

.breadcrumb a {
  color: var(--ps-grey-300);
  transition: color var(--t-fast);
}

.breadcrumb a:hover { color: var(--ps-green); }

.breadcrumb span { color: var(--ps-grey-700); font-weight: var(--fw-medium); }

.breadcrumb-sep { color: var(--ps-grey-100); }

/* ─── FORM ELEMENTS ──────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  color: var(--ps-navy);
}

.form-input {
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--ps-grey-100);
  border-radius: var(--r-md);
  font-size: var(--text-base);
  color: var(--ps-navy);
  background: var(--ps-white);
  transition: border-color var(--t-base), box-shadow var(--t-base);
  outline: none;
  width: 100%;
}

.form-input:focus {
  border-color: var(--ps-green);
  box-shadow: 0 0 0 3px var(--ps-green-08);
}

.form-input::placeholder { color: var(--ps-grey-300); }

.form-input-icon {
  position: relative;
}

.form-input-icon .form-input {
  padding-left: 42px;
}

.form-input-icon .input-icon {
  position: absolute;
  left: var(--sp-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--ps-grey-300);
  pointer-events: none;
  width: 18px;
  height: 18px;
}

/* ─── DIVIDER ────────────────────────────────────────────────── */
.divider {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  color: var(--ps-grey-300);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--ps-grey-100);
}

/* ─── ALERT ITEMS ────────────────────────────────────────────── */
.alert-item {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--ps-grey-100);
}

.alert-item:last-child { border-bottom: none; }

.alert-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

.alert-dot.danger  { background: var(--ps-danger); }
.alert-dot.warning { background: var(--ps-warning); }
.alert-dot.success { background: var(--ps-success); }
.alert-dot.info    { background: var(--ps-info); }

.alert-content {}

.alert-title {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--ps-navy);
  line-height: 1.3;
}

.alert-meta {
  font-size: var(--text-xs);
  color: var(--ps-grey-300);
  margin-top: 3px;
}

/* ─── EMPTY STATE ────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-16) var(--sp-8);
  color: var(--ps-grey-300);
  text-align: center;
}

.empty-state svg { width: 48px; height: 48px; margin-bottom: var(--sp-4); opacity: 0.4; }
.empty-state h3 { font-size: var(--text-lg); font-weight: var(--fw-semibold); color: var(--ps-navy); margin-bottom: var(--sp-2); }
.empty-state p { font-size: var(--text-sm); }

/* ─── FOOTER ─────────────────────────────────────────────────── */
.app-footer {
  padding: var(--sp-5) var(--sp-8);
  border-top: 1px solid var(--ps-grey-100);
  font-size: var(--text-xs);
  color: var(--ps-grey-300);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ─── GRIDS ──────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-5); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-5); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-5); }

/* ─── UTILITY ────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-5 { gap: var(--sp-5); }
.gap-6 { gap: var(--sp-6); }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mt-8 { margin-top: var(--sp-8); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-green { color: var(--ps-green); }
.text-navy { color: var(--ps-navy); }
.text-grey { color: var(--ps-grey-300); }
.font-semibold { font-weight: var(--fw-semibold); }
.font-bold { font-weight: var(--fw-bold); }
.w-full { width: 100%; }

/* ─── AI DISCLAIMER ──────────────────────────────────────────── */
.ai-disclaimer {
  font-size: 11px;
  color: #C8C5BD;
  border-top: 1px solid #F1F0EC;
  padding-top: 8px;
  margin-top: 16px;
  line-height: 1.4;
}
