/* ============================================================
   BNI Dolphins — Member Portal Stylesheet  v1.1
   Brand colours: BNI Red #CF2030, Granite #64666A, Sterling #C8C8C8
   Font: Arial / Helvetica (BNI brand standard)
   ============================================================ */

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

:root {
  --bni-red:        #CF2030;
  --bni-red-dark:   #a8182a;
  --bni-red-light:  #fdf0f1;
  --granite:        #64666A;
  --sterling:       #C8C8C8;
  --sterling-light: #F2F2F2;
  --sterling-mid:   #e8e8e8;
  --black:          #000000;
  --white:          #ffffff;
  --success:        #1a6a2a;
  --success-bg:     #eaf5ec;
  --info:           #1a4a9e;
  --info-bg:        #eef3fd;
  --font:           Arial, Helvetica, sans-serif;
  --radius:         6px;
  --radius-lg:      10px;
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.08);
  --shadow:         0 2px 8px rgba(0,0,0,0.10);
}

body { font-family: var(--font); font-size: 14px; color: var(--black); background: var(--sterling-light); min-height: 100vh; }
a { color: var(--bni-red); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Login -------------------------------------------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--sterling-light); padding: 20px; }
.login-card { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow); width: 100%; max-width: 420px; overflow: hidden; }
.login-header { background: var(--bni-red); padding: 28px 32px; text-align: center; }
.login-header .chapter-name { color: var(--white); font-size: 22px; font-weight: 700; letter-spacing: 0.5px; }
.login-header .tagline { color: rgba(255,255,255,0.75); font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; margin-top: 4px; }
.login-body { padding: 32px; }
.login-body h2 { font-size: 18px; font-weight: 700; margin-bottom: 20px; color: var(--black); }

/* ---- Portal layout ------------------------------------ */
.portal-wrap { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--white); border-right: 1px solid var(--sterling-mid); display: flex; flex-direction: column; flex-shrink: 0; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; }
.sidebar-brand { background: var(--bni-red); padding: 18px 20px; }
.sidebar-brand .chapter { color: var(--white); font-size: 16px; font-weight: 700; }
.sidebar-brand .sub { color: rgba(255,255,255,0.7); font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; margin-top: 2px; }
.sidebar-user { padding: 16px 20px; border-bottom: 1px solid var(--sterling-mid); display: flex; align-items: center; gap: 10px; }
.user-avatar-sm { width: 36px; height: 36px; border-radius: 50%; background: var(--bni-red-light); color: var(--bni-red); font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; }
.user-avatar-sm img { width: 36px; height: 36px; object-fit: cover; border-radius: 50%; }
.sidebar-user .user-name { font-size: 13px; font-weight: 700; color: var(--black); line-height: 1.2; }
.sidebar-user .user-role { font-size: 11px; color: var(--granite); }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-section-label { font-size: 10px; color: var(--sterling); text-transform: uppercase; letter-spacing: 1.5px; padding: 10px 20px 4px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 20px; font-size: 13px; color: var(--granite); border-left: 3px solid transparent; transition: background 0.12s, color 0.12s; text-decoration: none; }
.nav-link:hover { background: var(--sterling-light); color: var(--black); text-decoration: none; }
.nav-link.active { background: var(--bni-red-light); color: var(--bni-red); border-left-color: var(--bni-red); font-weight: 700; }
.nav-link svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--sterling-mid); }
.sidebar-footer form { margin: 0; padding: 0; }
.sidebar-footer form button { width: 100%; background: transparent; border: 1px solid var(--sterling); border-radius: var(--radius); padding: 8px; font-size: 12px; color: var(--granite); cursor: pointer; font-family: var(--font); }
.sidebar-footer form button:hover { background: var(--sterling-light); color: var(--black); }
.main-content { margin-left: 220px; flex: 1; padding: 28px; min-height: 100vh; }
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--black); }
.page-header p { font-size: 13px; color: var(--granite); margin-top: 3px; }

/* ---- Cards -------------------------------------------- */
.card { background: var(--white); border: 1px solid var(--sterling-mid); border-radius: var(--radius-lg); padding: 22px; margin-bottom: 18px; position: relative; }
.card-title { font-size: 11px; font-weight: 700; color: var(--granite); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 16px; }

/* ---- Stats -------------------------------------------- */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--white); border: 1px solid var(--sterling-mid); border-radius: var(--radius); padding: 16px 18px; }
.stat-value { font-size: 32px; font-weight: 700; color: var(--bni-red); line-height: 1; }
.stat-label { font-size: 11px; color: var(--granite); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }

