/* ==========================================================================
   STYLE: AFFILIATE PORTAL & ADMIN WORKSPACE RUMAH BESAR KEMASAN
   ========================================================================== */

:root {
  --primary: #1e3a8a;          /* RBK Deep Blue */
  --primary-hover: #1e40af;
  --primary-light: #eff6ff;
  --secondary: #0f172a;        /* Slate 900 */
  --accent-gold: #d97706;      /* Amber 600 */
  --accent-gold-light: #fef3c7;
  --success: #10b981;          /* Emerald 500 */
  --success-light: #ecfdf5;
  --warning: #f59e0b;          /* Amber 500 */
  --danger: #ef4444;           /* Rose 500 */
  --danger-light: #fef2f2;
  
  --bg-main: #f8fafc;          /* Slate 50 */
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: 'Poppins', var(--font-sans);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Container */
.app-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px 40px;
}

/* Header Navbar */
.app-navbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-sm);
}

.navbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  height: 40px;
  width: auto;
  object-fit: contain;
}

.brand-info h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--secondary);
  font-family: var(--font-display);
  line-height: 1.2;
}

.brand-info p {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* View Switcher Pill */
.view-switcher {
  display: flex;
  background: #f1f5f9;
  padding: 3px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

.view-btn {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: none;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  background: transparent;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.view-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* Banner Alert Info */
.info-banner {
  background: linear-gradient(135deg, #1e3a8a, #3b82f6);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin: 24px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  box-shadow: var(--shadow-md);
}

.info-banner h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.info-banner p {
  font-size: 0.85rem;
  opacity: 0.9;
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-gold {
  background: var(--accent-gold-light);
  color: var(--accent-gold);
}

.badge-success {
  background: var(--success-light);
  color: var(--success);
}

.badge-primary {
  background: var(--primary-light);
  color: var(--primary);
}

/* Grid Layouts */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  transition: transform 0.2s, box-shadow 0.2s;
}

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

.stat-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--secondary);
  font-family: var(--font-display);
}

.stat-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

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

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

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.card-title-group h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--secondary);
  font-family: var(--font-display);
}

.card-title-group p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* 3-Step Recurring Progress Tracker */
.stepper-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.step-item {
  flex: 1;
  background: #f8fafc;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}

.step-item.completed {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.step-item.active {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
  font-weight: 600;
}

.step-item.locked {
  background: #f1f5f9;
  color: #94a3b8;
}

.step-title {
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.step-reward {
  font-size: 0.7rem;
  font-weight: 500;
}

/* Customer Cards Grid */
.customer-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.customer-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  background: #ffffff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.customer-card:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow-sm);
}

.cust-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.cust-name {
  font-weight: 700;
  color: var(--secondary);
  font-size: 0.95rem;
}

.cust-brand {
  font-size: 0.8rem;
  color: var(--accent-gold);
  font-weight: 600;
}

.cust-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.85rem;
}

.custom-table th {
  background: #f8fafc;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.custom-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

.custom-table tr:hover td {
  background-color: #f8fafc;
}

/* Form & Input Elements */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.875rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #e2e8f0;
  color: var(--secondary);
}

.btn-secondary:hover {
  background: #cbd5e1;
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover {
  background: #059669;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.75rem;
}

/* Modal Dialog */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  padding: 16px;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  background: #fff;
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.2s ease;
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

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

.modal-header h4 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--secondary);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: #f8fafc;
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

/* Calculation Preview Box */
.calc-preview {
  background: #f0fdf4;
  border: 1px dashed #86efac;
  border-radius: var(--radius-md);
  padding: 14px;
  margin-top: 16px;
}

.calc-preview-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #166534;
  margin-bottom: 4px;
}

.calc-preview-details {
  font-size: 0.85rem;
  color: #14532d;
}

/* Tabs for Admin */
.admin-nav-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 24px;
  overflow-x: auto;
}

.admin-tab-btn {
  padding: 10px 18px;
  border: none;
  background: transparent;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all 0.2s;
}

.admin-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Responsive utilities */
@media (max-width: 768px) {
  .navbar-inner {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  .navbar-actions {
    width: 100%;
    justify-content: space-between;
  }
  .stepper-container {
    flex-direction: column;
  }
  .step-item {
    width: 100%;
  }
}
