/* =====================================================
   assets/css/style.css - CRM Quản lý khách hàng
   Mobile-first design, Bootstrap 5 enhancement
   ===================================================== */

/* ---- Google Font & Variables ---- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --primary:        #3b5bdb;
  --primary-dark:   #2f4ac7;
  --primary-light:  #eef2ff;
  --accent:         #f03e3e;
  --success:        #2f9e44;
  --warning:        #e67700;
  --bg-main:        #f1f3f9;
  --bg-card:        #ffffff;
  --text-main:      #1a1a2e;
  --text-muted:     #6c757d;
  --border:         #dee2e6;
  --radius:         12px;
  --radius-sm:      8px;
  --shadow:         0 2px 16px rgba(59,91,219,0.08);
  --shadow-lg:      0 8px 40px rgba(59,91,219,0.15);
  --transition:     0.2s ease;
  --font:           'Inter', sans-serif;
}

* { box-sizing: border-box; }

body {
  font-family: var(--font);
  background-color: var(--bg-main);
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.6;
}

/* =============================================
   LOGIN PAGE
   ============================================= */
.login-body {
  min-height: 100vh;
  background: linear-gradient(135deg, #3b5bdb 0%, #845ef7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-wrapper {
  width: 100%;
  max-width: 400px;
}

.login-card {
  background: var(--bg-card);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: slideUp 0.4s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-header {
  background: linear-gradient(135deg, #3b5bdb, #845ef7);
  padding: 36px 32px 28px;
  text-align: center;
}

.login-icon {
  width: 70px; height: 70px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  font-size: 32px; color: white;
  backdrop-filter: blur(10px);
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: white;
  margin: 0 0 4px;
}

.login-subtitle {
  color: rgba(255,255,255,0.8);
  margin: 0; font-size: 13px;
}

.login-body-inner {
  padding: 28px 32px 32px;
}

.login-btn {
  background: linear-gradient(135deg, #3b5bdb, #845ef7);
  border: none;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(59,91,219,0.35);
}

/* =============================================
   LAYOUT / NAVBAR
   ============================================= */
.topnav {
  background: linear-gradient(90deg, #3b5bdb, #845ef7);
  padding: 10px 16px;
  position: sticky; top: 0; z-index: 1000;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.topnav .brand {
  font-weight: 700;
  font-size: 16px;
  color: white;
  text-decoration: none;
  display: flex; align-items: center; gap: 8px;
}

.topnav .nav-actions {
  display: flex; align-items: center; gap: 8px;
}

.topnav .btn-nav {
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 13px;
  transition: all var(--transition);
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 5px;
}

.topnav .btn-nav:hover {
  background: rgba(255,255,255,0.25);
  color: white;
}

.topnav .btn-nav.active {
  background: rgba(255,255,255,0.3);
  font-weight: 600;
}

/* ---- Mobile: Icon lớn hơn, dễ bấm hơn ---- */
@media (max-width: 576px) {
  .topnav {
    padding: 8px 12px;
  }
  .topnav .nav-actions {
    gap: 4px;
  }
  .topnav .btn-nav {
    padding: 8px 10px;
    font-size: 20px;
    border-radius: 10px;
    min-width: 42px;
    min-height: 42px;
    justify-content: center;
  }
  .topnav .btn-nav i {
    font-size: 20px;
  }
}

/* =============================================
   PAGE CONTENT
   ============================================= */
.page-content {
  padding: 16px;
  max-width: 1200px;
  margin: 0 auto;
}

.page-header {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  color: var(--primary);
  display: flex; align-items: center; gap: 8px;
}

/* =============================================
   SEARCH BAR
   ============================================= */
.search-bar-wrapper {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

#searchInput {
  border-radius: 30px;
  padding-left: 40px;
  border: 2px solid var(--border);
  transition: border-color var(--transition);
  font-size: 14px;
}

#searchInput:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,91,219,0.1);
}

.search-icon {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 16px;
}

/* =============================================
   CUSTOMER CARD / TABLE
   ============================================= */
.customer-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Mobile: dạng card list */
.customer-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
  cursor: pointer;
}

.customer-item:last-child { border-bottom: none; }

.customer-item:hover {
  background: var(--primary-light);
}

.customer-avatar {
  width: 50px; height: 50px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary-light);
  flex-shrink: 0;
  cursor: pointer;
  transition: transform var(--transition);
}

.customer-avatar:hover { transform: scale(1.05); }

.customer-info { flex: 1; min-width: 0; }

.customer-name {
  font-weight: 600;
  font-size: 15px;
  margin: 0 0 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.customer-phone {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 4px;
}

.customer-money {
  display: flex; flex-wrap: wrap; gap: 6px;
  font-size: 12px;
}

.badge-money {
  padding: 2px 8px; border-radius: 30px;
  font-weight: 500;
}

.badge-total   { background: #e7f5ff; color: #1971c2; }
.badge-deposit { background: #ebfbee; color: #2f9e44; }
.badge-debt    { background: #fff5f5; color: #c92a2a; }

.customer-actions {
  display: flex; flex-direction: column; gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

/* Tablet+: dạng bảng */
@media (min-width: 768px) {
  .customer-table-wrapper { overflow-x: auto; }
  .customer-table {
    width: 100%; border-collapse: collapse; min-width: 700px;
  }
  .customer-table thead th {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
    font-size: 13px;
    padding: 12px 14px;
    white-space: nowrap;
    position: sticky; top: 0;
    border-bottom: 2px solid var(--primary);
  }
  .customer-table tbody tr:nth-child(even) { background: #fafbff; }
  .customer-table tbody tr:hover { background: var(--primary-light); }
  .customer-table tbody td {
    padding: 10px 14px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
  }
  .mobile-cards { display: none !important; }
  .desktop-table { display: block !important; }
}

@media (max-width: 767px) {
  .mobile-cards { display: block !important; }
  .desktop-table { display: none !important; }
}

/* =============================================
   MODALS
   ============================================= */
.modal-header-custom {
  background: linear-gradient(135deg, #3b5bdb, #845ef7);
  color: white;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 16px 20px;
}

.modal-header-custom .btn-close {
  filter: brightness(0) invert(1);
}

/* Preview ảnh trước khi upload */
#imagePreview {
  width: 100px; height: 100px;
  object-fit: cover;
  border-radius: 50%;
  border: 3px solid var(--primary-light);
  display: block; margin: 0 auto 8px;
}

/* Nút copy bên trong ô input */
.input-copy-wrapper {
  position: relative;
  width: 100%;
}

.input-copy-wrapper .form-control {
  padding-right: 40px;
}

.btn-copy-input {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: #8c98a4;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 5;
}

.btn-copy-input:hover {
  color: var(--primary);
  background: rgba(59, 91, 219, 0.08);
}

.btn-copy-input:active {
  transform: translateY(-50%) scale(0.92);
}

.btn-copy-input.copied {
  color: var(--success) !important;
  background: rgba(47, 158, 68, 0.12) !important;
}

/* Với ô textarea (Địa chỉ) */
.input-copy-wrapper.has-textarea .btn-copy-input {
  top: 8px;
  transform: none;
}

.input-copy-wrapper.has-textarea .btn-copy-input:active {
  transform: scale(0.92);
}

@media (max-width: 576px) {
  .input-copy-wrapper .form-control {
    padding-right: 44px;
  }
  .btn-copy-input {
    width: 34px;
    height: 34px;
    font-size: 16px;
  }
  .input-copy-wrapper.has-textarea .btn-copy-input {
    top: 6px;
    right: 6px;
  }
}

/* =============================================
   LIGHTBOX (ảnh phóng to)
   ============================================= */
.lightbox-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.88);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  animation: fadeIn 0.2s ease;
}

.lightbox-overlay.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}

.lightbox-img {
  max-width: 92vw;
  max-height: 88vh;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: zoomIn 0.25s ease;
}

@keyframes zoomIn {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.lightbox-close {
  position: absolute; top: 16px; right: 20px;
  font-size: 30px; color: white;
  cursor: pointer; line-height: 1;
  transition: transform var(--transition);
}

.lightbox-close:hover { transform: scale(1.2); }

/* =============================================
   STATS / REPORT CARDS
   ============================================= */
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.stat-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; margin: 0 auto 12px;
}

.stat-value {
  font-size: 24px; font-weight: 700;
  color: var(--primary);
}

.stat-label { font-size: 13px; color: var(--text-muted); }

/* Period tabs */
.period-tabs .nav-link {
  font-size: 13px; padding: 6px 14px;
  border-radius: 30px;
}

.period-tabs .nav-link.active {
  background: var(--primary);
  color: white !important;
  font-weight: 600;
}

/* Report table */
.report-table th {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600; font-size: 13px;
}

/* =============================================
   BUTTONS
   ============================================= */
.btn-add-customer {
  background: linear-gradient(135deg, #3b5bdb, #845ef7);
  color: white;
  border: none;
  border-radius: 30px;
  padding: 8px 18px;
  font-weight: 600;
  font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all var(--transition);
  box-shadow: 0 3px 12px rgba(59,91,219,0.25);
}

.btn-add-customer:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(59,91,219,0.35);
  color: white;
}

.btn-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none;
  font-size: 15px;
  transition: all var(--transition);
}

/* Mobile: btn-icon lớn hơn để dễ bấm */
@media (max-width: 576px) {
  .btn-icon {
    width: 40px;
    height: 40px;
    font-size: 18px;
    border-radius: 10px;
  }
}

.btn-edit  { background: #e7f5ff; color: #1971c2; }
.btn-delete{ background: #fff5f5; color: #c92a2a; }
.btn-edit:hover   { background: #1971c2; color: white; transform: scale(1.1); }
.btn-delete:hover { background: #c92a2a; color: white; transform: scale(1.1); }

/* =============================================
   PAGINATION
   ============================================= */
.pagination .page-link {
  border-radius: 8px !important;
  margin: 0 2px;
  color: var(--primary);
  border-color: var(--border);
  font-size: 13px;
}

.pagination .page-item.active .page-link {
  background: var(--primary);
  border-color: var(--primary);
}

/* =============================================
   TOAST NOTIFICATION
   ============================================= */
#toastContainer {
  position: fixed; bottom: 20px; right: 20px; z-index: 9998;
}

.toast-custom {
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  min-width: 280px;
}

/* =============================================
   CHANGE PASSWORD PAGE
   ============================================= */
.settings-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  max-width: 480px;
  margin: 0 auto;
}

.settings-header {
  background: linear-gradient(135deg, #3b5bdb, #845ef7);
  padding: 20px 24px;
  color: white;
}

.settings-body { padding: 24px; }

/* =============================================
   SPINNER / LOADING
   ============================================= */
.loading-row td {
  text-align: center; padding: 40px !important;
  color: var(--text-muted);
}

/* =============================================
   EMPTY STATE
   ============================================= */
.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state i { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { margin: 0; font-size: 14px; }

/* =============================================
   RESPONSIVE UTILS
   ============================================= */
@media (max-width: 576px) {
  .page-content { padding: 12px; }
  .topnav .brand span.brand-text { display: none; }
  .login-body-inner { padding: 20px 20px 24px; }
}
