/* === Sub Portal V2 Styles === */

/* --- Login Page --- */
.sub-login-body {
  background: linear-gradient(160deg, #7f1d1d 0%, #0c1220 60%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.sub-login-card {
  background: var(--bg-surface);
  border-radius: 16px;
  padding: 40px 28px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: var(--shadow-card);
}

.sub-login-brand { margin-bottom: 28px; }
.sub-login-brand img { height: 48px; }
.sub-login-brand h1 { font-size: 22px; font-weight: 700; color: var(--text-primary); margin-top: 12px; }
.sub-login-brand p { font-size: 14px; color: var(--text-muted); margin-top: 2px; }

.sub-phone-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.5px;
  outline: none;
  transition: border-color var(--transition);
  text-align: center;
}
.sub-phone-input:focus { border-color: var(--maroon); }
.sub-phone-input::placeholder { color: var(--text-muted); font-weight: 400; }

.sub-btn {
  width: 100%;
  padding: 14px;
  background: var(--maroon);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
  transition: background var(--transition);
  position: relative;
}
.sub-btn:hover { background: var(--maroon-light); }
.sub-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.sub-btn .spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.sub-error {
  color: var(--danger);
  font-size: 14px;
  min-height: 20px;
  margin-top: 8px;
}

.sub-success {
  color: var(--success);
  font-size: 14px;
  min-height: 20px;
  margin-top: 8px;
}

.sub-divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

/* Code Input Boxes */
.code-input-group {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 16px;
}
.code-digit {
  width: 44px;
  height: 52px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 600;
  text-align: center;
  outline: none;
  transition: border-color var(--transition);
}
.code-digit:focus { border-color: var(--maroon); }

.sub-footer-text {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 24px;
  line-height: 1.5;
}

/* --- Dashboard Layout --- */
.sub-app {
  min-height: 100vh;
  background: var(--bg-base);
  padding-bottom: 72px; /* space for bottom nav */
}

.sub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.sub-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sub-header-brand img { height: 28px; }
.sub-header-brand .sub-header-name { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.sub-header-brand .sub-header-trade { font-size: 12px; color: var(--text-secondary); }

.sub-header-logout {
  font-size: 13px;
  color: var(--text-secondary);
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
.sub-header-logout:hover { color: var(--text-primary); border-color: var(--text-secondary); }

/* Admin banner */
.sub-admin-banner {
  background: var(--maroon);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 500;
}
.sub-admin-banner button {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
}
.sub-admin-banner button:hover { background: rgba(255,255,255,0.3); }

/* --- Tab Content --- */
.sub-content { padding: 16px; }

/* Welcome section */
.sub-welcome h2 { font-size: 20px; font-weight: 700; color: var(--text-primary); }
.sub-welcome p { font-size: 14px; color: var(--text-secondary); margin-top: 2px; }

/* Stat Cards */
.sub-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}
.sub-stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.sub-stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}
.sub-stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Section headers */
.sub-section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 24px 0 12px;
}

