/* ═══════════════════════════════════════════════════════════════
   AFFILIATE ANGEL PRO — SALES & COMMISSION PORTAL STYLES
   ═══════════════════════════════════════════════════════════════ */
:root {
  --bg-page: #F8FAFC;
  --bg-sidebar: #FFFFFF;
  --bg-card: #FFFFFF;
  --border-color: #E2E8F0;
  --border-focus: #EA580C;
  --accent-orange: #EA580C;
  --accent-orange-light: #FFF7ED;
  --accent-green: #10B981;
  --accent-green-light: #ECFDF5;
  --accent-blue: #2563EB;
  --accent-blue-light: #EFF6FF;
  --accent-purple: #7C3AED;
  --accent-purple-light: #F5F3FF;
  --text-main: #0F172A;
  --text-muted: #64748B;
  --text-dim: #94A3B8;
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Sarabun', sans-serif;
  --font-code: 'Fira Code', monospace;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-page);
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 13.5px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════════════════════════════
   LOGIN SCREEN
   ═══════════════════════════════════════════════════════════════ */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #FFF7ED 0%, #F8FAFC 60%, #EFF6FF 100%);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.08);
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.brand-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--accent-orange);
  background: var(--accent-orange-light);
  border: 1px solid rgba(234, 88, 12, 0.2);
  padding: 3px 10px;
  border-radius: 9999px;
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}

.login-title {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.login-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
}

.input-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 12px;
  font-size: 0.95rem;
}

.input-icon-wrap input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-family: var(--font-body);
  background: #FFFFFF;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-icon-wrap input:focus {
  border-color: var(--accent-orange);
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.15);
}

.btn-login-submit {
  background: linear-gradient(135deg, #EA580C 0%, #C2410C 100%);
  color: #FFFFFF;
  border: none;
  padding: 11px;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.25);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-login-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(234, 88, 12, 0.35);
}

.login-error {
  background: #FEF2F2;
  border: 1px solid #FCA5A5;
  color: #DC2626;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

.login-hint-box {
  margin-top: 10px;
  background: #F8FAFC;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.login-hint-box ul {
  list-style: none;
  margin-top: 6px;
}

.login-hint-box li {
  margin-bottom: 3px;
}

/* ═════════════════════════════════════════════════════════════
   MAIN PORTAL LAYOUT (Sidebar + Main Area)
   ═════════════════════════════════════════════════════════════ */
.portal-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Left Sidebar */
.portal-sidebar {
  width: 250px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 20px 16px;
  z-index: 10;
}

.sidebar-brand {
  margin-bottom: 24px;
}

.brand-logo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.brand-icon {
  font-size: 1.8rem;
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent-orange);
}

.brand-tagline {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: block;
}

.user-profile-box {
  background: #F8FAFC;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.user-avatar-badge {
  font-size: 1.3rem;
}

.user-meta-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.user-email-display {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-owner {
  color: var(--accent-orange);
}

.btn-sidebar-logout {
  width: 100%;
  background: #475569;
  color: #FFFFFF;
  border: none;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-sidebar-logout:hover {
  background: #334155;
}

.sidebar-nav-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.side-nav-item, .side-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  text-align: left;
}

.side-nav-item:hover, .side-nav-link:hover {
  background: #F1F5F9;
  color: var(--text-main);
}

.side-nav-item.active {
  background: #EA580C;
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.25);
}

/* Main Content Area */
.portal-main-area {
  flex: 1;
  padding: 24px 28px;
  overflow-y: auto;
}

/* Sales Hub Header & Sub-Tabs */
.sales-hub-header {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.sales-page-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.sales-sub-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sub-tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: #F8FAFC;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.84rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.sub-tab-btn:hover {
  background: #F1F5F9;
  color: var(--text-main);
}

.sub-tab-btn.active {
  background: #EA580C;
  border-color: #EA580C;
  color: #FFFFFF;
  box-shadow: 0 4px 10px rgba(234, 88, 12, 0.25);
}

