/* ==========================================================================
   PIHU TOOLS - ADMIT CARD & MARKSHEET MULTI-PDF COMPRESSOR STYLESHEET
   Unified Studio Architecture matching pdf-tools.html (.pdf-studio-theme)
   ========================================================================== */

/* Left Sidebar Controls Panel */
.pdf-studio-theme .sidebar-tools-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.pdf-studio-theme .sidebar-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  margin-bottom: 2px;
  color: #1f2d48;
  font-size: 0.8rem;
  font-weight: 700;
  border-bottom: 1px solid #e2e8f0;
}

[data-theme="dark"] .pdf-studio-theme .sidebar-section-title {
  color: #f1f5f9;
  border-color: #334155;
}

/* Sidebar Tool Cards */
.compressor-card {
  background: #ffffff;
  border: 1px solid #d9dde2;
  border-radius: 6px;
  padding: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .compressor-card {
  background: #1e293b;
  border-color: #334155;
}

.compressor-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #f1f5f9;
}

[data-theme="dark"] .compressor-card-header {
  border-color: #334155;
}

.compressor-card-title {
  font-size: 0.82rem;
  font-weight: 800;
  color: #1f2d48;
  display: flex;
  align-items: center;
  gap: 6px;
}

[data-theme="dark"] .compressor-card-title {
  color: #f8fafc;
}

.compressor-step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #2563eb;
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Preset Chips Grid */
.preset-chips-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.preset-chip-btn {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
  min-height: 64px;
}

[data-theme="dark"] .preset-chip-btn {
  background: #0f172a;
  border-color: #334155;
}

.preset-chip-btn b {
  font-size: 0.74rem;
  font-weight: 800;
  color: #1f2d48;
  line-height: 1.25;
}

[data-theme="dark"] .preset-chip-btn b {
  color: #f8fafc;
}

.preset-chip-btn small {
  font-size: 0.63rem;
  color: #64748b;
  line-height: 1.2;
}

[data-theme="dark"] .preset-chip-btn small {
  color: #94a3b8;
}

.preset-chip-btn:hover {
  border-color: #93c5fd;
  background: #f8fbff;
}

[data-theme="dark"] .preset-chip-btn:hover {
  background: #1e293b;
  border-color: #60a5fa;
}

.preset-chip-btn.active {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: inset 3px 0 #2563eb;
}

[data-theme="dark"] .preset-chip-btn.active {
  background: #1e3a8a33;
  border-color: #3b82f6;
  box-shadow: inset 3px 0 #60a5fa;
}

.preset-chip-btn.active b {
  color: #2563eb;
}

[data-theme="dark"] .preset-chip-btn.active b {
  color: #60a5fa;
}

/* Form Fields & Grid */
.gov-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.gov-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
  min-width: 0;
}

.gov-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #1f2d48;
}

[data-theme="dark"] .gov-label {
  color: #e2e8f0;
}

.gov-input,
.gov-select {
  width: 100%;
  padding: 6px 8px;
  font-size: 0.78rem;
  font-family: inherit;
  font-weight: 600;
  color: #1e293b;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}

[data-theme="dark"] .gov-input,
[data-theme="dark"] .gov-select {
  background: #0f172a;
  border-color: #334155;
  color: #f8fafc;
}

.gov-input:focus,
.gov-select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.gov-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.74rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
  cursor: pointer;
  user-select: none;
}

[data-theme="dark"] .gov-check-row {
  color: #cbd5e1;
}

.gov-check-row input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: #2563eb;
  cursor: pointer;
}

/* Border Tool Box */
.border-tool-box {
  background: #eff6ff;
  border: 1px dashed #93c5fd;
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 10px;
}

[data-theme="dark"] .border-tool-box {
  background: #1e293b;
  border-color: #3b82f6;
}

/* Realtime Stats Grid */
.gov-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 8px 6px;
  text-align: center;
  margin-bottom: 10px;
}

[data-theme="dark"] .gov-stats-grid {
  background: #0f172a;
  border-color: #334155;
}

.gov-stat-item span {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.2px;
  margin-bottom: 2px;
}

.gov-stat-item b {
  font-size: 0.82rem;
  font-weight: 800;
  color: #0f172a;
}

[data-theme="dark"] .gov-stat-item b {
  color: #f8fafc;
}

.compression-review-hint {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
  padding: 8px 10px;
  border-left: 3px solid #2563eb;
  border-radius: 4px;
  background: #eff6ff;
  color: #1e40af;
  font-size: 0.72rem;
  line-height: 1.35;
}

[data-theme="dark"] .compression-review-hint {
  background: #1e293b;
  color: #93c5fd;
  border-color: #3b82f6;
}

.compression-review-hint span {
  color: #64748b;
  font-size: 0.66rem;
}

