/**
 * VAG Partner Pro — Responsive CSS v3.1
 * Mobile-first: 320px → 360px → 390px → 414px → 768px → 1024px → 1366px → 1920px
 * Fixes: dropdown cutoff, overflow, form layout, progress bar, upload cards, admin panel
 */

/* ── GLOBAL RESETS ──────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* ── GLOBAL SELECT FIX (cross-browser) ──────────────────────────────── */
select,
.vag-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px !important;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  min-height: 48px;
  width: 100%;
  max-width: 100%;
  display: block;
}

/* ── GLOBAL INPUT FIX ───────────────────────────────────────────────── */
input,
textarea,
select {
  max-width: 100%;
  font-family: inherit;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="number"],
input[type="url"],
input[type="date"],
input[type="datetime-local"],
textarea {
  width: 100%;
  min-height: 44px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1.5px solid #e2e8f0;
  font-size: 15px;
  line-height: 1.5;
  color: #1e293b;
  background: #fff;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* ── BUTTONS ────────────────────────────────────────────────────────── */
button,
.vag-btn,
.vag-btn-primary,
.vag-btn-secondary {
  touch-action: manipulation;
  cursor: pointer;
  min-height: 44px;
  font-family: inherit;
  white-space: nowrap;
}

/* ── IMAGES ─────────────────────────────────────────────────────────── */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ══════════════════════════════════════════════════════════════════════
   FRONTEND APPLY FORM
══════════════════════════════════════════════════════════════════════ */

/* Progress Bar */
.vag-progress-bar-wrap {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  padding: 0;
  width: 100%;
  overflow-x: hidden;
}

.vag-progress-steps {
  display: flex;
  justify-content: center;
  gap: 0;
  width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.vag-progress-steps::-webkit-scrollbar { display: none; }

.vag-progress-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 10px;
  min-width: 70px;
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  position: relative;
  white-space: nowrap;
  flex: 1;
}

.vag-progress-step .step-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: #f0f4f8;
  border: 2px solid #e2e8f0;
  transition: all 0.3s;
}

.vag-progress-step.active .step-icon {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
  box-shadow: 0 4px 12px rgba(37,99,235,0.3);
}

.vag-progress-step.done .step-icon {
  background: #10b981;
  border-color: #10b981;
  color: #fff;
}

/* Form Container */
.vag-apply-form-wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  width: 100%;
}

/* Form Grid */
.vag-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.vag-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vag-form-group label {
  font-size: 13px;
  font-weight: 700;
  color: #374151;
  display: block;
}

/* Upload Cards */
.vag-upload-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.vag-upload-card {
  border: 2px dashed #e2e8f0;
  border-radius: 12px;
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #f8fafc;
}

.vag-upload-card:hover {
  border-color: #2563eb;
  background: #eff6ff;
}

.vag-upload-card input[type="file"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* OTP Step */
.vag-otp-container {
  max-width: 460px;
  margin: 0 auto;
  text-align: center;
  padding: 20px 16px;
}

.vag-otp-inputs {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 24px 0;
  flex-wrap: wrap;
}

.vag-otp-digit {
  width: 52px;
  height: 60px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  font-size: 28px;
  font-weight: 800;
  text-align: center;
  color: #1e293b;
  background: #f8fafc;
  outline: none;
  transition: all 0.2s;
  padding: 0;
  min-height: unset;
}

.vag-otp-digit:focus {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}

.vag-resend-timer {
  font-size: 13px;
  color: #94a3b8;
}

/* ══════════════════════════════════════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════════════════════════════════════ */

.vag-auth-page {
  min-height: 100vh;
  overflow-x: hidden;
}

.vag-auth-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
}

