/* =========================================================
   Kels & Mels Travel - Admin Panel Theme (Bootstrap 5)
   Brand colors taken from the KM logo
   ========================================================= */
:root {
  --km-navy: #0b4462;       /* "KM" letters */
  --km-navy-dark: #072f45;
  --km-blue: #1779b9;       /* plane */
  --km-blue-light: #e8f2fa;
  --km-yellow: #fff200;     /* suitcase */
  --km-yellow-soft: #fffbcc;
  --km-ink: #1a1530;        /* tagline text */
  --km-bg: #f3f6f9;
  --km-border: #e3e8ee;
  --km-muted: #6b7a8a;
  --sidebar-w: 260px;
  --header-h: 64px;

  --bs-primary: var(--km-blue);
  --bs-primary-rgb: 23, 121, 185;
  --bs-link-color: var(--km-blue);
  --bs-link-hover-color: var(--km-navy);
  --bs-body-font-family: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-body-color: var(--km-ink);
}

body { background: var(--km-bg); font-size: .925rem; }

/* ---------- Buttons ---------- */
.btn-primary {
  --bs-btn-bg: var(--km-blue); --bs-btn-border-color: var(--km-blue);
  --bs-btn-hover-bg: var(--km-navy); --bs-btn-hover-border-color: var(--km-navy);
  --bs-btn-active-bg: var(--km-navy-dark); --bs-btn-active-border-color: var(--km-navy-dark);
}
.btn-navy {
  --bs-btn-color: #fff; --bs-btn-bg: var(--km-navy); --bs-btn-border-color: var(--km-navy);
  --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--km-navy-dark); --bs-btn-hover-border-color: var(--km-navy-dark);
}
.btn-accent {
  --bs-btn-color: var(--km-navy); --bs-btn-bg: var(--km-yellow); --bs-btn-border-color: var(--km-yellow);
  --bs-btn-hover-color: var(--km-navy); --bs-btn-hover-bg: #e6da00; --bs-btn-hover-border-color: #e6da00;
  font-weight: 600;
}
.form-control:focus, .form-select:focus {
  border-color: var(--km-blue); box-shadow: 0 0 0 .2rem rgba(23,121,185,.15);
}
.text-navy { color: var(--km-navy) !important; }
.bg-navy { background: var(--km-navy) !important; }

/* =========================================================
   AUTH PAGES (login, forgot password)
   ========================================================= */
.auth-wrap { min-height: 100vh; display: flex; }
.auth-brand {
  flex: 1 1 50%; position: relative; overflow: hidden; color: #fff;
  background: linear-gradient(150deg, var(--km-navy) 0%, var(--km-navy-dark) 55%, var(--km-blue) 140%);
  display: flex; flex-direction: column; justify-content: space-between; padding: 3rem;
}
.auth-brand::before { /* yellow speed stripes, echoing the logo */
  content: ""; position: absolute; left: -60px; bottom: 80px; width: 420px; height: 220px;
  background: repeating-linear-gradient(-18deg, var(--km-yellow) 0 10px, transparent 10px 24px);
  opacity: .18; transform: skewY(-8deg);
}
.auth-brand .plane-ico { font-size: 9rem; color: rgba(255,255,255,.06); position: absolute; right: -20px; top: 18%; transform: rotate(-20deg); }
.auth-brand h1 { font-weight: 700; font-size: 2.2rem; line-height: 1.25; max-width: 440px; }
.auth-brand h1 span { color: var(--km-yellow); }
.auth-brand .feature { display: flex; gap: .75rem; align-items: center; margin-bottom: .9rem; opacity: .92; }
.auth-brand .feature i { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: rgba(255,255,255,.1); color: var(--km-yellow); }