[data-theme="dark"] .compression-review-hint span {
  color: #94a3b8;
}

.gov-status-box {
  font-size: 0.75rem;
  font-weight: 600;
  color: #334155;
  padding: 8px 10px;
  border-radius: 6px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  word-break: break-word;
}

[data-theme="dark"] .gov-status-box {
  background: #0f172a;
  border-color: #334155;
  color: #cbd5e1;
}

.gov-status-box.success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #15803d;
}

.gov-status-box.warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #b45309;
}

.gov-status-box.error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}

.gov-progress-wrap {
  margin-bottom: 10px;
}

.gov-progress-bar {
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: #e2e8f0;
  overflow: hidden;
  appearance: none;
  border: none;
}

.gov-progress-bar::-webkit-progress-bar {
  background: #e2e8f0;
}

.gov-progress-bar::-webkit-progress-value {
  background: linear-gradient(90deg, #2563eb 0%, #ea580c 100%);
}

/* Action Buttons (Gov & Tool Style) */
.gov-btn,
.btn {
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-decoration: none;
  user-select: none;
  box-sizing: border-box;
}

.gov-btn:disabled,
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.gov-btn-primary,
.btn-primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}

.gov-btn-primary:hover:not(:disabled),
.btn-primary:hover:not(:disabled) {
  background: #1d4ed8;
  border-color: #1d4ed8;
}

.gov-btn-secondary,
.btn-secondary {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #334155;
}

[data-theme="dark"] .gov-btn-secondary,
[data-theme="dark"] .btn-secondary {
  background: #1e293b;
  border-color: #334155;
  color: #f8fafc;
}

.gov-btn-secondary:hover:not(:disabled),
.btn-secondary:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: #94a3b8;
}

[data-theme="dark"] .gov-btn-secondary:hover:not(:disabled),
[data-theme="dark"] .btn-secondary:hover:not(:disabled) {
  background: #334155;
}

.gov-btn-danger,
.btn-danger {
  background: #fee2e2;
  border-color: #fecaca;
  color: #dc2626;
}

.gov-btn-danger:hover:not(:disabled),
.btn-danger:hover:not(:disabled) {
  background: #fca5a5;
}

.gov-btn-orange {
  background: #ea580c;
  border-color: #ea580c;
  color: #ffffff;
}

.gov-btn-orange:hover:not(:disabled) {
  background: #c2410c;
}

.gov-btn-green {
  background: #16a34a;
  border-color: #16a34a;
  color: #ffffff;
}

.gov-btn-green:hover:not(:disabled) {
  background: #15803d;
}

.gov-btn-sm,
.btn-sm {
  padding: 4px 8px;
  font-size: 0.72rem;
}

/* ==========================================================================
   STAGE MAIN & CARDS (.has-files)
   ========================================================================== */
.gov-stage-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #e2e5e9;
  overflow-y: auto;
  box-sizing: border-box;
  min-height: 540px;
}

[data-theme="dark"] .gov-stage-main {
  background: #0b1120;
}

/* Welcome dropzone in initial empty state */
.gov-stage-main .studio-welcome-dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* When files are loaded */
.gov-stage-main.has-files {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 14px;
  align-items: start;
  padding: 14px;
}

.gov-stage-main.has-files #cardPdfQueue,
.gov-stage-main.has-files #cardPageSelector {
  grid-column: 1;
  min-width: 0;
  margin-top: 0 !important;
}

.gov-stage-main.has-files #cardLivePreview {
  grid-column: 2;
  grid-row: 1 / span 2;
  min-width: 0;
  margin-top: 0 !important;
  position: sticky;
  top: 14px;
}

/* Cards on Main Stage */
.gov-stage-main .gov-card {
  background: #ffffff;
  border: 1px solid #d9dde2;
  border-radius: 6px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .gov-stage-main .gov-card {
  background: #1e293b;
  border-color: #334155;
}

.gov-stage-main .gov-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}

[data-theme="dark"] .gov-stage-main .gov-card-header {
  border-color: #334155;
}

.gov-stage-main .gov-card-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: #1f2d48;
}

[data-theme="dark"] .gov-stage-main .gov-card-title {
  color: #f8fafc;
}

.gov-badge-official {
  font-size: 0.72rem;
  font-weight: 800;
  color: #2563eb;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 3px 8px;
  border-radius: 4px;
}

[data-theme="dark"] .gov-badge-official {
  background: #1e3a8a33;
  border-color: #3b82f6;
  color: #60a5fa;
}

/* PDF Files Queue List */
.pdf-queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e8f0;
}

[data-theme="dark"] .pdf-queue-header {
  border-color: #334155;
}

.pdf-queue-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: #1f2d48;
}

[data-theme="dark"] .pdf-queue-title {
  color: #f8fafc;
}

