/* =========================================================
   MAA Buildcon ERP — Core Stylesheet
   Developed by Xceptive Solutions LLP
   ========================================================= */

:root {
  --brand: #1f3a5f;          /* deep steel navy */
  --brand-dark: #142a47;
  --brand-light: #2c5282;
  --accent: #f59e0b;         /* construction amber */
  --accent-dark: #d97706;
  --success: #16a34a;
  --danger: #dc2626;
  --info: #0284c7;
  --warning: #ea580c;

  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8ef;
  --text: #1e293b;
  --text-muted: #64748b;

  --sidebar-w: 260px;
  --sidebar-mini-w: 72px;
  --header-h: 60px;
  --bottomnav-h: 62px;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 4px 16px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; }

.text-muted-2 { color: var(--text-muted) !important; }
.fw-600 { font-weight: 600; }
.fs-12 { font-size: 12px; }
.fs-13 { font-size: 13px; }

/* ---------- Brand mark ---------- */
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; letter-spacing: .5px;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(245, 158, 11, .35);
}
.brand-name { font-weight: 700; font-size: 16px; line-height: 1.1; color: #fff; }
.brand-sub { font-size: 11px; color: rgba(255,255,255,.6); letter-spacing: .4px; }

/* =========================================================
   SIDEBAR
   ========================================================= */
.app-sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--brand-dark);
  color: #cbd5e1;
  z-index: 1040;
  display: flex; flex-direction: column;
  transition: width .25s ease, transform .25s ease;
}
.sidebar-brand {
  height: var(--header-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar-menu {
  flex: 1; overflow-y: auto;
  padding: 12px 10px 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.15) transparent;
}
.menu-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px;
  color: rgba(255,255,255,.4);
  padding: 14px 12px 6px;
  font-weight: 600;
}
.menu-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #cbd5e1;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.menu-link i.mi { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
.menu-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.menu-link.active {
  background: linear-gradient(90deg, rgba(245,158,11,.22), rgba(245,158,11,.05));
  color: #fff;
  box-shadow: inset 3px 0 0 var(--accent);
}
.menu-link .caret { margin-left: auto; font-size: 12px; transition: transform .2s; }
.menu-link[aria-expanded="true"] .caret { transform: rotate(90deg); }
.menu-link .badge { margin-left: auto; }

.submenu { list-style: none; padding: 2px 0 6px 0; margin: 0; }
.submenu a {
  display: block;
  padding: 7px 12px 7px 46px;
  color: #94a3b8;
  font-size: 13px;
  border-radius: 6px;
  position: relative;
}
.submenu a::before {
  content: ""; position: absolute; left: 22px; top: 50%;
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; opacity: .5; transform: translateY(-50%);
}
.submenu a:hover { color: #fff; background: rgba(255,255,255,.04); }
.submenu a.active { color: var(--accent); font-weight: 600; }
.submenu a.active::before { opacity: 1; }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 11px; color: rgba(255,255,255,.45);
  flex-shrink: 0;
}

/* Mini (collapsed) sidebar — desktop only */
@media (min-width: 992px) {
  body.sidebar-mini .app-sidebar { width: var(--sidebar-mini-w); }
  body.sidebar-mini .app-sidebar .brand-text,
  body.sidebar-mini .app-sidebar .menu-title,
  body.sidebar-mini .app-sidebar .menu-link span,
  body.sidebar-mini .app-sidebar .menu-link .caret,
  body.sidebar-mini .app-sidebar .menu-link .badge,
  body.sidebar-mini .app-sidebar .submenu,
  body.sidebar-mini .app-sidebar .sidebar-footer { display: none !important; }
  body.sidebar-mini .app-sidebar .menu-link { justify-content: center; }
  body.sidebar-mini .app-sidebar .sidebar-brand { justify-content: center; padding: 0; }
  body.sidebar-mini .app-main { margin-left: var(--sidebar-mini-w); }
}
.min-w-0 { min-width: 0; }

.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .5);
  z-index: 1035;
  opacity: 0; visibility: hidden;
  transition: opacity .2s;
}

/* =========================================================
   HEADER
   ========================================================= */