.badge-pending-count {
  background: #EF4444;
  color: #FFF;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 9999px;
  margin-left: 4px;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
}

.kpi-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.icon-orange { background: var(--accent-orange-light); }
.icon-green { background: var(--accent-green-light); }
.icon-blue { background: var(--accent-blue-light); }
.icon-purple { background: var(--accent-purple-light); }

.kpi-lbl {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 500;
  display: block;
  margin-bottom: 2px;
}

.kpi-val {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
}

.text-green { color: var(--accent-green); }
.text-blue { color: var(--accent-blue); }
.text-purple { color: var(--accent-purple); }

/* Card Boxes */
.card-box {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.card-box-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.card-box-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.card-box-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Ledger Toolbar */
.ledger-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.ledger-heading {
  font-family: var(--font-heading);
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-main);
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-ico {
  position: absolute;
  left: 10px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.search-input-wrap input {
  padding: 7px 12px 7px 32px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  outline: none;
  width: 200px;
}

.search-input-wrap input:focus {
  border-color: var(--accent-orange);
}

.filter-dropdown {
  padding: 7px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  background: #FFFFFF;
  color: var(--text-main);
  outline: none;
  font-family: var(--font-heading);
}

.btn-export-sales {
  background: #F8FAFC;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 7px 14px;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
}

.btn-export-sales:hover {
  background: #F1F5F9;
}

/* Sales Ledger Table */
.table-responsive-container {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.sales-ledger-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  background: #FFFFFF;
}

.sales-ledger-table th {
  background: #F8FAFC;
  padding: 10px 14px;
  font-weight: 700;
  text-align: left;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  font-family: var(--font-heading);
}

.sales-ledger-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #F1F5F9;
  color: var(--text-main);
}

.sales-ledger-table tbody tr:hover {
  background: #FAFAFA;
}

.btn-slip-view {
  color: #2563EB;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  background: transparent;
  border: none;
  font-size: 0.8rem;
}

.btn-slip-view:hover {
  color: #1D4ED8;
}

.btn-tbl-action {
  background: #F1F5F9;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 0.78rem;
  cursor: pointer;
  margin-right: 4px;
}

.btn-tbl-action:hover {
  background: #E2E8F0;
}

/* Forms */
.sale-entry-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.span-2 { grid-column: span 2; }
.full-width { grid-column: 1 / -1; }

.sale-entry-form input, .sale-entry-form select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-family: var(--font-body);
  background: #FFFFFF;
  outline: none;
}

.sale-entry-form input:focus, .sale-entry-form select:focus {
  border-color: var(--accent-orange);
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.15);
}

.btn-primary-action {
  background: linear-gradient(135deg, #EA580C 0%, #C2410C 100%);
  color: #FFFFFF;
  border: none;
  padding: 9px 20px;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.86rem;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(234, 88, 12, 0.2);
  transition: transform 0.15s;
}

.btn-primary-action:hover {
  transform: translateY(-1px);
}

.btn-action-outline {
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
}

.form-submit-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 500px;
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
}

.btn-close-modal {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 14px 20px;
  background: #F8FAFC;
  border-top: 1px solid var(--border-color);
  display: flex;
}

.key-display-box {
  margin: 14px 0;
  padding: 14px;
  background: #FFF7ED;
  border: 1px dashed #EA580C;
  border-radius: var(--radius-md);
}

.key-display-box code {
  font-family: var(--font-code);
  font-size: 1.15rem;
  font-weight: 700;
  color: #EA580C;
}

/* Team Grid */
.team-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.team-card-item {
  background: #F8FAFC;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 10000;
}

.toast {
  background: #0F172A;
  color: #FFFFFF;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  animation: slideInToast 0.25s ease-out;
}

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

@media (max-width: 900px) {
  .portal-wrapper { flex-direction: column; }
  .portal-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border-color); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid-3, .team-cards-grid { grid-template-columns: 1fr; }
}