/* ---- Forms -------------------------------------------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 11px; font-weight: 700; color: var(--granite); text-transform: uppercase; letter-spacing: 0.5px; }
.form-input, .form-select, .form-textarea { border: 1px solid var(--sterling); border-radius: var(--radius); padding: 9px 12px; font-size: 13px; font-family: var(--font); color: var(--black); background: var(--white); transition: border-color 0.12s; }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--bni-red); }
.form-textarea { resize: vertical; min-height: 90px; }
.form-hint { font-size: 11px; color: var(--granite); }
.form-error { font-size: 11px; color: var(--bni-red); margin-top: 3px; }

/* ---- Buttons ------------------------------------------ */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 20px; border-radius: var(--radius); font-size: 13px; font-weight: 700; font-family: var(--font); cursor: pointer; border: 1px solid transparent; text-decoration: none; transition: background 0.12s; }
.btn-primary { background: var(--bni-red); color: var(--white); border-color: var(--bni-red); }
.btn-primary:hover { background: var(--bni-red-dark); text-decoration: none; color: var(--white); }
.btn-secondary { background: transparent; color: var(--granite); border-color: var(--sterling); }
.btn-secondary:hover { background: var(--sterling-light); text-decoration: none; color: var(--black); }
.btn-danger { background: transparent; color: var(--bni-red); border-color: var(--bni-red); }
.btn-danger:hover { background: var(--bni-red-light); text-decoration: none; }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-row { display: flex; gap: 10px; margin-top: 18px; }

/* ---- Alerts ------------------------------------------- */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 13px; margin-bottom: 18px; border: 1px solid transparent; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: #b8dfc0; }
.alert-info    { background: var(--info-bg);    color: var(--info);    border-color: #b8cef7; }
.alert-error   { background: var(--bni-red-light); color: var(--bni-red); border-color: #f5c0c5; }

/* ---- Directory ---------------------------------------- */
.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.member-card { background: var(--white); border: 1px solid var(--sterling-mid); border-radius: var(--radius-lg); padding: 18px; display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; transition: border-color 0.12s, box-shadow 0.12s; }
.member-card:hover { border-color: var(--bni-red); box-shadow: var(--shadow-sm); text-decoration: none; }
.member-initials { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; flex-shrink: 0; }
.member-card .name { font-size: 14px; font-weight: 700; color: var(--black); }
.member-card .company { font-size: 12px; color: var(--granite); }
.member-card .role-tag { font-size: 11px; color: var(--bni-red); margin-top: 2px; }

/* ---- Badges ------------------------------------------- */
.badge { display: inline-block; font-size: 11px; padding: 3px 10px; border-radius: 20px; font-weight: 700; }
.badge-red  { background: var(--bni-red); color: var(--white); }
.badge-grey { background: var(--sterling-light); color: var(--granite); }
.badge-hot  { background: var(--bni-red-light); color: var(--bni-red); }

/* ---- Referrals ---------------------------------------- */
.referral-list { display: flex; flex-direction: column; }
.referral-item { display: flex; gap: 14px; align-items: flex-start; padding: 16px 0; border-bottom: 1px solid var(--sterling-light); }
.referral-item:last-child { border-bottom: none; }
.referral-item .rname { font-size: 14px; font-weight: 700; color: var(--black); }
.referral-item .rcompany { font-size: 12px; color: var(--granite); }
.referral-item .rask { font-size: 13px; color: var(--black); margin-top: 4px; }
.referral-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.referral-tag { font-size: 11px; padding: 2px 9px; background: var(--sterling-light); color: var(--granite); border-radius: 4px; }
.referral-tag.hot { background: var(--bni-red-light); color: var(--bni-red); }

/* ---- File uploads ------------------------------------- */
.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }

/* Upload cards: overflow visible so dashed border isn't clipped by border-radius */
.upload-grid .card { padding: 20px; overflow: visible; }

/* Reset form element defaults inside cards */
.card form { margin: 0; padding: 0; display: block; }

.upload-zone {
  display: block;
  border: 2px dashed var(--sterling);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  box-sizing: border-box;
  width: 100%;
  margin: 0;
}
.upload-zone:hover { border-color: var(--bni-red); background: var(--bni-red-light); }
.upload-zone .uz-icon { font-size: 28px; margin-bottom: 8px; }
.upload-zone .uz-label { font-size: 13px; font-weight: 700; color: var(--black); }
.upload-zone .uz-hint { font-size: 11px; color: var(--granite); margin-top: 3px; }
.upload-zone input[type="file"] { display: none; }

.file-item { display: flex; align-items: center; gap: 12px; padding: 12px; background: var(--sterling-light); border-radius: var(--radius); margin-bottom: 8px; }
.file-icon { width: 38px; height: 38px; border-radius: var(--radius); background: var(--bni-red); color: var(--white); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.file-name { font-size: 13px; font-weight: 700; color: var(--black); }
.file-meta { font-size: 11px; color: var(--granite); }
.file-live { font-size: 11px; color: var(--success); background: var(--success-bg); padding: 2px 8px; border-radius: 20px; }

/* ---- Profile ------------------------------------------ */
.profile-hero { display: flex; align-items: flex-start; gap: 20px; margin-bottom: 24px; }
.profile-avatar-lg { width: 80px; height: 80px; border-radius: 50%; background: var(--bni-red-light); color: var(--bni-red); font-size: 28px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; border: 3px solid var(--sterling-light); }
.profile-avatar-lg img { width: 80px; height: 80px; object-fit: cover; border-radius: 50%; }

/* ---- Misc --------------------------------------------- */
.search-bar { display: flex; gap: 10px; margin-bottom: 20px; }
.search-bar input { flex: 1; }
.search-bar button { flex-shrink: 0; }
.progress-wrap { background: var(--sterling-mid); border-radius: 4px; height: 8px; overflow: hidden; margin-top: 6px; }
.progress-bar  { height: 100%; background: var(--bni-red); border-radius: 4px; transition: width 0.4s; }
.activity-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--sterling-light); }
.activity-item:last-child { border-bottom: none; }
.activity-item .a-text { font-size: 13px; color: var(--black); }
.activity-item .a-time { font-size: 11px; color: var(--sterling); margin-top: 2px; }
.divider { border: none; border-top: 1px solid var(--sterling-mid); margin: 20px 0; }

