/* Campaigns — App Styles */
:root {
    --mw-green: #1a7a4a;
    --mw-gold:  #d4a017;
    --mw-flag-black: #000000;
    --mw-flag-red: #BB0000;
    --mw-flag-green: #006600;
    --mw-flag-rail: 12px;
    --mw-flag-rail-v: linear-gradient(
      to bottom,
      #000000 0% 30%,
      #ffffff 30% 35%,
      #bb0000 35% 65%,
      #ffffff 65% 70%,
      #006600 70% 100%
    );
    --mw-flag-rail-h: linear-gradient(
      to right,
      #000000 0% 20%,
      #ffffff 20% 24%,
      #bb0000 24% 76%,
      #ffffff 76% 80%,
      #006600 80% 100%
    );
  }
  
  body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: #f5f7fa;
    font-size: 0.93rem;
    padding-left: var(--mw-flag-rail);
    padding-right: var(--mw-flag-rail);
  }

  /* Kenyan flag color rails — poster edge on left / right */
  body::before,
  body::after {
    content: "";
    position: fixed;
    top: 0;
    bottom: 0;
    width: var(--mw-flag-rail);
    background: var(--mw-flag-rail-v);
    z-index: 1040;
    pointer-events: none;
  }
  body::before {
    left: 0;
    box-shadow: 3px 0 10px rgba(0, 0, 0, 0.08);
  }
  body::after {
    right: 0;
    box-shadow: -3px 0 10px rgba(0, 0, 0, 0.08);
  }

  /* Keep sticky navbar above page content (do not override position: sticky) */
  .navbar.sticky-top {
    z-index: 1030;
  }
  .navbar .dropdown-menu {
    z-index: 1035;
  }
  .navbar .dropdown-header {
    font-size: 0.68rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-weight: 700;
    color: #6c757d;
    padding-top: 0.55rem;
    padding-bottom: 0.2rem;
  }
  
  /* Navbar accent */
  .navbar.bg-primary { background: linear-gradient(135deg, #1565C0 0%, #0d47a1 100%) !important; }

  /* Candidate brand icon (favicon + navbar) */
  .brand-icon {
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
  }
  .brand-icon-nav { width: 32px; height: 32px; }
  .brand-icon-landing { width: 36px; height: 36px; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
  .brand-icon-login { width: 40px; height: 40px; }
  
  /* Stat cards */
  .stat-card { border: none; border-radius: 12px; transition: transform .15s, box-shadow .15s; color: inherit; }
  .stat-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,.12); }
  a.stat-card { cursor: pointer; }
  a.stat-card:focus-visible { outline: 2px solid #1565C0; outline-offset: 2px; }
  a.dash-widget-link { color: inherit; transition: transform .15s, box-shadow .15s; }
  a.dash-widget-link:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,.12) !important; }
  a.dash-widget-link:focus-visible { outline: 2px solid #1565C0; outline-offset: 2px; }
  .stat-icon { width: 52px; height: 52px; border-radius: 10px; display:flex; align-items:center; justify-content:center; font-size: 1.5rem; }
  
  /* Tables */
  .table-hover tbody tr:hover { background: #eef2ff; }
  .table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: #6c757d; border-bottom: 2px solid #dee2e6; }
  
  /* Support badges */
  .badge-strong    { background:#198754; color:#fff; }
  .badge-medium    { background:#0d6efd; color:#fff; }
  .badge-weak      { background:#fd7e14; color:#fff; }
  .badge-undecided { background:#e9ecef; color:#495057; }
  .badge-none      { background:#dee2e6; color:#6c757d; }
  
  /* Sidebar layout */
  .page-wrapper { display: flex; flex: 1; }
  .sidebar { width: 240px; min-height: calc(100vh - 56px); background: #fff; border-right: 1px solid #dee2e6; flex-shrink:0; }
  .main-content { flex: 1; padding: 1.5rem; overflow-x: hidden; }
  
  /* Result cards */
  .result-card { border-left: 4px solid #1565C0; }
  .screenshot-thumb { width: 100px; height: 70px; object-fit: cover; border-radius: 6px; cursor: pointer; border: 2px solid #dee2e6; }
  .screenshot-thumb:hover { border-color: #1565C0; }
  
  /* Form cards */
  .form-card { background: #fff; border-radius: 12px; padding: 1.75rem; box-shadow: 0 2px 12px rgba(0,0,0,.07); }

  /* Searchable select (type-to-filter dropdown) */
  .searchable-select-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    max-height: 240px;
    overflow-y: auto;
    margin-top: 2px;
    border-radius: 0.375rem;
  }
  .searchable-select-menu .list-group-item { font-size: 0.9rem; }
  .searchable-select-input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236c757d' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242 1.1a5.5 5.5 0 1 1 0-11 5.5 5.5 0 0 1 0 11z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2.25rem; }
  
  /* Progress bar tally */
  .tally-bar { height: 22px; border-radius: 8px; }

  /* Polling station map picker */
  .station-map { height: 220px; border-radius: 8px; border: 1px solid #dee2e6; z-index: 1; }

  /* Election day agent duty sidebar */
  .duty-sidebar .list-group-item { border-left: 0; border-right: 0; }
  .duty-toggle-btn.btn-danger { box-shadow: 0 0 0 2px rgba(220,53,69,.25); }
  
  /* Mobile offcanvas menu (below lg the navbar becomes a slide-in panel) */
  @media (max-width: 991.98px) {
    .navbar-offcanvas {
      background: linear-gradient(160deg, #1565C0 0%, #0d47a1 100%);
      color: #fff;
      width: 290px;
    }
    .navbar-offcanvas .offcanvas-header { border-bottom: 1px solid rgba(255,255,255,.2); }
    .navbar-offcanvas .offcanvas-title { color: #fff; font-size: 1rem; }
    .navbar-offcanvas .nav-link { color: rgba(255,255,255,.9); padding: .65rem .25rem; font-size: 1.02rem; }
    .navbar-offcanvas .nav-link:hover,
    .navbar-offcanvas .nav-link.show { color: #fff; }
    .navbar-offcanvas .nav-item { border-bottom: 1px solid rgba(255,255,255,.08); }
    .navbar-offcanvas .dropdown-menu {
      background: rgba(0,0,0,.18);
      border: 0;
      box-shadow: none;
      margin-bottom: .5rem;
    }
    .navbar-offcanvas .dropdown-item { color: rgba(255,255,255,.85); padding: .5rem 1rem; }
    .navbar-offcanvas .dropdown-item:hover,
    .navbar-offcanvas .dropdown-item:active { background: rgba(255,255,255,.12); color: #fff; }
    .navbar-offcanvas .dropdown-divider { border-color: rgba(255,255,255,.2); }
    .navbar-offcanvas .dropdown-header { color: rgba(255,255,255,.55); }
  }

  .navbar-user-btn { max-width: 11rem; }
  .navbar-user-name { max-width: 8rem; }
  .navbar-user-menu { min-width: 12rem; }
  .navbar-actions .dropdown-toggle::after { margin-left: .2rem; }

  /* Mobile responsiveness */
  @media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { padding: .75rem; }
    .stat-card .fs-2 { font-size: 1.4rem !important; }
    .stat-card .fs-4 { font-size: 1.15rem !important; }
    .stat-icon { width: 42px; height: 42px; font-size: 1.2rem; }
    .table { font-size: .85rem; }
    .form-card { padding: 1rem; }
    h4, h5 { font-size: 1.05rem; }
    .btn-sm { white-space: nowrap; }
  }
  
  /* Security alert levels */
  .alert-level-red    { background:#dc3545; color:#fff; }
  .alert-level-amber  { background:#fd7e14; color:#fff; }
  .alert-level-yellow { background:#ffc107; color:#212529; }

  /* Security widget panel (admin + security desk) */
  .security-widget-panel {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    gap: .6rem;
    max-width: 220px;
  }
  .security-widget {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .15rem;
    padding: .75rem 1rem;
    border: 3px solid #fff;
    border-radius: 12px;
    color: #fff;
    font-weight: 700;
    box-shadow: 0 4px 20px rgba(0,0,0,.35);
    text-align: center;
    width: 100%;
  }
  .security-widget-red    { background: #dc3545; }
  .security-widget-amber  { background: #fd7e14; }
  .security-widget-yellow { background: #e6a800; color: #212529; }
  .security-widget .widget-name { font-size: 1rem; line-height: 1.2; }
  .security-widget .widget-level { font-size: .7rem; opacity: .9; text-transform: uppercase; }
  .security-widget .widget-pulse { font-size: .65rem; letter-spacing: .08em; }
  .security-widget.blinking { animation: sec-blink 1s ease-in-out infinite; }
  @keyframes sec-blink {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: .65; transform: scale(1.04); box-shadow: 0 0 30px rgba(220,53,69,.8); }
  }
  .alert-bell-menu { max-height: 400px; overflow-y: auto; }

  /* Search highlight */
  mark { background: #fff3cd; padding: 0 2px; border-radius: 3px; }
  
  /* Analytics reports */
  .reports-page .report-section { page-break-inside: avoid; }
  .reports-page .card { break-inside: avoid; }
  .reports-nav .nav-link { font-size: 0.875rem; padding: 0.35rem 0.75rem; }
  .reports-nav .nav-link.active { font-weight: 600; }

  /* Curved Kenyan-color poster edge along the bottom */
  .footer {
    position: relative;
    overflow: visible;
    border-top: none !important;
    background: #f5f7fa !important;
    padding-bottom: 1.85rem;
  }
  .footer::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 100vw;
    height: 18px;
    background: var(--mw-flag-rail-h);
    border-radius: 50% 50% 0 0 / 100% 100% 0 0;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
    pointer-events: none;
    z-index: 0;
  }
  .footer .container-fluid {
    position: relative;
    z-index: 1;
  }

  /* Print styles for results & reports */
  @media print {
    body {
      padding-left: 0;
      padding-right: 0;
    }
    body::before,
    body::after,
    .footer::before { display: none !important; }
    .navbar, .sidebar, .btn, .no-print, footer, #sosBtn, #alertBellBtn { display: none !important; }
    .main-content { padding: 0; }
    .reports-page .card { box-shadow: none !important; border: 1px solid #dee2e6 !important; }
  }

  @media (max-width: 768px) {
    :root { --mw-flag-rail: 8px; }
    .footer::before { height: 12px; }
  }

  /* Confirmation modal */
  .mw-confirm-dialog { max-width: 420px; }
  .mw-confirm-dialog.mw-confirm-with-sender { max-width: 480px; }
  .mw-confirm-card { border-radius: 14px; overflow: hidden; }
  #mwConfirmSender.is-invalid { border-color: #dc3545; }
  #mwConfirmSenderWrap .form-label { font-size: 0.9rem; }
  .mw-confirm-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
  }
  .mw-confirm-icon.variant-danger { background: #fde8ea; color: #dc3545; }
  .mw-confirm-icon.variant-warning { background: #fff3cd; color: #b58100; }
  .mw-confirm-icon.variant-success { background: #d1e7dd; color: #198754; }
  .mw-confirm-icon.variant-primary { background: #cfe2ff; color: #0d6efd; }
  .mw-confirm-message { line-height: 1.55; font-size: 0.95rem; }
  #mwConfirmModal .modal-footer { border-radius: 0 0 14px 14px; }

  /* In-page visit camera (getUserMedia) */
  .visit-camera-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
  }
  .visit-camera-panel {
    width: min(100%, 28rem);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }
  .visit-camera-video {
    width: 100%;
    max-height: 70vh;
    object-fit: cover;
    border-radius: 0.75rem;
    background: #111;
  }
  .visit-camera-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: space-between;
  }
  .visit-camera-hint { text-align: center; }
  body.visit-camera-open { overflow: hidden; }