/* ============================================================
   JGI Recruitment Portal - Global Styles
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand-primary:   #1a3c6e;
  --brand-accent:    #c8922a;
  --brand-light:     #e8f0fb;
  --text-primary:    #1e1e2e;
  --text-secondary:  #5a6478;
  --text-muted:      #8a94a6;
  --border:          #d4d9e2;
  --bg-page:         #f4f6fa;
  --bg-white:        #ffffff;
  --success:         #1a8a4a;
  --success-bg:      #e8f7ef;
  --error:           #c0392b;
  --error-bg:        #fdf0ee;
  --warning:         #b45309;
  --warning-bg:      #fef3c7;
  --info:            #1a3c6e;
  --info-bg:         #e8f0fb;
  --radius-sm:       6px;
  --radius-md:       10px;
  --radius-lg:       16px;
  --shadow-sm:       0 1px 3px rgba(0,0,0,.08);
  --shadow-md:       0 4px 16px rgba(0,0,0,.10);
  --shadow-lg:       0 8px 32px rgba(0,0,0,.13);
  --font:            'Inter', system-ui, -apple-system, sans-serif;
  --transition:      180ms ease;
}

html { font-size: 15px; }

body {
  font-family: var(--font);
  background: var(--bg-page);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--brand-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Typography --- */
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.35rem; font-weight: 600; }
h3 { font-size: 1.1rem;  font-weight: 600; }
h4 { font-size: .95rem;  font-weight: 600; }

/* ============================================================
   Layout Shell
   ============================================================ */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--brand-primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-x: hidden;
  overflow-y: auto;
  transition: width 0.22s ease;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.sidebar-logo .logo-mark {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: .3px;
  line-height: 1.3;
}

.sidebar-logo .logo-sub {
  font-size: .7rem;
  opacity: .6;
  margin-top: 2px;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0;
}

.nav-section-label {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .8px;
  opacity: .5;
  padding: 12px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: .88rem;
  color: rgba(255,255,255,.75);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  border-left: 3px solid transparent;
  text-decoration: none;
}

.nav-item:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
  text-decoration: none;
}

.nav-item.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  border-left-color: var(--brand-accent);
}

.nav-item .nav-icon {
  width: 18px;
  text-align: center;
  font-style: normal;
  opacity: .85;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.12);
  font-size: .82rem;
}

.sidebar-footer .user-name {
  font-weight: 600;
  color: #fff;
}

.sidebar-footer .user-role {
  opacity: .55;
  font-size: .74rem;
  text-transform: capitalize;
  margin-top: 1px;
}

.sidebar-footer .btn-signout {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: .78rem;
  color: rgba(255,255,255,.55);
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  font-family: var(--font);
}

.sidebar-footer .btn-signout:hover { color: #fff; }

/* --- Chrome custom scrollbar for sidebar (Firefox uses scrollbar-width: thin) --- */
.sidebar::-webkit-scrollbar,
.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}
.sidebar::-webkit-scrollbar-track,
.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar::-webkit-scrollbar-thumb,
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.25);
  border-radius: 4px;
}
.sidebar::-webkit-scrollbar-thumb:hover,
.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.45);
}
.sidebar { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.25) transparent; }
.sidebar-nav { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.25) transparent; }

/* --- Collapsible sidebar --- */

