/* BNI North Star Dashboard — App Styles */

:root {
  --bni-red:      #CC0000;
  --bni-yellow:   #F9A800;
  --bni-green:    #007A33;
  --band-red:     #FF0000;
  --band-yellow:  #FFEB9C;
  --band-green:   #00B050;
  --band-red-bg:  #FFC7CE;
  --band-yellow-bg: #FFEB9C;
  --band-green-bg: #C6EFCE;
  --gray-100: #f8f9fa;
  --gray-200: #e9ecef;
  --gray-700: #495057;
  --gray-900: #212529;
  --shadow: 0 2px 8px rgba(0,0,0,0.10);
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  line-height: 1.5;
}

/* ── Layout ─────────────────────────────────────────────────────── */

.nav {
  background: var(--bni-red);
  color: #fff;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
}

.nav-brand {
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: .02em;
}

.nav-links { display: flex; gap: 1rem; align-items: center; }

.nav-links a {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-size: .9rem;
  padding: .25rem .5rem;
  border-radius: 4px;
  transition: background .15s;
}

.nav-links a:hover { background: rgba(255,255,255,.15); color: #fff; }

.nav-user { font-size: .85rem; }

/* ── Nav user dropdown ──────────────────────────────────────────── */

.nav-user-wrap { position: relative; }

.nav-user-btn {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25);
  color: #fff;
  padding: .3rem .75rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: .85rem;
  display: flex;
  align-items: center;
  gap: .4rem;
  white-space: nowrap;
}
.nav-user-btn:hover { background: rgba(255,255,255,.25); }

.nav-caret { font-size: .7rem; opacity: .8; }

.nav-user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + .4rem);
  right: 0;
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  z-index: 1000;
  overflow: hidden;
}
.nav-user-dropdown.open { display: block; }

.nav-dropdown-header {
  padding: .6rem 1rem;
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
  color: var(--gray-700);
  font-size: .85rem;
}

.nav-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: .6rem 1rem;
  font-size: .9rem;
  color: var(--gray-900);
  cursor: pointer;
  transition: background .1s;
}
.nav-dropdown-item:hover { background: var(--gray-100); }

.nav-dropdown-divider {
  height: 1px;
  background: var(--gray-200);
  margin: .25rem 0;
}

.nav-dropdown-danger { color: var(--bni-red); }
.nav-dropdown-danger:hover { background: #fff5f5; }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ── Cards ──────────────────────────────────────────────────────── */

.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-title {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-700);
  margin-bottom: .25rem;
}

.card-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
}

.card-sub { font-size: .8rem; color: var(--gray-700); margin-top: .25rem; }

/* ── KPI Grid ───────────────────────────────────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  border-radius: var(--radius);
  padding: 1.1rem 1rem;
  box-shadow: var(--shadow);
  text-align: center;
  position: relative;
  transition: transform .15s;
}

.kpi-card:hover { transform: translateY(-2px); }

.kpi-card.green  { background: var(--band-green-bg);  border-left: 4px solid var(--bni-green); }
.kpi-card.yellow { background: var(--band-yellow-bg); border-left: 4px solid var(--bni-yellow); }
.kpi-card.red    { background: var(--band-red-bg);    border-left: 4px solid var(--bni-red); }
.kpi-card.neutral{ background: #fff; border-left: 4px solid var(--gray-200); }

.kpi-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; opacity: .7; }
.kpi-value { font-size: 1.8rem; font-weight: 800; margin: .1rem 0; }
.kpi-band  { font-size: .7rem; font-weight: 600; text-transform: uppercase; }

.kpi-card.green  .kpi-band { color: var(--bni-green); }
.kpi-card.yellow .kpi-band { color: #8a6d00; }
.kpi-card.red    .kpi-band { color: var(--bni-red); }

/* ── Member Grid ────────────────────────────────────────────────── */

.member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.member-card {
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .15s;
  border-top: 4px solid transparent;
}

