/*
  PAK+ OffloadLink — Professional Redesign
*/
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --primary:        #0059A3; /* PakEnergy Blue */
  --primary-hover:  #00427A;
  --secondary:      #2699FB; /* Accent Blue */
  --bg-page:        #F4F7F9; /* Very light cool grey */
  --surface:        #FFFFFF;
  --surface-glass:  rgba(255, 255, 255, 0.85); /* For glassmorphism */
  --text-heading:   #1A2B3C;
  --text-body:      #4A5568;
  --text-muted:     #718096;
  --border:         #E2E8F0;
  --error:          #E53E3E;
  --error-bg:       #FFF5F5;
  --success:        #38A169;
  --success-bg:     #F0FFF4;
  
  --radius-card:    16px;
  --radius-input:   10px;
  --radius-pill:    999px;
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
  --shadow-md:      0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
  --shadow-lg:      0 10px 25px -3px rgba(0,0,0,0.05), 0 4px 10px -2px rgba(0,0,0,0.02);
}

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

body {
  min-height: 100vh;
  font-family: 'Inter', -apple-system, sans-serif;
  color: var(--text-body);
  background: var(--bg-page);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  position: relative;
  overflow-x: hidden;
}

/* Background Wrapper Logo Effect */
.bg-wrapper-logo {
  position: fixed;
  top: -10%;
  right: -20%;
  width: 80vh;
  height: 80vh;
  background-image: url('../img/logo.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.04;
  z-index: -1;
  pointer-events: none;
  transform: rotate(-15deg);
}

.app-shell {
  width: min(800px, 100%);
  margin: 0 auto;
  padding: 40px 20px calc(120px + env(safe-area-inset-bottom));
  position: relative;
  z-index: 1;
}

/* ── Typography ── */
h1, h2, h3, h4 { color: var(--text-heading); font-weight: 700; margin-top: 0; }
h1 { font-size: clamp(28px, 5vw, 36px); line-height: 1.2; letter-spacing: -0.03em; margin-bottom: 4px; }
h2 { font-size: 20px; letter-spacing: -0.01em; margin-bottom: 20px; }

/* ── Header ── */
.app-header {
  padding: 0 0 32px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.brand-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.brand-logo-img {
  max-width: 180px;
  height: auto;
  margin-bottom: 8px;
}
.eyebrow {
  margin: 0 0 4px; color: var(--primary);
  font-size: 14px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.subtitle { 
  margin: 8px 0 0; 
  color: var(--text-muted); 
  font-size: 16px; 
  font-weight: 400; 
}

/* ── Stepper ── */
.stage-bar {
  display: flex; gap: 8px; margin-bottom: 32px;
  overflow-x: auto; scrollbar-width: none;
}
.stage-bar::-webkit-scrollbar { display: none; }
.step {
  flex: 1; min-width: max-content;
  padding: 10px 16px; border-radius: var(--radius-pill);
  font-size: 14px; font-weight: 600; text-align: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}
.step.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(0, 89, 163, 0.3);
}
.step.completed {
  background: var(--success-bg);
  border-color: var(--success);
  color: var(--success);
}
.step.completed::before {
  content: ""; display: inline-block; width: 16px; height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2338A169'%3E%3Cpath fill-rule='evenodd' d='M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-size: contain; background-repeat: no-repeat;
}

/* ── Cards / Sections ── */
.card { 
  margin: 0 0 24px; padding: 28px; 
  border-radius: var(--radius-card); 
  border: 1px solid rgba(255, 255, 255, 0.5); 
  background: var(--surface-glass); 
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg); 
}
.section { opacity: 0; display: none; transition: opacity 0.3s ease; }
.section.visible { opacity: 1; display: block; }
.hidden { display: none !important; }

.field-grid { display: grid; gap: 20px; grid-template-columns: 1fr; }

/* ── Form Controls ── */
label { display: block; margin: 0 0 6px; font-size: 14px; font-weight: 600; color: var(--text-heading); }
.label-opt { font-weight: 400; color: var(--text-muted); font-size: 13px; }

input, select, textarea {
  width: 100%; min-height: 52px; 
  border: 1px solid var(--border);
  border-radius: var(--radius-input); 
  padding: 14px 16px; margin: 0 0 20px; 
  background: var(--surface);
  font: inherit; font-size: 15px; color: var(--text-heading);
  transition: all 0.2s ease;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
}
textarea { min-height: 100px; resize: vertical; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(38, 153, 251, 0.2);
}
input:disabled { background: var(--bg-page); color: var(--text-muted); border-color: var(--border); }

/* Custom Dropdown styling */
select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23A0AEC0'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 20px;
  padding-right: 48px;
}
select:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%230059A3'%3E%3Cpath fill-rule='evenodd' d='M14.707 12.707a1 1 0 01-1.414 0L10 9.414l-3.293 3.293a1 1 0 01-1.414-1.414l4-4a1 1 0 011.414 0l4 4a1 1 0 010 1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
}

