/* ===== Cortex — Components (Graphite Enterprise) ===== */

/* ===== CARDS ===== */
.card{ background:var(--panel); border:1px solid var(--border-color); border-radius:var(--border-radius-lg);
  box-shadow:var(--shadow-sm); overflow:hidden; transition:border-color var(--transition-fast), box-shadow var(--transition-fast); }
.card:hover{ border-color:var(--border-color-hover); }
.card-header{ padding:17px 20px; border-bottom:1px solid var(--border-subtle);
  display:flex; align-items:center; justify-content:space-between; }
.card-header h3{ font-size:14.5px; font-weight:700; letter-spacing:-.01em; }
.card-body{ padding:20px; }

/* ===== STAT / KPI CARDS ===== */
.stat-cards-grid{ display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:16px; }
.stat-card{ background:var(--panel); border:1px solid var(--border-color); border-radius:var(--border-radius-lg);
  padding:18px; position:relative; overflow:hidden; transition:transform var(--transition-fast),box-shadow var(--transition-fast),border-color var(--transition-fast);
  animation:slideUp .4s ease backwards; }
.stat-card:nth-child(1){animation-delay:0ms}.stat-card:nth-child(2){animation-delay:70ms}
.stat-card:nth-child(3){animation-delay:140ms}.stat-card:nth-child(4){animation-delay:210ms}
.stat-card::before{ content:''; position:absolute; top:0; left:0; bottom:0; width:3px; background:var(--brand); opacity:0; transition:opacity var(--transition-fast); }
.stat-card:hover{ transform:translateY(-2px); box-shadow:var(--shadow-md); border-color:var(--border-color-hover); }
.stat-card:hover::before{ opacity:1; }
.stat-card-header{ display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; }
.stat-card-icon{ width:36px; height:36px; border-radius:9px; display:flex; align-items:center; justify-content:center;
  flex-shrink:0; background:var(--brand-050); color:var(--brand); }
.stat-card-icon svg{ color:currentColor; width:18px; height:18px; }
.stat-card-icon.slate{ background:var(--slate-050); color:var(--slate); }
.stat-card-icon.neutral{ background:var(--bg-hover); color:var(--text-secondary); }
.stat-card-value{ font-family:var(--font-mono); font-size:28px; font-weight:600; letter-spacing:-.02em; line-height:1;
  margin:2px 0 8px; animation:countUp .5s ease backwards; animation-delay:.15s; }
.stat-card-label{ font-size:12.5px; color:var(--text-muted); }
.stat-card-trend{ display:inline-flex; align-items:center; gap:4px; font-family:var(--font-mono); font-size:11.5px; font-weight:600;
  padding:3px 8px; border-radius:6px; }
.stat-card-trend.up{ color:var(--color-success); background:var(--color-success-bg); }
.stat-card-trend.down{ color:var(--color-danger); background:var(--color-danger-bg); }

/* ===== BUTTONS ===== */
.btn{ display:inline-flex; align-items:center; justify-content:center; gap:8px; padding:9px 16px;
  border-radius:10px; font-family:var(--font-family); font-size:13.5px; font-weight:700; line-height:1.4;
  cursor:pointer; border:1px solid transparent; transition:all var(--transition-fast); text-decoration:none; white-space:nowrap; }
