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

:root {
  --primary: #1e88e5;  /* Blue - Mabang brand color */
  --primary-dark: #1565c0;
  --primary-light: #e3f2fd;
  --secondary: #f5f5f5;
  --text: #212121;
  --text-light: #757575;
  --border: #e0e0e0;
  --bg: #f5f5f5;
  --white: #ffffff;
  --success: #4caf50;
  --error: #f44336;
  --warning: #ff9800;
  --blue: #2196f3;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Hidden */
.hidden { display: none !important; }

.page { display: none; }
.page.active { display: block; }

/* Form Sections */
.form-section {
  background: white;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.form-section h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  color: #333;
}

/* Radio Group - Label | Option | Option layout */
.radio-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.radio-row .radio-label {
  font-size: 14px;
  color: #666;
  width: 76px;
  flex-shrink: 0;
}

.radio-group {
  display: flex;
  gap: 8px;
  flex: 1;
}

.radio-item {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  background: #f5f5f5;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
  font-weight: 500;
  border: 2px solid transparent;
  flex: 1;
  text-align: center;
  min-width: 0;
  word-break: keep-all;
  overflow: hidden;
}

.radio-item:has(input:checked) {
  background: #e3f2fd;
  border-color: #1e88e5;
  color: #1e88e5;
}

.radio-item input {
  display: none;
}

/* Address Selection Cards */
.address-card {
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.address-card:hover {
  border-color: #bbb;
}

.address-card.selected {
  border-color: #1e88e5;
  background: #f0f7ff;
}

.address-card .radio-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.address-card.selected .radio-circle {
  border-color: #1e88e5;
}

.address-card.selected .radio-circle::after {
  content: '';
  width: 12px;
  height: 12px;
  background: #1e88e5;
  border-radius: 50%;
}

.address-card .address-content {
  flex: 1;
}

.address-card .default-tag {
  display: inline-block;
  background: #e3f2fd;
  color: #1e88e5;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  margin-bottom: 6px;
}

.address-card .address-name {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 4px;
}

.address-card .address-detail {
  font-size: 13px;
  color: #666;
  line-height: 1.5;
}

.address-card .address-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.address-card .btn-edit,
.address-card .btn-delete {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  border: none;
}

.address-card .btn-edit {
  background: #f5f5f5;
  color: #333;
}

.address-card .btn-delete {
  background: #ffebee;
  color: #e53935;
}

/* Address Options */
.address-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-left: 86px; /* align with radio-group options */
}

.address-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  background: #f9f9f9;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
}

.address-option:has(input:checked) {
  border-color: #1e88e5;
  background: #e3f2fd;
}

.address-option input {
  margin-top: 3px;
  accent-color: #1e88e5;
}

.address-option .address-info {
  flex: 1;
}

.address-option .address-info .name {
  font-weight: 600;
  margin-bottom: 4px;
}

.address-option .address-info .detail {
  font-size: 13px;
  color: #666;
}

/* Fee Note */
.fee-note {
  background: #fff8e1;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
}

.fee-note p {
  margin: 4px 0;
}

/* Fee Summary */
.fee-summary {
  background: #f5f5f5;
  padding: 12px;
  border-radius: 8px;
}

.fee-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #e0e0e0;
}

.fee-row:last-child {
  border-bottom: none;
}

.fee-row.total {
  font-weight: 600;
  font-size: 16px;
  color: #1e88e5;
  padding-top: 12px;
}

.fee-row.balance {
  color: #4caf50;
}

.fee-row.balance.insufficient {
  color: #f44336;
}

/* Buttons */
.btn-secondary {
  padding: 8px 16px;
  background: #f5f5f5;
  color: #333;
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

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

.btn-outline {
  padding: 8px 16px;
  background: transparent;
  color: #1e88e5;
  border: 1px solid #1e88e5;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}

.btn-outline:hover {
  background: #e3f2fd;
}

.btn-primary {
  padding: 12px;
  background: #1e88e5;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
}

/* Address Dropdown */
.address-dropdown {
  margin-top: 4px;
}

.address-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
  font-size: 13px;
}

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

.address-item:hover {
  background: #f5f5f5;
}

.address-item .address-main {
  font-weight: 600;
  color: #333;
}

.address-item .address-detail {
  font-size: 12px;
  color: #666;
  margin-top: 2px;
}

/* Login Screen */
#login-screen {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-box {
  background: var(--white);
  padding: 40px;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 400px;
  margin: 20px;
}

.login-box .brand {
  text-align: center;
  margin-bottom: 30px;
}

.login-box .brand h1 {
  color: var(--primary);
  font-size: 28px;
  margin-bottom: 5px;
}

.login-box .brand p {
  color: var(--text-light);
  font-size: 14px;
}

