/* ========================================
   PermanaNet Sales CRM - Main Stylesheet
   Brand: Deep Navy #0D2B55, Cyan #00A8E8, Orange #F47B20
   ======================================== */

:root {
  --primary:        #0D2B55;
  --primary-light:  #1A3D73;
  --primary-dark:   #08203F;
  --accent:         #00A8E8;
  --accent-light:   #33BCEF;
  --accent-dark:    #007BB5;
  --orange:         #F47B20;
  --orange-light:   #F79448;
  --orange-dark:    #D4620E;
  --success:        #1DB87E;
  --success-bg:     #E8F9F2;
  --danger:         #E53935;
  --danger-bg:      #FDECEC;
  --warning:        #F59E0B;
  --warning-bg:     #FEF3E2;
  --info:           #3B82F6;
  --info-bg:        #EFF6FF;
  --gray-50:        #F8FAFC;
  --gray-100:       #F1F5F9;
  --gray-200:       #E2E8F0;
  --gray-300:       #CBD5E1;
  --gray-400:       #94A3B8;
  --gray-500:       #64748B;
  --gray-600:       #475569;
  --gray-700:       #334155;
  --gray-800:       #1E293B;
  --gray-900:       #0F172A;
  --sidebar-w:      260px;
  --topbar-h:       64px;
  --radius:         10px;
  --radius-sm:      6px;
  --radius-lg:      14px;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08);
  --shadow:         0 4px 16px rgba(13,43,85,.10);
  --shadow-lg:      0 8px 32px rgba(13,43,85,.14);
  --font:           'Inter', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--gray-50); color: var(--gray-800); display: flex; min-height: 100vh; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--primary);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: transform .25s ease;
  box-shadow: 4px 0 20px rgba(0,0,0,.18);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: var(--primary-dark);
}
.brand-img { width: 36px; height: 36px; object-fit: contain; border-radius: 8px; background: rgba(255,255,255,.1); padding: 4px; }
.brand-name { display: block; color: #fff; font-weight: 700; font-size: 15px; line-height: 1; }
.brand-sub  { display: block; color: var(--accent-light); font-size: 10px; font-weight: 400; text-transform: uppercase; letter-spacing: .08em; margin-top: 1px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-section { margin-bottom: 20px; }
.nav-section-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: rgba(255,255,255,.35); padding: 0 12px; display: block; margin-bottom: 6px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.75);
  font-size: 13.5px;
  font-weight: 400;
  transition: all .15s;
  position: relative;
}
.nav-item i { width: 18px; text-align: center; font-size: 14px; color: rgba(255,255,255,.5); }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item:hover i { color: var(--accent-light); }
.nav-item.active { background: var(--accent); color: #fff; font-weight: 500; }
.nav-item.active i { color: #fff; }
.nav-badge { margin-left: auto; background: var(--orange); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 20px; min-width: 18px; text-align: center; display: none; }
.nav-badge:not(:empty) { display: inline-block; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  background: rgba(0,0,0,.15);
}
.user-avatar-sm {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-meta { flex: 1; min-width: 0; }
.user-meta-name { display: block; color: #fff; font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta-role { display: block; font-size: 10px; font-weight: 500; text-transform: capitalize; padding: 1px 6px; border-radius: 20px; margin-top: 2px; width: fit-content; }
.btn-logout { color: rgba(255,255,255,.5); font-size: 15px; padding: 4px; transition: color .15s; }
.btn-logout:hover { color: var(--danger); }

/* Role badge colors */
.role-general_manager { background: var(--orange); color: #fff; }
.role-sales_manager   { background: var(--accent); color: #fff; }
.role-sales           { background: var(--success); color: #fff; }
.role-telemarketing   { background: #8B5CF6; color: #fff; }
.role-admin           { background: var(--gray-500); color: #fff; }

/* ---- MAIN WRAPPER ---- */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-sm);
}
.sidebar-toggle { display: none; background: none; border: none; font-size: 18px; color: var(--gray-600); cursor: pointer; }
.topbar-title { flex: 1; font-size: 16px; font-weight: 600; color: var(--gray-800); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-user { padding: 2px; }

.main-content { flex: 1; padding: 24px; }

/* ---- ALERTS ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.alert-success { background: var(--success-bg); color: #0D6E4B; border-left: 4px solid var(--success); }
.alert-danger   { background: var(--danger-bg);  color: #9B1C1C; border-left: 4px solid var(--danger); }
.alert-warning  { background: var(--warning-bg); color: #92400E; border-left: 4px solid var(--warning); }
.alert-info     { background: var(--info-bg);    color: #1E40AF; border-left: 4px solid var(--info); }

/* ---- CARDS ---- */
.card {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.card-title { font-size: 15px; font-weight: 600; color: var(--gray-800); }
.card-body  { padding: 20px; }

/* ---- STAT CARDS ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.stat-icon.blue   { background: #EFF6FF; color: var(--info); }
.stat-icon.green  { background: var(--success-bg); color: var(--success); }
.stat-icon.orange { background: #FEF3E2; color: var(--orange); }
.stat-icon.red    { background: var(--danger-bg); color: var(--danger); }
.stat-icon.navy   { background: #E8EDF5; color: var(--primary); }
.stat-icon.cyan   { background: #E0F5FD; color: var(--accent); }
.stat-val   { font-size: 24px; font-weight: 700; color: var(--gray-900); line-height: 1; }
.stat-label { font-size: 12px; color: var(--gray-500); margin-top: 3px; }
.stat-sub   { font-size: 11.5px; margin-top: 5px; }
.stat-sub.up   { color: var(--success); }
.stat-sub.down { color: var(--danger); }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-sm { padding: 6px 13px; font-size: 12.5px; }
.btn-xs { padding: 4px 10px; font-size: 11.5px; }
.btn-lg { padding: 11px 24px; font-size: 14.5px; }

.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-light); color: #fff; }
.btn-accent    { background: var(--accent); color: #fff; }
.btn-accent:hover   { background: var(--accent-dark); color: #fff; }
.btn-orange    { background: var(--orange); color: #fff; }
.btn-orange:hover   { background: var(--orange-dark); color: #fff; }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover  { background: #179066; color: #fff; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover   { background: #C62828; color: #fff; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-outline   { background: transparent; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover  { background: var(--gray-100); }
.btn-light     { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-light:hover    { background: var(--gray-200); }

/* ---- BADGES / STAGES ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
}
/* Stage badges */
.badge-new          { background: var(--gray-100);  color: var(--gray-600); }
.badge-canvasing    { background: #EDE9FE; color: #5B21B6; }
.badge-telemarketing{ background: #E0E7FF; color: #3730A3; }
.badge-meeting      { background: #E0F5FD; color: var(--accent-dark); }
.badge-call         { background: #FEF9C3; color: #854D0E; }
.badge-presentation { background: #FEF3E2; color: var(--orange-dark); }
.badge-negotiation  { background: #FFF1F2; color: #9F1239; }
.badge-deal         { background: var(--success-bg); color: #065F46; }
.badge-lost         { background: var(--danger-bg);  color: #7F1D1D; }
/* Approval */
.badge-pending  { background: #FEF9C3; color: #854D0E; }
.badge-approved { background: var(--success-bg); color: #065F46; }
.badge-rejected { background: var(--danger-bg);  color: #7F1D1D; }
/* Source */
.badge-source { background: var(--info-bg); color: #1E40AF; }
/* Product category */
.badge-dedicated  { background: #E8EDF5; color: var(--primary); }
.badge-hosta      { background: #E0F5FD; color: var(--accent-dark); }
.badge-imore      { background: #EDE9FE; color: #5B21B6; }
.badge-home       { background: var(--success-bg); color: #065F46; }
.badge-dwdm       { background: #FEF3E2; color: var(--orange-dark); }
.badge-dark_fiber { background: var(--gray-800); color: var(--gray-200); }

/* ---- TABLE ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  background: var(--gray-50);
  color: var(--gray-600);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  vertical-align: middle;
}
tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }
.td-actions { display: flex; gap: 4px; align-items: center; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--gray-700); margin-bottom: 6px; }
.form-label .req { color: var(--danger); }
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--gray-800);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  font-family: var(--font);
}
.form-control:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,168,232,.12); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24'%3E%3Cpath stroke='%2364748B' stroke-width='2' d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 32px; }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 0 18px; }
.form-text { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

/* ---- PIPELINE KANBAN ---- */
.pipeline-board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; }
.pipeline-col {
  min-width: 250px;
  max-width: 280px;
  background: var(--gray-100);
  border-radius: var(--radius-lg);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.pipeline-col-header {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 7px;
  border-bottom: 1px solid var(--gray-200);
}
.col-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.col-title { font-size: 13px; font-weight: 600; color: var(--gray-700); flex: 1; }
.col-count-badge { background: var(--gray-300); color: var(--gray-700); font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 10px; }
.pipeline-col-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; flex: 1; overflow-y: auto; max-height: 60vh; }
.lead-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: box-shadow .15s;
}
.lead-card:hover { box-shadow: var(--shadow); }
.lead-card-title { font-size: 13px; font-weight: 600; color: var(--gray-800); margin-bottom: 4px; }
.lead-card-sub   { font-size: 12px; color: var(--gray-500); margin-bottom: 8px; }
.lead-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.lead-value { font-size: 12px; font-weight: 600; color: var(--primary); }

/* ---- PAGE HEADER ---- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.page-header-left h1 { font-size: 22px; font-weight: 700; color: var(--gray-900); }
.page-header-left p  { font-size: 13px; color: var(--gray-500); margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- FILTER BAR ---- */
.filter-bar {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  margin-bottom: 20px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.filter-bar .form-group { margin: 0; min-width: 160px; flex: 1; }
.filter-bar .form-label { font-size: 11.5px; }

/* ---- AUTH ---- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  background: var(--primary);
}
.auth-left {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 40px;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
  position: relative;
  overflow: hidden;
}
.auth-left::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: rgba(0,168,232,.08);
  top: -100px; right: -100px;
}
.auth-left::after {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: rgba(244,123,32,.07);
  bottom: -80px; left: -80px;
}
.auth-brand { text-align: center; position: relative; z-index: 1; }
.auth-brand img { width: 90px; margin-bottom: 20px; filter: brightness(0) invert(1); }
.auth-brand h2 { font-size: 28px; font-weight: 700; color: #fff; margin-bottom: 8px; }
.auth-brand p  { font-size: 14px; color: rgba(255,255,255,.65); line-height: 1.6; max-width: 320px; }
.auth-features { margin-top: 36px; display: flex; flex-direction: column; gap: 14px; }
.auth-feature { display: flex; align-items: center; gap: 12px; color: rgba(255,255,255,.8); font-size: 13px; }
.auth-feature i { width: 32px; height: 32px; border-radius: 8px; background: rgba(255,255,255,.12); display: flex; align-items: center; justify-content: center; font-size: 14px; color: var(--accent-light); }

.auth-right {
  width: 460px;
  min-width: 380px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 50px;
}
.auth-form { width: 100%; }
.auth-form h3 { font-size: 24px; font-weight: 700; color: var(--gray-900); margin-bottom: 6px; }
.auth-form p  { font-size: 14px; color: var(--gray-500); margin-bottom: 32px; }
.auth-submit { width: 100%; padding: 12px; font-size: 15px; margin-top: 8px; }

/* ---- TABS ---- */
.tabs { display: flex; gap: 2px; background: var(--gray-100); border-radius: var(--radius-sm); padding: 4px; margin-bottom: 20px; width: fit-content; }
.tab-btn { padding: 7px 16px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; cursor: pointer; border: none; background: transparent; color: var(--gray-600); transition: all .15s; }
.tab-btn.active { background: #fff; color: var(--primary); box-shadow: var(--shadow-sm); }

/* ---- TIMELINE ---- */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item { display: flex; gap: 14px; padding-bottom: 20px; position: relative; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before { content: ''; position: absolute; left: 14px; top: 28px; bottom: 0; width: 2px; background: var(--gray-200); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0; z-index: 1; }
.timeline-dot.stage  { background: var(--accent); color: #fff; }
.timeline-dot.note   { background: var(--gray-200); color: var(--gray-600); }
.timeline-dot.approval { background: var(--success-bg); color: var(--success); border: 2px solid var(--success); }
.timeline-dot.rejection { background: var(--danger-bg); color: var(--danger); border: 2px solid var(--danger); }
.timeline-dot.call   { background: #EDE9FE; color: #5B21B6; }
.timeline-dot.meeting{ background: #E0F5FD; color: var(--accent-dark); }
.timeline-body { flex: 1; }
.timeline-title { font-size: 13px; font-weight: 500; color: var(--gray-800); }
.timeline-time  { font-size: 11.5px; color: var(--gray-400); margin-top: 1px; }

/* ---- MODALS ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200; display: none; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: var(--radius-lg); width: 500px; max-width: 94vw; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-header { padding: 18px 22px; border-bottom: 1px solid var(--gray-200); display: flex; justify-content: space-between; align-items: center; }
.modal-title { font-size: 16px; font-weight: 600; color: var(--gray-900); }
.modal-close { background: none; border: none; font-size: 18px; color: var(--gray-400); cursor: pointer; }
.modal-close:hover { color: var(--gray-700); }
.modal-body { padding: 22px; }
.modal-footer { padding: 16px 22px; border-top: 1px solid var(--gray-100); display: flex; justify-content: flex-end; gap: 8px; }

/* ---- PROGRESS BAR ---- */
.progress { height: 8px; background: var(--gray-200); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 4px; transition: width .3s; }
.progress-bar.primary { background: var(--primary); }
.progress-bar.success { background: var(--success); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger  { background: var(--danger); }
.progress-bar.accent  { background: var(--accent); }

/* ---- MISC ---- */
.text-muted  { color: var(--gray-400); }
.text-sm     { font-size: 12px; }
.fw-600      { font-weight: 600; }
.text-success{ color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning{ color: var(--warning); }
.text-primary{ color: var(--primary); }
.text-accent { color: var(--accent); }
.text-orange { color: var(--orange); }
.d-flex      { display: flex; }
.align-center{ align-items: center; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.mb-0        { margin-bottom: 0; }
.mb-16       { margin-bottom: 16px; }
.mb-24       { margin-bottom: 24px; }
.mt-12       { margin-top: 12px; }
.ml-auto     { margin-left: auto; }
.w-100       { width: 100%; }
.currency    { font-weight: 600; color: var(--primary); }

/* ---- RESPONSIVE ---- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .auth-left { display: none; }
  .auth-right { width: 100%; min-width: 0; }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 600px) {
  .main-content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; }
}