.app-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left .25s ease;
}
.app-header {
  position: sticky; top: 0; z-index: 1030;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
}
.btn-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 18px;
  position: relative;
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--surface-2); color: var(--brand); }
.btn-icon .dot {
  position: absolute; top: 7px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); border: 2px solid #fff;
}
.header-search {
  position: relative; max-width: 380px; flex: 1;
}
.header-search input {
  border-radius: 10px; padding-left: 38px;
  background: var(--surface-2); border-color: var(--border);
  height: 38px;
}
.header-search i {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted);
}
.fy-pill {
  font-size: 12px; font-weight: 600;
  background: #eef4ff; color: var(--brand-light);
  border-radius: 20px; padding: 6px 12px;
  white-space: nowrap;
}
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px 4px 4px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
}
.user-chip .u-name { font-weight: 600; font-size: 13px; line-height: 1.1; }
.user-chip .u-role { font-size: 11px; color: var(--text-muted); }

/* =========================================================
   CONTENT
   ========================================================= */
.app-content { flex: 1; padding: 22px 20px; }

.page-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 18px;
}
.page-title { font-size: 20px; font-weight: 700; margin: 0; }
.breadcrumb { font-size: 12px; margin: 2px 0 0; }
.breadcrumb a { color: var(--text-muted); }

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: var(--surface);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap;
}
.card-title { font-size: 15px; font-weight: 600; margin: 0; }

/* KPI cards */
.kpi {
  padding: 16px;
  display: flex; gap: 14px; align-items: flex-start;
  height: 100%;
}
.kpi-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.kpi-value { font-size: 20px; font-weight: 700; margin: 2px 0; white-space: nowrap; }
.kpi-trend { font-size: 12px; font-weight: 600; }
.kpi-trend.up, .kpi-trend .up { color: var(--success); }
.kpi-trend.down, .kpi-trend .down { color: var(--danger); }
a.card.kpi { transition: box-shadow .15s, border-color .15s; }
a.card.kpi:hover { border-color: var(--brand-light); }

.bg-soft-brand   { background: #e6eef8; color: var(--brand-light); }
.bg-soft-accent  { background: #fef3c7; color: var(--accent-dark); }
.bg-soft-success { background: #dcfce7; color: var(--success); }
.bg-soft-danger  { background: #fee2e2; color: var(--danger); }
.bg-soft-info    { background: #e0f2fe; color: var(--info); }
.bg-soft-warning { background: #ffedd5; color: var(--warning); }

/* Quick actions */
.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.qa-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 14px 6px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 12px; font-weight: 500; text-align: center;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.qa-item i { font-size: 22px; }
.qa-item:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--accent); color: var(--text); }

/* Segmented period toggle */
.seg {
  display: inline-flex; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 3px;
}
.seg button {
  border: 0; background: transparent;
  padding: 5px 12px; font-size: 12px; font-weight: 600;
  border-radius: 7px; color: var(--text-muted);
}
.seg button.active { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }

/* Tables */
.table { margin: 0; }
.table > :not(caption) > * > * { padding: 11px 14px; border-color: var(--border); }
.table thead th {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); font-weight: 600;
  background: var(--surface-2);
  white-space: nowrap;
}
.table td { vertical-align: middle; }
.table-hover tbody tr:hover > * { background: #fafbfd; }

/* Bill type tags */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; font-weight: 600;
  padding: 3px 8px; border-radius: 20px;
  white-space: nowrap;
}
.tag-gst    { background: #e0f2fe; color: #0369a1; }
.tag-nogst  { background: #f1f5f9; color: #475569; }
.tag-stock  { background: #dcfce7; color: #15803d; }
.tag-bill   { background: #fef3c7; color: #b45309; }
.tag-cn     { background: #ede9fe; color: #6d28d9; }
.tag-dn     { background: #fee2e2; color: #b91c1c; }

/* Cost list */
.cost-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.cost-row:last-child { border-bottom: 0; }
.cost-row .p-ico {
  width: 38px; height: 38px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--brand); font-size: 18px; flex-shrink: 0;
}
.cost-row .p-name { font-weight: 600; font-size: 13.5px; }
.cost-row .p-meta { font-size: 11.5px; color: var(--text-muted); }
.cost-row .p-price { margin-left: auto; text-align: right; }
.cost-row .p-price .v { font-weight: 700; font-size: 14px; }

.progress { height: 6px; border-radius: 6px; background: #eef2f7; }

/* Buttons */
.btn { border-radius: 10px; font-weight: 500; font-size: 13.5px; }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #1f2937; }
.btn-accent:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }

/* =========================================================
   FOOTER
   ========================================================= */
.app-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px; color: var(--text-muted);
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: space-between;
}
.app-footer a { color: var(--brand-light); font-weight: 600; }

/* =========================================================
   MOBILE BOTTOM NAV + FAB
   ========================================================= */
.bottom-nav { display: none; }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--bottomnav-h) + 16px);
  width: 54px; height: 54px; border-radius: 50%;
  background: var(--accent); color: #1f2937;
  display: none; align-items: center; justify-content: center;
  font-size: 26px; border: 0;
  box-shadow: 0 8px 20px rgba(245, 158, 11, .45);
  z-index: 1025;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); }
  body.sidebar-open .app-sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-overlay { opacity: 1; visibility: visible; }
  body.sidebar-open { overflow: hidden; }

  .app-main { margin-left: 0; }
  .app-header { padding: 0 12px; }
  .app-content { padding: 16px 12px calc(var(--bottomnav-h) + 24px); }
  .app-footer { padding-bottom: calc(var(--bottomnav-h) + 14px); justify-content: center; text-align: center; }

  .bottom-nav {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0;
    height: var(--bottomnav-h);
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(16,24,40,.06);
    z-index: 1030;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav a {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px;
    color: var(--text-muted);
    font-size: 10.5px; font-weight: 500;
  }
  .bottom-nav a i { font-size: 20px; }
  .bottom-nav a.active { color: var(--brand); }
  .bottom-nav a.active i { color: var(--accent-dark); }
  .fab { display: flex; }
}

@media (max-width: 575.98px) {
  .page-title { font-size: 18px; }
  .kpi { padding: 12px; gap: 10px; }
  .kpi-icon { width: 38px; height: 38px; font-size: 17px; border-radius: 10px; }
  .kpi-value { font-size: 16px; }
  .kpi-label { font-size: 11px; }
  .quick-actions { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .qa-item { padding: 10px 4px; font-size: 10.5px; }
  .qa-item i { font-size: 19px; }
  .card-header { padding: 12px; }
  .table > :not(caption) > * > * { padding: 9px 10px; }
}

/* =========================================================
   LOGIN
   ========================================================= */
.login-wrap {
  min-height: 100vh;
  display: grid; grid-template-columns: 1.1fr 1fr;
}
.login-hero {
  background:
    linear-gradient(160deg, rgba(20,42,71,.96), rgba(31,58,95,.92)),
    repeating-linear-gradient(45deg, rgba(255,255,255,.03) 0 12px, transparent 12px 24px);
  color: #fff;
  padding: 48px;
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.login-hero::after {
  content: ""; position: absolute; right: -120px; bottom: -120px;
  width: 360px; height: 360px; border-radius: 50%;
  border: 40px solid rgba(245,158,11,.12);
}
.login-hero h1 { font-size: 34px; font-weight: 800; line-height: 1.2; }
.login-hero h1 span { color: var(--accent); }
.hero-points { list-style: none; padding: 0; margin: 24px 0 0; }
.hero-points li { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; color: rgba(255,255,255,.85); }
.hero-points i { color: var(--accent); font-size: 18px; }

.login-panel {
  display: flex; align-items: center; justify-content: center;
  padding: 32px 20px;
  background: var(--surface);
}
.login-card { width: 100%; max-width: 400px; }
.login-card .form-control, .login-card .form-select {
  height: 46px; border-radius: 10px; font-size: 14px;
}
.login-card .input-group-text { border-radius: 10px; background: var(--surface-2); }
.login-card .btn-lg { height: 48px; font-size: 15px; font-weight: 600; }
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 .2rem rgba(245,158,11,.2);
}

@media (max-width: 991.98px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { padding: 28px 22px 60px; min-height: auto; }
  .login-hero h1 { font-size: 24px; }
  .login-hero .hero-points, .login-hero .hero-foot { display: none; }
  .login-panel {
    margin-top: -36px; border-radius: 22px 22px 0 0;
    align-items: flex-start; position: relative; z-index: 2;
  }
}
.text-brand { color: var(--brand-light) !important; }
.fw-700 { font-weight: 700 !important; }
