/* ============================================================
   Trilianpay CRM — Main Stylesheet
   Colour scheme: Navy #1a2e5a  |  Teal #00c9a7
   Update CSS variables below to match brand colours
   ============================================================ */

:root {
  --primary:        #1a2e5a;
  --primary-light:  #263f7a;
  --primary-dark:   #111f3d;
  --accent:         #00c9a7;
  --accent-dark:    #00a589;
  --blue:           #4e73df;
  --indigo:         #5a5acb;
  --success:        #1cc88a;
  --danger:         #e74a3b;
  --warning:        #f6c23e;
  --info:           #36b9cc;
  --orange:         #fd7e14;
  --sidebar-w:      260px;
  --topbar-h:       64px;
  --bg:             #f0f4f8;
  --card-bg:        #ffffff;
  --text:           #2d3748;
  --text-muted:     #718096;
  --border:         #e2e8f0;
  --radius:         10px;
  --shadow:         0 2px 12px rgba(0,0,0,.08);
  --shadow-lg:      0 8px 32px rgba(0,0,0,.12);
  --transition:     all .2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}
a { text-decoration: none; color: var(--primary); }
a:hover { color: var(--accent); }

/* ===== LAYOUT ===== */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--primary);
  overflow-y: auto;
  z-index: 1000;
  transition: transform .3s ease;
  display: flex;
  flex-direction: column;
}
.main-wrap {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin .3s ease;
}
.page-content {
  padding: 24px;
  flex: 1;
}

