/**
 * BYOD User Dashboard Frontend Styles
 * Loaded on pages containing [byod_dashboard]
 * Depends on: admin/css/byod-overview.css (loaded first)
 * Version: 1.0.1
 */

/* ── Dashboard Wrapper ───────────────────────────────────────────────────── */
.byod-user-dashboard {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #0F172A;
}

/* ── Tab Navigation ──────────────────────────────────────────────────────── */
.byod-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 0;
  border-bottom: 2px solid #E2E8F0;
  padding: 0;
}

.byod-tab {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 600;
  color: #64748B;
  cursor: pointer;
  margin-bottom: -2px;
  transition: all 0.2s ease;
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
}

.byod-tab:hover    { color: #2563EB; }
.byod-tab.active   { color: #2563EB; border-bottom-color: #2563EB; }

/* ── Tab Content ─────────────────────────────────────────────────────────── */
.byod-tab-content {
  background: #FFFFFF;
  border-radius: 0 0 12px 12px;
  padding: 32px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
  border: 1px solid #E2E8F0;
  border-top: none;
}

.byod-tab-panel { animation: byodFadeIn 0.25s ease; }

@keyframes byodFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Stat Grid (4 columns) ───────────────────────────────────────────────── */
/* User dashboard uses .byod-stat-grid (no 's'); byod-overview.css has .byod-stats-grid */
.byod-user-dashboard .byod-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

/* Ensure stat cards are clickable/interactive in dashboard context */
.byod-user-dashboard .byod-stat-card {
  cursor: pointer;
}

.byod-user-dashboard .byod-stat-card:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px rgba(15,23,42,0.08);
}

/* Stat Card Color Variants — used by user dashboard */
.byod-stat-card-warning { border-top: 3px solid #F59E0B; }
.byod-stat-card-success { border-top: 3px solid #22C55E; }
.byod-stat-card-error   { border-top: 3px solid #EF4444; }
.byod-stat-card-info    { border-top: 3px solid #38BDF8; }

.byod-stat-card-warning .byod-stat-icon { color: #F59E0B; }
.byod-stat-card-success .byod-stat-icon { color: #22C55E; }
.byod-stat-card-error   .byod-stat-icon { color: #EF4444; }
.byod-stat-card-info    .byod-stat-icon { color: #38BDF8; }

/* Stat icon (Material Symbol inside card) */
.byod-stat-icon.material-symbols-outlined {
  font-size: 40px;
  display: block;
  margin: 0 auto 12px;
  font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 40;
}

.byod-stat-value {
  font-size: 40px;
  font-weight: 700;
  color: #0F172A;
  line-height: 1;
  margin-bottom: 8px;
  font-family: 'Poppins', sans-serif;
}

.byod-stat-label {
  font-size: 13px;
  font-weight: 500;
  color: #64748B;
}

/* ── Quota Box — Overview Tab ────────────────────────────────────────────── */
.byod-quota-box-overview {
  background: #FFFFFF;
  border: 2px solid #E5E7EB;
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 24px;
}

.byod-quota-box-overview .byod-quota-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.byod-quota-box-overview .byod-quota-header .material-symbols-outlined {
  font-size: 24px;
  color: #475569;
}

.byod-quota-box-overview .byod-quota-header strong {
  font-size: 16px;
  font-weight: 600;
  color: #0F172A;
  font-family: 'Poppins', sans-serif;
}

.byod-quota-box-overview .byod-quota-text {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 500;
  color: #334155;
}

/* Progress track */
.byod-quota-box-overview .byod-quota-progress {
  width: 100%;
  height: 26px;
  background: #F1F5F9;
  border-radius: 8px;
  overflow: visible;
  position: relative;
}

/* Progress fill — width set inline by PHP */
.byod-quota-box-overview .byod-quota-progress-bar {
  height: 100%;
  border-radius: 8px;
  transition: width 0.5s ease;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 12px;
  min-width: 40px;
}

.byod-quota-percentage {
  font-size: 11px;
  font-weight: 700;
  color: #FFFFFF;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  white-space: nowrap;
}

/* Progress colour variants */
.byod-progress-blue   { background: linear-gradient(90deg, #3B82F6, #2563EB); }
.byod-progress-orange { background: linear-gradient(90deg, #FB923C, #F59E0B); }
.byod-progress-red    { background: linear-gradient(90deg, #F87171, #EF4444); }

/* ── Quick Actions Bar ───────────────────────────────────────────────────── */
.byod-quick-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  padding: 14px 16px;
  background: #F8FAFC;
  border-radius: 8px;
  border: 1px solid #E5E7EB;
  flex-wrap: wrap;
}

.byod-quick-actions .button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.byod-quick-actions .button .material-symbols-outlined { font-size: 18px; }

/* ── Icon-only action buttons (in domains table) ─────────────────────────── */
.byod-actions { white-space: nowrap; }

.byod-btn-icon {
  background: transparent;
  border: 1px solid #E5E7EB;
  padding: 5px 7px;
  margin: 0 2px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  min-height: 30px;
}

.byod-btn-icon .material-symbols-outlined { font-size: 18px; color: #475569; display: block; }
.byod-btn-icon:hover                     { background: #F8FAFC; border-color: #CBD5E1; }
.byod-btn-test-domain:hover  .material-symbols-outlined { color: #2563EB; }
.byod-btn-edit-domain:hover  .material-symbols-outlined { color: #F59E0B; }
.byod-btn-delete-domain:hover .material-symbols-outlined { color: #EF4444; }
.byod-btn-icon:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── IMAP Status Indicators ─────────────────────────────────────────────── */
.byod-imap-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: help;
  white-space: nowrap;
}

.byod-imap-status .material-symbols-outlined { font-size: 16px; }
.byod-imap-label { white-space: nowrap; }

.byod-imap-connected { background: #DCFCE7; color: #166534; }
.byod-imap-connected .material-symbols-outlined { color: #16A34A; }

.byod-imap-failed    { background: #FEE2E2; color: #991B1B; }
.byod-imap-failed    .material-symbols-outlined { color: #DC2626; }

.byod-imap-unknown   { background: #F1F5F9; color: #475569; }
.byod-imap-unknown   .material-symbols-outlined { color: #64748B; }

/* ── Rejection Reason (table cell) ─────────────────────────────────────── */
.byod-rejection-reason {
  display: block;
  font-size: 12px;
  color: #991B1B;
  background: #FEE2E2;
  border-left: 3px solid #EF4444;
  padding: 4px 8px;
  border-radius: 4px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Quota Box — Add Domain Tab ─────────────────────────────────────────── */
.byod-quota-box {
  background: linear-gradient(135deg, #EFF6FF, #DBEAFE);
  border: 2px solid #93C5FD;
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 24px;
}

.byod-quota-box .byod-quota-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.byod-quota-box .byod-quota-header .material-symbols-outlined { font-size: 24px; color: #2563EB; }
.byod-quota-box .byod-quota-header strong { font-size: 16px; font-weight: 600; color: #1E40AF; font-family: 'Poppins', sans-serif; }

.byod-quota-box .byod-quota-content p { margin: 0 0 12px; font-size: 15px; color: #1E3A8A; }
.byod-quota-box .byod-quota-content strong { color: #1E40AF; }

/* Simple progress bar (add tab) */
.byod-quota-box .byod-quota-progress {
  width: 100%;
  height: 8px;
  background: rgba(255,255,255,0.6);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}

.byod-quota-box .byod-quota-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #3B82F6, #2563EB);
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* ── Add Domain Header ───────────────────────────────────────────────────── */
.byod-add-domain  { }
.byod-add-header  { margin-bottom: 24px; padding-bottom: 20px; border-bottom: 2px solid #F1F5F9; }
.byod-add-header h2 { font-size: 20px; font-weight: 600; color: #0F172A; margin: 0 0 8px; font-family: 'Poppins', sans-serif; }
.byod-add-header p  { font-size: 14px; color: #64748B; margin: 0; line-height: 1.6; }

/* ── Notice / Error ─────────────────────────────────────────────────────── */
.byod-notice {
  padding: 14px 18px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.byod-notice.byod-error,
.byod-notice p { margin: 0; }
.byod-error { background: #FEE2E2; border-left: 4px solid #EF4444; color: #991B1B; }
.byod-success-notice { background: #DCFCE7; border-left: 4px solid #22C55E; color: #166534; }

/* ── Form overrides (frontend context) ──────────────────────────────────── */
.byod-user-dashboard .form-actions {
  margin-top: 24px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.byod-user-dashboard .byod-test-result {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.6;
}

.byod-user-dashboard .byod-test-result.byod-test-success { background: #DCFCE7; border-left: 4px solid #16A34A; color: #166534; }
.byod-user-dashboard .byod-test-result.byod-test-error   { background: #FEE2E2; border-left: 4px solid #DC2626; color: #991B1B; }

/* Button overrides — match M3 in frontend */
.byod-user-dashboard .button {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid #E5E7EB;
  background: #FFFFFF;
  color: #475569;
  min-height: 40px;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Poppins', sans-serif;
}

.byod-user-dashboard .button:hover { background: #F8FAFC; border-color: #CBD5E1; }

.byod-user-dashboard .button-primary {
  background: #2563EB !important;
  border-color: #2563EB !important;
  color: #FFFFFF !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.byod-user-dashboard .button-primary:hover {
  background: #1D4ED8 !important;
  border-color: #1D4ED8 !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 6px rgba(37,99,235,0.25) !important;
}

.byod-user-dashboard .button:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* Form message (AJAX feedback below form) */
#byod-form-message {
  margin-top: 20px;
  padding: 14px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  animation: byodSlideDown 0.3s ease;
  border-left: 4px solid;
  line-height: 1.6;
}

#byod-form-message.byod-success { background: #DCFCE7; color: #166534; border-left-color: #22C55E; }
#byod-form-message.byod-error   { background: #FEE2E2; color: #991B1B; border-left-color: #EF4444; }
#byod-form-message.byod-info    { background: #E0F2FE; color: #075985; border-left-color: #38BDF8; }

@keyframes byodSlideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .byod-user-dashboard .byod-stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .byod-user-dashboard { padding: 12px; }
  .byod-tab-content { padding: 20px 16px; }

  .byod-tabs { flex-wrap: wrap; }
  .byod-tab  { flex: 1 1 auto; padding: 10px 12px; font-size: 13px; text-align: center; }

  .byod-user-dashboard .byod-stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }

  .byod-quick-actions { flex-direction: column; }
  .byod-quick-actions .button { width: 100%; justify-content: center; }

  /* Hide "Submitted" column on narrow screens */
  .byod-user-dashboard .byod-domains-table thead th:nth-child(4),
  .byod-user-dashboard .byod-domains-table tbody td:nth-child(4) { display: none; }

  .byod-user-dashboard .form-actions { flex-direction: column; }
  .byod-user-dashboard .form-actions .button { width: 100%; justify-content: center; }

  .byod-quota-box-overview,
  .byod-quota-box { padding: 16px; }
}