/* Quick Quote Box */
.quick-quote-box {
  background: var(--white);
  padding: 30px;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  width: 100%;
  max-width: 360px;
  margin: 20px;
}

.quick-quote-box .brand {
  text-align: center;
  margin-bottom: 20px;
}

.quick-quote-box .brand h1 {
  color: var(--primary);
  font-size: 22px;
  margin-bottom: 5px;
}

.qq-section {
  margin-bottom: 14px;
}

.qq-label {
  display: block;
  font-size: 12px;
  color: #888;
  margin-bottom: 6px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.qq-radio-group {
  display: flex;
  gap: 8px;
}

.qq-radio-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.qq-radio-item:has(input:checked) {
  border-color: var(--primary);
  background: rgba(30, 136, 229, 0.08);
  color: var(--primary);
  font-weight: 600;
}

.qq-radio-item input {
  display: none;
}

.qq-section input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.qq-section input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
}

.qq-result {
  background: #f5f5f5;
  border-radius: 10px;
  padding: 14px;
  margin: 16px 0;
}

.qq-result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 15px;
}

.qq-result-row span:first-child {
  color: #666;
}

.qq-result-row span:last-child {
  font-weight: 700;
  font-size: 20px;
  color: var(--primary);
}

.qq-result-row.sub {
  margin-top: 4px;
  font-size: 12px;
  color: #999;
}

.qq-result-row.sub span {
  font-weight: normal !important;
  font-size: 12px !important;
  color: #999 !important;
}

.qq-cta {
  display: block;
  text-align: center;
  padding: 12px;
  background: var(--primary);
  color: white;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s;
  margin-top: 4px;
}

.qq-cta:hover {
  background: #1565c0;
}

form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

input {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
}

input:focus {
  outline: none;
  border-color: var(--primary);
}

button {
  padding: 14px;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s;
}

button:hover { background: var(--primary-dark); }
button.secondary { background: var(--secondary); color: var(--text); }
button.secondary:hover { background: #e0e0e0; }

/* Tab buttons for coupons page */
.tab-btn { padding: 8px 16px; border: 1px solid #ddd; background: white; color: #333 !important; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 400; }
.tab-btn.active { background: #27ae60; color: white; border-color: #27ae60; }

.switch-mode {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-light);
}

.switch-mode a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.error {
  color: var(--error);
  font-size: 14px;
  text-align: center;
  margin-top: 10px;
}

/* Main Layout */
#main-screen {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--white);
  border-right: 1px solid var(--border);
  position: fixed;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

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

.sidebar-logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
}

.sidebar-user {
  padding: 20px;
  background: var(--secondary);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 15px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}

.user-info h4 {
  font-size: 14px;
  margin-bottom: 2px;
}

.user-info p {
  font-size: 12px;
  color: var(--text-light);
}

.user-balance {
  background: var(--white);
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 10px;
}

.balance-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
}

.balance-row:last-child { margin-bottom: 0; }
.balance-row span:last-child { font-weight: 600; }

.balance-row .credit { color: var(--success); }

.btn-topup {
  width: 100%;
  padding: 10px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

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

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: var(--text);
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
  font-size: 14px;
}

.nav-item:hover {
  background: var(--secondary);
  color: var(--primary);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
  border-left: 3px solid var(--primary);
}

.nav-item i {
  width: 24px;
  margin-right: 12px;
  font-size: 16px;
  text-align: center;
}

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 20px;
}

.sidebar-footer {
  padding: 15px 20px;
  border-top: 1px solid var(--border);
}