/* Pull tab — protrudes from sidebar's right edge, always accessible */
.sidebar-pull-tab {
  position: fixed;
  left: 240px;
  top: 88px;
  width: 18px;
  height: 52px;
  background: #fff;
  border: 1px solid rgba(0,0,0,0.14);
  border-left: none;
  border-radius: 0 10px 10px 0;
  box-shadow: 3px 2px 12px rgba(0,0,0,0.13);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 200;
  padding: 0;
  color: var(--brand-primary);
  transition: left 0.22s ease, background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.sidebar-pull-tab:hover {
  background: var(--brand-primary);
  color: #fff;
  box-shadow: 4px 2px 18px rgba(0,0,0,0.20);
}
body.sidebar-collapsed .sidebar-pull-tab { left: 56px; }
.sidebar-pull-tab .icon-expand { display: none; }

/* === Base (expanded) transitions — define the EXPAND animation (with delay) === */
/* Text appears AFTER sidebar has opened; prevents text rendering in a narrow bar */
.sidebar-logo .logo-mark,
.sidebar-logo .logo-sub {
  overflow: hidden; max-height: 60px;
  transition: opacity 0.22s ease 0.15s, max-height 0.25s ease 0.15s;
}
.sidebar-logo .logo-abbrev {
  overflow: hidden; max-height: 0; opacity: 0;
  font-size: 1rem; font-weight: 800; letter-spacing: 1px; line-height: 1.3; text-align: center;
  /* On expand: hides fast (no delay) */
  transition: opacity 0.08s ease 0s, max-height 0.1s ease 0s;
}
.nav-section-label {
  overflow: hidden; max-height: 60px;
  transition: opacity 0.22s ease 0.12s, max-height 0.25s ease 0.12s, padding 0.25s ease 0.12s;
}
.nav-item-label,
.signout-text {
  white-space: nowrap; overflow: hidden; max-width: 200px;
  /* Appear with delay so sidebar width is mostly open first */
  transition: opacity 0.22s ease 0.15s, max-width 0.25s ease 0.15s;
}
.sidebar-footer .user-name,
.sidebar-footer .user-role {
  overflow: hidden; max-height: 40px;
  transition: opacity 0.22s ease 0.15s, max-height 0.25s ease 0.15s;
}

/* === Collapsed state — elements hide fast; sidebar then shrinks === */
body.sidebar-collapsed .sidebar { width: 56px; }
body.sidebar-collapsed .main-content { margin-left: 56px; }
body.sidebar-collapsed .sidebar-logo { padding: 14px 0 10px; text-align: center; }
body.sidebar-collapsed .sidebar-logo .logo-mark,
body.sidebar-collapsed .sidebar-logo .logo-sub {
  opacity: 0; max-height: 0;
  transition: opacity 0.06s ease 0s, max-height 0.06s ease 0s;
}
body.sidebar-collapsed .sidebar-logo .logo-abbrev {
  opacity: 1; max-height: 40px;
  /* Slight delay so sidebar starts narrowing before JGI fades in */
  transition: opacity 0.2s ease 0.1s, max-height 0.22s ease 0.1s;
}
body.sidebar-collapsed .nav-section-label {
  opacity: 0; max-height: 0; padding: 0;
  transition: opacity 0.06s ease 0s, max-height 0.06s ease 0s, padding 0.06s ease 0s;
}
/* Centre icons when collapsed */
body.sidebar-collapsed .nav-item,
body.sidebar-collapsed .nav-item.active {
  border-left-color: transparent;
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}
body.sidebar-collapsed .nav-item-label,
body.sidebar-collapsed .signout-text {
  opacity: 0; max-width: 0;
  transition: opacity 0.05s ease 0s, max-width 0.06s ease 0s;
}
body.sidebar-collapsed .sidebar-footer { padding: 10px 20px; }
body.sidebar-collapsed .sidebar-footer .user-name,
body.sidebar-collapsed .sidebar-footer .user-role {
  opacity: 0; max-height: 0;
  transition: opacity 0.06s ease 0s, max-height 0.06s ease 0s;
}
body.sidebar-collapsed .sidebar-footer .btn-signout { margin-top: 0; }
body.sidebar-collapsed .sidebar-pull-tab .icon-collapse { display: none; }
body.sidebar-collapsed .sidebar-pull-tab .icon-expand { display: flex; }

/* Custom nav tooltip — replaces slow native title tooltip */
.nav-tooltip {
  position: fixed;
  top: 0;
  left: 70px;
  transform: translateY(-50%);
  background: var(--brand-primary);
  color: #fff;
  padding: 6px 14px;
  border-radius: 7px;
  font-size: .79rem;
  font-weight: 500;
  letter-spacing: .015em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.08s ease;
  z-index: 300;
  box-shadow: 0 6px 20px rgba(0,0,0,0.28), 0 0 0 1px rgba(255,255,255,0.07) inset;
}
.nav-tooltip.visible { opacity: 1; }
/* Left-pointing caret connecting tooltip to icon */
.nav-tooltip::before {
  content: '';
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: var(--brand-primary);
}

/* --- Main content area --- */
.main-content {
  margin-left: 240px;
  flex: 1;
  padding: 32px 36px;
  min-height: 100vh;
  transition: margin-left 0.22s ease;
}

/* --- Top bar --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.topbar-title h1 { font-size: 1.45rem; }

.topbar-title p {
  color: var(--text-secondary);
  font-size: .87rem;
  margin-top: 2px;
}

/* ============================================================
   Cards
   ============================================================ */

.card {
  background: var(--bg-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.card-header h2,
.card-header h3 { margin: 0; }

/* --- Stat Cards --- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-white);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}

.stat-card .stat-label {
  font-size: .75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 6px;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--brand-primary);
  line-height: 1;
}

.stat-card .stat-sub {
  font-size: .77rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition), box-shadow var(--transition), opacity var(--transition);
  font-family: var(--font);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--brand-primary);
  color: #fff;
  border-color: var(--brand-primary);
}
.btn-primary:hover:not(:disabled) { background: #142f58; }

.btn-accent {
  background: var(--brand-accent);
  color: #fff;
  border-color: var(--brand-accent);
}
.btn-accent:hover:not(:disabled) { background: #b07a22; }

.btn-secondary {
  background: var(--bg-white);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-page); }

.btn-danger {
  background: var(--error);
  color: #fff;
  border-color: var(--error);
}
.btn-danger:hover:not(:disabled) { background: #a93226; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-page);
  color: var(--text-primary);
}

.btn-sm  { padding: 6px 12px; font-size: .8rem; }
.btn-lg  { padding: 12px 28px; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }

/* ============================================================
   Forms
   ============================================================ */

.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: .83rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-label .required { color: var(--error); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg-white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(26,60,110,.1);
}

.form-control::placeholder { color: var(--text-muted); }

.form-control.is-error { border-color: var(--error); }
.form-control.is-error:focus { box-shadow: 0 0 0 3px rgba(192,57,43,.1); }

.form-hint {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-error {
  font-size: .78rem;
  color: var(--error);
  margin-top: 4px;
}

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }

/* ============================================================
   Alerts
   ============================================================ */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: .87rem;
  margin-bottom: 18px;
}
.alert-msg { flex: 1; }
.alert-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0 0 8px;
  opacity: .55;
  color: inherit;
  flex-shrink: 0;
  margin-top: -1px;
}
.alert-close:hover { opacity: 1; }

.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #a3d9b8; }
.alert-error   { background: var(--error-bg);   color: var(--error);   border: 1px solid #f0b8b2; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #fcd34d; }
.alert-info    { background: var(--info-bg);    color: var(--info);    border: 1px solid #a8c4e8; }

/* ============================================================
   Tables
   ============================================================ */

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}

thead th {
  text-align: left;
  font-size: .73rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}

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

tbody td {
  padding: 12px 14px;
  vertical-align: middle;
  color: var(--text-primary);
}

/* ============================================================
   Badges
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: capitalize;
  letter-spacing: .35px;
  white-space: nowrap;
  vertical-align: middle;
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.45), 0 1px 2px rgba(0,0,0,0.07);
}

.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-green  { background: #dcfce7; color: #166534; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-gray   { background: #f1f5f9; color: #475569; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-navy   { background: var(--brand-light); color: var(--brand-primary); }
.badge-gold   { background: #fef3c7; color: #92400e; }

/* Filter tab pills — used on table pages */
.filter-tabs { display: flex; gap: 6px; padding: 10px 16px 0; flex-wrap: wrap; }
.status-tab {
  padding: 4px 14px;
  border-radius: 99px;
  font-size: .76rem;
  font-weight: 600;
  letter-spacing: .2px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.status-tab:hover { background: var(--bg-page); color: var(--text-primary); }
.status-tab.active { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }

/* ============================================================
   Modal
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(12px);
  transition: transform var(--transition);
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2,
.modal-header h3 { margin: 0; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 4px;
}
.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ============================================================
   Spinner / Loading
   ============================================================ */

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
}

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

.loading-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.loading-state .spinner {
  width: 28px;
  height: 28px;
  color: var(--brand-primary);
  margin-bottom: 12px;
}

/* ============================================================
   Empty State
   ============================================================ */

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: .5;
}

.empty-state p { font-size: .9rem; margin-top: 4px; }

/* ============================================================
   Pipeline Stage Badge Colors
   ============================================================ */

.stage-new          { background: #f1f5f9; color: #475569; }
.stage-shortlisted  { background: #dbeafe; color: #1e40af; }
.stage-interview_1  { background: #ede9fe; color: #7c3aed; }
.stage-interview_2  { background: #ede9fe; color: #5b21b6; }
.stage-verbal_offer { background: #fef3c7; color: #b45309; }
.stage-approval     { background: #fef9c3; color: #92400e; }
.stage-offered      { background: #dcfce7; color: #166534; }
.stage-hired        { background: #bbf7d0; color: #14532d; }
.stage-rejected     { background: #fee2e2; color: #991b1b; }

/* ============================================================
   Utility Classes
   ============================================================ */

.text-muted     { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-error     { color: var(--error); }
.text-success   { color: var(--success); }
.text-center    { text-align: center; }
.text-right     { text-align: right; }

.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

.hidden { display: none !important; }

/* ============================================================
   Login Page
   ============================================================ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f2547 0%, #1a3c6e 60%, #1e4d8c 100%);
  padding: 24px;
}

.login-card {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: 40px 40px 36px;
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .company-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--brand-primary);
  letter-spacing: .2px;
}

.login-logo .portal-name {
  font-size: .75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-top: 3px;
}

.login-logo .logo-divider {
  width: 44px;
  height: 3px;
  background: var(--brand-accent);
  border-radius: 2px;
  margin: 10px auto 0;
}

.login-card h2 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.login-card .login-subtitle {
  font-size: .84rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.login-footer {
  margin-top: 22px;
  text-align: center;
  font-size: .78rem;
  color: var(--text-muted);
}
