/* ==========================================================================
   Student & Govt Exam Form Resizer Pro - Studio Design System
   Modern 2-Column Master Studio Architecture matching aadhaar-pan-studio.html
   ========================================================================== */

/* Two-Column Master Studio Workspace */
.student-mobile-actions { display: none; }


.studio-workspace-grid {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  padding: 10px 14px 20px 14px;
  box-sizing: border-box;
  background: var(--gov-bg, #f1f5f9);
}

/* Visible tool map: settings, preview, adjustments. */
.student-setup-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  background: #fff;
  border-bottom: 1px solid #fed7aa;
}
.student-setup-bar .asset-pills { width: min(460px, 55%); }
.student-setup-bar .asset-pill { flex-direction: row; padding: 9px 8px; }
.student-setup-bar > label { margin: 0; cursor: pointer; white-space: nowrap; }
.studio-workspace-grid > * { min-width: 0; }

@media (min-width: 1100px) {
  .studio-workspace-grid {
    height: calc(100dvh - 76px);
    overflow: hidden;
  }
  .floating-tools-sidebar {
    height: 100%;
    max-height: 100%;
    overflow-y: auto;
  }
  .stage-main-wrapper {
    height: 100%;
    max-height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .stage-viewport-box {
    flex: 1 1 0;
    min-height: 0;
  }
}

@media (max-width: 1099px) {
  .studio-workspace-grid {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
    padding: 8px 10px 30px 10px;
  }
  .floating-tools-sidebar {
    order: 2;
    max-height: none;
  }
  .stage-main-wrapper {
    order: 1;
  }
  .stage-viewport-box {
    height: 60vh;
    min-height: 380px;
  }
}

/* ==========================================================================
   Left Sidebar Styling
   ========================================================================== */
.floating-tools-sidebar {
  background: #ffffff;
  border: 1px solid #d9dde2;
  border-radius: 8px;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 #f5f5f5;
  display: flex;
  flex-direction: column;
  gap: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.floating-tools-sidebar::-webkit-scrollbar {
  width: 5px;
}
.floating-tools-sidebar::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

[data-theme="dark"] .floating-tools-sidebar {
  background: #111827;
  border-color: #1f2937;
}

/* Sidebar Cards */
.sidebar-card-box {
  padding: 12px 14px;
  border-bottom: 1px solid #fed7aa;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #ffffff;
}

[data-theme="dark"] .sidebar-card-box {
  background: #111827;
  border-color: #1f2937;
}

.sidebar-card-box:last-child {
  border-bottom: none;
}

.sidebar-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 800;
  color: #1e293b;
  padding-bottom: 6px;
  border-bottom: 1px solid #f1f5f9;
  margin: 0;
}

[data-theme="dark"] .sidebar-card-title {
  color: #f1f5f9;
  border-color: #1f2937;
}

/* Asset Pills */
.asset-pills {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 0;
  padding: 0;
}

.asset-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1.5px solid #cbd5e1;
  background-color: #f8fafc;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.asset-pill:hover {
  border-color: #ea580c;
  color: #ea580c;
  background-color: #fff7ed;
}

