/* ================================================================
   FAUEL – App Layout & Design System
   Bootstrap 4.5 companion stylesheet
   ================================================================ */

:root {
  --sb-width: 260px;
  --sb-bg: #1e293b;
  --sb-border: rgba(255,255,255,.07);
  --sb-color: #94a3b8;
  --sb-color-hover: #e2e8f0;
  --sb-active-bg: rgba(59,130,246,.15);
  --sb-active-color: #60a5fa;
  --sb-brand-bg: #0f172a;
  --bar-h: 56px;
  --primary: #3b82f6;
  --content-bg: #f1f5f9;
  --radius: 10px;
}

/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--content-bg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  font-size: .9rem;
  color: #1e293b;
}

a { color: var(--primary); }
a:hover { color: #2563eb; }

/* ── App wrapper ── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ================================================================
   SIDEBAR
   ================================================================ */
.app-sidebar {
  width: var(--sb-width);
  min-height: 100vh;
  background: var(--sb-bg);
  position: fixed;
  top: 0;
  left: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1030;
  display: flex;
  flex-direction: column;
  transition: transform .25s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}
.app-sidebar::-webkit-scrollbar { width: 4px; }
.app-sidebar::-webkit-scrollbar-track { background: transparent; }
.app-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 4px; }

/* Brand */
.sb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  height: var(--bar-h);
  background: var(--sb-brand-bg);
  text-decoration: none !important;
  color: #fff !important;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: .2px;
  flex-shrink: 0;
}
.sb-brand img {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  object-fit: contain;
  background: #fff;
  padding: 2px;
}

/* Project context badge */
.sb-project {
  margin: 10px 12px 4px;
  padding: 10px 12px;
  background: rgba(255,255,255,.05);
  border-radius: 8px;
  border: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.sb-project-name {
  color: #e2e8f0;
  font-weight: 600;
  font-size: .8rem;
  line-height: 1.35;
  margin-bottom: 2px;
}
.sb-project-code {
  color: #475569;
  font-size: .72rem;
  font-family: monospace;
}

/* Navigation container */
.sb-nav {
  flex: 1;
  padding: 6px 0 8px;
}

/* Section label */
.sb-label {
  padding: 14px 20px 4px;
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #475569;
  user-select: none;
}

/* Plain link (top-level, no children) */
.sb-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--sb-color);
  text-decoration: none !important;
  font-size: .84rem;
  transition: background .15s, color .15s;
  white-space: nowrap;
  overflow: hidden;
}
.sb-link:hover { background: rgba(255,255,255,.05); color: var(--sb-color-hover); }
.sb-link.active {
  background: var(--sb-active-bg);
  color: var(--sb-active-color);
  font-weight: 600;
}
.sb-link > i { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; }

/* Collapsible group toggle (button) */
.sb-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--sb-color);
  font-size: .84rem;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
  overflow: hidden;
}
.sb-toggle:hover { background: rgba(255,255,255,.05); color: var(--sb-color-hover); }
.sb-toggle > .icon { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; }
.sb-toggle > .label { flex: 1; }

/* Chevron */
.sb-chevron {
  margin-left: auto;
  font-size: .72rem;
  transition: transform .2s ease;
  flex-shrink: 0;
  color: #475569;
}
.sb-toggle[aria-expanded="true"] .sb-chevron { transform: rotate(180deg); }

