/* ============================================================
   WebX POS - Main Stylesheet
   Brand: Purple #7C3AED | Green #10B981
   ============================================================ */

:root {
  --purple: #7C3AED;
  --purple-dark: #5B21B6;
  --purple-light: #EDE9FE;
  --green: #10B981;
  --green-dark: #059669;
  --sidebar-width: 250px;
  --sidebar-bg: #1E1B2E;
  --navbar-height: 60px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #F8F7FF;
  color: #1F2937;
  margin: 0;
  overflow-x: hidden;
}

/* ---- Sidebar ---- */
.wrapper { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  min-height: 100vh;
  position: fixed;
  left: 0; top: 0;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform 0.3s ease, width 0.3s ease;
  overflow-y: auto;
}

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease;
  min-width: 0;
}

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

/* Sidebar Header */
.sidebar-header {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-logo { display: flex; align-items: center; gap: 10px; }
.brand-icon {
  width: 36px; height: 36px;
  background: var(--purple);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 18px; color: white;
}
.brand-name { font-weight: 800; font-size: 16px; color: white; display: block; line-height: 1; }
.brand-sub { font-size: 10px; color: rgba(255,255,255,0.5); display: block; }
.sidebar-toggle { color: rgba(255,255,255,0.6); border: none; background: none; }
.sidebar-toggle:hover { color: white; }

/* Sidebar User */
.sidebar-user {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--purple), var(--purple-dark));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: white; font-size: 14px;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; color: white; }
.user-role { font-size: 10px; background: rgba(124,58,237,0.3); color: var(--purple-light); border: none; padding: 1px 6px; }

/* Sidebar Menu */
.sidebar-menu {
  list-style: none;
  padding: 12px 0;
  margin: 0;
  flex: 1;
}
.menu-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,0.35);
  padding: 12px 20px 6px;
  font-weight: 600;
}
.sidebar-menu li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: 0;
  transition: all 0.2s;
  margin: 1px 8px;
  border-radius: 8px;
}
.sidebar-menu li a i { font-size: 16px; width: 20px; }
.sidebar-menu li a:hover { color: white; background: rgba(255,255,255,0.08); }
.sidebar-menu li.active a { color: white; background: var(--purple); }

/* Sidebar Footer */
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.logout-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 8px;
  transition: all 0.2s;
}
.logout-btn:hover { color: white; background: rgba(255,100,100,0.15); }

