/* ============ RESET & BASE ============ */
* { margin:0; padding:0; box-sizing:border-box; }

:root{
  --bg: #fbf7f8;
  --card-bg: #ffffff;
  --border: #ffe1e8;
  --text-primary: #221b22;
  --text-secondary: #8a818c;
  --red: #e11d48;
  --red-dark: #be123c;
  --pink: #ec4899;
  --gradient: linear-gradient(135deg, #ff5f7e 0%, #ff2d6e 100%);
  --gradient-soft: linear-gradient(135deg, #fff0f4 0%, #ffe4ec 100%);
  --green: #16a34a;
  --amber: #d97706;
  --shadow-sm: 0 4px 14px rgba(225, 29, 72, 0.06);
  --shadow-md: 0 10px 30px rgba(225, 29, 72, 0.10);
  --radius: 18px;
  --sidebar-width: 250px;
  --sidebar-width-md: 220px;
  --sidebar-width-sm: 200px;
  --sidebar-width-icon: 74px;
  --sidebar-width-icon-sm: 62px;
}

html { scroll-behavior: smooth; }

body{
  font-family: 'Poppins', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
}

button, input { font-family: inherit; }
a { text-decoration: none; color: inherit; }
svg { width: 18px; height: 18px; }

.accent{ color: var(--red); }

/* ============ APP SHELL ============ */
.app-shell{
  min-height: 100vh;
  display: flex;
  align-items: stretch;
}

/* ============ PERMANENT SIDEBAR ============ */
.sidebar{
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;

  display: flex;
  flex-direction: column;

  padding: 22px 14px;
  background: #ffffff;
  border-right: 1px solid #f3dce3;
  box-shadow: 5px 0 24px rgba(225, 29, 72, 0.04);

  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar::-webkit-scrollbar{ width: 5px; }
.sidebar::-webkit-scrollbar-thumb{ background: #ffd7e2; border-radius: 10px; }

.sidebar-header{
  display:flex;
  align-items:center;
  padding: 0 8px 22px;
  margin-bottom: 20px;
  border-bottom: 1px solid #f4e5e9;
}

.brand{ display:flex; align-items:center; gap:10px; }

.brand-icon{
  width:38px; height:38px;
  border-radius: 11px;
  background: var(--gradient);
  display:flex; align-items:center; justify-content:center;
  box-shadow: var(--shadow-md);
  flex-shrink:0;
}
.brand-icon svg{ width:19px; height:19px; }

.brand-text{ display:flex; flex-direction:column; line-height:1.25; overflow:hidden; }
.brand-name{ font-weight:800; font-size:14.5px; letter-spacing:0.3px; white-space:nowrap; }
.brand-tag{ font-size:10px; color: var(--text-secondary); font-weight:500; margin-top:1px; white-space:nowrap; }

.sidebar-section-label{
  font-size:10.5px;
  font-weight:700;
  letter-spacing:1px;
  color: #c9c0c6;
  text-transform: uppercase;
  padding: 0 12px;
  margin-bottom: 10px;
  white-space: nowrap;
}

.nav-list{
  display:flex;
  flex-direction:column;
  gap: 4px;
  flex: 1;
}

.nav-item{
  display:flex;
  align-items:center;
  gap:12px;
  min-height: 42px;
  padding: 10px 13px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: 0.18s ease;
}
.nav-item svg{ width:17px; height:17px; color: #93888e; flex-shrink:0; transition:0.18s; }

.nav-item:hover{
  background: var(--gradient-soft);
  color: var(--red-dark);
}
.nav-item:hover svg{ color: var(--red); }

.nav-item.active{
  background: var(--gradient-soft);
  color: var(--red);
  box-shadow: inset 3px 0 0 var(--red);
}
.nav-item.active svg{ color: var(--red); }

.sidebar-footer{
  border-top: 1px solid #f4e5e9;
  padding-top: 16px;
  margin-top: 18px;
  display:flex;
  flex-direction:column;
  gap: 14px;
}

.sos-nav{
  color: var(--red) !important;
  background: #fff2f5;
  font-weight:700;
}
.sos-nav svg{ color: var(--red) !important; }
.sos-nav:hover{
  color: #fff !important;
  background: var(--gradient);
  box-shadow: var(--shadow-md);
}
.sos-nav:hover svg{ color: #fff !important; }

.user-card{
  display:flex; align-items:center; gap:10px;
  padding: 8px;
  border-radius: 12px;
  background: #fdfafb;
  border: 1px solid var(--border);
}
.user-avatar{
  width:34px; height:34px; border-radius:50%;
  background: var(--gradient);
  color:#fff; font-weight:700; font-size:12px;
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0;
}
.user-info{ display:flex; flex-direction:column; overflow:hidden; flex:1; }
.user-name{ font-size:12.5px; font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.user-email{ font-size:10.5px; color: var(--text-secondary); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.user-logout{ width:15px; height:15px; color: var(--text-secondary); cursor:pointer; flex-shrink:0; }
.user-logout:hover{ color: var(--red); }

/* ============ MAIN CONTENT (WEBSITE) ============ */
.main-content{
  width: calc(100% - var(--sidebar-width));
  min-width: 0;
  margin-left: var(--sidebar-width);
}

.page{ max-width:1480px; margin:0 auto; padding: 30px 34px 60px; }

.women-safety-strip{
  background: var(--gradient-soft);
  border: 1px solid var(--border);
  color: var(--red-dark);
  font-size: 13.5px;
  font-weight:500;
  padding: 10px 18px;
  border-radius: 12px;
  margin-bottom: 20px;
}

.status-live{
  display:inline-flex; align-items:center; gap:8px;
  font-size:12px; font-weight:700; letter-spacing:0.5px;
  color: var(--green);
  margin-bottom:10px;
}

.pulse-dot{
  width:8px; height:8px; border-radius:50%;
  background: var(--green);
  animation: pulse 1.6s infinite;
}
@keyframes pulse{
  0%{ box-shadow:0 0 0 0 rgba(22,163,74,0.5); }
  70%{ box-shadow:0 0 0 8px rgba(22,163,74,0); }
  100%{ box-shadow:0 0 0 0 rgba(22,163,74,0); }
}

.page-head-row{
  display:flex; align-items:flex-end; justify-content:space-between;
  gap:20px; flex-wrap:wrap;
}
.page-head h1{ font-size: clamp(24px, 3vw, 32px); font-weight:800; margin-bottom:6px; }
.page-head p{ color: var(--text-secondary); font-size:14.5px; max-width:560px; }

.page-head-actions{ display:flex; gap:12px; }

/* ============ BUTTONS ============ */
.btn{
  display:inline-flex; align-items:center; gap:8px;
  padding: 11px 18px;
  border-radius: 12px;
  font-weight:600;
  font-size:14px;
  border:none;
  cursor:pointer;
  transition: 0.2s ease;
  white-space:nowrap;
}
.btn svg{ width:16px; height:16px; }

.btn-outline{
  background:#fff;
  border: 1.5px solid var(--border);
  color: var(--text-primary);
}
.btn-outline:hover{ border-color: var(--pink); color: var(--red); background: var(--gradient-soft); }

.btn-danger{
  background: var(--gradient-soft);
  color: var(--red);
  border: 1.5px solid #ffd0dc;
}
.btn-danger:hover{ background: var(--gradient); color:#fff; }

.btn-danger-solid{
  background: var(--gradient);
  color:#fff;
  box-shadow: var(--shadow-md);
}
.btn-danger-solid:hover{ filter: brightness(1.06); transform: translateY(-1px); }

.btn-block{ width:100%; justify-content:center; }

.link-btn{
  background:none; border:none; cursor:pointer;
  color: var(--red); font-weight:600; font-size:13px;
}
.link-btn:hover{ text-decoration: underline; }

/* ============ GRID LAYOUT ============ */
.grid{
  display:grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 22px;
  margin-top: 22px;
}
.col-main, .col-side{ display:flex; flex-direction:column; gap:22px; }

/* ============ CARDS ============ */
.card{
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.25s, transform 0.25s;
}
.card:hover{ box-shadow: var(--shadow-md); }

.card-top{
  display:flex; align-items:center; justify-content:space-between;
  gap:12px; margin-bottom: 18px; flex-wrap:wrap;
}
.card-top h3{
  display:flex; align-items:center; gap:8px;
  font-size:16px; font-weight:700; color: var(--text-primary);
}
.card-top h3 svg{ color: var(--red); }

.label{
  font-size:11px; font-weight:700; letter-spacing:0.6px;
  color: var(--text-secondary); text-transform:uppercase;
}

/* ---- Route Card ---- */
.route-card h2{ font-size:19px; font-weight:800; margin-top:4px; }

.badges{ display:flex; gap:8px; flex-wrap:wrap; }
.badge{
  display:inline-flex; align-items:center; gap:6px;
  padding: 6px 12px; border-radius: 20px;
  font-size:12px; font-weight:700;
}
.badge-safe{ background:#e9f9ef; color: var(--green); }
.dot-green{ width:7px; height:7px; border-radius:50%; background: var(--green); display:inline-block; }
.badge-score{ background: var(--gradient-soft); color: var(--red-dark); }

.route-points{
  display:flex; align-items:center; gap:14px;
  margin: 18px 0;
  background: #fdf7f9;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}
.point{ display:flex; align-items:center; gap:12px; flex:1; }
.point-icon{
  width:38px; height:38px; border-radius:10px;
  display:flex; align-items:center; justify-content:center;
  flex-shrink:0;
}
.point-icon.origin{ background:#ffeef2; color: var(--red); }
.point-icon.destination{ background:#fde7ef; color: var(--pink); }
.point-info{ display:flex; flex-direction:column; }
.point-label{ font-size:11px; color: var(--text-secondary); font-weight:600; }
.point-value{ font-size:14.5px; font-weight:700; }

.route-line{ flex:0 0 60px; height:2px; background: linear-gradient(90deg, var(--red), var(--pink)); position:relative; }
.route-line span{
  position:absolute; right:-3px; top:-3px;
  width:8px; height:8px; border-radius:50%;
  background: var(--pink);
}

.eta-row{
  display:flex; align-items:center; justify-content:space-between;
  font-size:13.5px; color: var(--text-secondary);
  margin-bottom:10px; flex-wrap:wrap; gap:8px;
}
.eta-left{ display:flex; align-items:center; gap:8px; }
.eta-left svg{ color: var(--red); }
.eta-left strong{ color: var(--text-primary); }
#progressPercent{ font-weight:700; color: var(--red); }

.progress-track{
  width:100%; height:8px; border-radius:20px;
  background: #fdeef2; overflow:hidden; margin-bottom:14px;
}
.progress-fill{
  height:100%; width:0%;
  background: var(--gradient);
  border-radius:20px;
  transition: width 0.4s ease;
}

.manual-row{
  display:flex; align-items:center; gap:12px;
  font-size:13px; color: var(--text-secondary);
  font-weight:600; margin-bottom:22px; flex-wrap:wrap;
}
.manual-row input[type="range"]{
  flex:1; min-width:120px; accent-color: var(--red);
  cursor:pointer;
}

.ai-actions h3{ font-size:14px; font-weight:700; margin-bottom:14px; color: var(--text-primary); }

.actions-grid{
  display:grid; grid-template-columns: repeat(3, 1fr); gap:14px;
}
.action-btn{
  background:#fdfafb;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 18px 12px;
  display:flex; flex-direction:column; align-items:center; text-align:center; gap:8px;
  cursor:pointer;
  transition: 0.2s;
}
.action-btn:hover{ border-color: var(--pink); background: var(--gradient-soft); transform: translateY(-2px); }
.action-btn.loading{ opacity:0.7; pointer-events:none; }
.action-icon{
  width:42px; height:42px; border-radius:50%;
  background: var(--gradient-soft); color: var(--red);
  display:flex; align-items:center; justify-content:center;
}
.action-title{ font-weight:700; font-size:13px; }
.action-sub{ font-size:11px; color: var(--text-secondary); }

/* ---- Environmental Card ---- */
.live-chip{
  font-size:11px; font-weight:700; color: var(--green);
  background:#e9f9ef; padding:5px 10px; border-radius:20px;
}
.env-metrics{ display:flex; flex-direction:column; gap:18px; }
.metric-head{ display:flex; justify-content:space-between; font-size:13.5px; font-weight:600; margin-bottom:6px; }
.metric-value.good{ color: var(--green); }
.metric-value.warn{ color: var(--pink); }
.meter{ width:100%; height:7px; background:#f5eef1; border-radius:20px; overflow:hidden; }
.meter-fill{ height:100%; border-radius:20px; transition: width 0.5s; }
.meter-fill.good{ background: var(--green); }
.meter-fill.warn{ background: var(--pink); }
.metric-note{ font-size:12px; color: var(--text-secondary); margin-top:6px; }

/* ---- Siren / SOS Cards ---- */
.siren-card, .sos-card{ text-align:center; }
.circle-icon{
  width:56px; height:56px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  margin: 0 auto 14px;
}
.circle-icon.muted{ background:#f5eef1; color: var(--text-secondary); }
.circle-icon.danger{ background: var(--gradient-soft); color: var(--red); }
.siren-card h3, .sos-card h3{ font-size:16px; font-weight:700; margin-bottom:6px; }
.siren-card p, .sos-card p{ font-size:13px; color: var(--text-secondary); margin-bottom:18px; }

.sos-card{
  border: 1.5px solid #ffd0dc;
  background: linear-gradient(180deg, #fff, #fff7f9);
}

#sirenBtn.active-alarm{
  background: var(--gradient); color:#fff; border-color: transparent;
  animation: sirenPulse 1s infinite;
}
@keyframes sirenPulse{
  0%{ box-shadow: 0 0 0 0 rgba(225,29,72,0.5); }
  70%{ box-shadow: 0 0 0 12px rgba(225,29,72,0); }
  100%{ box-shadow: 0 0 0 0 rgba(225,29,72,0); }
}

/* ---- Contacts Card ---- */
.contacts-list{ list-style:none; display:flex; flex-direction:column; gap:12px; }
.contacts-list li{
  display:flex; align-items:center; justify-content:space-between;
  font-size:13.5px; font-weight:600;
  padding: 10px 12px;
  background: #fdfafb;
  border: 1px solid var(--border);
  border-radius: 12px;
}
.contacts-list li small{ color: var(--text-secondary); font-weight:500; }

.status-badge{
  font-size:10.5px; font-weight:700; padding:4px 10px; border-radius:20px;
}
.status-live{ background:#e9f9ef; color: var(--green); }
.status-notified{ background:#fff4e2; color: var(--amber); }
.status-pending{ background:#f1f1f4; color: var(--text-secondary); }

/* ============ FOOTER ============ */
.page-footer{
  margin-top: 34px;
  text-align:center;
  font-size: 13px;
  color: var(--text-secondary);
  padding: 18px;
  border-top: 1px dashed var(--border);
}
.page-footer strong{ color: var(--red); }

/* ============ FLOATING SOS BUTTON ============ */
.fab-sos{
  position: fixed;
  bottom: 26px; right: 26px;
  width: 62px; height: 62px;
  border-radius: 50%;
  background: var(--gradient);
  border: none;
  display:flex; align-items:center; justify-content:center;
  cursor:pointer;
  box-shadow: 0 10px 30px rgba(225,29,72,0.35);
  z-index: 60;
}
.fab-ring{
  position:absolute; inset:-6px;
  border-radius:50%;
  border: 2px solid rgba(225,29,72,0.4);
  animation: ringPulse 1.8s infinite;
}
@keyframes ringPulse{
  0%{ transform: scale(1); opacity:1; }
  100%{ transform: scale(1.5); opacity:0; }
}

/* ============ TOASTS ============ */
.toast-container{
  position: fixed; bottom: 26px; left: 26px;
  display:flex; flex-direction:column; gap:10px;
  z-index: 200;
}
.toast{
  background:#fff;
  border-left: 4px solid var(--red);
  box-shadow: var(--shadow-md);
  padding: 13px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight:600;
  max-width: 320px;
  transform: translateX(-120%);
  opacity:0;
  transition: 0.35s ease;
}
.toast.show{ transform: translateX(0); opacity:1; }
.toast-success{ border-left-color: var(--green); }
.toast-danger{ border-left-color: var(--red); }
.toast-info{ border-left-color: var(--pink); }

/* ============ MODALS ============ */
.modal-overlay{
  position:fixed; inset:0;
  background: rgba(30,10,20,0.45);
  display:flex; align-items:center; justify-content:center;
  opacity:0; visibility:hidden; transition: 0.25s;
  z-index: 300;
  padding: 20px;
}
.modal-overlay.show{ opacity:1; visibility:visible; }

.modal{
  background:#fff;
  border-radius: 18px;
  padding: 28px;
  max-width: 420px;
  width:100%;
  text-align:center;
  transform: scale(0.9);
  transition: 0.25s;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal-overlay.show .modal{ transform: scale(1); }
.modal h2{ font-size:19px; margin-bottom:10px; }
.modal p{ color: var(--text-secondary); font-size:14px; margin-bottom:20px; }
.modal-actions{ display:flex; gap:12px; }
.modal-actions .btn{ flex:1; justify-content:center; }

.modal-icon{
  width:50px; height:50px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  margin: 0 auto 14px;
}
.modal-icon.danger{ background: var(--gradient-soft); color: var(--red); }

.manage-list{ list-style:none; text-align:left; display:flex; flex-direction:column; gap:10px; margin-bottom:16px; max-height:220px; overflow-y:auto; }
.manage-list li{
  display:flex; justify-content:space-between; align-items:center;
  background:#fdfafb; border:1px solid var(--border);
  padding:10px 12px; border-radius:10px; font-size:13.5px; font-weight:600;
}
.manage-list button{
  background:#fff0f4; color: var(--red); border:none;
  width:26px; height:26px; border-radius:50%; cursor:pointer; font-weight:700;
}

.add-contact-form{ display:flex; gap:8px; margin-bottom:14px; flex-wrap:wrap; }
.add-contact-form input{
  flex:1; min-width:100px;
  padding:10px 12px; border-radius:10px;
  border: 1.5px solid var(--border);
  font-size:13px;
}
.add-contact-form input:focus{ outline:none; border-color: var(--pink); }

/* SOS full-screen alert flash */
body.sos-alert::after{
  content:'';
  position:fixed; inset:0; pointer-events:none;
  border: 6px solid var(--red);
  animation: alertFlash 1s infinite;
  z-index: 400;
}
@keyframes alertFlash{
  0%,100%{ opacity: 0.15; }
  50%{ opacity: 0.6; }
}

/* ============================================
   RESPONSIVE — SIDEBAR STAYS PERMANENT/VISIBLE
   ============================================ */

@media (max-width: 1200px){
  .grid{ grid-template-columns: 1fr; }
}

/* Tablet: shrink sidebar text a bit, keep full labels */
@media (max-width: 1100px){
  .sidebar{
    width: var(--sidebar-width-md);
    min-width: var(--sidebar-width-md);
  }
  .main-content{
    width: calc(100% - var(--sidebar-width-md));
    margin-left: var(--sidebar-width-md);
  }
  .page{ padding: 26px 24px 50px; }
  .nav-item{ font-size:12.5px; }
}

/* Small tablet: sidebar narrower still, labels smaller */
@media (max-width: 850px){
  .sidebar{
    width: var(--sidebar-width-sm);
    min-width: var(--sidebar-width-sm);
    padding: 20px 10px;
  }
  .main-content{
    width: calc(100% - var(--sidebar-width-sm));
    margin-left: var(--sidebar-width-sm);
  }
  .brand-name{ font-size:13px; }
  .brand-tag{ font-size:9px; }
  .nav-item{ gap:9px; padding:9px 10px; font-size:11.5px; }
  .page{ padding: 22px 18px 45px; }
  .page-head-actions{ width:100%; }
  .page-head-actions .btn{ flex:1; justify-content:center; }
  .actions-grid{ grid-template-columns: 1fr 1fr; }
  .route-points{ flex-wrap:wrap; }
  .route-line{ display:none; }
}

/* Mobile: sidebar collapses to ICON-ONLY, but NEVER hides */
@media (max-width: 650px){
  .sidebar{
    width: var(--sidebar-width-icon);
    min-width: var(--sidebar-width-icon);
    padding: 18px 9px;
  }
  .main-content{
    width: calc(100% - var(--sidebar-width-icon));
    margin-left: var(--sidebar-width-icon);
  }

  .sidebar-header{ justify-content:center; padding: 0 0 18px; }
  .brand-text{ display:none; }
  .brand-icon{ width:38px; height:38px; }

  .sidebar-section-label{ display:none; }

  .nav-item{ justify-content:center; gap:0; padding:12px 8px; }
  .nav-label{
    position:absolute; width:1px; height:1px;
    overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap;
  }
  .nav-item svg{ width:19px; height:19px; }

  .sidebar-footer{ gap:10px; }
  .sos-nav .nav-label{ display:none; }

  .user-card{ justify-content:center; padding:7px 4px; }
  .user-info, .user-logout{ display:none; }
  .user-avatar{ width:34px; height:34px; }

  .page{ padding: 18px 14px 40px; }
  .women-safety-strip{ font-size:11px; padding:10px 12px; }
  .page-head h1{ font-size:23px; }
  .page-head p{ font-size:12px; }
  .actions-grid{ grid-template-columns: 1fr; }
}

/* Extra small mobile: sidebar even thinner icon rail */
@media (max-width: 480px){
  .sidebar{
    width: var(--sidebar-width-icon-sm);
    min-width: var(--sidebar-width-icon-sm);
    padding-left:6px; padding-right:6px;
  }
  .main-content{
    width: calc(100% - var(--sidebar-width-icon-sm));
    margin-left: var(--sidebar-width-icon-sm);
  }
  .nav-item{ padding:11px 5px; }
  .nav-item svg{ width:17px; height:17px; }
  .page{ padding: 15px 10px 35px; }
  .page-head-actions{ flex-direction:column; }
  .page-head-actions .btn{ width:100%; }
  .card{ padding:16px; }
  .fab-sos{ width:56px; height:56px; bottom:18px; right:18px; }
  .modal{ padding:22px; }
  .add-contact-form{ flex-direction:column; }
}