.pdf-queue-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pdf-queue-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}

.pdf-queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

[data-theme="dark"] .pdf-queue-item {
  background: #0f172a;
  border-color: #334155;
}

.pdf-queue-item:hover {
  border-color: #93c5fd;
  background: #ffffff;
}

[data-theme="dark"] .pdf-queue-item:hover {
  background: #1e293b;
  border-color: #3b82f6;
}

.pdf-queue-item.active {
  background: #eff6ff;
  border-color: #93c5fd;
  box-shadow: inset 3px 0 #2563eb;
}

[data-theme="dark"] .pdf-queue-item.active {
  background: #1e3a8a26;
  border-color: #3b82f6;
  box-shadow: inset 3px 0 #60a5fa;
}

.pdf-queue-checkbox {
  width: 16px;
  height: 16px;
  accent-color: #2563eb;
  cursor: pointer;
  flex-shrink: 0;
}

.pdf-queue-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.pdf-queue-meta {
  flex: 1;
  min-width: 0;
}

.pdf-queue-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

[data-theme="dark"] .pdf-queue-name {
  color: #f8fafc;
}

.pdf-queue-details {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  color: #64748b;
  font-weight: 600;
  flex-wrap: wrap;
}

.pdf-status-pill {
  font-size: 0.64rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.pdf-status-pill.ready { background: #e2e8f0; color: #334155; }
.pdf-status-pill.compressing { background: #dbeafe; color: #1d4ed8; }
.pdf-status-pill.done { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.pdf-status-pill.warning { background: #fef3c7; color: #b45309; }
.pdf-status-pill.error { background: #fee2e2; color: #b91c1c; }

.pdf-queue-item-btns {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.pdf-queue-item-btns .btn-compress-single {
  background: #1e3a8a;
  border-color: #1e3a8a;
  color: #ffffff;
}

.pdf-queue-item-btns .btn-compress-single:hover:not(:disabled) {
  background: #2563eb;
  border-color: #2563eb;
}

/* Active PDF Page Inspector & Selection Grid */
.pdf-pages-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}

.pdf-page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
  gap: 10px;
  max-height: 360px;
  overflow-y: auto;
  padding: 2px;
}

.pdf-page-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  user-select: none;
}

[data-theme="dark"] .pdf-page-card {
  background: #0f172a;
  border-color: #334155;
}

.pdf-page-card:hover {
  border-color: #93c5fd;
  transform: translateY(-1px);
}

.pdf-page-card.selected {
  border-color: #2563eb;
  background: #f0fdf4;
}

[data-theme="dark"] .pdf-page-card.selected {
  background: #14532d2b;
  border-color: #22c55e;
}

.pdf-page-card.active-preview {
  box-shadow: 0 0 0 2px #ea580c;
}

.pdf-page-card input[type="checkbox"] {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 15px;
  height: 15px;
  accent-color: #2563eb;
  cursor: pointer;
  z-index: 2;
}

.pdf-page-thumb {
  width: 100%;
  height: 120px;
  object-fit: contain;
  background: #f8fafc;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
  margin-bottom: 4px;
}

[data-theme="dark"] .pdf-page-thumb {
  background: #1e293b;
  border-color: #334155;
}

.pdf-page-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: #1f2d48;
}

[data-theme="dark"] .pdf-page-label {
  color: #e2e8f0;
}

/* Live High-Res Stage Preview */
.pdf-live-stage {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 440px;
  position: relative;
}

[data-theme="dark"] .pdf-live-stage {
  background: #0f172a;
  border-color: #334155;
}

.pdf-stage-toolbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e2e8f0;
}

[data-theme="dark"] .pdf-stage-toolbar {
  border-color: #334155;
}

.pdf-stage-canvas-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  max-height: 520px;
  padding: 10px;
  background: #e2e5e9;
  border-radius: 4px;
  box-sizing: border-box;
}

[data-theme="dark"] .pdf-stage-canvas-wrap {
  background: #020617;
}

#pdfLiveCanvas {
  max-width: 100%;
  height: auto;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  border-radius: 4px;
  background: #ffffff;
}

#pdfLiveCanvas.is-zoomed {
  max-width: none;
}

/* Toast Container */
.gov-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  background: rgba(15, 23, 42, 0.95);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  transform: translateY(100px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.gov-toast.show {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Responsive Adjustments */
@media (max-width: 1100px) {
  .gov-stage-main.has-files {
    grid-template-columns: minmax(0, 1fr);
  }

  .gov-stage-main.has-files #cardLivePreview {
    grid-column: 1;
    grid-row: auto;
    position: static;
  }
}

@media (max-width: 768px) {
  .preset-chips-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .gov-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .pdf-queue-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .pdf-queue-item-btns {
    width: 100%;
    justify-content: flex-end;
  }
}