.vag-auth-brand-panel {
  background: linear-gradient(135deg, var(--vag-primary, #2563eb) 0%, var(--vag-secondary, #1e3a5f) 100%);
  padding: 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.vag-auth-card {
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  overflow-y: auto;
}

.vag-auth-card-inner {
  width: 100%;
  max-width: 420px;
}

/* ══════════════════════════════════════════════════════════════════════
   ADMIN PANEL
══════════════════════════════════════════════════════════════════════ */

.vag-admin-wrap {
  max-width: 100%;
  overflow-x: hidden;
}

.vag-admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 20px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  margin-bottom: 20px;
}

.vag-app-detail-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 24px;
}

.vag-settings-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  background: #f8fafc;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

.vag-stab {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  color: #64748b;
  transition: all 0.2s;
  white-space: nowrap;
}

.vag-stab:hover { background: #fff; color: #2563eb; }
.vag-stab.active { background: #2563eb; color: #fff; }

/* ══════════════════════════════════════════════════════════════════════
   BREAKPOINT: ≤1200px
══════════════════════════════════════════════════════════════════════ */
@media (max-width: 1200px) {
  .vag-app-detail-grid {
    grid-template-columns: 300px 1fr;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   BREAKPOINT: ≤1024px (Landscape Tablets / Small Laptops)
══════════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .vag-auth-split {
    grid-template-columns: 1fr;
  }
  .vag-auth-brand-panel {
    display: none;
  }
  .vag-auth-card {
    min-height: 100vh;
    padding: 32px 24px;
  }
  .vag-app-detail-grid {
    grid-template-columns: 1fr;
  }
  .vag-form-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   BREAKPOINT: ≤768px (Tablets)
══════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Form */
  .vag-form-grid {
    grid-template-columns: 1fr !important;
  }

  .vag-apply-form-wrap {
    padding: 16px 12px 32px;
  }

  /* Progress bar - hide labels on small screens */
  .vag-progress-step .step-label {
    display: none;
  }

  .vag-progress-step {
    min-width: 44px;
    padding: 10px 4px;
  }

  /* Upload cards */
  .vag-upload-cards {
    grid-template-columns: 1fr 1fr;
  }

  /* Admin panel */
  .vag-admin-header {
    flex-direction: column;
    align-items: flex-start;
  }

  /* Stat cards */
  .vag-stat-grid,
  .vag-stats-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Tables */
  .vag-admin-table {
    font-size: 12px;
  }
  .vag-admin-table th,
  .vag-admin-table td {
    padding: 8px 10px;
  }

  /* Settings */
  .vag-settings-tabs {
    gap: 2px;
  }
  .vag-stab {
    padding: 8px 10px;
    font-size: 12px;
  }

  /* Modals */
  .vag-modal-inner {
    width: calc(100vw - 32px);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    margin: 20px 16px;
    border-radius: 14px;
  }

  /* Meeting scheduler grid */
  [style*="grid-template-columns:1fr 1fr"] {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   BREAKPOINT: ≤480px (Large Phones)
══════════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  /* Upload cards */
  .vag-upload-cards {
    grid-template-columns: 1fr;
  }

  /* OTP inputs */
  .vag-otp-digit {
    width: 44px;
    height: 52px;
    font-size: 24px;
  }

  /* Stat cards */
  .vag-stat-grid,
  .vag-stats-grid {
    grid-template-columns: 1fr !important;
  }

  /* Hero banner */
  .vag-apply-hero {
    padding: 24px 16px;
  }

  .vag-apply-hero h1 {
    font-size: 20px;
  }

  /* Form nav buttons */
  .vag-form-nav {
    flex-direction: column;
    gap: 10px;
  }

  .vag-form-nav button {
    width: 100%;
  }

  /* Admin EC stat cards */
  .vag-ec-stat-cards {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   BREAKPOINT: ≤414px (iPhone Plus / Pixel)
══════════════════════════════════════════════════════════════════════ */
@media (max-width: 414px) {
  html { font-size: 15px; }

  .vag-auth-card {
    padding: 24px 16px;
  }

  .vag-auth-card-inner {
    max-width: 100%;
  }

  input,
  textarea,
  select,
  .vag-select {
    font-size: 16px; /* Prevents iOS auto-zoom on focus */
  }

  .vag-progress-step {
    min-width: 36px;
    padding: 8px 2px;
  }

  .vag-progress-step .step-icon {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   BREAKPOINT: ≤390px (iPhone 14 / Pixel 7)
══════════════════════════════════════════════════════════════════════ */
@media (max-width: 390px) {
  .vag-otp-inputs {
    gap: 6px;
  }
  .vag-otp-digit {
    width: 40px;
    height: 48px;
    font-size: 22px;
    border-radius: 8px;
  }
  .vag-ec-stat-cards {
    grid-template-columns: 1fr !important;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   BREAKPOINT: ≤360px (Smaller Android Phones)
══════════════════════════════════════════════════════════════════════ */
@media (max-width: 360px) {
  html { font-size: 14px; }

  .vag-apply-form-wrap {
    padding: 12px 8px 28px;
  }

  .vag-upload-card {
    padding: 14px 10px;
    min-height: 90px;
  }

  .vag-otp-digit {
    width: 36px;
    height: 44px;
    font-size: 20px;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   BREAKPOINT: ≤320px (Very Small Phones)
══════════════════════════════════════════════════════════════════════ */
@media (max-width: 320px) {
  .vag-otp-inputs {
    gap: 4px;
  }
  .vag-otp-digit {
    width: 32px;
    height: 40px;
    font-size: 18px;
  }
  .vag-progress-steps {
    justify-content: flex-start;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   LARGE SCREENS: ≥1366px+
══════════════════════════════════════════════════════════════════════ */
@media (min-width: 1366px) {
  .vag-form-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
  .vag-upload-cards {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 1920px) {
  .vag-apply-form-wrap {
    max-width: 1000px;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   SCROLLABLE TABLE WRAPPER (Mobile)
══════════════════════════════════════════════════════════════════════ */
.vag-table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 10px;
}

/* ══════════════════════════════════════════════════════════════════════
   NOTIFICATION TOAST (fixed positioning)
══════════════════════════════════════════════════════════════════════ */
.vag-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 999999;
  max-width: calc(100vw - 40px);
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
  animation: vag-slide-in 0.3s ease;
  word-break: break-word;
}

@keyframes vag-slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);   opacity: 1; }
}

@keyframes vag-fadein {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════════════════════════════════
   DASHBOARD SIDEBAR
══════════════════════════════════════════════════════════════════════ */
.vag-dashboard-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  max-width: 100%;
}

@media (max-width: 900px) {
  .vag-dashboard-layout {
    grid-template-columns: 1fr;
  }
  .vag-dashboard-sidebar {
    display: none;
  }
  .vag-dashboard-sidebar.mobile-open {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    z-index: 9999;
    overflow-y: auto;
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
  }
  .vag-mobile-sidebar-toggle {
    display: flex;
  }
}

.vag-mobile-sidebar-toggle {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--vag-primary, #2563eb);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 16px;
  width: 100%;
}

/* ══════════════════════════════════════════════════════════════════════
   PRINT
══════════════════════════════════════════════════════════════════════ */
@media print {
  .vag-progress-bar-wrap,
  .vag-form-nav,
  .vag-admin-header,
  .vag-dashboard-sidebar {
    display: none !important;
  }
}