.member-card:hover { transform: translateY(-2px); }
.member-card.green  { background: var(--band-green-bg);  border-top-color: var(--bni-green); }
.member-card.yellow { background: var(--band-yellow-bg); border-top-color: var(--bni-yellow); }
.member-card.red    { background: var(--band-red-bg);    border-top-color: var(--bni-red); }

.member-name  { font-weight: 600; font-size: .95rem; }
.member-score { font-size: 1.6rem; font-weight: 800; }
.member-band  { font-size: .7rem; text-transform: uppercase; font-weight: 600; opacity: .7; }

/* ── Tables ─────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { padding: .5rem .75rem; text-align: left; border-bottom: 1px solid var(--gray-200); }
th { background: var(--gray-100); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
tr:hover td { background: #f0f4ff; }

.badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge.green  { background: var(--band-green-bg);  color: var(--bni-green); }
.badge.yellow { background: var(--band-yellow-bg); color: #7a5d00; }
.badge.red    { background: var(--band-red-bg);    color: var(--bni-red); }
.badge.admin  { background: #e8eaf6; color: #3949ab; }
.badge.member { background: var(--gray-200); color: var(--gray-700); }
.badge.active { background: #e8f5e9; color: #2e7d32; }
.badge.inactive { background: #fce4ec; color: #c62828; }

/* ── Forms ──────────────────────────────────────────────────────── */

.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .85rem; font-weight: 500; margin-bottom: .35rem; }

.form-control {
  width: 100%;
  padding: .5rem .75rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: .9rem;
  outline: none;
  transition: border-color .15s;
}

.form-control:focus { border-color: var(--bni-red); box-shadow: 0 0 0 3px rgba(204,0,0,.1); }

/* ── Buttons ────────────────────────────────────────────────────── */

.btn {
  display: inline-block;
  padding: .5rem 1.1rem;
  border: none;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
}

.btn:hover  { opacity: .87; }
.btn:active { transform: scale(.97); }

.btn-primary   { background: var(--bni-red); color: #fff; }
.btn-secondary { background: var(--gray-200); color: var(--gray-900); }
.btn-sm        { padding: .3rem .75rem; font-size: .8rem; }
.btn-danger    { background: #c62828; color: #fff; }

/* ── Tabs ───────────────────────────────────────────────────────── */

.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--gray-200); margin-bottom: 1.5rem; }

.tab-btn {
  padding: .6rem 1.25rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 500;
  color: var(--gray-700);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color .15s;
}