/* ---- Responsive --------------------------------------- */
/* Dashboard metric layout */
.dash-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 16px;
  margin-bottom: 16px;
  align-items: start;
}
.dash-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.dash-chart-card {
  min-width: 0; /* prevent grid blowout */
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-220px); }
  .main-content { margin-left: 0; padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr; }
  .upload-grid { grid-template-columns: 1fr; }
  .member-grid { grid-template-columns: 1fr; }

  /* Dashboard: stack donut above charts on mobile */
  .dash-row    { grid-template-columns: 1fr; }
  .dash-charts { grid-template-columns: 1fr; }

  /* Constrain and centre the donut card on mobile */
  .dash-row > .card:first-child {
    max-width: 280px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
  }
}

/* ============================================================
   Mobile Navigation
   ============================================================ */

/* Hamburger button — hidden on desktop */
.mobile-nav-toggle {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 200;
  background: var(--bni-red);
  border: none;
  border-radius: var(--radius);
  width: 40px;
  height: 40px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0;
}
.mobile-nav-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: white;
  border-radius: 2px;
  transition: transform 0.2s, opacity 0.2s;
}
.mobile-nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.mobile-nav-toggle.open span:nth-child(2) { opacity: 0; }
.mobile-nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Overlay behind sidebar on mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 99;
}
.sidebar-overlay.visible { display: block; }

@media (max-width: 768px) {
  /* Show hamburger */
  .mobile-nav-toggle { display: flex; }

  /* Sidebar slides in from left */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 150;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  }
  .sidebar.open { transform: translateX(0); }

  /* Main content fills full width */
  .main-content {
    margin-left: 0;
    padding: 16px;
    padding-top: 64px; /* room for hamburger */
  }

  /* Stack stat row to single column */
  .stat-row { grid-template-columns: 1fr; gap: 10px; }

  /* Stack form grid */
  .form-grid { grid-template-columns: 1fr; }
  .form-group.full { grid-column: 1; }

  /* Stack upload grid */
  .upload-grid { grid-template-columns: 1fr; }

  /* Stack member grid */
  .member-grid { grid-template-columns: 1fr; }

  /* Dashboard two-column sections */
  div[style*="grid-template-columns: 1fr 1fr"] {
    display: flex !important;
    flex-direction: column !important;
  }

  /* Table scroll on small screens */
  .card table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Profile hero stack on mobile */
  .profile-hero { flex-direction: column; align-items: center; text-align: center; }

  /* Page header action buttons */
  .page-header > div[style*="justify-content:space-between"] {
    flex-direction: column !important;
    gap: 12px !important;
    align-items: flex-start !important;
  }

  /* Referral items */
  .referral-item { flex-wrap: wrap; }
  .referral-item .btn { margin-top: 8px; }

  /* File items */
  .file-item { flex-wrap: wrap; gap: 8px; }
  .file-item .btn { flex: 1; text-align: center; justify-content: center; }

  /* Search bar */
  .search-bar { flex-wrap: wrap; }
  .search-bar input { min-width: 0; }
}