/* Sub-level link */
.sb-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 20px 7px 48px;
  color: #64748b;
  font-size: .82rem;
  text-decoration: none !important;
  transition: background .15s, color .15s;
}
.sb-sub:hover { background: rgba(255,255,255,.04); color: #e2e8f0; }
.sb-sub.active { color: var(--sb-active-color); font-weight: 600; }

/* Sub-group toggle inside a collapse */
.sb-subtoggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 20px 7px 48px;
  color: #64748b;
  font-size: .82rem;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: color .15s;
}
.sb-subtoggle:hover { color: #e2e8f0; }
.sb-subtoggle[aria-expanded="true"] .sb-chevron { transform: rotate(180deg); }

/* Sub-sub-level link */
.sb-subsub {
  display: flex;
  align-items: center;
  padding: 6px 20px 6px 66px;
  color: #475569;
  font-size: .79rem;
  text-decoration: none !important;
  transition: background .15s, color .15s;
}
.sb-subsub::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  background: currentColor;
  border-radius: 50%;
  margin-right: 8px;
  opacity: .5;
  flex-shrink: 0;
}
.sb-subsub:hover { color: #e2e8f0; }
.sb-subsub.active { color: var(--sb-active-color); font-weight: 600; }

/* Divider */
.sb-divider {
  height: 1px;
  background: var(--sb-border);
  margin: 6px 16px;
}

/* Footer of sidebar */
.sb-footer {
  flex-shrink: 0;
  padding: 6px 0 12px;
  border-top: 1px solid var(--sb-border);
}
.sb-footer .sb-link { font-size: .82rem; }
.sb-footer .sb-link.danger { color: #f87171; }
.sb-footer .sb-link.danger:hover { background: rgba(239,68,68,.12); color: #fca5a5; }

/* ================================================================
   TOP BAR
   ================================================================ */
.app-topbar {
  height: var(--bar-h);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 1020;
  box-shadow: 0 1px 2px rgba(0,0,0,.05);
  flex-shrink: 0;
}

.topbar-toggle {
  background: none;
  border: none;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  color: #64748b;
  font-size: 1.25rem;
  line-height: 1;
  display: none;
  margin-right: 4px;
}
.topbar-toggle:hover { background: #f1f5f9; }

.topbar-title {
  font-weight: 600;
  color: #1e293b;
  font-size: .92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #475569;
  font-size: .82rem;
  white-space: nowrap;
}
.topbar-user i { font-size: 1.15rem; }

/* ================================================================
   CONTENT AREA
   ================================================================ */
.app-content {
  margin-left: var(--sb-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left .25s ease;
}

.app-main {
  flex: 1;
  padding: 28px 24px;
  min-width: 0;
}

/* Page header */
.page-header {
  margin-bottom: 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid #e2e8f0;
}
.page-header h1,
.page-header .page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 4px;
}
.page-header .breadcrumb {
  margin: 0;
  padding: 0;
  background: none;
  font-size: .8rem;
  color: #64748b;
}
.page-header .breadcrumb-item + .breadcrumb-item::before { color: #94a3b8; }

/* ================================================================
   CARDS
   ================================================================ */
.card {
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  border-radius: var(--radius) !important;
}
.card-header {
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 600;
  color: #1e293b;
  border-radius: var(--radius) var(--radius) 0 0 !important;
}

/* Action cards (dashboard shortcuts) */
.action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 16px 20px;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius);
  background: #fff;
  transition: box-shadow .2s, transform .15s;
  text-decoration: none !important;
  color: #1e293b !important;
  height: 100%;
  cursor: pointer;
}
.action-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,.09);
  transform: translateY(-2px);
  border-color: #c7d2fe;
}
.action-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  margin-bottom: 12px;
  flex-shrink: 0;
}
.action-title { font-weight: 600; font-size: .88rem; margin-bottom: 4px; }
.action-desc  { font-size: .78rem; color: #64748b; line-height: 1.4; }

/* Icon color helpers */
.icon-blue   { background: #eff6ff; color: #3b82f6; }
.icon-green  { background: #f0fdf4; color: #22c55e; }
.icon-purple { background: #faf5ff; color: #a855f7; }
.icon-orange { background: #fff7ed; color: #f97316; }
.icon-red    { background: #fff1f2; color: #ef4444; }
.icon-teal   { background: #f0fdfa; color: #14b8a6; }
.icon-indigo { background: #eef2ff; color: #6366f1; }
.icon-slate  { background: #f8fafc; color: #64748b; }

/* Section heading on dashboard */
.section-heading {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .9px;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 14px;
  margin-top: 4px;
}

/* Status badges */
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-approved { background: #dcfce7; color: #166534; }
.badge-review   { background: #dbeafe; color: #1e40af; }

/* ================================================================
   TABLES
   ================================================================ */
.table thead th {
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
  font-weight: 600;
  font-size: .82rem;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
}
.table td { vertical-align: middle; font-size: .87rem; }
.table-hover tbody tr:hover { background: #f8fafc; }

/* ================================================================
   FORMS
   ================================================================ */
.form-control { border-color: #e2e8f0; border-radius: 7px !important; font-size: .87rem; }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.form-select { border-radius: 7px !important; }
.form-label { font-weight: 600; font-size: .84rem; color: #374151; margin-bottom: 5px; }

/* ================================================================
   BUTTONS
   ================================================================ */
.btn { border-radius: 7px !important; font-size: .85rem; font-weight: 500; }
.btn-sm { font-size: .78rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: #2563eb; border-color: #2563eb; }

/* ================================================================
   ALERTS
   ================================================================ */
.alert { border-radius: 8px; font-size: .87rem; border-width: 0; }
.alert-danger  { background: #fff1f2; color: #991b1b; border-left: 4px solid #ef4444; }
.alert-warning { background: #fffbeb; color: #92400e; border-left: 4px solid #f59e0b; }
.alert-success { background: #f0fdf4; color: #166534; border-left: 4px solid #22c55e; }
.alert-info    { background: #eff6ff; color: #1e40af; border-left: 4px solid #3b82f6; }

/* ================================================================
   MOBILE OVERLAY
   ================================================================ */
.sb-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1029;
  opacity: 0;
  transition: opacity .25s;
}
.sb-overlay.is-open {
  display: block;
  opacity: 1;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(calc(-1 * var(--sb-width))); }
  .app-sidebar.is-open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,.2); }
  .app-content { margin-left: 0; }
  .topbar-toggle { display: block; }
  .app-main { padding: 18px 14px; }
}

@media (max-width: 575.98px) {
  .app-main { padding: 14px 10px; }
  .action-icon { width: 42px; height: 42px; font-size: 1.2rem; }
}

/* ================================================================
   LOGIN PAGE
   ================================================================ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
}
.login-logo {
  display: block;
  margin: 0 auto 20px;
  width: 72px;
  height: 72px;
  object-fit: contain;
}
.login-title {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 6px;
}
.login-subtitle {
  text-align: center;
  font-size: .84rem;
  color: #64748b;
  margin-bottom: 28px;
}
.login-card .form-control {
  height: 44px;
  padding: 0 14px;
  font-size: .9rem;
}
.login-card .btn-primary {
  height: 44px;
  font-size: .95rem;
  font-weight: 600;
}
.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: .78rem;
  color: #94a3b8;
}