/* ===== SIDEBAR ===== */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.brand-logo {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; color: #fff;
  flex-shrink: 0;
}
.brand-name { color: #fff; font-weight: 700; font-size: 16px; line-height: 1.2; }
.brand-sub  { color: var(--accent); font-size: 10px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.user-name  { color: #fff; font-size: 13px; font-weight: 600; }
.user-role  { color: rgba(255,255,255,.5); font-size: 11px; }

.sidebar-nav { padding: 10px 10px 20px; flex: 1; }
.nav-section {
  color: rgba(255,255,255,.35);
  font-size: 10px; font-weight: 700;
  letter-spacing: 1.2px; text-transform: uppercase;
  padding: 14px 10px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  color: rgba(255,255,255,.7);
  padding: 9px 12px;
  border-radius: 8px;
  margin-bottom: 2px;
  font-size: 13.5px;
  transition: var(--transition);
  cursor: pointer;
}
.nav-item i:first-child { width: 18px; text-align: center; font-size: 13px; }
.nav-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; font-weight: 600; }
.nav-item.active i:first-child { color: #fff; }
.nav-external { opacity: .8; }
.nav-external:hover { opacity: 1; }
.text-danger-light { color: rgba(255,100,100,.8) !important; }
.text-danger-light:hover { color: #ff6b6b !important; background: rgba(255,100,100,.1) !important; }

/* ===== TOPBAR ===== */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky; top: 0; z-index: 500;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.btn-sidebar-toggle, .btn-collapse {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 18px; padding: 4px 8px;
}
.topbar-search {
  position: relative; display: flex; align-items: center;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 14px; gap: 8px;
  width: 320px;
}
.topbar-search i { color: var(--text-muted); }
.topbar-search input {
  border: none; background: none; outline: none;
  font-size: 14px; color: var(--text); width: 100%;
}
.search-dropdown {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); max-height: 360px; overflow-y: auto; z-index: 9999;
  display: none;
}
.search-dropdown.show { display: block; }
.search-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; cursor: pointer; transition: var(--transition);
  border-bottom: 1px solid var(--border);
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--bg); }
.search-item-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.search-item-name  { font-weight: 600; font-size: 13px; }
.search-item-meta  { font-size: 12px; color: var(--text-muted); }

/* ===== BUTTONS ===== */
.btn-accent {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.btn-accent:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }

/* ===== FLASH ===== */
.flash-container { padding: 0 24px; }

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; gap: 16px; flex-wrap: wrap;
}
.page-header-left h1 {
  font-size: 22px; font-weight: 700; color: var(--primary); margin: 0;
}
.page-header-left .breadcrumb { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== STAT CARDS ===== */
.stat-card {
  background: #fff; border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
  border-left: 4px solid var(--accent);
  transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.stat-card.blue   { border-color: var(--blue); }
.stat-card.green  { border-color: var(--success); }
.stat-card.orange { border-color: var(--orange); }
.stat-card.red    { border-color: var(--danger); }
.stat-card.purple { border-color: var(--indigo); }
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.stat-icon.teal   { background: rgba(0,201,167,.12); color: var(--accent); }
.stat-icon.blue   { background: rgba(78,115,223,.12); color: var(--blue); }
.stat-icon.green  { background: rgba(28,200,138,.12); color: var(--success); }
.stat-icon.orange { background: rgba(253,126,20,.12); color: var(--orange); }
.stat-icon.red    { background: rgba(231,74,59,.12);  color: var(--danger); }
.stat-icon.purple { background: rgba(90,90,203,.12); color: var(--indigo); }
.stat-value { font-size: 28px; font-weight: 800; line-height: 1; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .5px; margin-top: 3px; }

/* ===== CARDS ===== */
.crm-card {
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.crm-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.crm-card-title { font-size: 15px; font-weight: 700; color: var(--primary); }
.crm-card-body  { padding: 20px; }

/* ===== TABLES ===== */
.crm-table { width: 100%; border-collapse: collapse; }
.crm-table th {
  background: var(--bg); color: var(--text-muted);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  padding: 10px 14px; text-align: left; white-space: nowrap;
}
.crm-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.crm-table tr:last-child td { border-bottom: none; }
.crm-table tr:hover td { background: var(--bg); }
.crm-table .contact-cell { display: flex; align-items: center; gap: 10px; }
.contact-avatar {
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.contact-name { font-weight: 600; color: var(--primary); font-size: 13.5px; }
.contact-company { font-size: 12px; color: var(--text-muted); }

/* ===== FILTERS ===== */
.filter-bar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  margin-bottom: 20px; background: #fff;
  padding: 12px 16px; border-radius: var(--radius); box-shadow: var(--shadow);
}
.filter-bar input, .filter-bar select {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 7px 12px; font-size: 13px; outline: none; background: #fff;
}
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--accent); }

/* ===== PIPELINE / KANBAN ===== */
.kanban-board { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 16px; min-height: 70vh; }
.kanban-col { min-width: 260px; flex: 0 0 280px; background: var(--bg); border-radius: var(--radius); display: flex; flex-direction: column; }
.kanban-col-header {
  padding: 14px 16px; font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: space-between;
  border-radius: var(--radius) var(--radius) 0 0;
}
.kanban-col.lead        .kanban-col-header { background: #e8edf7; color: var(--primary); }
.kanban-col.opportunity .kanban-col-header { background: #e0f7fa; color: #0097a7; }
.kanban-col.deal        .kanban-col-header { background: #fff8e1; color: #f57c00; }
.kanban-col.client      .kanban-col-header { background: #e8f5e9; color: #2e7d32; }
.kanban-cards { padding: 10px; flex: 1; min-height: 100px; }
.kanban-card {
  background: #fff; border-radius: 8px; padding: 14px;
  margin-bottom: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.08);
  cursor: grab; transition: var(--transition);
  border-left: 3px solid var(--accent);
}
.kanban-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.kanban-card.sortable-ghost { opacity: .4; }
.kanban-card-name { font-weight: 700; font-size: 13.5px; color: var(--primary); }
.kanban-card-company { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.kanban-card-value { font-size: 13px; font-weight: 600; color: var(--success); margin-top: 8px; }
.kanban-card-meta { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.kanban-col-count { background: rgba(0,0,0,.12); color: inherit; border-radius: 12px; padding: 1px 8px; font-size: 12px; }

/* ===== CALENDAR ===== */
.fc .fc-toolbar-title { font-size: 18px !important; font-weight: 700 !important; color: var(--primary) !important; }
.fc .fc-button-primary { background: var(--primary) !important; border-color: var(--primary) !important; }
.fc .fc-button-primary:hover { background: var(--primary-light) !important; }
.fc .fc-event { background: var(--accent) !important; border-color: var(--accent) !important; border-radius: 4px !important; }
.fc .fc-daygrid-day.fc-day-today { background: rgba(0,201,167,.05) !important; }

/* ===== CONTACT DETAIL ===== */
.contact-detail-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; border-radius: var(--radius); padding: 28px;
  margin-bottom: 24px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.contact-detail-avatar {
  width: 72px; height: 72px; border-radius: 18px;
  background: rgba(255,255,255,.2); display: flex; align-items: center;
  justify-content: center; font-size: 26px; font-weight: 800; flex-shrink: 0;
}
.contact-detail-name  { font-size: 22px; font-weight: 800; }
.contact-detail-meta  { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 6px; opacity: .85; font-size: 13px; }
.contact-detail-meta span { display: flex; align-items: center; gap: 6px; }
.contact-action-btns  { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.contact-action-btns a {
  background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.3);
  border-radius: 6px; padding: 6px 14px; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 6px; transition: var(--transition);
}
.contact-action-btns a:hover { background: rgba(255,255,255,.25); color: #fff; }

/* ===== ACTIVITY FEED ===== */
.activity-feed { list-style: none; padding: 0; }
.activity-item  { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: none; }
.activity-icon  { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.activity-icon.call  { background: rgba(28,200,138,.12); color: var(--success); }
.activity-icon.email { background: rgba(78,115,223,.12); color: var(--blue); }
.activity-icon.text  { background: rgba(0,201,167,.12);  color: var(--accent); }
.activity-icon.note  { background: rgba(246,194,62,.12);  color: var(--warning); }
.activity-icon.meet  { background: rgba(90,90,203,.12);  color: var(--indigo); }
.activity-icon.file  { background: rgba(253,126,20,.12);  color: var(--orange); }
.activity-body  { flex: 1; }
.activity-subject { font-weight: 600; font-size: 13.5px; }
.activity-desc { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }
.activity-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ===== TASK LIST ===== */
.task-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.task-item:last-child { border-bottom: none; }
.task-item.completed .task-title { text-decoration: line-through; color: var(--text-muted); }
.task-check input { width: 18px; height: 18px; cursor: pointer; accent-color: var(--accent); }
.task-title { font-weight: 600; font-size: 13.5px; }
.task-meta  { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.task-due.overdue { color: var(--danger) !important; font-weight: 600; }

/* ===== DOCUMENT CARDS ===== */
.doc-card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; transition: var(--transition); position: relative;
}
.doc-card:hover { box-shadow: var(--shadow-lg); border-color: var(--accent); }
.doc-icon { font-size: 32px; margin-bottom: 10px; }
.doc-name { font-weight: 600; font-size: 13.5px; color: var(--primary); word-break: break-word; }
.doc-meta { font-size: 12px; color: var(--text-muted); margin-top: 6px; }
.doc-actions { display: flex; gap: 6px; margin-top: 12px; }

/* ===== PAYMENTS ===== */
.payment-amount { font-size: 17px; font-weight: 800; color: var(--success); }
.payment-amount.negative { color: var(--danger); }

/* ===== FORMS ===== */
.form-control, .form-select {
  border-color: var(--border); border-radius: 7px; font-size: 13.5px;
  padding: 8px 12px; transition: var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,201,167,.15);
}
.form-label { font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.section-heading { font-size: 13px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .5px; margin: 20px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--accent); }

/* ===== TABS ===== */
.nav-tabs .nav-link { color: var(--text-muted); font-weight: 600; font-size: 13px; border: none; padding: 10px 16px; }
.nav-tabs .nav-link:hover { color: var(--primary); }
.nav-tabs .nav-link.active { color: var(--primary); border-bottom: 2px solid var(--accent); background: none; }
.nav-tabs { border-bottom: 1px solid var(--border); }

/* ===== SUPPORT TICKET ===== */
.ticket-card { background: #fff; border-radius: var(--radius); padding: 18px; margin-bottom: 12px; box-shadow: var(--shadow); border-left: 4px solid var(--border); cursor: pointer; transition: var(--transition); }
.ticket-card:hover { box-shadow: var(--shadow-lg); }
.ticket-card.open        { border-color: var(--danger); }
.ticket-card.in_progress { border-color: var(--warning); }
.ticket-card.waiting     { border-color: var(--info); }
.ticket-card.resolved    { border-color: var(--success); }
.ticket-card.closed      { border-color: #aaa; }
.ticket-title { font-weight: 700; font-size: 14px; color: var(--primary); }
.ticket-meta  { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ===== SETTINGS ===== */
.integration-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; display: flex; align-items: flex-start; gap: 16px;
  transition: var(--transition); background: #fff;
}
.integration-card:hover { border-color: var(--accent); }
.integration-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.integration-connected { border-color: var(--success); background: rgba(28,200,138,.03); }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #ccc; margin-right: 5px; }
.status-dot.connected { background: var(--success); }

/* ===== MOBILE ===== */
@media (max-width: 767px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .page-content { padding: 16px; }
  .kanban-board { flex-direction: column; }
  .kanban-col { min-width: auto; flex: none; }
  .topbar { padding: 0 16px; }
  .stat-value { font-size: 22px; }
}
@media (max-width: 576px) {
  .contact-detail-header { flex-direction: column; }
  .filter-bar { flex-direction: column; align-items: stretch; }
}

/* ===== UTILITIES ===== */
.text-accent { color: var(--accent) !important; }
.bg-accent   { background: var(--accent) !important; }
.border-accent { border-color: var(--accent) !important; }
.fw-700 { font-weight: 700 !important; }
.gap-2 { gap: .5rem; }
.scrollable-x { overflow-x: auto; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state i { font-size: 48px; opacity: .3; margin-bottom: 16px; }
.empty-state h4 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }

/* Login page */
.login-page { background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--accent-dark) 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: #fff; border-radius: 16px; padding: 40px; width: 100%; max-width: 420px; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.login-logo { width: 52px; height: 52px; background: linear-gradient(135deg, var(--accent), var(--accent-dark)); border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 900; color: #fff; margin: 0 auto 20px; }
.login-title { text-align: center; font-size: 22px; font-weight: 800; color: var(--primary); }
.login-sub   { text-align: center; color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }
