/* ============================================
   EasyCredit Platform - Main Styles
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Barlow:wght@300;400;500;600;700;800&family=Barlow+Condensed:wght@500;600;700&display=swap');

:root {
  --ec-red:        #E01B1B;
  --ec-red-dark:   #B01515;
  --ec-red-light:  #ff3333;
  --ec-slate:      #3D4F61;
  --ec-slate-dark: #2a3845;
  --ec-slate-light:#5a7080;
  --ec-bg:         #0f1923;
  --ec-bg2:        #16222e;
  --ec-bg3:        #1d2f3f;
  --ec-card:       #1a2838;
  --ec-border:     rgba(255,255,255,0.08);
  --ec-text:       #e8edf2;
  --ec-text-muted: #7a96ab;
  --ec-sidebar-w:  260px;
  --ec-header-h:   64px;
  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm:     0 2px 8px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; }

body {
  font-family: 'Barlow', sans-serif;
  background: var(--ec-bg);
  color: var(--ec-text);
  font-size: 15px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--ec-bg2); }
::-webkit-scrollbar-thumb { background: var(--ec-slate); border-radius: 3px; }

/* ============================================
   LAYOUT
   ============================================ */
.ec-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.ec-sidebar {
  width: var(--ec-sidebar-w);
  background: var(--ec-bg2);
  border-right: 1px solid var(--ec-border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.ec-sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--ec-border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.ec-sidebar-brand img {
  height: 36px;
  filter: brightness(1.1);
}

.ec-sidebar-brand .brand-text {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ec-text);
  letter-spacing: 0.5px;
}

.ec-sidebar-brand .brand-version {
  font-size: 0.7rem;
  color: var(--ec-text-muted);
  display: block;
  margin-top: -4px;
}

/* ---- User info in sidebar ---- */
.ec-sidebar-user {
  padding: 16px 20px;
  border-bottom: 1px solid var(--ec-border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.ec-sidebar-user .user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ec-red), var(--ec-slate));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: white;
  flex-shrink: 0;
  text-transform: uppercase;
}

.ec-sidebar-user .user-info .user-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ec-text);
  line-height: 1.2;
}

.ec-sidebar-user .user-info .user-role {
  font-size: 0.72rem;
  color: var(--ec-red);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ---- Nav ---- */
.ec-nav {
  flex: 1;
  padding: 12px 12px;
}

.ec-nav-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--ec-text-muted);
  padding: 8px 8px 4px;
  margin-top: 8px;
}

.ec-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--ec-text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.2s;
  margin-bottom: 2px;
  position: relative;
}

.ec-nav-link i {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.ec-nav-link:hover {
  background: var(--ec-bg3);
  color: var(--ec-text);
}

.ec-nav-link.active {
  background: linear-gradient(135deg, rgba(224,27,27,0.2), rgba(61,79,97,0.2));
  color: var(--ec-text);
  border-left: 3px solid var(--ec-red);
}

.ec-nav-link .badge {
  margin-left: auto;
  font-size: 0.65rem;
}

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

/* ---- Header ---- */
.ec-header {
  height: var(--ec-header-h);
  background: var(--ec-bg2);
  border-bottom: 1px solid var(--ec-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 900;
  gap: 16px;
}

.ec-header .page-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--ec-text);
  letter-spacing: 0.5px;
  flex: 1;
}

.ec-header .header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ec-sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--ec-text);
  font-size: 1.3rem;
  padding: 4px;
  cursor: pointer;
}

/* ---- Page content ---- */
.ec-content {
  flex: 1;
  padding: 24px;
}

/* ============================================
   CARDS
   ============================================ */
.ec-card {
  background: var(--ec-card);
  border: 1px solid var(--ec-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.ec-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--ec-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.ec-card-header .card-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--ec-text);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ec-card-body { padding: 20px; }

/* ---- Stat cards ---- */
.ec-stat-card {
  background: var(--ec-card);
  border: 1px solid var(--ec-border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.ec-stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--stat-color, var(--ec-red));
}

.ec-stat-card:hover {
  border-color: rgba(224,27,27,0.3);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.ec-stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  background: var(--stat-bg, rgba(224,27,27,0.15));
  color: var(--stat-color, var(--ec-red));
  flex-shrink: 0;
}

.ec-stat-info .stat-value {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 1.6rem;
  color: var(--ec-text);
  line-height: 1;
}

.ec-stat-info .stat-label {
  font-size: 0.8rem;
  color: var(--ec-text-muted);
  font-weight: 500;
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ============================================
   TABLES
   ============================================ */
.ec-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.ec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.ec-table thead th {
  background: var(--ec-bg3);
  color: var(--ec-text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--ec-border);
  white-space: nowrap;
}

.ec-table tbody tr {
  border-bottom: 1px solid var(--ec-border);
  transition: background 0.15s;
}

.ec-table tbody tr:hover {
  background: rgba(255,255,255,0.03);
}

.ec-table tbody td {
  padding: 12px 14px;
  vertical-align: middle;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn-ec-primary {
  background: var(--ec-red);
  border: none;
  color: white;
  font-weight: 600;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.btn-ec-primary:hover {
  background: var(--ec-red-dark);
  color: white;
  transform: translateY(-1px);
}

.btn-ec-ghost {
  background: transparent;
  border: 1px solid var(--ec-border);
  color: var(--ec-text-muted);
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.btn-ec-ghost:hover {
  border-color: var(--ec-red);
  color: var(--ec-red);
  background: rgba(224,27,27,0.05);
}

/* ============================================
   FORMS
   ============================================ */
.form-control, .form-select {
  background: var(--ec-bg3) !important;
  border: 1px solid var(--ec-border) !important;
  color: var(--ec-text) !important;
  border-radius: var(--radius-sm) !important;
  font-size: 0.9rem !important;
  padding: 9px 14px !important;
  transition: border-color 0.2s !important;
}

.form-control:focus, .form-select:focus {
  border-color: var(--ec-red) !important;
  box-shadow: 0 0 0 3px rgba(224,27,27,0.15) !important;
  outline: none !important;
}

.form-control::placeholder { color: var(--ec-text-muted) !important; }

.form-label {
  color: var(--ec-text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

/* ---- Bootstrap overrides for dark theme ---- */
.form-select option { background: var(--ec-bg3); }
.input-group-text {
  background: var(--ec-bg3) !important;
  border-color: var(--ec-border) !important;
  color: var(--ec-text-muted) !important;
}

/* ============================================
   BADGES
   ============================================ */
.badge { font-size: 0.72rem; font-weight: 600; padding: 4px 8px; }

/* ============================================
   NOTES TIMELINE
   ============================================ */
.ec-timeline { position: relative; padding-left: 32px; }

.ec-timeline::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--ec-border);
}

.ec-timeline-item {
  position: relative;
  margin-bottom: 20px;
}

.ec-timeline-dot {
  position: absolute;
  left: -26px;
  top: 12px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  z-index: 1;
  background: var(--ec-bg3);
  border: 2px solid var(--ec-border);
  color: var(--ec-text-muted);
}

.ec-timeline-dot.dot-call    { background: rgba(13,202,240,0.2); border-color: #0dcaf0; color: #0dcaf0; }
.ec-timeline-dot.dot-payment { background: rgba(25,135,84,0.2);  border-color: #198754; color: #198754; }
.ec-timeline-dot.dot-visit   { background: rgba(255,193,7,0.2);  border-color: #ffc107; color: #ffc107; }
.ec-timeline-dot.dot-promise { background: rgba(13,110,253,0.2); border-color: #0d6efd; color: #0d6efd; }
.ec-timeline-dot.dot-other   { background: rgba(108,117,125,0.2);border-color: #6c757d; color: #6c757d; }

.ec-timeline-card {
  background: var(--ec-bg3);
  border: 1px solid var(--ec-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}

.ec-timeline-card .note-meta {
  font-size: 0.75rem;
  color: var(--ec-text-muted);
  margin-bottom: 6px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.ec-timeline-card .note-content {
  font-size: 0.9rem;
  color: var(--ec-text);
  line-height: 1.5;
}

.ec-timeline-card .note-action {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--ec-red);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ============================================
   CLIENT PROFILE HEADER
   ============================================ */
.client-profile-header {
  background: linear-gradient(135deg, var(--ec-card), var(--ec-bg3));
  border: 1px solid var(--ec-border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
}

.client-avatar-lg {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ec-red), var(--ec-slate));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.client-info-main .client-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--ec-text);
  line-height: 1;
  margin-bottom: 4px;
}

.client-info-main .client-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--ec-text-muted);
}

.client-info-main .client-meta span {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* ============================================
   FOOTER
   ============================================ */
.ec-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--ec-border);
  background: var(--ec-bg2);
  font-size: 0.8rem;
  color: var(--ec-text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.ec-footer a { color: var(--ec-red); text-decoration: none; }

/* ============================================
   ALERTS & FLASH
   ============================================ */
.alert {
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.9rem;
}

.alert-success { background: rgba(25,135,84,0.15); border-color: rgba(25,135,84,0.3); color: #75b798; }
.alert-danger   { background: rgba(220,53,69,0.15); border-color: rgba(220,53,69,0.3);  color: #ea868f; }
.alert-warning  { background: rgba(255,193,7,0.15); border-color: rgba(255,193,7,0.3);  color: #ffc107; }
.alert-info     { background: rgba(13,202,240,0.15);border-color: rgba(13,202,240,0.3); color: #6edff6; }

/* ============================================
   MISC
   ============================================ */
.text-ec-red    { color: var(--ec-red) !important; }
.text-ec-slate  { color: var(--ec-slate) !important; }
.text-ec-muted  { color: var(--ec-text-muted) !important; }
.bg-ec-card     { background: var(--ec-card) !important; }

.divider {
  height: 1px;
  background: var(--ec-border);
  margin: 16px 0;
}

/* Phone call button */
.btn-call {
  background: rgba(25,135,84,0.15);
  border: 1px solid rgba(25,135,84,0.4);
  color: #75b798;
  border-radius: 50px;
  padding: 4px 12px;
  font-size: 0.8rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s;
}

.btn-call:hover {
  background: rgba(25,135,84,0.3);
  color: #a3cfbb;
}

/* Overdue highlight */
.overdue-row { background: rgba(220,53,69,0.05) !important; }
.overdue-row:hover { background: rgba(220,53,69,0.1) !important; }

/* Search box */
.ec-search {
  position: relative;
  max-width: 300px;
}

.ec-search input {
  padding-left: 36px !important;
}

.ec-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ec-text-muted);
  font-size: 0.9rem;
}

/* Modal dark theme */
.modal-content {
  background: var(--ec-card);
  border: 1px solid var(--ec-border);
  border-radius: var(--radius);
  color: var(--ec-text);
}

.modal-header {
  border-bottom: 1px solid var(--ec-border);
  padding: 16px 20px;
}

.modal-footer { border-top: 1px solid var(--ec-border); }

.modal-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.5px;
}

.btn-close { filter: invert(1); opacity: 0.7; }
