/* ============================================================================
   Freemen Push Panel — Design system
   tokens -> base -> layout -> components -> utilities
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---------------------------------------------------------------------------
   TOKENS
   --------------------------------------------------------------------------- */
:root {
  --ink-900: #10151F;
  --ink-700: #232C3D;
  --ink-500: #5A6478;
  --paper:   #F7F6F3;
  --surface: #FFFFFF;
  --line:    #E4E1DA;
  --gold:    #B8860B;
  --gold-lift: #D9A520;
  --green:   #1B7F5A;
  --amber:   #B45309;
  --red:     #B3261E;

  --green-tint: rgba(27, 127, 90, 0.12);
  --amber-tint: rgba(180, 83, 9, 0.12);
  --red-tint:   rgba(179, 38, 30, 0.12);
  --gold-tint:  rgba(184, 134, 11, 0.12);

  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --fs-30: 30px;
  --fs-22: 22px;
  --fs-17: 17px;
  --fs-15: 15px;
  --fs-13: 13px;
  --fs-11: 11px;

  --radius: 10px;
  --sidebar-w: 248px;
  --transition: 120ms ease-out;
}

/* ---------------------------------------------------------------------------
   BASE
   --------------------------------------------------------------------------- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--paper);
  color: var(--ink-900);
  font-family: var(--font-ui);
  font-size: var(--fs-15);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; letter-spacing: -0.011em; font-weight: 600; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }

.num {
  font-family: var(--font-mono);
  font-size: 0.92em;
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

*:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--ink-900);
  color: #C7CCD6;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo .mark {
  font-weight: 600;
  font-size: var(--fs-17);
  letter-spacing: 0.02em;
  color: #fff;
}
.sidebar-logo .sub {
  display: block;
  font-size: var(--fs-11);
  color: #7C879C;
  margin-top: 2px;
}

.nav-group {
  padding: 18px 12px 4px;
}
.nav-group-label {
  font-size: var(--fs-11);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #5E6A80;
  padding: 0 10px 6px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 14px;
  color: #C7CCD6;
  border-left: 2px solid transparent;
  margin-bottom: 2px;
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover { background: rgba(255,255,255,0.05); color: #fff; }
.nav-link.active {
  background: var(--ink-700);
  color: #fff;
  border-left: 2px solid var(--gold);
  font-weight: 500;
}
.nav-link i { font-size: 16px; width: 18px; text-align: center; }

.nav-footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1030;
}

.app-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 12px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1020;
}
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--ink-500); }
.role-chip {
  font-size: var(--fs-11);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--gold-tint);
  color: var(--gold);
  font-weight: 600;
}

.app-content {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 32px 48px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-header h1 { font-size: var(--fs-22); }
.page-header .page-desc { font-size: 13px; color: var(--ink-500); margin-top: 4px; }

.section-stack > * + * { margin-top: 24px; }

/* ---------------------------------------------------------------------------
   COMPONENTS
   --------------------------------------------------------------------------- */

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-body { padding: 18px; }
.card-body.p-0 { padding: 0; }

/* Stat tile */
.stat-tile { padding: 18px; }
.stat-tile .label { font-size: var(--fs-11); text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-500); }
.stat-tile .value { font-size: var(--fs-30); font-weight: 600; margin-top: 6px; }
.stat-tile .value.green { color: var(--green); }
.stat-tile .value.red { color: var(--red); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-900);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.btn:hover { background: #F1EFEA; }
.btn--sm { padding: 5px 10px; font-size: 13px; }
.btn--primary {
  background: var(--gold);
  border-color: var(--gold);
  color: #fff;
}
.btn--primary:hover { background: var(--gold-lift); border-color: var(--gold-lift); }
.btn--danger {
  background: var(--surface);
  border-color: var(--red);
  color: var(--red);
}
.btn--danger:hover { background: var(--red-tint); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: #F1EFEA; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Fields */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 5px;
  color: var(--ink-900);
}
.field .help {
  font-size: 12px;
  color: var(--ink-500);
  margin-top: 5px;
}
.field .error {
  font-size: 12px;
  color: var(--red);
  margin-top: 5px;
}
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="url"],
.field input[type="number"],
.field input[type="file"],
.field select,
.field textarea {
  width: 100%;
  font-family: var(--font-ui);
  font-size: 14px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--ink-900);
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--gold);
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}
.field.has-error input, .field.has-error textarea, .field.has-error select {
  border-color: var(--red);
}

/* Toggle switch */
.toggle { position: relative; display: inline-block; width: 38px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .track {
  position: absolute; inset: 0; background: var(--line); border-radius: 999px;
  transition: background var(--transition); cursor: pointer;
}
.toggle .track::before {
  content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform var(--transition);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.toggle input:checked + .track { background: var(--gold); }
.toggle input:checked + .track::before { transform: translateX(16px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tab {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-500);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  cursor: pointer;
}
.tab:hover { color: var(--ink-900); }
.tab.active { color: var(--ink-900); border-bottom-color: var(--gold); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Data table */
.table-wrap { overflow-x: auto; }
.table-data { width: 100%; border-collapse: collapse; font-size: 14px; }
.table-data thead th {
  position: sticky; top: 0; background: var(--surface);
  text-align: left; font-size: var(--fs-11); text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--ink-500); font-weight: 600;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
}
.table-data th.num, .table-data td.num { text-align: right; }
.table-data tbody td { padding: 0 14px; height: 44px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table-data tbody tr:hover { background: rgba(0,0,0,0.02); }
.table-data th.sortable { cursor: pointer; user-select: none; }
.table-data th.sortable .sort-arrow { margin-left: 4px; opacity: 0.4; }
.table-data th.sortable.sorted .sort-arrow { opacity: 1; }

.table-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-top: 1px solid var(--line);
  font-size: 13px; color: var(--ink-500);
}

/* Status pill */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-11); text-transform: uppercase; letter-spacing: 0.05em;
  font-weight: 600; padding: 3px 8px; border-radius: 999px;
}
.pill--green { background: var(--green-tint); color: var(--green); }
.pill--amber { background: var(--amber-tint); color: var(--amber); }
.pill--red { background: var(--red-tint); color: var(--red); }
.pill--neutral { background: #EEECE6; color: var(--ink-500); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
}
.empty-state h3 { font-size: 15px; margin-bottom: 6px; }
.empty-state p { font-size: 13px; color: var(--ink-500); margin-bottom: 16px; }

/* Skeleton loaders */
.skeleton {
  background: linear-gradient(90deg, #ECEAE4 25%, #F4F2ED 37%, #ECEAE4 63%);
  background-size: 400% 100%;
  animation: skeleton-wave 1.4s ease infinite;
  border-radius: 6px;
}
@keyframes skeleton-wave { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* Toasts */
.toast-stack {
  position: fixed; bottom: 20px; right: 20px; z-index: 1080;
  display: flex; flex-direction: column; gap: 8px;
}
.toast-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--ink-900); color: #fff;
  padding: 12px 16px; border-radius: 8px;
  font-size: 13px; min-width: 240px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  animation: toast-in var(--transition);
}
.toast-item.success i { color: #6FE0B4; }
.toast-item.danger i { color: #FF8A80; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* Modal (used with Bootstrap's JS behavior, restyled) */
.modal-content {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(16,21,31,0.18);
}
.modal-header, .modal-footer { border-color: var(--line); }
.modal-title { font-size: 16px; font-weight: 600; }

/* Config health strip */
.health-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}
.health-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line);
  font-size: 13px; background: var(--surface);
}
.health-item .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.health-item .dot.ok { background: var(--green); }
.health-item .dot.bad { background: var(--red); }

/* Android preview frame */
.phone-frame {
  width: 300px;
  margin: 0 auto;
  border: 10px solid var(--ink-900);
  border-radius: 34px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(16,21,31,0.15);
}
.phone-screen { padding: 14px 10px; background: #f1f3f4; min-height: 200px; }
.phone-notif { background: #fff; border-radius: 12px; padding: 10px 12px; }
.phone-notif .app-row { font-size: 11px; color: #5f6368; display: flex; align-items: center; gap: 5px; margin-bottom: 4px; }
.phone-notif .title { font-weight: 600; font-size: 13.5px; color: #111; }
.phone-notif .body { font-size: 12.5px; color: #3c4043; margin-top: 2px; }
.phone-notif img { width: 100%; border-radius: 8px; margin-top: 8px; max-height: 130px; object-fit: cover; }

/* ---------------------------------------------------------------------------
   UTILITIES
   --------------------------------------------------------------------------- */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 6px; }
.gap-2 { gap: 12px; }
.gap-3 { gap: 18px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.text-muted { color: var(--ink-500); }
.text-sm { font-size: 13px; }
.text-xs { font-size: var(--fs-11); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.w-full { width: 100%; }
.hidden { display: none !important; }

@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; }
  .app-main { margin-left: 0; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
/* =========================================================
   SIDEBAR BRAND / LOGO
   ========================================================= */

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

.sidebar-logo-main {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.sidebar-logo-icon {
    width: 44px;
    height: 44px;

    flex: 0 0 44px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #f4c430;
    color: #111827;

    border-radius: 10px;

    font-size: 24px;
    font-weight: 800;
    line-height: 1;

    box-shadow:
        0 4px 14px rgba(0,0,0,0.22);
}

.sidebar-logo-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-logo-title {
    color: #ffffff;

    font-size: 23px;
    font-weight: 700;
    line-height: 1.1;

    letter-spacing: -0.4px;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-logo-panel {
    margin-top: 4px;

    color: #8d99ad;

    font-size: 13px;
    font-weight: 500;

    line-height: 1.2;

    letter-spacing: 0.4px;
}


/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1200px) {

    .sidebar-logo {
        padding-left: 18px;
        padding-right: 18px;
    }

    .sidebar-logo-title {
        font-size: 21px;
    }

}


@media (max-width: 991px) {

    .sidebar-logo {
        padding: 18px 16px;
    }

    .sidebar-logo-icon {
        width: 40px;
        height: 40px;
        flex-basis: 40px;

        font-size: 21px;
        border-radius: 9px;
    }

    .sidebar-logo-title {
        font-size: 19px;
    }

    .sidebar-logo-panel {
        font-size: 12px;
    }

}


@media (max-width: 575px) {

    .sidebar-logo {
        padding: 14px 14px;
    }

    .sidebar-logo-main {
        gap: 10px;
    }

    .sidebar-logo-icon {
        width: 38px;
        height: 38px;
        flex-basis: 38px;
    }

    .sidebar-logo-title {
        font-size: 18px;
    }

}