.btn-logout {
  width: 100%;
  padding: 10px;
  background: transparent;
  color: var(--text-light);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

.btn-logout:hover {
  background: var(--secondary);
  color: var(--text);
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 260px;
}

/* Top Header */
.top-header {
  background: var(--white);
  padding: 15px 30px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

.search-bar {
  display: flex;
  align-items: center;
  background: var(--secondary);
  border-radius: 8px;
  padding: 10px 15px;
  width: 350px;
}

.search-bar i {
  color: var(--text-light);
  margin-right: 10px;
}

.search-bar input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  padding: 0;
}

.search-bar input:focus {
  outline: none;
}

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

.header-actions i {
  font-size: 20px;
  color: var(--text-light);
  cursor: pointer;
}

.header-actions i:hover { color: var(--primary); }

/* Page Content */
.page-content {
  padding: 25px 30px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
}

.page-title {
  font-size: 22px;
  font-weight: 600;
}

.page-actions {
  display: flex;
  gap: 10px;
}

.btn-new {
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 25px;
}

.stat-card {
  background: var(--white);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.stat-card .label {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}

.stat-card .value.primary { color: #212121; }
.stat-card .value.success { color: var(--success); }
.stat-card .value.warning { color: var(--warning); }

/* Data Table */
.table-card {
  background: var(--white);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  overflow: hidden;
}

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

.table-title {
  font-size: 16px;
  font-weight: 600;
}

.table-filters {
  display: flex;
  gap: 10px;
}

.table-filters select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: white;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background: var(--secondary);
}

th {
  padding: 12px 15px;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-light);
}

td {
  padding: 15px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

tr:last-child td { border-bottom: none; }
tr:hover { background: #fafafa; }

.parcel-id {
  font-weight: 600;
  color: var(--primary);
}

.status-badge {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.status-predicted { background: #fff3cd; color: #856404; }
.status-in_transit { background: #cce5ff; color: #004085; }
.status-arrived { background: #d4edda; color: #155724; }
.status-pending { background: #fff3cd; color: #856404; }
.status-paid { background: #d4edda; color: #155724; }
.status-shipped { background: #cce5ff; color: #004085; }
.status-delivered { background: #e2e3e5; color: #383d41; }
.status-in_storage { background: #e2e3e5; color: #383d41; }
.status-草稿 { background: #e2e3e5; color: #6c757d; }
.status-待称重 { background: #fff3cd; color: #856404; }
.status-待付款 { background: #ffeaa7; color: #d63031; font-weight: 700; }
.status-已发货 { background: #d4edda; color: #155724; }

.action-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: white;
  font-size: 12px;
  cursor: pointer;
  color: #212121;
}

.action-btn:hover {
  background: var(--secondary);
  color: var(--primary);
  border-color: var(--primary);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state i {
  font-size: 64px;
  color: var(--border);
  margin-bottom: 20px;
}

.empty-state h3 {
  font-size: 18px;
  margin-bottom: 10px;
  color: var(--text);
}

.empty-state p {
  color: var(--text-light);
  font-size: 14px;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-top: 1px solid var(--border);
}

.pagination-info {
  font-size: 13px;
  color: var(--text-light);
}

.pagination-buttons {
  display: flex;
  gap: 5px;
}

.pagination-buttons button {
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: white;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}

.pagination-buttons button:hover {
  background: var(--secondary);
}

.pagination-buttons button.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* Warehouse Info Cards */
.warehouse-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 25px;
}

.warehouse-card {
  background: var(--white);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  border-left: 4px solid var(--primary);
}

.warehouse-card h4 {
  font-size: 16px;
  color: var(--primary);
  margin-bottom: 12px;
}

.warehouse-card .address {
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 8px;
  color: #000;
}

.warehouse-card .contact {
  font-size: 13px;
  color: #000;
}

/* Modal */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-content {
  background: var(--white);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  max-width: 450px;
}

.modal-content h3 {
  font-size: 18px;
  margin-bottom: 20px;
}

.modal-content button[type="button"] {
  width: 100%;
  margin-top: 10px;
  background: var(--secondary);
  color: var(--text);
}

/* Profile Section */
.profile-card {
  background: var(--white);
  padding: 25px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.profile-item {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.profile-item:last-child { border-bottom: none; }
.profile-item label { color: var(--text-light); }
.profile-item span { font-weight: 600; }

/* Mobile nav */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid #eee;
  z-index: 999;
  padding: 8px 0 env(safe-area-inset-bottom, 8px);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}
.mobile-nav .nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px;
  color: #888;
  font-size: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.mobile-nav .nav-item i { font-size: 18px; }
.mobile-nav .nav-item.active { color: #27ae60; }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .mobile-nav { display: flex; }
  body { padding-bottom: 70px; }
  .main-content {
    margin-left: 0 !important;
    padding: 0;
  }
  #app {
    max-width: 100% !important;
    margin: 0 auto;
    padding: 12px 0;
  }
  .page {
    padding: 0;
    background: transparent;
  }
  .page.active {
    display: block;
  }
  .page-header {
    padding: 0 16px;
    background: transparent;
    margin-bottom: 12px;
  }
  .page-title {
    font-size: 20px;
  }
  .table-card {
    background: #fff;
    border-radius: 12px;
    padding: 0;
    box-shadow: none;
    border: 1px solid #eee;
  }
  .table-card .table-header {
    padding: 12px 16px;
  }
  .table-card table {
    font-size: 13px;
  }
  .table-card td, .table-card th {
    padding: 8px 4px;
  }
  .form-section {
    border-radius: 8px;
    margin: 0 16px 12px;
    padding: 12px;
  }
}

/* Toast Notifications */
.toast {
  background: #2c3e50;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  pointer-events: auto;
  animation: toastIn 0.3s ease;
  max-width: 300px;
}
.toast.success { background: #27ae60; }
.toast.error { background: #e74c3c; }
.toast.warning { background: #f39c12; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(20px); }
}