.btn-primary{ background:var(--brand); color:#fff; }
.btn-primary:hover{ background:var(--brand-700); }
.btn-slate{ background:var(--slate); color:#fff; }
.btn-slate:hover{ background:var(--slate-600); }
.btn-secondary{ background:var(--panel); color:var(--text-secondary); border-color:var(--border-color); }
.btn-secondary:hover{ background:var(--panel-2); color:var(--text-primary); border-color:var(--border-color-hover); }
.btn-danger{ background:var(--color-danger-bg); color:var(--color-danger); }
.btn-danger:hover{ filter:brightness(.97); }
.btn-ghost{ background:transparent; color:var(--text-secondary); border-color:var(--border-color); }
.btn-ghost:hover{ background:var(--panel-2); color:var(--text-primary); }
.btn-sm{ padding:7px 12px; font-size:12.5px; }
.btn-block{ width:100%; }
.btn + .btn{ margin-left:8px; }
.btn-icon{ background:none; border:none; color:var(--text-secondary); cursor:pointer; display:inline-flex;
  align-items:center; justify-content:center; padding:8px; border-radius:10px; transition:all var(--transition-fast); }
.btn-icon:hover{ color:var(--text-primary); background:var(--panel-2); }

/* ===== BADGES ===== */
.badge{ display:inline-flex; align-items:center; gap:5px; padding:3px 10px; border-radius:7px;
  font-size:11.5px; font-weight:700; white-space:nowrap; }
.badge-success{ background:var(--color-success-bg); color:var(--color-success); }
.badge-warning{ background:var(--color-warning-bg); color:var(--color-warning); }
.badge-danger{ background:var(--color-danger-bg); color:var(--color-danger); }
.badge-info{ background:var(--color-info-bg); color:var(--color-info); }
.badge-secondary{ background:var(--bg-hover); color:var(--text-secondary); }

/* ===== TABLES ===== */
.table-container{ border-radius:var(--border-radius-lg); overflow:hidden; background:var(--panel); border:1px solid var(--border-color); box-shadow:var(--shadow-sm); }
.table-toolbar{ display:flex; align-items:center; justify-content:space-between; padding:16px 18px; gap:14px; flex-wrap:wrap; border-bottom:1px solid var(--border-subtle); }
.table-search{ position:relative; display:flex; align-items:center; }
.table-search svg{ position:absolute; left:12px; color:var(--text-muted); pointer-events:none; }
.table-search input{ padding:9px 14px 9px 36px; min-width:280px; background:var(--panel); border:1px solid var(--border-color);
  border-radius:10px; color:var(--text-primary); font-family:var(--font-family); font-size:13px; outline:none; transition:var(--transition-fast); }
.table-search input:focus{ border-color:var(--brand); box-shadow:var(--shadow-glow); }
.table-search input::placeholder{ color:var(--text-muted); }
.data-table{ width:100%; border-collapse:collapse; }
.data-table thead{ background:var(--panel-2); }
.data-table th{ padding:12px 16px; text-align:left; font-family:var(--font-mono); font-size:10.5px; text-transform:uppercase;
  color:var(--text-muted); font-weight:500; letter-spacing:.08em; white-space:nowrap; user-select:none; }
.data-table th.sortable{ cursor:pointer; }
.data-table th.sortable:hover{ color:var(--text-primary); }
.data-table td{ padding:13px 16px; border-bottom:1px solid var(--border-subtle); font-size:13px; vertical-align:middle; }
.data-table tbody tr{ transition:background var(--transition-fast); }
.data-table tbody tr:hover{ background:var(--panel-2); }
.data-table tbody tr:last-child td{ border-bottom:none; }
.employee-cell{ display:flex; align-items:center; gap:11px; }
.employee-cell .info{ display:flex; flex-direction:column; }
.employee-cell .name{ font-weight:700; }
.employee-cell .sub{ font-size:11.5px; color:var(--text-muted); }
.table-avatar{ width:34px; height:34px; border-radius:9px; display:flex; align-items:center; justify-content:center;
  font-family:var(--font-mono); font-size:11.5px; font-weight:600; color:#fff; flex-shrink:0; }
.table-actions{ display:flex; gap:4px; }
.table-pagination{ display:flex; align-items:center; justify-content:center; gap:6px; padding:14px 18px; border-top:1px solid var(--border-subtle); }
.table-pagination button{ width:34px; height:34px; display:flex; align-items:center; justify-content:center; background:var(--panel);
  border:1px solid var(--border-color); border-radius:9px; color:var(--text-secondary); font-size:13px; cursor:pointer; transition:var(--transition-fast); }
.table-pagination button:hover{ background:var(--panel-2); color:var(--text-primary); }
.table-pagination button.active{ background:var(--brand); color:#fff; border-color:var(--brand); }
.table-pagination button:disabled{ opacity:.35; cursor:not-allowed; }
.table-info{ font-size:11.5px; color:var(--text-muted); padding:0 12px; }

/* ===== MODALS ===== */
.modal-overlay{ position:fixed; inset:0; background:rgba(15,20,25,.42); backdrop-filter:blur(3px);
  z-index:1000; display:flex; align-items:center; justify-content:center; animation:fadeIn .2s ease; padding:16px; }
.modal{ background:var(--panel); border-radius:var(--border-radius-xl); border:1px solid var(--border-color);
  width:100%; max-height:90vh; overflow:hidden; animation:slideUp .3s ease; display:flex; flex-direction:column; box-shadow:var(--shadow-lg); }
.modal-sm{ max-width:420px; } .modal-md{ max-width:580px; } .modal-lg{ max-width:740px; }
.modal-header{ display:flex; align-items:center; justify-content:space-between; padding:18px 22px; border-bottom:1px solid var(--border-subtle); flex-shrink:0; }
.modal-header h3{ font-size:16px; font-weight:800; letter-spacing:-.01em; }
.modal-close{ width:32px; height:32px; display:flex; align-items:center; justify-content:center; background:none; border:none;
  color:var(--text-muted); border-radius:8px; cursor:pointer; transition:var(--transition-fast); }
.modal-close:hover{ background:var(--color-danger-bg); color:var(--color-danger); }
.modal-body{ padding:22px; overflow-y:auto; flex:1; max-height:calc(90vh - 140px); }
.modal-footer{ display:flex; align-items:center; justify-content:flex-end; gap:10px; padding:16px 22px; border-top:1px solid var(--border-subtle); flex-shrink:0; }

/* ===== FORMS ===== */
.form-group{ margin-bottom:18px; }
.form-label{ display:block; font-size:12.5px; font-weight:700; color:var(--text-secondary); margin-bottom:7px; }
.form-input{ width:100%; padding:10px 13px; background:var(--panel); border:1px solid var(--border-color);
  border-radius:10px; color:var(--text-primary); font-family:var(--font-family); font-size:13.5px; transition:var(--transition-fast); outline:none; }
.form-input:focus{ border-color:var(--brand); box-shadow:var(--shadow-glow); }
.form-input::placeholder{ color:var(--text-muted); }
select.form-input{ appearance:none; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236a727d' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:right 12px center; padding-right:36px; }
textarea.form-input{ min-height:80px; resize:vertical; }
.form-row{ display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.form-error{ font-size:12.5px; color:var(--color-danger); margin-top:5px; }

/* ===== TOASTS ===== */
.toast-container{ position:fixed; top:16px; right:16px; z-index:2000; display:flex; flex-direction:column; gap:10px; pointer-events:none; }
.toast{ padding:13px 16px; border-radius:11px; font-size:13px; font-weight:600; animation:slideIn .3s ease;
  min-width:280px; max-width:420px; display:flex; align-items:center; gap:11px; box-shadow:var(--shadow-lg); pointer-events:auto; background:var(--panel); border:1px solid var(--border-color); }
.toast-success{ border-left:3px solid var(--color-success); color:var(--color-success); }
.toast-error{ border-left:3px solid var(--color-danger); color:var(--color-danger); }
.toast-warning{ border-left:3px solid var(--color-warning); color:var(--color-warning); }
.toast-info{ border-left:3px solid var(--color-info); color:var(--color-info); }

/* ===== PAGE HEADER ===== */
.page-header{ display:flex; align-items:flex-end; justify-content:space-between; margin-bottom:24px; flex-wrap:wrap; gap:16px; }
.page-header h1{ font-size:24px; font-weight:800; letter-spacing:-.025em; }
.page-header p{ font-size:13.5px; color:var(--text-muted); margin-top:5px; }
.page-header-actions{ display:flex; align-items:center; gap:10px; }

/* ===== TABS ===== */
.tabs-header{ display:flex; gap:0; border-bottom:1px solid var(--border-color); margin-bottom:22px; overflow-x:auto; }
.tab-btn{ padding:11px 18px; font-size:13.5px; font-weight:700; color:var(--text-muted); border:none; background:none;
  border-bottom:2px solid transparent; cursor:pointer; transition:var(--transition-fast); white-space:nowrap; }
.tab-btn:hover{ color:var(--text-primary); }
.tab-btn.active{ color:var(--brand); border-bottom-color:var(--brand); }
.tab-content{ animation:fadeIn .3s ease; }

/* ===== EMPTY / LOADING ===== */
.empty-state{ display:flex; flex-direction:column; align-items:center; justify-content:center; padding:48px; text-align:center; }
.empty-state svg{ width:56px; height:56px; color:var(--text-tertiary); margin-bottom:14px; }
.empty-state p{ color:var(--text-muted); font-size:13.5px; }
.loading-spinner{ display:flex; align-items:center; justify-content:center; padding:48px; }
.loading-spinner::after{ content:''; width:30px; height:30px; border:3px solid var(--border-color); border-top-color:var(--brand); border-radius:50%; animation:spin .7s linear infinite; }

/* ===== CHART / FILTER ===== */
.chart-container{ position:relative; width:100%; }
.chart-container canvas{ width:100%!important; height:100%!important; }
.filter-bar{ display:flex; gap:8px; margin-bottom:22px; flex-wrap:wrap; }
.filter-btn{ padding:7px 15px; border-radius:9px; font-size:13px; font-weight:600; background:var(--panel);
  color:var(--text-secondary); border:1px solid var(--border-color); cursor:pointer; transition:var(--transition-fast); }
.filter-btn:hover{ background:var(--panel-2); color:var(--text-primary); }
.filter-btn.active{ background:var(--brand-050); color:var(--brand-700); border-color:var(--brand); }

@media (max-width:768px){
  .stat-cards-grid{ grid-template-columns:1fr 1fr; }
  .form-row{ grid-template-columns:1fr; }
  .table-toolbar{ flex-direction:column; align-items:stretch; }
  .table-search input{ min-width:unset; width:100%; }
  .page-header{ flex-direction:column; align-items:flex-start; }
}
@media (max-width:480px){ .stat-cards-grid{ grid-template-columns:1fr; } }

/* ===== Notification panel + Global search dropdown ===== */
.notif-panel, .search-results{ position:fixed; z-index:1200; background:var(--panel); border:1px solid var(--border-color);
  border-radius:12px; box-shadow:var(--shadow-lg); min-width:290px; max-width:340px; overflow:hidden; animation:slideDown .18s ease; }
.notif-panel.hidden, .search-results.hidden{ display:none; }
.notif-head{ padding:12px 16px; font-weight:700; font-size:13px; border-bottom:1px solid var(--border-subtle); }
.notif-item{ display:flex; align-items:center; gap:10px; padding:12px 16px; font-size:13px; color:var(--text-secondary);
  border-bottom:1px solid var(--border-subtle); text-decoration:none; transition:var(--transition-fast); }
.notif-item:last-child{ border-bottom:none; }
.notif-item:hover{ background:var(--panel-2); color:var(--text-primary); }
.notif-dot{ width:8px; height:8px; border-radius:50%; flex:none; }
.notif-dot.danger{ background:var(--color-danger); } .notif-dot.warn{ background:var(--color-warning); }
.notif-dot.info{ background:var(--slate); } .notif-dot.ok{ background:var(--color-success); }
.search-results .sr-item{ display:flex; align-items:center; gap:9px; padding:10px 14px; font-size:13px; color:var(--text-primary);
  border-bottom:1px solid var(--border-subtle); text-decoration:none; }
.search-results .sr-item:last-child{ border-bottom:none; }
.search-results .sr-item:hover{ background:var(--panel-2); }
.sr-tag{ font-family:var(--font-mono); font-size:10px; padding:2px 6px; border-radius:5px; background:var(--brand-050); color:var(--brand-700); flex:none; }
.sr-empty{ padding:14px; font-size:13px; color:var(--text-muted); text-align:center; }
