/* ==========================================================================
   DCAS FYUGP Question Paper Maker — Modern UI Design System
   ========================================================================== */

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #475569;
  --text-light: #64748b;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft: #eff6ff;
  --accent: #dc2626;
  --accent-soft: #fef2f2;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.14);
  --font-ui: 'Segoe UI Variable', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-ui);
  font-size: 13.5px;
  color: var(--text);
  background: var(--bg);
  letter-spacing: -0.008em;
  -webkit-font-smoothing: antialiased;
}

/* Subtle Top Progress Bar */
.top-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: #1d4ed8;
  z-index: 999;
  opacity: 0;
  transition: width 0.25s ease, opacity 0.2s ease;
}

.top-progress.active {
  opacity: 1;
  width: 78%;
}

.top-progress.done {
  opacity: 0;
  width: 100%;
}

/* Top Navigation Bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 20px;
  background: #ffffff;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-badge {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #1e3a8a;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.brand-text h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.brand-text span {
  font-size: 11.5px;
  color: var(--text-light);
  display: block;
}

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.btn:hover:not(:disabled) {
  background: var(--surface-alt);
  border-color: var(--border-strong);
  transform: translateY(-0.5px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 1px 3px rgba(29, 78, 216, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-accent:hover:not(:disabled) {
  background: #b91c1c;
  border-color: #b91c1c;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.btn-ghost:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: transparent;
}

.btn-pill {
  border-radius: 999px;
}

.btn-sm {
  padding: 5.5px 11px;
  font-size: 12px;
}

/* Segmented Toggles */
.segmented {
  display: inline-flex;
  background: #eef2f6;
  padding: 3px;
  border-radius: 9px;
  border: 1px solid var(--border);
  gap: 2px;
  width: 100%;
}

.segmented button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 6px 10px;
  border-radius: 7px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.segmented button.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-xs);
}

/* Section Editor Tabs */
.sec-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: #eef2f6;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}

.sec-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 8px;
  border: none;
  border-radius: 7px;
  background: transparent;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.sec-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.sec-panel {
  display: none;
}

.sec-panel.active {
  display: block;
  animation: fadeIn 0.14s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Sliding Switch */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track {
  width: 38px;
  height: 22px;
  background: #cbd5e1;
  border-radius: 999px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.switch-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}

.switch input:checked + .switch-track {
  background: var(--primary);
}

.switch input:checked + .switch-track::after {
  transform: translateX(16px);
}

/* Mobile View Switcher */
.mobile-tabs {
  display: none;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  gap: 8px;
}

/* Main Workspace Layout */
.workspace {
  display: grid;
  grid-template-columns: minmax(410px, 510px) 1fr;
  height: calc(100vh - 57px);
  overflow: hidden;
}

.editor-pane {
  overflow-y: auto;
  padding: 14px 18px 60px;
  border-right: 1px solid var(--border);
  background: var(--bg);
}

.preview-pane {
  overflow: auto;
  padding: 16px 24px 40px;
  background-color: #e5e7eb;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.preview-toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  max-width: 210mm;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  padding: 9px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.toolbar-select {
  appearance: none;
  padding: 5.5px 26px 5.5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

.toolbar-select:hover {
  border-color: var(--border-strong);
}

.filename-pill {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Preview Zoom Wrapper */
.preview-stage {
  display: flex;
  justify-content: center;
  width: 100%;
}

.paper-sheet.zoom-75 {
  zoom: 0.78;
}

.paper-sheet.zoom-100 {
  zoom: 1;
}

@media print {
  .paper-sheet.zoom-75,
  .paper-sheet.zoom-100 {
    zoom: 1 !important;
  }
}

/* Cards & Form Controls */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 11px;
}

.card-title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 7px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 9px;
}

.field:last-child {
  margin-bottom: 0;
}

.field label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 7.5px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

.field input:disabled,
.field select:disabled {
  background: var(--surface-alt);
  color: var(--text-light);
  cursor: not-allowed;
}

.field textarea {
  resize: vertical;
  min-height: 220px;
  line-height: 1.52;
  font-size: 13px;
}

/* Collapsible College Header */
.college-details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  background: var(--surface-alt);
  margin-bottom: 10px;
}

.college-details summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
}

.college-details summary::-webkit-details-marker {
  display: none;
}

.college-details[open] summary {
  margin-bottom: 8px;
}

/* Badges & Status Pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2.5px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.badge-ok {
  background: var(--success-soft);
  color: var(--success);
}

.badge-warn {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge-info {
  background: var(--primary-soft);
  color: var(--primary);
}

.badge-lock {
  background: #e2e8f0;
  color: var(--text-muted);
}

/* Pattern Summary Strip */
.pattern-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  padding: 8px 11px;
  background: var(--primary-soft);
  border: 1px solid #dbeafe;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  color: #1e40af;
  margin-top: 10px;
}

.pattern-strip strong {
  font-weight: 700;
}

.section-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.helper-hint {
  font-size: 11.5px;
  color: var(--text-light);
  margin-top: 7px;
  line-height: 1.45;
}

.helper-hint code {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--primary);
}

/* Upload Dropzone */
.upload-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: 12px;
}

.upload-bar p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

/* Search Input with Clear Button */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-wrap input {
  width: 100%;
  padding: 8px 30px 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.search-clear {
  position: absolute;
  right: 6px;
  border: none;
  background: transparent;
  color: var(--text-light);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 5px;
  display: none;
}

.search-clear.visible {
  display: block;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
}

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--surface-alt);
}

/* Question Bank List */
.bank-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.bank-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.15s;
}

.bank-item:hover {
  border-color: var(--border-strong);
}

.bank-item-meta h4 {
  margin: 0 0 2px;
  font-size: 13.5px;
  color: var(--text);
}

.bank-item-meta p {
  margin: 0;
  font-size: 12px;
  color: var(--text-light);
}

.bank-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* Password Show/Hide wrapper */
.pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.pw-wrap input {
  padding-right: 60px;
}

.pw-toggle {
  position: absolute;
  right: 6px;
  border: none;
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  background: #0f172a;
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* Responsive */
@media (max-width: 1024px) {
  .mobile-tabs {
    display: flex;
  }

  .workspace {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - 102px);
    overflow: visible;
  }

  .editor-pane,
  .preview-pane {
    display: none;
    height: auto;
    overflow: visible;
  }

  .editor-pane.mobile-active,
  .preview-pane.mobile-active {
    display: flex;
    flex-direction: column;
  }
}

@media (max-width: 600px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .topbar {
    padding: 10px 12px;
  }
}