/* ── Buttons ── */
button {
  width: 100%; min-height: 52px; 
  border: 1px solid transparent; border-radius: var(--radius-input);
  padding: 14px 24px; margin: 0 0 16px; 
  cursor: pointer; font: inherit; font-size: 16px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
button:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary { 
  background: var(--primary); color: #fff; 
  box-shadow: 0 4px 12px rgba(0, 89, 163, 0.2);
}
.btn-primary:hover:not(:disabled) { 
  background: var(--primary-hover); 
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 89, 163, 0.3);
}

.btn-outline { 
  background: var(--surface); color: var(--primary); 
  border: 2px solid var(--primary); 
}
.btn-outline:hover:not(:disabled) { 
  background: rgba(0, 89, 163, 0.05); 
}

/* Utility mapped buttons */
button[type="button"].primary { @extend .btn-primary; background: var(--primary); color: #fff; border-color: var(--primary); }
button[type="button"].secondary { background: var(--surface); color: var(--text-heading); border: 1px solid var(--border); }
button[type="button"].secondary:hover:not(:disabled) { background: var(--bg-page); border-color: var(--primary); color: var(--primary); }
#addManualTicketBtn { background: transparent; color: var(--primary); border: 2px dashed var(--primary); }
#addManualTicketBtn:hover { background: rgba(0, 89, 163, 0.05); }
#validateAllTicketsBtn { background: var(--success); color: #fff; box-shadow: 0 4px 12px rgba(56, 161, 105, 0.2); }
#validateAllTicketsBtn:hover { background: #2F855A; }

.row.two { display: grid; gap: 16px; grid-template-columns: 1fr; }
.meta-grid { display: grid; gap: 20px; grid-template-columns: 1fr; }
.checkbox-row { 
  display: flex; align-items: center; gap: 12px; margin-bottom: 24px; cursor: pointer; 
  padding: 16px; border-radius: var(--radius-input);
  background: rgba(0, 89, 163, 0.03); border: 1px solid rgba(0, 89, 163, 0.1);
  transition: all 0.2s ease;
}
.checkbox-row:hover { background: rgba(0, 89, 163, 0.06); }
.checkbox-row input { width: 24px; height: 24px; margin: 0; min-height: auto; cursor: pointer; accent-color: var(--primary); }
.checkbox-row span { font-weight: 600; color: var(--primary); }

.status { margin: 4px 0 16px; font-size: 14px; font-weight: 500; color: var(--text-muted); }
.status.success { color: var(--success); }
.status.error   { color: var(--error); }

/* ── Error Banner ── */
.error-box, .alert.error {
  margin: 0 0 20px; 
  background: var(--error-bg); 
  border: 1px solid rgba(229, 62, 62, 0.2);
  border-left: 4px solid var(--error);
  border-radius: 6px;
  padding: 16px; 
  font-size: 14px; color: var(--error); font-weight: 500; line-height: 1.5;
  display: flex; gap: 12px; align-items: flex-start;
  box-shadow: var(--shadow-sm);
}
.error-box::before {
  content: "";
  display: block; width: 20px; height: 20px; flex-shrink: 0; margin-top: -1px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23E53E3E'%3E%3Cpath fill-rule='evenodd' d='M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z' clip-rule='evenodd'/%3E%3C/svg%3E");
}

/* ── Product Type Chips ── */
.product-type-list {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px;
}
.chip {
  background: var(--surface); color: var(--text-body);
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  padding: 8px 16px; font-size: 14px; font-weight: 500; line-height: 1.4;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.2s ease;
}
.chip.selected {
  background: var(--primary); color: #fff; border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 89, 163, 0.2);
}
.chip.selected::before {
  content: ""; display: inline-block; width: 14px; height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23FFFFFF'%3E%3Cpath fill-rule='evenodd' d='M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-size: contain; background-repeat: no-repeat;
}

/* ── QR video ── */
#qrVideo {
  width: 100%; min-height: 240px; max-height: 400px;
  border-radius: var(--radius-card); background: #1A202C; 
  object-fit: cover; margin-bottom: 20px;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}