/* ---- Top Navbar ---- */
.top-navbar {
  height: var(--navbar-height);
  background: white;
  border-bottom: 1px solid #E5E7EB;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 8px rgba(0,0,0,0.06);
}
.navbar-left { display: flex; align-items: center; gap: 12px; }
.page-title { font-weight: 700; font-size: 15px; color: #374151; }
.navbar-right { display: flex; align-items: center; gap: 8px; }
.nav-avatar {
  width: 32px; height: 32px;
  background: var(--purple);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; color: white; font-size: 13px;
}
.user-menu-btn { border: 1px solid #E5E7EB; border-radius: 20px; padding: 4px 12px; }
.sidebar-toggle-mobile { display: none; }

/* ---- Page Header ---- */
.page-header { margin-bottom: 20px; }
.page-title-h1 { font-size: 22px; font-weight: 800; color: #111827; margin-bottom: 2px; }

/* ---- KPI Cards ---- */
.kpi-card {
  background: white;
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border: 1px solid #F3F4F6;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  border-left: 4px solid transparent;
  transition: transform 0.2s;
}
.kpi-card:hover { transform: translateY(-2px); }
.kpi-purple { border-left-color: var(--purple); }
.kpi-green { border-left-color: var(--green); }
.kpi-blue { border-left-color: #3B82F6; }
.kpi-teal { border-left-color: #14B8A6; }
.kpi-red { border-left-color: #EF4444; }
.kpi-orange { border-left-color: #F59E0B; }
.kpi-icon { font-size: 22px; color: #9CA3AF; }
.kpi-purple .kpi-icon { color: var(--purple); }
.kpi-green .kpi-icon { color: var(--green); }
.kpi-blue .kpi-icon { color: #3B82F6; }
.kpi-teal .kpi-icon { color: #14B8A6; }
.kpi-red .kpi-icon { color: #EF4444; }
.kpi-orange .kpi-icon { color: #F59E0B; }
.kpi-value { font-size: 20px; font-weight: 800; color: #111827; line-height: 1; }
.kpi-label { font-size: 11px; color: #6B7280; font-weight: 500; }

/* ---- Badges ---- */
.badge-status-active, .badge-status-paid { background: #D1FAE5; color: #065F46; }
.badge-status-draft { background: #F3F4F6; color: #4B5563; }
.badge-status-sent { background: #DBEAFE; color: #1E40AF; }
.badge-status-overdue { background: #FEE2E2; color: #991B1B; }
.badge-status-cancelled { background: #F3F4F6; color: #6B7280; }
.badge-status-partial { background: #FEF3C7; color: #92400E; }
.badge-status-lead { background: #FEF3C7; color: #92400E; }
.badge-status-inactive { background: #F3F4F6; color: #6B7280; }
.badge-status-paused { background: #FEF3C7; color: #92400E; }
.badge-status-completed { background: #D1FAE5; color: #065F46; }
.badge-status-pending { background: #FEF3C7; color: #92400E; }
.badge-status-approved { background: #DBEAFE; color: #1E40AF; }
.badge-status-comm-pending { background: #FEF3C7; color: #92400E; }
.badge-status-comm-approved { background: #DBEAFE; color: #1E40AF; }
.badge-status-comm-paid { background: #D1FAE5; color: #065F46; }

/* Project type badges */
.project-type-meta_ads { background: #EFF6FF; color: #1D4ED8; }
.project-type-seo { background: #F0FDF4; color: #15803D; }
.project-type-website { background: #FDF4FF; color: #7E22CE; }
.project-type-social_media { background: #FFF7ED; color: #C2410C; }
.project-type-other { background: #F9FAFB; color: #374151; }

/* Role badges */
.role-badge-admin { background: #FEE2E2; color: #991B1B; }
.role-badge-manager { background: #EDE9FE; color: #5B21B6; }
.role-badge-staff { background: #F3F4F6; color: #374151; }

/* ---- Cards ---- */
.card { border: 1px solid #F3F4F6; border-radius: 12px; }
.card-header { background: white; border-bottom: 1px solid #F3F4F6; padding: 14px 18px; }
.card-footer { background: #FAFAFA; border-top: 1px solid #F3F4F6; padding: 12px 18px; }

/* ---- Table Styles ---- */
.table th { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: #6B7280; }
.table td { vertical-align: middle; font-size: 14px; }
.table-danger-subtle { background: rgba(254,242,242,0.7); }

/* ---- Forms ---- */
.form-label { font-weight: 600; font-size: 13px; color: #374151; }
.form-label.required::after { content: ' *'; color: #EF4444; }
.form-control:focus, .form-select:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(124,58,237,0.12); }

/* ---- Buttons ---- */
.btn-primary { background: var(--purple); border-color: var(--purple); }
.btn-primary:hover { background: var(--purple-dark); border-color: var(--purple-dark); }
.btn-outline-purple { color: var(--purple); border-color: var(--purple); }
.btn-outline-purple:hover { background: var(--purple); color: white; }
.btn-outline-green { color: var(--green); border-color: var(--green); }
.btn-outline-green:hover { background: var(--green); color: white; }
.text-purple { color: var(--purple) !important; }
.text-green { color: var(--green) !important; }

/* Small buttons */
.btn-xs { padding: 2px 7px; font-size: 12px; }
.btn-icon { padding: 3px 7px; }

/* ---- Invoice Preview ---- */
.invoice-preview { border-radius: 12px; overflow: hidden; }
.invoice-header {
  background: linear-gradient(135deg, var(--purple), var(--purple-dark));
  color: white;
  padding: 28px 32px;
}
.agency-name { font-size: 24px; font-weight: 800; margin-bottom: 6px; }
.agency-details { font-size: 12px; opacity: 0.85; line-height: 1.6; }
.invoice-label { font-size: 30px; font-weight: 900; letter-spacing: 2px; }
.invoice-num { font-size: 14px; opacity: 0.9; margin-top: 4px; }
.inv-section-label { font-size: 11px; font-weight: 700; letter-spacing: 1px; color: var(--purple); text-transform: uppercase; margin-bottom: 6px; }
.inv-items-table thead tr { background: var(--purple); color: white; }
.inv-items-table thead th { padding: 10px 14px; }
.totals-table td { padding: 5px 8px; }
.totals-table .total-row td { padding-top: 8px; border-top: 2px solid var(--purple-light); }

/* ---- Client/Member Cards ---- */
.client-avatar {
  width: 50px; height: 50px;
  background: linear-gradient(135deg, var(--purple), var(--purple-dark));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 22px; color: white;
}
.member-avatar {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--purple), #4C1D95);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px; color: white;
  flex-shrink: 0;
}
.payment-icon {
  width: 44px; height: 44px;
  background: #D1FAE5;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #059669;
}

/* Info list */
.info-list { display: flex; flex-direction: column; gap: 8px; }
.info-item { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: #4B5563; }
.info-item i { color: var(--purple); width: 16px; flex-shrink: 0; margin-top: 2px; }

/* Detail labels */
.detail-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; color: #9CA3AF; margin-bottom: 3px; }
.detail-value { font-size: 14px; font-weight: 500; color: #1F2937; }

/* Rank badge */
.rank-badge {
  width: 22px; height: 22px;
  background: var(--purple-light);
  color: var(--purple);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}

/* Member card */
.member-card { transition: box-shadow 0.2s; }
.member-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.1) !important; }

/* Totals box in invoice create */
.totals-box { background: #FAFAFE; border-radius: 8px; padding: 16px; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .sidebar-toggle-mobile { display: block; }
  .content-area { padding: 16px; }
  .page-title-h1 { font-size: 18px; }
  .kpi-value { font-size: 16px; }
}

/* ---- DataTables customization ---- */
.dataTables_wrapper .dataTables_filter input { border: 1px solid #E5E7EB; border-radius: 6px; padding: 4px 10px; }
.dataTables_wrapper .dataTables_length select { border: 1px solid #E5E7EB; border-radius: 6px; }
table.dataTable thead .sorting::before, table.dataTable thead .sorting::after,
table.dataTable thead .sorting_asc::before, table.dataTable thead .sorting_desc::after { opacity: 0.5; }

/* ---- Scrollbar ---- */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

/* ---- Flatpickr ---- */
.flatpickr-day.selected { background: var(--purple); border-color: var(--purple); }
.flatpickr-day.selected:hover { background: var(--purple-dark); }