.tab-btn.active { color: var(--bni-red); border-bottom-color: var(--bni-red); }
.tab-btn:hover  { color: var(--bni-red); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Section headers ────────────────────────────────────────────── */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-title { font-size: 1.1rem; font-weight: 700; }

/* ── Summary bar ────────────────────────────────────────────────── */

.summary-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.summary-stat {
  padding: .5rem 1rem;
  border-radius: 6px;
  font-size: .85rem;
  font-weight: 600;
}

.summary-stat.green  { background: var(--band-green-bg);  color: var(--bni-green); }
.summary-stat.yellow { background: var(--band-yellow-bg); color: #7a5d00; }
.summary-stat.red    { background: var(--band-red-bg);    color: var(--bni-red); }
.summary-stat.neutral{ background: #fff; border: 1px solid var(--gray-200); }

/* ── Alert / Modal ──────────────────────────────────────────────── */

.alert {
  padding: .75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: .875rem;
}

.alert-success { background: #e8f5e9; color: #2e7d32; border-left: 4px solid var(--bni-green); }
.alert-error   { background: #fce4ec; color: #c62828; border-left: 4px solid var(--bni-red); }
.alert-info    { background: #e3f2fd; color: #1565c0; border-left: 4px solid #1565c0; }

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 1.75rem;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}

.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem; }

/* ── Login page ─────────────────────────────────────────────────── */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #8b0000 0%, #cc0000 60%, #f9a800 100%);
}

.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}

.login-logo { text-align: center; margin-bottom: 1.5rem; }
.login-logo h1 { font-size: 1.4rem; color: var(--bni-red); font-weight: 800; }
.login-logo p  { font-size: .85rem; color: var(--gray-700); margin-top: .25rem; }

/* ── Chart containers ───────────────────────────────────────────── */

.chart-wrap { position: relative; height: 280px; margin-bottom: 1.5rem; }

/* ── Nav hamburger (hidden on desktop) ──────────────────────────── */

.nav-toggle {
  display: none;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.25);
  color: #fff;
  font-size: 1.3rem;
  line-height: 1;
  padding: .3rem .55rem;
  border-radius: 5px;
  cursor: pointer;
  flex-shrink: 0;
}
.nav-toggle:hover { background: rgba(255,255,255,.28); }

/* ── Responsive ─────────────────────────────────────────────────── */

@media (max-width: 768px) {

  /* Nav */
  .nav {
    flex-wrap: wrap;
    height: auto;
    padding: .55rem 1rem;
    gap: .4rem;
  }
  .nav-brand { flex: 1; padding: .15rem 0; }
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    flex-direction: column;
    width: 100%;
    order: 10;
    border-top: 1px solid rgba(255,255,255,.18);
    padding: .5rem 0;
    gap: 0;
  }
  .nav.nav-open .nav-links { display: flex; }
  .nav-links a {
    padding: .65rem .5rem;
    font-size: .95rem;
    border-radius: 0;
    border-bottom: 1px solid rgba(255,255,255,.1);
  }
  .nav-links a:last-child { border-bottom: none; }

  /* Tabs: scrollable row */
  .tabs {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { flex-shrink: 0; padding: .55rem .9rem; font-size: .82rem; }

  /* Modals: bottom sheet */
  .modal-overlay.open { align-items: flex-end; }
  .modal {
    max-width: 100% !important;
    width: 100% !important;
    border-radius: var(--radius) var(--radius) 0 0 !important;
    max-height: 90vh;
    overflow-y: auto;
    padding: 1.25rem 1rem;
  }

  /* Container */
  .container { padding: 1rem .75rem; }

  /* Section headers: wrap */
  .section-header { flex-wrap: wrap; gap: .5rem; }

  /* KPI grid */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-bottom: 1rem; }

  /* Member grid */
  .member-grid { grid-template-columns: repeat(2, 1fr); gap: .75rem; }

  /* Charts */
  .chart-wrap { height: 200px; }

  /* Summary bar */
  .summary-stat { padding: .35rem .65rem; font-size: .8rem; }

  /* Summary bar wraps tighter */
  .summary-bar { gap: .5rem; }

  /* Template cards: stack */
  .template-card { flex-direction: column; gap: .5rem; }

  /* Form 2-col grids inside modals: single column */
  .modal [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
  .modal [style*="grid-column"] {
    grid-column: auto !important;
  }

  /* Admin upload grid */
  .admin-upload-grid { grid-template-columns: 1fr !important; }

  /* Buttons in tight rows */
  .flex.gap-1 { flex-wrap: wrap; }

  /* Table: shrink font slightly */
  table { font-size: .82rem; }
  th, td { padding: .4rem .6rem; }
}

@media (max-width: 480px) {
  .kpi-value { font-size: 1.5rem; }
  .member-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: .5rem; }
  .nav-brand { font-size: .95rem; }
  .chart-wrap { height: 170px; }
}

/* ── Utilities ──────────────────────────────────────────────────── */

.hidden { display: none !important; }
.flex { display: flex; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-sm { font-size: .85rem; }
.text-muted { color: var(--gray-700); }
.text-right { text-align: right; }
.w-full { width: 100%; }
.spinner { display: inline-block; width: 1rem; height: 1rem; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