.search-hint {
  font-size: 14px; color: var(--text-muted);
  line-height: 1.5; margin: -8px 0 20px;
}
.search-hint strong { color: var(--text-heading); font-weight: 700; }

/* ── Ticket cards (Avatar Slot & Grid) ── */
.ticket-summary-header {
  display: flex; align-items: center; gap: 16px; margin-bottom: 20px;
}
.ticket-avatar {
  width: 48px; height: 48px; border-radius: 12px;
  background: rgba(0, 89, 163, 0.1);
  display: grid; place-items: center; flex-shrink: 0;
}
.ticket-avatar::after {
  content: ""; display: block; width: 24px; height: 24px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230059A3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'%3E%3C/path%3E%3Cpolyline points='14 2 14 8 20 8'%3E%3C/polyline%3E%3Cline x1='16' y1='13' x2='8' y2='13'%3E%3C/line%3E%3Cline x1='16' y1='17' x2='8' y2='17'%3E%3C/line%3E%3Cpolyline points='10 9 9 9 8 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-size: contain; background-repeat: no-repeat;
}
.ticket-summary-title { margin: 0; font-size: 18px; font-weight: 700; color: var(--text-heading); }
.ticket-facts-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px;
  background: var(--bg-page); padding: 16px; border-radius: var(--radius-input);
}
.fact-item { display: flex; flex-direction: column; gap: 6px; }
.fact-label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.fact-value { font-size: 15px; color: var(--text-heading); font-weight: 700; }

.nav-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.back-btn {
  background: transparent; color: var(--primary);
  border: none; width: auto; min-height: auto;
  padding: 8px 0; font-size: 15px; margin: 0;
}
.back-btn:hover { background: transparent; color: var(--primary-hover); text-decoration: underline; }

/* ── Ticket tabs ── */
.ticket-tabs {
  display: flex; overflow-x: auto; gap: 12px; margin-bottom: 24px; padding-bottom: 8px; scrollbar-width: none;
}
.ticket-tabs::-webkit-scrollbar { display: none; }
.ticket-tab-btn {
  white-space: nowrap; width: auto; min-height: 44px; margin: 0;
  border-radius: var(--radius-pill); font-size: 14px;
  background: var(--surface); color: var(--text-body); border: 1px solid var(--border);
}
.ticket-tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Submit lifecycle ── */
#submitAttemptDots { letter-spacing: 0.15em; font-size: 20px; margin-top: 12px; color: var(--primary); }
#pollStatus        { margin-top: 12px; color: var(--primary); font-weight: 500; }
#dashboardLinkWrap { margin-top: 24px; text-align: center; }
#dashboardLinkWrap a { color: var(--primary); font-weight: 600; text-decoration: none; padding: 12px 24px; border: 1px solid var(--primary); border-radius: var(--radius-pill); display: inline-block; transition: all 0.2s ease;}
#dashboardLinkWrap a:hover { background: var(--primary); color: #fff; }

/* ── Responsive ── */
@media (min-width: 600px) {
  .app-shell { padding: 48px 24px 60px; }
  .row.two   { grid-template-columns: 1fr 1fr; }
  .meta-grid { grid-template-columns: repeat(3, 1fr); }
  .ticket-facts-grid { grid-template-columns: repeat(4, 1fr); }
  .field-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 900px) {
  .field-grid { grid-template-columns: repeat(3, 1fr); }
  .app-header { flex-direction: row; justify-content: space-between; text-align: left; }
  .brand-row { flex-direction: row; gap: 20px; }
  .subtitle { margin: 0; text-align: right; }
}