.asset-pill.active {
  background-color: #ea580c;
  border-color: #ea580c;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

/* Scale Pills */
.scale-pills {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}

.scale-pill {
  padding: 5px 2px;
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background-color: #f8fafc;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s ease;
}

.scale-pill:hover, .scale-pill.active {
  border-color: #ea580c;
  color: #ea580c;
  background-color: #fff7ed;
  font-weight: 800;
}

/* Lighting Pills */
.lighting-pills {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.lighting-pill {
  padding: 6px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background-color: #f8fafc;
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.15s ease;
  text-align: center;
  white-space: nowrap;
}

.lighting-pill:hover, .lighting-pill.active {
  border-color: #ea580c;
  color: #ea580c;
  background-color: #fff7ed;
  font-weight: 800;
}

/* KB Quota Meter */
.kb-quota-meter {
  background: #f8fafc;
  border: 1px solid #fed7aa;
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

[data-theme="dark"] .kb-quota-meter {
  background: #1f2937;
  border-color: #374151;
}

.kb-progress-bar-wrap {
  background: #fed7aa;
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
}

.kb-progress-bar-fill {
  background: linear-gradient(90deg, #10b981, #c2410c);
  height: 100%;
  transition: width 0.3s ease;
}

/* ==========================================================================
   Right Main Stage Container
   ========================================================================== */
.stage-main-wrapper {
  background: #ffffff;
  border: 1px solid #d9dde2;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

[data-theme="dark"] .stage-main-wrapper {
  background: #111827;
  border-color: #1f2937;
}

/* Stage Header & Step Switcher */
.stage-top-bar {
  background: #fafafa;
  border-bottom: 1px solid #d9dde2;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 48px;
}

[data-theme="dark"] .stage-top-bar {
  background: #1f2937;
  border-color: #374151;
}

.stage-step-pills {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #eaedf2;
  border-radius: 8px;
  padding: 3px;
}

[data-theme="dark"] .stage-step-pills {
  background: #374151;
}

.stage-step-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  border: none;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.stage-step-pill:hover {
  color: #0f172a;
}

.stage-step-pill.active {
  background: #ffffff;
  color: #c2410c;
  font-weight: 800;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .stage-step-pill.active {
  background: #111827;
  color: #38bdf8;
}

/* Stage Live Badge */
.stage-live-badge {
  font-weight: 700;
  font-size: 0.74rem;
  padding: 4px 10px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.badge-front { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }
.badge-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.badge-warning { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }

/* Stage Viewport Area */
.stage-viewport-box {
  background-color: #e2e5e9;
  background-image: radial-gradient(#cbd5e1 1.2px, transparent 1.2px);
  background-size: 16px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: auto;
  padding: 16px;
  user-select: none;
  box-sizing: border-box;
}

[data-theme="dark"] .stage-viewport-box {
  background-color: #090d16;
  background-image: radial-gradient(#1e293b 1.2px, transparent 1.2px);
}

/* Step 1 Crop View Wrap */
#stdViewCropWrap {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Crop Canvas Styling */
#stdCropCanvas {
  max-width: 100%;
  max-height: calc(100dvh - 220px);
  object-fit: contain;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  border-radius: 4px;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

@media (max-width: 760px) {
  #stdCropCanvas {
    max-height: 52vh;
  }
}

/* Floating Live HUD */
.crop-live-hud {
  position: absolute;
  top: 14px;
  left: 14px;
  background: rgba(15, 23, 42, 0.88);
  color: #ffffff;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(6px);
  z-index: 50;
}

.hud-pulse {
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
}

/* Initial Clean Dropzone */
.std-dropzone-box {
  background: #ffffff;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.06);
  width: 100%;
  max-width: 480px;
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

[data-theme="dark"] .std-dropzone-box {
  background: #1f2937;
  border-color: #374151;
}

.std-dropzone-box:hover {
  border-color: #ea580c;
  background-color: #fff7ed;
}

.wa-stage-toolbar {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  max-width: calc(100% - 24px);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  justify-content: center;
  background: rgba(15, 23, 42, 0.94);
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(254, 215, 170, 0.25);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
  z-index: 80;
  backdrop-filter: blur(8px);
}

.wa-stage-toolbar::-webkit-scrollbar {
  display: none;
}

@media (max-width: 680px) {
  .wa-stage-toolbar {
    bottom: 8px;
    padding: 5px 8px;
    gap: 4px;
    justify-content: flex-start;
  }
  .wa-toolbar-btn {
    padding: 4px 8px;
    font-size: 0.7rem;
    white-space: nowrap;
  }
}

.wa-toolbar-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  flex-shrink: 0;
}

.wa-toolbar-btn:hover {
  background: rgba(234, 88, 12, 0.35);
  border-color: #ffbd8a;
  color: #ffffff;
}

.wa-toolbar-btn.primary {
  background: linear-gradient(135deg, #ea580c, #c2410c);
  border-color: transparent;
  color: #ffffff;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(234, 88, 12, 0.4);
}

.wa-toolbar-btn.primary:hover {
  background: linear-gradient(135deg, #c2410c, #9a3412);
  transform: translateY(-1px);
}

/* Step 2 Output Preview Wrap */
#stdViewOutputWrap {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 16px;
  box-sizing: border-box;
}

.preview-box-container {
  background: #ffffff;
  padding: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 90%;
}

#stdOutputCanvas {
  max-width: 100%;
  max-height: calc(100dvh - 300px);
  object-fit: contain;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  display: block;
}

/* Studio Stats Bar */
.studio-stats-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  width: 100%;
  max-width: 650px;
  margin-top: 14px;
}

.studio-stat-item {
  background: #ffffff;
  border: 1px solid #fed7aa;
  border-radius: 6px;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 100px;
}

[data-theme="dark"] .studio-stat-item {
  background: #1f2937;
  border-color: #374151;
}

.studio-stat-label {
  font-size: 0.68rem;
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
}

.studio-stat-val {
  font-size: 0.82rem;
  font-weight: 800;
  color: #0f172a;
}

[data-theme="dark"] .studio-stat-val {
  color: #f8fafc;
}

/* Toast */
.std-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #1f2937;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.25);
  font-size: 0.85rem;
  font-weight: 700;
  z-index: 9999;
  transition: opacity 0.3s ease;
}

@media (max-width: 680px) {
  body { padding-bottom: calc(82px + env(safe-area-inset-bottom)); }
  .gov-header-inner { flex-wrap: wrap; padding: 8px 10px; gap: 8px; }
  .gov-header-nav { display: none !important; }
  .gov-brand { min-width: 0; }
  .gov-brand-title { flex-wrap: wrap; font-size: 14px; }
  .gov-brand-subtitle { font-size: 11px; }
  .header-actions { margin-left: auto; }
  #stdHeaderBtnDownload { display: none; }
  .studio-workspace-grid { gap: 10px; padding: 8px; }
  .stage-top-bar { padding: 8px; gap: 8px; }
  .stage-step-pills { width: 100%; }
  .stage-step-pill { flex: 1; justify-content: center; padding: 10px 4px; white-space: normal; }
  .stage-viewport-box { height: 46vh; min-height: 300px; padding: 8px 8px 64px; }
  #stdCropCanvas { max-height: 32vh; }
  .wa-stage-toolbar { border-radius: 12px; bottom: 8px; width: calc(100% - 16px); box-sizing: border-box; }
  .wa-toolbar-btn { min-height: 44px; }
  .sidebar-card-box { padding: 12px; }
  .sidebar-card-title { font-size: 14px; padding: 8px 0; }
  .floating-tools-sidebar input:not([type=range]):not([type=checkbox]):not([type=color]),
  .floating-tools-sidebar select { font-size: 16px !important; min-height: 44px; }
  .asset-pill, .scale-pill, .lighting-pill { min-height: 44px; }
  .lighting-pills { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #stdViewOutputWrap { padding: 4px; justify-content: flex-start; }
  #stdOutputCanvas { max-height: 23vh; }
  .studio-stats-bar { gap: 4px; margin-top: 6px; }
  .studio-stat-item { min-width: 0; padding: 4px 6px; }
  .student-mobile-actions { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000; align-items: center; gap: 12px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid #fed7aa; box-shadow: 0 -3px 15px #0001; }
  .student-mobile-actions span { flex: 1; min-width: 0; font-size: 12px; color: #334155; }
  .student-mobile-actions button { min-height: 44px; }
  .std-toast { bottom: 90px; left: 12px; right: 12px; }
}

/* Final responsive workspace rules. */
@media (min-width: 1100px) {
  .studio-workspace-grid { grid-template-columns: 290px minmax(0, 1fr) 310px; height: auto; min-height: calc(100dvh - 150px); overflow: visible; align-items: start; }
  .student-size-panel { grid-column: 1; }
  .stage-main-wrapper { grid-column: 2; grid-row: 1; position: sticky; top: 10px; height: calc(100dvh - 160px); min-height: 500px; }
  .student-adjust-panel { grid-column: 3; }
  .floating-tools-sidebar { height: auto; max-height: none; overflow: visible; }
  .sidebar-card-box { padding: 10px; gap: 8px; }
  .sidebar-card-title { flex-wrap: wrap; gap: 6px; }
  .lighting-pills { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stage-top-bar > div:last-child { gap: 5px !important; }
  .stage-top-bar .btn { font-size: 12px; }
  .stage-viewport-box { padding: 12px; }
}
.wa-stage-toolbar { position: static; transform: none; margin: 8px auto; border-radius: 10px; max-width: calc(100% - 16px); flex-wrap: wrap; overflow: visible; justify-content: center; flex-shrink: 0; }
@media (max-width: 1099px) {
  .studio-workspace-grid { grid-template-columns: minmax(0, 1fr); }
  .stage-main-wrapper { order: 0; }
  .student-size-panel { order: 1; }
  .student-adjust-panel { order: 2; }
  .floating-tools-sidebar { width: 100%; }
  .stage-viewport-box { padding-bottom: 12px; }
  .student-setup-bar { flex-wrap: wrap; gap: 8px; }
  .student-setup-bar .asset-pills { width: 100%; order: 2; }
  .student-setup-bar > .stage-live-badge { margin-left: auto; }
}
@media (max-width: 680px) {
  .wa-stage-toolbar { width: calc(100% - 16px); padding: 6px; gap: 5px; }
  .wa-toolbar-btn { flex: 1 1 28%; justify-content: center; padding: 8px 4px; }
  .stage-viewport-box { height: 42vh; min-height: 280px; padding: 8px; }
  #stdCropCanvas { max-height: 36vh; }
  .stage-top-bar > div:last-child { width: 100%; }
  #stageTopBtnDownload, #stdBtnApplyCrop { display: none; }
  .sidebar-card-box .btn { min-height: 40px; }
  .sidebar-card-box input[type=range] { min-height: 36px; }
  .student-setup-bar .asset-pill { font-size: 12px; flex-direction: column; }
  .student-setup-bar { padding: 8px; }
  .sidebar-card-title { flex-wrap: wrap; gap: 8px; }
}