/* Job / Activity Cards */
.sub-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.sub-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.sub-card-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.sub-card-subtitle { font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.sub-card-amount { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.sub-card-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}
.sub-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.sub-btn-sm {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background var(--transition);
}
.sub-btn-accept {
  background: var(--maroon);
  color: #fff;
  flex: 1;
}
.sub-btn-accept:hover { background: var(--maroon-light); }
.sub-btn-decline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.sub-btn-decline:hover { color: var(--text-primary); border-color: var(--text-secondary); }
.sub-btn-invoice {
  background: var(--maroon);
  color: #fff;
  flex: 1;
}
.sub-btn-plans {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* Status badges */
.sub-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.sub-badge-pending { background: rgba(234,179,8,0.15); color: #eab308; }
.sub-badge-submitted { background: rgba(234,179,8,0.15); color: #eab308; }
.sub-badge-approved { background: rgba(34,197,94,0.15); color: #22c55e; }
.sub-badge-paid, .sub-badge-qb_entered { background: rgba(59,130,246,0.15); color: #3b82f6; }
.sub-badge-rejected { background: rgba(239,68,68,0.15); color: #ef4444; }

/* Activity feed */
.sub-activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.sub-activity-item:last-child { border-bottom: none; }
.sub-activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--maroon);
  margin-top: 6px;
  flex-shrink: 0;
}
.sub-activity-text { font-size: 14px; color: var(--text-primary); }
.sub-activity-detail { font-size: 12px; color: var(--text-muted); }

/* --- Bottom Nav --- */
.sub-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.sub-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0 6px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition);
  background: none;
  border: none;
  -webkit-tap-highlight-color: transparent;
}
.sub-nav-item.active { color: var(--maroon-light); }
.sub-nav-item svg { width: 22px; height: 22px; margin-bottom: 2px; }

/* --- Invoice Modal --- */
.sub-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sub-modal {
  background: var(--bg-surface);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px 20px;
  animation: slideUp 0.25s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.sub-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.sub-modal-title { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.sub-modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
}

.sub-form-group {
  margin-bottom: 16px;
}
.sub-form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.sub-form-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
  transition: border-color var(--transition);
}
.sub-form-input:focus { border-color: var(--maroon); }

.sub-file-upload {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition);
}
.sub-file-upload:hover { border-color: var(--text-secondary); }
.sub-file-upload-text { font-size: 14px; color: var(--text-secondary); }
.sub-file-upload-name { font-size: 13px; color: var(--success); margin-top: 6px; display: none; }

/* Empty state */
.sub-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* Schedule items */
.sub-schedule-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.sub-schedule-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--maroon-light);
}

/* --- Sub Calendar --- */
.sub-cal-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.sub-cal-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sub-cal-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sub-cal-nav-btn:hover { border-color: var(--maroon); }
.sub-cal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 140px;
  text-align: center;
}
.sub-cal-today-btn {
  padding: 6px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.sub-cal-today-btn:hover { color: var(--text-primary); border-color: var(--maroon); }

.sub-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  background: var(--bg-surface);
  border-radius: 12px;
  padding: 8px;
}
.sub-cal-hdr {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 6px 0;
  text-transform: uppercase;
}
.sub-cal-day {
  min-height: 64px;
  padding: 4px 3px;
  border-radius: 6px;
  position: relative;
  background: var(--bg-base);
}
.sub-cal-empty { background: transparent; }
.sub-cal-today { background: rgba(127, 29, 29, 0.15); }
.sub-cal-num {
  font-size: 11px;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 2px;
  text-align: center;
}
.sub-cal-today .sub-cal-num { color: var(--maroon-light); font-weight: 700; }

.sub-cal-evt {
  font-size: 9px;
  padding: 2px 3px;
  border-radius: 3px;
  color: #fff;
  margin-bottom: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  line-height: 1.4;
}
.sub-cal-evt:active { opacity: 0.7; }
.sub-cal-more {
  font-size: 8px;
  color: var(--text-muted);
  text-align: center;
}

/* Calendar detail modal */
.sub-cal-detail {
  padding: 20px;
}
.sub-cal-detail-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.sub-cal-detail-build {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}
.sub-cal-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.sub-cal-detail-label { color: var(--text-muted); }
.sub-cal-detail-value { color: var(--text-primary); font-weight: 500; }
.sub-cal-detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

/* --- Next Check Card --- */
.sub-next-check {
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.sub-next-check-active {
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.25);
}
.sub-next-check-empty {
  background: var(--bg-surface);
  border: 1px solid var(--border);
}
.sub-next-check-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.sub-next-check-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.sub-next-check-amount {
  font-size: 32px;
  font-weight: 700;
  color: #22c55e;
}
.sub-next-check-date {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}
.sub-next-check-detail {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}
.sub-next-check-empty .sub-next-check-detail {
  margin-top: 0;
}

/* Payroll date on invoice cards */
.sub-card-payroll {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Updated badge colors for payroll flow */
.sub-badge-submitted { background: rgba(234,179,8,0.15); color: #eab308; }
.sub-badge-approved { background: rgba(59,130,246,0.15); color: #3b82f6; }
.sub-badge-paid, .sub-badge-qb_entered { background: rgba(34,197,94,0.15); color: #22c55e; }

/* Tab visibility */
.sub-tab { display: none; }
.sub-tab.active { display: block; }
