/* ============================================================
   Corporate Travel Admin — Main Stylesheet
   ============================================================ */

/* ── Variables ───────────────────────────────────────────── */
:root {
  --sidebar-width:     260px;
  --topbar-height:     64px;

  --color-bg:          #f1f5f9;
  --color-surface:     #ffffff;
  --color-border:      #e2e8f0;

  --color-primary:     #3b82f6;
  --color-primary-dk:  #2563eb;
  --color-primary-lt:  #eff6ff;
  --color-success:     #10b981;
  --color-danger:      #ef4444;
  --color-warning:     #f59e0b;
  --color-info:        #6366f1;
  --color-secondary:   #64748b;

  --color-text:        #0f172a;
  --color-text-muted:  #64748b;

  --sidebar-bg:        #0f172a;
  --sidebar-text:      #94a3b8;
  --sidebar-active-bg: rgba(59,130,246,.12);
  --sidebar-active:    #ffffff;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:  0 10px 40px rgba(0,0,0,.12);

  --radius-sm:  .5rem;
  --radius-md:  .75rem;
  --radius-lg:  1rem;
  --radius-xl:  1.25rem;

  --font-base:  'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--font-base); color: var(--color-text); line-height: 1.6; }
a    { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
svg  { display: inline-block; vertical-align: middle; }
code { font-family: 'Fira Code', 'Consolas', monospace; }
img  { max-width: 100%; }

/* ── Auth Layout ─────────────────────────────────────────── */
.auth-body {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.auth-container {
  width: 100%;
  max-width: 420px;
}

.auth-card {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
}

.auth-header { text-align: center; margin-bottom: 2rem; }

.auth-logo {
  width: 56px; height: 56px;
  background: var(--color-primary);
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 1rem;
  letter-spacing: -.5px;
}

.auth-title    { font-size: 1.5rem; font-weight: 700; color: var(--color-text); }
.auth-subtitle { color: var(--color-text-muted); font-size: .9rem; margin-top: .25rem; }

.auth-form     { display: flex; flex-direction: column; gap: 1.25rem; }
.auth-footer   { text-align: center; margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--color-border); }

/* ── App Shell ───────────────────────────────────────────── */
.app-body { background: var(--color-bg); min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform .25s ease;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #1e293b transparent;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .875rem;
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-logo-icon {
  width: 40px; height: 40px;
  background: var(--color-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-logo-name { display: block; font-size: .85rem; font-weight: 700; color: #fff; line-height: 1.2; }
.sidebar-logo-sub  { display: block; font-size: .7rem; color: var(--sidebar-text); }

.sidebar-nav { flex: 1; padding: 1rem 0; }

.nav-section-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #475569;
  padding: 1rem 1.25rem .4rem;
}

.nav-group { display: flex; flex-direction: column; }

.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1.25rem;
  color: var(--sidebar-text);
  font-size: .875rem;
  font-weight: 500;
  border-radius: 0;
  transition: background .15s, color .15s;
  text-decoration: none;
  position: relative;
}

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

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: var(--color-primary);
  border-radius: 0 4px 4px 0;
}

.nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: .7;
}

.nav-item.active .nav-icon, .nav-item:hover .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: .75rem;
}

.sidebar-user     { flex: 1; min-width: 0; display: flex; align-items: center; gap: .625rem; }
.sidebar-user-avatar {
  width: 34px; height: 34px;
  background: var(--color-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; }
.sidebar-user-name  { font-size: .8rem; font-weight: 600; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-email { font-size: .7rem; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-logout {
  color: #475569;
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
  flex-shrink: 0;
}
.sidebar-logout:hover { color: var(--color-danger); background: rgba(239,68,68,.1); text-decoration: none; }
.sidebar-logout svg   { width: 18px; height: 18px; }

/* ── Main Wrapper ────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .25s ease;
}

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.topbar-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: .4rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
}
.topbar-toggle:hover { background: var(--color-bg); }
.topbar-toggle svg   { width: 20px; height: 20px; }

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  flex: 1;
}

.topbar-actions { display: flex; align-items: center; gap: 1rem; }

.topbar-avatar {
  width: 36px; height: 36px;
  background: var(--color-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
}

/* ── Page Content ────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 2rem;
  max-width: 1400px;
  width: 100%;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.page-title    { font-size: 1.5rem; font-weight: 700; color: var(--color-text); line-height: 1.2; }
.page-subtitle { color: var(--color-text-muted); font-size: .875rem; margin-top: .25rem; }
.page-subtitle a { color: var(--color-primary); }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
}

.card-body { padding: 1.5rem; }
.card-body.p-0 { padding: 0; }

/* ── Stats Grid ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(179px, 1fr));
  gap: 1.25rem;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px 10px;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, transform .2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-icon {
  width: 30px; height: 30px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 24px; height: 24px; }

.stat-icon-blue   { background: #eff6ff; color: #3b82f6; }
.stat-icon-green  { background: #f0fdf4; color: #10b981; }
.stat-icon-purple { background: #f5f3ff; color: #8b5cf6; }
.stat-icon-orange { background: #fff7ed; color: #f59e0b; }

.stat-value { font-size: 1.75rem; font-weight: 800; color: var(--color-text); line-height: 1; }
.stat-label { font-size: .8rem; color: var(--color-text-muted); margin-top: .35rem; font-weight: 500; }

/* ── Tables ──────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.table thead tr {
  background: #f8fafc;
  border-bottom: 2px solid var(--color-border);
}

.table th {
  padding: .875rem 1.25rem;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-text-muted);
  text-align: left;
  white-space: nowrap;
}

.table td {
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  color: var(--color-text);
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr:hover { background: #fafbfc; }

.table-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: .875rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:hover { text-decoration: none; opacity: .9; }
.btn svg   { width: 16px; height: 16px; }

.btn-primary   { background: var(--color-primary);   color: #fff;                   border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-dk); }

.btn-secondary { background: var(--color-bg);        color: var(--color-text);       border-color: var(--color-border); }
.btn-secondary:hover { background: #e2e8f0; }

.btn-ghost     { background: transparent;             color: var(--color-text-muted); border-color: transparent; }
.btn-ghost:hover { background: var(--color-bg); color: var(--color-text); }

.btn-danger    { background: var(--color-danger);     color: #fff;                    border-color: var(--color-danger); }

.btn-block { width: 100%; justify-content: center; padding: .75rem; font-size: 1rem; }

.btn-icon {
  width: 32px; height: 32px;
  padding: 0;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .15s;
  color: var(--color-text-muted);
  text-decoration: none;
}
.btn-icon:hover            { background: #e2e8f0; color: var(--color-text); text-decoration: none; }
.btn-icon svg              { width: 15px; height: 15px; }
.btn-icon-danger:hover     { background: #fef2f2; color: var(--color-danger); border-color: #fecaca; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group   { display: flex; flex-direction: column; gap: .4rem; }
.form-row     { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: 1.25rem; }
.form-row .form-group { margin-bottom: 0; }

.form-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--color-text);
}
.form-label.required::after {
  content: ' *';
  color: var(--color-danger);
}

.form-control {
  padding: .625rem .875rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-family: var(--font-base);
  color: var(--color-text);
  background: var(--color-surface);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
  line-height: 1.5;
}
.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.form-control.is-invalid  { border-color: var(--color-danger); }
.form-control::placeholder { color: #94a3b8; }

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

.form-hint        { font-size: .75rem; color: var(--color-text-muted); margin-top: .25rem; }
.invalid-feedback { font-size: .75rem; color: var(--color-danger); margin-top: .25rem; }

.form-actions {
  display: flex;
  align-items: center;
  gap: .75rem;
  justify-content: flex-end;
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
}

.form-layout-split {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.settings-row {
  display: grid;
  grid-template-columns: 240px 1fr;
  align-items: flex-start;
  gap: 1rem;
  padding: .875rem 0;
  border-bottom: 1px solid var(--color-border);
}
.settings-row:last-child { border-bottom: none; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: .625rem;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

/* ── Search Form ─────────────────────────────────────────── */
.search-form {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.search-form .form-control { max-width: 320px; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .875rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: .875rem;
  font-weight: 500;
  margin-bottom: 1.25rem;
  position: relative;
}
.alert svg     { width: 18px; height: 18px; flex-shrink: 0; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-close   {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  font-size: 1.25rem;
  line-height: 1;
  opacity: .6;
  padding: 0 .25rem;
}
.alert-close:hover { opacity: 1; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 2rem;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  line-height: 1.4;
}
.badge-success   { background: #dcfce7; color: #166534; }
.badge-danger    { background: #fee2e2; color: #991b1b; }
.badge-warning   { background: #fef9c3; color: #854d0e; }
.badge-info      { background: #ede9fe; color: #5b21b6; }
.badge-secondary { background: #f1f5f9; color: #475569; }

/* ── Utility ─────────────────────────────────────────────── */
.text-muted { color: var(--color-text-muted) !important; }

.user-cell {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.user-avatar-sm {
  width: 34px; height: 34px;
  background: var(--color-primary-lt);
  color: var(--color-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.code-pill {
  background: #f1f5f9;
  padding: .15rem .5rem;
  border-radius: .375rem;
  font-size: .8rem;
  color: #475569;
  border: 1px solid #e2e8f0;
}

/* ── Permissions Grid ────────────────────────────────────── */
.permissions-grid  { display: flex; flex-direction: column; gap: 1rem; max-height: 520px; overflow-y: auto; }
.perm-module       { border: 1px solid var(--color-border); border-radius: var(--radius-sm); overflow: hidden; }
.perm-module-header { background: #f8fafc; padding: .625rem 1rem; border-bottom: 1px solid var(--color-border); }
.perm-module-label  { display: flex; align-items: center; gap: .5rem; font-size: .8rem; font-weight: 700; color: var(--color-text); cursor: pointer; }
.perm-module-label input { accent-color: var(--color-primary); }
.perm-items         { display: flex; flex-wrap: wrap; gap: .5rem; padding: .75rem 1rem; }
.perm-item          { display: flex; align-items: center; gap: .4rem; font-size: .8rem; cursor: pointer; background: var(--color-bg); padding: .3rem .7rem; border-radius: 2rem; border: 1px solid var(--color-border); }
.perm-item:hover    { border-color: var(--color-primary); }
.perm-item input    { accent-color: var(--color-primary); width: 14px; height: 14px; }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--color-text-muted);
}
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 1rem; display: block; opacity: .35; }
.empty-state p   { margin-bottom: 1.5rem; font-size: .95rem; }

/* ── Detail Grid (booking show) ──────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  align-items: start;
}

.detail-list { display: flex; flex-direction: column; gap: .5rem; }
.detail-row  { display: grid; grid-template-columns: 140px 1fr; gap: .5rem; align-items: baseline; }
.detail-row dt { font-size: .8rem; font-weight: 600; color: var(--color-text-muted); }
.detail-row dd { font-size: .875rem; color: var(--color-text); }

/* ── Approval Steps ───────────────────────────────────────── */
.approval-step {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  transition: background .15s;
}
.approval-step:last-child { border-bottom: none; }
.approval-step.approved   { background: #f0fdf4; }
.approval-step.rejected   { background: #fef2f2; }
.approval-step.pending    { background: #fffbeb; }

.approval-step-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: .8rem;
  font-weight: 700;
}
.approved .approval-step-icon  { background: #dcfce7; color: #166534; }
.rejected .approval-step-icon  { background: #fee2e2; color: #991b1b; }
.pending  .approval-step-icon  { background: #fef9c3; color: #854d0e; }
.skipped  .approval-step-icon  { background: #f1f5f9; color: #64748b; }
.approval-step-icon svg { width: 16px; height: 16px; }
.approval-step-info { flex: 1; }

/* ── Notes ────────────────────────────────────────────────── */
.note-item {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
}
.note-item:last-of-type { border-bottom: none; }
.note-meta {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8rem;
  color: var(--color-text-muted);
  margin-bottom: .4rem;
}
.note-meta strong { color: var(--color-text); }
.note-text { font-size: .875rem; line-height: 1.6; }

/* ── Status Pills ─────────────────────────────────────────── */
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem 1rem;
  border-radius: 2rem;
  font-size: .8rem;
  font-weight: 600;
  border: 1.5px solid transparent;
  text-decoration: none;
  transition: all .15s;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border-color: var(--color-border);
}
.stat-pill:hover, .stat-pill.active { text-decoration: none; }
.stat-pill strong { font-size: 1rem; font-weight: 800; }
.stat-pill-success.active { background: #f0fdf4; border-color: #86efac; color: #166534; }
.stat-pill-danger.active  { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.stat-pill-warning.active { background: #fffbeb; border-color: #fcd34d; color: #854d0e; }
.stat-pill-info.active    { background: #ede9fe; border-color: #c4b5fd; color: #5b21b6; }
.stat-pill-secondary.active { background: #f1f5f9; border-color: #94a3b8; color: #334155; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.modal-box {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  padding: 2rem;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
}

/* ── Step Cards (workflow form) ───────────────────────────── */
.step-card {
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  background: var(--color-bg);
}
.step-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .875rem;
}

/* ── Urgent row ───────────────────────────────────────────── */
.row-urgent { background: #fff8f8 !important; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-wrapper {
    margin-left: 0;
  }
  .form-layout-split {
    grid-template-columns: 1fr;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .page-content { padding: 1.25rem; }
  .stats-grid   { grid-template-columns: 1fr; }
  .page-header  { flex-direction: column; }
  .auth-card    { padding: 1.75rem; }
  .settings-row { grid-template-columns: 1fr; }
}