.auth-form { flex: 1 1 50%; display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; background: #fff; }
.auth-card { width: 100%; max-width: 410px; }
.auth-card .logo { height: 96px; }
.auth-card h2 { font-weight: 700; color: var(--km-navy); }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--km-muted); }
.input-icon .form-control { padding-left: 42px; height: 48px; border-radius: 10px; }
.input-icon .toggle-pass { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--km-muted); padding: 6px 10px; }
.auth-card .btn-lg { height: 48px; border-radius: 10px; font-size: 1rem; font-weight: 600; }

@media (max-width: 991.98px) {
  .auth-brand { display: none; }
  .auth-form { background: linear-gradient(180deg, var(--km-blue-light), #fff 40%); }
}

/* =========================================================
   APP LAYOUT (sidebar + header)
   ========================================================= */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 1040;
  background: var(--km-navy); color: #cfe0ec; display: flex; flex-direction: column;
  transition: transform .25s ease;
}
.sidebar-logo { background: #fff; height: var(--header-h); display: flex; align-items: center; justify-content: center; border-bottom: 3px solid var(--km-yellow); }
.sidebar-logo img { height: 50px; }
.sidebar-menu { flex: 1; overflow-y: auto; padding: .75rem .75rem 1.5rem; }
.sidebar-menu::-webkit-scrollbar { width: 5px; }
.sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 5px; }
.menu-title { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #7fa3bb; margin: 1rem .75rem .4rem; }
.sidebar-menu .nav-link {
  color: #cfe0ec; display: flex; align-items: center; gap: .75rem; padding: .6rem .8rem;
  border-radius: 8px; margin-bottom: 2px; font-size: .9rem;
}
.sidebar-menu .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar-menu .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-menu .nav-link.active { background: var(--km-blue); color: #fff; box-shadow: inset 3px 0 0 var(--km-yellow); }
.sidebar-menu .nav-link .badge { margin-left: auto; }
.sidebar-footer { padding: .9rem 1rem; border-top: 1px solid rgba(255,255,255,.08); font-size: .8rem; color: #7fa3bb; }

.app-header {
  position: fixed; top: 0; right: 0; left: var(--sidebar-w); height: var(--header-h); z-index: 1030;
  background: #fff; border-bottom: 1px solid var(--km-border);
  display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem;
}
.app-header .btn-icon { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--km-border); background: #fff; display: grid; place-items: center; color: var(--km-navy); position: relative; }
.app-header .btn-icon:hover { background: var(--km-blue-light); }
.app-header .btn-icon .dot { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: #dc3545; color: #fff; font-size: .62rem; line-height: 16px; text-align: center; }
.header-search { max-width: 340px; }
.header-search .form-control { border-radius: 10px; background: var(--km-bg); border-color: transparent; padding-left: 38px; }
.header-search i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--km-muted); }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; background: var(--km-yellow); color: var(--km-navy); flex-shrink: 0; }
.avatar-lg { width: 96px; height: 96px; font-size: 2rem; }
.user-btn { border: 0; background: none; display: flex; align-items: center; gap: .6rem; padding: 4px 6px; border-radius: 10px; }
.user-btn:hover { background: var(--km-bg); }
.user-btn .name { font-weight: 600; font-size: .875rem; line-height: 1.1; color: var(--km-navy); text-align: left; }
.user-btn .role { font-size: .72rem; color: var(--km-muted); }

.notif-menu { width: 340px; padding: 0; }
.notif-item { display: flex; gap: .75rem; padding: .75rem 1rem; border-bottom: 1px solid var(--km-border); white-space: normal; }
.notif-item:hover { background: var(--km-bg); }
.notif-item .ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.notif-item.unread { background: #f7fbff; }

.app-main { margin-left: var(--sidebar-w); padding: calc(var(--header-h) + 1.5rem) 1.5rem 1.5rem; min-height: 100vh; display: flex; flex-direction: column; }
.app-footer { margin-top: auto; padding-top: 1.5rem; font-size: .8rem; color: var(--km-muted); }

.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-head h4 { margin: 0; font-weight: 700; color: var(--km-navy); }
.breadcrumb { margin: 0; font-size: .8rem; }

/* Role switcher (demo only - removed in PHP) */
.role-switch .btn { font-size: .78rem; }

/* Cards */
.card { border: 1px solid var(--km-border); border-radius: 14px; box-shadow: 0 1px 2px rgba(11,68,98,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--km-border); padding: .9rem 1.25rem; font-weight: 600; color: var(--km-navy); border-radius: 14px 14px 0 0 !important; }
.stat-card { padding: 1.15rem 1.25rem; display: flex; align-items: center; gap: 1rem; height: 100%; }
.stat-card .ico { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 1.4rem; flex-shrink: 0; }
.stat-card .val { font-size: 1.5rem; font-weight: 700; color: var(--km-navy); line-height: 1.1; }
.stat-card .lbl { font-size: .8rem; color: var(--km-muted); }
.ico-blue { background: var(--km-blue-light); color: var(--km-blue); }
.ico-navy { background: #e2ecf2; color: var(--km-navy); }
.ico-yellow { background: var(--km-yellow-soft); color: #9a8f00; }
.ico-green { background: #e5f6ec; color: #198754; }
.ico-red { background: #fdeaea; color: #dc3545; }

.welcome-card {
  background: linear-gradient(120deg, var(--km-navy), var(--km-blue)); color: #fff; border: 0; position: relative; overflow: hidden;
}
.welcome-card::after { content: ""; position: absolute; right: -40px; bottom: -30px; width: 260px; height: 140px; background: repeating-linear-gradient(-18deg, var(--km-yellow) 0 8px, transparent 8px 20px); opacity: .25; }
.welcome-card .clock { font-size: 1.8rem; font-weight: 700; }

.table > :not(caption) > * > * { padding: .75rem 1rem; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--km-muted); background: #f8fafc; font-weight: 600; }

/* Profile */
.profile-cover { height: 110px; background: linear-gradient(120deg, var(--km-navy), var(--km-blue)); border-radius: 14px 14px 0 0; position: relative; }
.profile-cover::after { content: ""; position: absolute; right: 20px; bottom: 15px; width: 160px; height: 70px; background: repeating-linear-gradient(-18deg, var(--km-yellow) 0 6px, transparent 6px 16px); opacity: .35; }
.profile-avatar-wrap { margin-top: -48px; position: relative; display: inline-block; }
.profile-avatar-wrap .avatar-lg { border: 4px solid #fff; }
.profile-avatar-wrap .cam { position: absolute; right: 0; bottom: 4px; width: 30px; height: 30px; border-radius: 50%; background: var(--km-blue); color: #fff; border: 2px solid #fff; display: grid; place-items: center; font-size: .8rem; }
.info-list li { display: flex; justify-content: space-between; padding: .55rem 0; border-bottom: 1px dashed var(--km-border); font-size: .875rem; }
.info-list li span:first-child { color: var(--km-muted); }
.nav-tabs .nav-link { color: var(--km-muted); font-weight: 500; border: 0; border-bottom: 2px solid transparent; }
.nav-tabs .nav-link.active { color: var(--km-blue); border-bottom-color: var(--km-blue); background: none; }

.strength { height: 6px; border-radius: 4px; background: var(--km-border); overflow: hidden; }
.strength > div { height: 100%; width: 0; transition: width .25s, background .25s; }
.rule-list li { font-size: .82rem; color: var(--km-muted); margin-bottom: .3rem; }
.rule-list li.ok { color: #198754; }

/* Backdrop for mobile sidebar */
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(7,47,69,.5); z-index: 1035; display: none; }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .app-header { left: 0; padding: 0 .75rem; }
  .app-main { margin-left: 0; padding: calc(var(--header-h) + 1rem) .9rem 1rem; }
}
@media (max-width: 575.98px) {
  .notif-menu { width: calc(100vw - 24px); }
  .stat-card { padding: .9rem; gap: .75rem; }
  .stat-card .ico { width: 44px; height: 44px; font-size: 1.2rem; }
  .stat-card .val { font-size: 1.2rem; }
  .page-head h4 { font-size: 1.15rem; }
  .table > :not(caption) > * > * { padding: .6rem .7rem; }
}

/* =========================================================
   SUPER ADMIN PAGES
   ========================================================= */
/* "Login as" bar */
.imp-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 44px; z-index: 1050;
  background: var(--km-yellow); color: var(--km-navy); font-size: .85rem;
  display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 0 1rem;
}
body.impersonating .sidebar, body.impersonating .app-header { top: 44px; }
body.impersonating .app-main { padding-top: calc(var(--header-h) + 44px + 1.5rem); }
@media (max-width: 575.98px) { .imp-bar { font-size: .72rem; height: 56px; } body.impersonating .sidebar, body.impersonating .app-header { top: 56px; } body.impersonating .app-main { padding-top: calc(var(--header-h) + 56px + 1rem); } }

/* Filter bar above tables */
.filter-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; padding: 1rem 1.25rem; border-bottom: 1px solid var(--km-border); }
.filter-bar .form-control, .filter-bar .form-select { min-width: 150px; }
.filter-bar .search-box { position: relative; flex: 1 1 220px; }
.filter-bar .search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--km-muted); }
.filter-bar .search-box input { padding-left: 34px; }
.filter-bar label { font-size: .72rem; color: var(--km-muted); margin-bottom: 2px; display: block; }
@media (max-width: 575.98px) { .filter-bar > * { flex: 1 1 100%; } .filter-bar .form-control, .filter-bar .form-select { min-width: 0; width: 100%; } }

.btn-act { width: 32px; height: 32px; padding: 0; display: inline-grid; place-items: center; border-radius: 8px; }
.table td .small-muted { font-size: .75rem; color: var(--km-muted); }
.table tfoot td { font-weight: 700; background: #f8fafc; color: var(--km-navy); }
.avatar-sm { width: 32px; height: 32px; font-size: .75rem; }
.mini-stat { border: 1px solid var(--km-border); border-radius: 12px; padding: .8rem 1rem; background: #fff; height: 100%; }
.mini-stat .v { font-size: 1.25rem; font-weight: 700; color: var(--km-navy); }
.mini-stat .l { font-size: .75rem; color: var(--km-muted); }

/* Tabs as pills inside cards */
.nav-pills .nav-link { color: var(--km-muted); font-weight: 500; border-radius: 8px; padding: .45rem .9rem; font-size: .875rem; white-space: nowrap; }
.nav-pills .nav-link.active { background: var(--km-blue); }
.tabs-scroll { overflow-x: auto; flex-wrap: nowrap; }

/* Form section titles */
.form-section { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--km-blue); font-weight: 600; margin: 1.25rem 0 .75rem; padding-bottom: .4rem; border-bottom: 1px dashed var(--km-border); }
.form-section:first-child { margin-top: 0; }
.form-label { font-size: .82rem; font-weight: 500; margin-bottom: .3rem; }
.req::after { content: " *"; color: #dc3545; }

/* Wizard steps (employee form) */
.wizard-steps { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: 2px; }
.wizard-steps .step { flex: 1 0 auto; display: flex; align-items: center; gap: .5rem; padding: .6rem .9rem; border-radius: 10px; background: var(--km-bg); color: var(--km-muted); font-size: .82rem; font-weight: 500; border: 0; }
.wizard-steps .step .n { width: 24px; height: 24px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: .75rem; border: 1px solid var(--km-border); }
.wizard-steps .step.active { background: var(--km-blue); color: #fff; }
.wizard-steps .step.active .n { color: var(--km-blue); border-color: #fff; }
.wizard-steps .step.done .n { background: #198754; color: #fff; border-color: #198754; }

/* Kanban */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 1rem; overflow-x: auto; padding-bottom: .5rem; }
.kanban-col { background: #eef3f7; border-radius: 12px; padding: .75rem; min-height: 200px; }
.kanban-col h6 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--km-muted); display: flex; justify-content: space-between; }
.kanban-card { background: #fff; border-radius: 10px; padding: .75rem; margin-bottom: .6rem; border: 1px solid var(--km-border); font-size: .85rem; }
.kanban-card .t { font-weight: 600; color: var(--km-navy); margin-bottom: .3rem; }

/* Permission matrix */
.perm-table th, .perm-table td { text-align: center; vertical-align: middle; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.perm-table .form-check-input { float: none; margin: 0; }

/* Calendar grid (attendance) */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-grid .d { aspect-ratio: 1; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: .78rem; background: var(--km-bg); }
.cal-grid .d small { font-size: .6rem; }
.cal-grid .h { text-align: center; font-size: .7rem; color: var(--km-muted); font-weight: 600; }
.cal-grid .P { background: #e5f6ec; color: #146c43; } .cal-grid .L { background: #fff4d6; color: #997404; }
.cal-grid .A { background: #fdeaea; color: #b02a37; } .cal-grid .V { background: var(--km-blue-light); color: var(--km-blue); }
.cal-grid .W { background: transparent; color: #adb5bd; } .cal-grid .H { background: #efedff; color: #5a3fd1; }

/* Catalogue cards */
.cat-card img, .cat-card .ph { height: 150px; object-fit: cover; width: 100%; border-radius: 14px 14px 0 0; }
.cat-card .ph { display: grid; place-items: center; font-size: 2.5rem; color: #fff; }
.ph-1 { background: linear-gradient(135deg, #1779b9, #4fc3f7); } .ph-2 { background: linear-gradient(135deg, #0b4462, #1779b9); }
.ph-3 { background: linear-gradient(135deg, #c69c00, #fff200); } .ph-4 { background: linear-gradient(135deg, #198754, #6fcf97); }

/* Invoice paper */
.invoice-paper { background: #fff; max-width: 860px; margin: 0 auto; padding: 2.5rem; border-radius: 14px; border: 1px solid var(--km-border); }
.invoice-paper .inv-title { font-size: 1.6rem; font-weight: 700; color: var(--km-navy); letter-spacing: .04em; }
.invoice-paper table th { background: var(--km-navy) !important; color: #fff !important; }
.inv-stripe { height: 6px; background: repeating-linear-gradient(-18deg, var(--km-yellow) 0 8px, var(--km-navy) 8px 16px); border-radius: 3px; }
@media (max-width: 575.98px) { .invoice-paper { padding: 1.25rem; } }

/* Upload drop zone */
.dropzone { border: 2px dashed #b9cfe0; border-radius: 12px; padding: 1.5rem; text-align: center; background: #f7fbff; cursor: pointer; color: var(--km-muted); }
.dropzone:hover { border-color: var(--km-blue); }
.file-chip { display: inline-flex; align-items: center; gap: .4rem; background: var(--km-bg); border-radius: 8px; padding: .3rem .6rem; font-size: .8rem; margin: .25rem .25rem 0 0; }

.chart-box { position: relative; height: 280px; }
.timeline { list-style: none; padding-left: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 1rem 1.5rem; border-left: 2px solid var(--km-border); margin-left: .5rem; font-size: .85rem; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: var(--km-blue); border: 2px solid #fff; }

@media print {
  .sidebar, .app-header, .page-head, .no-print, .app-footer, .imp-bar { display: none !important; }
  .app-main { margin: 0; padding: 0; }
  body { background: #fff; }
  .invoice-paper, .card { border: 0; box-shadow: none; }
}

/* Keep absolutely positioned checkboxes (btn-check) inside scrolling tables */
.table-responsive, .tabs-scroll { position: relative; }
.invoice-paper { overflow-wrap: anywhere; }
/* .card is a column flexbox in Bootstrap; stat cards sit in a row */
.stat-card { flex-direction: row; }
.welcome-card h3, .welcome-card h1 { color: #fff; }
.table td.text-end, .table th.text-end { white-space: nowrap; }
