/* ══════════════════════════════════════════════
   IMG → PDF  |  style.css
   Theme: UniversityNotes.co.in
   Light, clean, academic — blue primary accent
   ══════════════════════════════════════════════ */

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

:root {
  --bg:        #f4f6fb;
  --surface:   #ffffff;
  --surface2:  #f0f4ff;
  --border:    #dde3f0;
  --accent:    #2563eb;
  --accent-h:  #1d4ed8;
  --accent-bg: #eff6ff;
  --danger:    #dc2626;
  --warn:      #d97706;
  --success:   #16a34a;
  --text:      #1e293b;
  --sub:       #475569;
  --muted:     #94a3b8;
  --mono:      'JetBrains Mono', 'Fira Mono', monospace;
  --display:   'Nunito', 'Poppins', sans-serif;
  --body:      'Nunito', sans-serif;
  --r:         10px;
  --shadow-sm: 0 1px 3px rgba(37,99,235,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 16px rgba(37,99,235,.10), 0 2px 6px rgba(0,0,0,.06);
  --shadow-lg: 0 8px 32px rgba(37,99,235,.13), 0 4px 12px rgba(0,0,0,.08);
}

html, body { height: 100%; }

body {
  background:  var(--bg);
  color:       var(--text);
  font-family: var(--body);
  font-size:   14px;
  overflow-x:  hidden;
  line-height: 1.6;
}

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500&display=swap');

/* ══════════════════════════════════════
   TOP NAV BAR — matches universitynotes
   ══════════════════════════════════════ */
.topbar {
  background:    var(--accent);
  padding:       0 28px;
  height:        52px;
  display:       flex;
  align-items:   center;
  justify-content: space-between;
  box-shadow:    0 2px 8px rgba(37,99,235,.25);
  position:      sticky;
  top:           0;
  z-index:       100;
}

.topbar-logo {
  display:     flex;
  align-items: center;
  gap:         10px;
  text-decoration: none;
}

.topbar-logo-icon {
  width:         32px;
  height:        32px;
  background:    #fff;
  border-radius: 8px;
  display:       flex;
  align-items:   center;
  justify-content: center;
  font-size:     18px;
}

.topbar-logo-text {
  font-family:    var(--display);
  font-weight:    800;
  font-size:      1.1rem;
  color:          #fff;
  letter-spacing: -.3px;
}

.topbar-logo-text span {
  opacity: .75;
  font-weight: 600;
}

.topbar-back {
  font-size:     13px;
  color:         rgba(255,255,255,.85);
  text-decoration: none;
  display:       flex;
  align-items:   center;
  gap:           5px;
  transition:    color .15s;
}
.topbar-back:hover { color: #fff; }

/* ══════════════════════════════════════
   PAGE WRAPPER
   ══════════════════════════════════════ */
.page-wrap {
  max-width:  960px;
  margin:     0 auto;
  padding:    28px 20px 48px;
  display:    flex;
  flex-direction: column;
  gap:        24px;
}

/* ══════════════════════════════════════
   HERO HEADER
   ══════════════════════════════════════ */
.hero {
  background:    linear-gradient(135deg, var(--accent) 0%, #1d4ed8 100%);
  border-radius: 16px;
  padding:       28px 32px;
  color:         #fff;
  display:       flex;
  align-items:   center;
  gap:           20px;
  box-shadow:    var(--shadow-lg);
  position:      relative;
  overflow:      hidden;
}

.hero::before {
  content: '';
  position: absolute;
  right: -40px; top: -40px;
  width: 200px; height: 200px;
  background: rgba(255,255,255,.06);
  border-radius: 50%;
}
.hero::after {
  content: '';
  position: absolute;
  right: 60px; bottom: -60px;
  width: 140px; height: 140px;
  background: rgba(255,255,255,.05);
  border-radius: 50%;
}

.hero-icon {
  font-size:     2.8rem;
  flex-shrink:   0;
  filter:        drop-shadow(0 2px 8px rgba(0,0,0,.2));
}

.hero-text h1 {
  font-family:    var(--display);
  font-size:      1.6rem;
  font-weight:    800;
  letter-spacing: -.5px;
  line-height:    1.2;
}

.hero-text p {
  font-size:  13px;
  opacity:    .85;
  margin-top: 5px;
  font-weight: 500;
}

/* ══════════════════════════════════════
   MAIN GRID
   ══════════════════════════════════════ */
.main-grid {
  display: grid;
  gap:     20px;
  grid-template-columns: 1fr;
}

@media (min-width: 700px) {
  .main-grid {
    grid-template-columns: 320px 1fr;
    align-items: start;
  }
}

/* ══════════════════════════════════════
   CARD BASE
   ══════════════════════════════════════ */
.card {
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: var(--r);
  box-shadow:    var(--shadow-sm);
}

/* ══════════════════════════════════════
   LEFT COLUMN
   ══════════════════════════════════════ */
.left-col {
  display:        flex;
  flex-direction: column;
  gap:            16px;
}

/* ── Drop zone ── */
.dropzone {
  border:        2px dashed var(--border);
  border-radius: var(--r);
  background:    var(--accent-bg);
  padding:       32px 20px;
  text-align:    center;
  cursor:        pointer;
  position:      relative;
  transition:    border-color .2s, background .2s, box-shadow .2s;
  display:       flex;
  flex-direction: column;
  align-items:   center;
  gap:           8px;
}
.dropzone input[type="file"] {
  position: absolute; inset: 0;
  opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--accent);
  background:   #dbeafe;
  box-shadow:   0 0 0 4px rgba(37,99,235,.1);
}

.dz-icon  { font-size: 2.4rem; line-height: 1; }
.dz-title {
  font-family: var(--display);
  font-size:   1rem;
  font-weight: 700;
  color:       var(--accent);
}
.dz-sub { font-size: 12px; color: var(--muted); }

/* ── Options panel ── */
.options-panel {
  display:        flex;
  flex-direction: column;
  gap:            14px;
  padding:        18px;
  background:     var(--surface);
  border:         1px solid var(--border);
  border-radius:  var(--r);
  box-shadow:     var(--shadow-sm);
}

.options-title {
  font-size:      11px;
  font-weight:    700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color:          var(--muted);
  margin-bottom:  2px;
}

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

.opt-group { display: flex; flex-direction: column; gap: 5px; }

.opt-group label {
  font-size:      11px;
  font-weight:    700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color:          var(--sub);
}

.opt-group select {
  width:         100%;
  background:    var(--bg);
  border:        1.5px solid var(--border);
  color:         var(--text);
  font-family:   var(--body);
  font-size:     13px;
  font-weight:   500;
  padding:       9px 12px;
  border-radius: 8px;
  outline:       none;
  appearance:    none;
  cursor:        pointer;
  transition:    border-color .15s, box-shadow .15s;
  background-image: 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='%2394a3b8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.opt-group select:focus {
  border-color: var(--accent);
  box-shadow:   0 0 0 3px rgba(37,99,235,.12);
}

/* ── Action row ── */
.action-row {
  display: flex;
  gap:     10px;
}

.btn-convert {
  flex:           1;
  font-family:    var(--display);
  font-weight:    800;
  font-size:      .95rem;
  padding:        13px 20px;
  background:     var(--accent);
  color:          #fff;
  border:         none;
  border-radius:  var(--r);
  cursor:         pointer;
  transition:     background .15s, transform .15s, box-shadow .15s;
  box-shadow:     0 4px 12px rgba(37,99,235,.3);
}
.btn-convert:hover:not(:disabled) {
  background:  var(--accent-h);
  transform:   translateY(-1px);
  box-shadow:  0 6px 20px rgba(37,99,235,.35);
}
.btn-convert:disabled {
  background:  #93c5fd;
  box-shadow:  none;
  cursor:      not-allowed;
}

.btn-add {
  font-family:   var(--body);
  font-size:     13px;
  font-weight:   600;
  padding:       13px 16px;
  background:    var(--bg);
  border:        1.5px solid var(--border);
  color:         var(--sub);
  border-radius: var(--r);
  cursor:        pointer;
  position:      relative;
  white-space:   nowrap;
  transition:    border-color .15s, color .15s;
}
.btn-add input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%;
}
.btn-add:hover { border-color: var(--accent); color: var(--accent); }

/* ── Batch info ── */
.batch-info {
  display:       none;
  font-size:     12px;
  color:         var(--sub);
  background:    var(--accent-bg);
  border:        1px solid #bfdbfe;
  border-radius: var(--r);
  padding:       9px 13px;
  font-weight:   500;
}
.batch-info.visible { display: block; }

/* ── Drive toggle ── */
.drive-toggle {
  display:       flex;
  align-items:   center;
  gap:           12px;
  padding:       12px 14px;
  background:    var(--bg);
  border:        1.5px solid var(--border);
  border-radius: var(--r);
  cursor:        pointer;
  user-select:   none;
  transition:    border-color .2s, background .2s;
}
.drive-toggle:hover          { border-color: var(--accent); background: var(--accent-bg); }
.drive-toggle input[type="checkbox"] { display: none; }

.toggle-track {
  position:      relative;
  width:         38px; height: 22px; flex-shrink: 0;
  background:    var(--border);
  border-radius: 11px;
  transition:    background .2s;
}
.toggle-thumb {
  position:    absolute; top: 3px; left: 3px;
  width: 16px; height: 16px;
  background:    #fff;
  border-radius: 50%;
  box-shadow:    0 1px 3px rgba(0,0,0,.2);
  transition:    transform .2s;
}
.toggle-track.on              { background: var(--accent); }
.toggle-track.on .toggle-thumb { transform: translateX(16px); }

.toggle-text  { display: flex; flex-direction: column; gap: 2px; }
.toggle-title { font-size: 13px; color: var(--text); font-weight: 600; }
.toggle-sub   { font-size: 11px; color: var(--muted); }

/* ══════════════════════════════════════
   RIGHT COLUMN
   ══════════════════════════════════════ */
.right-col {
  display:        flex;
  flex-direction: column;
  gap:            16px;
  min-width:      0;
}

/* ── Preview section ── */
#preview-section {
  display:       block; /* always visible */
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: var(--r);
  padding:       16px;
  box-shadow:    var(--shadow-sm);
}

/* Empty state — shown when no images selected */
.preview-empty {
  display:        flex;
  flex-direction: column;
  align-items:    center;
  justify-content: center;
  gap:            8px;
  min-height:     160px;
  color:          var(--muted);
  font-size:      13px;
  font-weight:    500;
}
.preview-empty-icon { font-size: 2rem; opacity: .4; }

.preview-header {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  margin-bottom:   12px;
  gap:             10px;
  flex-wrap:       wrap;
}

.img-count {
  font-size:   12px;
  font-weight: 700;
  color:       var(--accent);
  background:  var(--accent-bg);
  padding:     3px 10px;
  border-radius: 20px;
  border:      1px solid #bfdbfe;
}

.preview-header-right { display: flex; align-items: center; gap: 12px; }

.size-inline { display: flex; align-items: center; gap: 8px; }
.size-track {
  width: 80px; height: 5px;
  background: var(--border); border-radius: 3px; overflow: hidden;
}
.size-fill {
  height: 100%; background: var(--accent);
  border-radius: 3px; transition: width .3s, background .3s; width: 0%;
}
.size-fill.warning { background: var(--warn); }
.size-fill.danger  { background: var(--danger); }
.size-txt { font-size: 11px; color: var(--muted); white-space: nowrap; font-weight: 600; }

.clear-btn {
  font-size:     12px;
  font-weight:   600;
  color:         var(--danger);
  background:    none;
  border:        1.5px solid #fca5a5;
  padding:       4px 10px;
  border-radius: var(--r);
  cursor:        pointer;
  transition:    background .15s;
}
.clear-btn:hover { background: #fef2f2; }

/* ── Thumbnail grid — fixed height, internal scroll ── */
.grid {
  display:               grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap:                   8px;
  max-height:            240px;
  overflow-y:            auto;
  overflow-x:            hidden;
  /* thin scrollbar */
  scrollbar-width:       thin;
  scrollbar-color:       var(--border) transparent;
  padding-right:         2px; /* prevent clipping on scroll */
}
.grid::-webkit-scrollbar       { width: 5px; }
.grid::-webkit-scrollbar-track { background: transparent; }
.grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

@media (min-width: 700px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    max-height:            260px;
  }
}

.thumb-wrap {
  position: relative; aspect-ratio: 1;
  border-radius: 8px; overflow: hidden;
  border: 2px solid var(--border); background: var(--bg);
  cursor: grab; transition: transform .15s, box-shadow .15s;
}
.thumb-wrap:hover       { transform: scale(1.04); box-shadow: var(--shadow); }
.thumb-wrap.dragging    { opacity: .4; cursor: grabbing; }
.thumb-wrap.drag-target { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,.2); }

.thumb-wrap img { width:100%; height:100%; object-fit:cover; display:block; pointer-events:none; }

.thumb-remove {
  position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px;
  background: var(--danger); color: #fff; border: none; border-radius: 50%;
  font-size: 13px; cursor: pointer; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s;
}
.thumb-wrap:hover .thumb-remove { opacity: 1; }

.thumb-order {
  position: absolute; bottom: 3px; left: 3px;
  background: rgba(37,99,235,.85); color: #fff;
  font-size: 9px; font-weight: 700; padding: 2px 5px; border-radius: 4px;
  pointer-events: none;
}

/* ── Size warning ── */
.size-warn {
  margin-top:    10px;
  font-size:     12px;
  font-weight:   500;
  color:         var(--danger);
  background:    #fef2f2;
  border:        1px solid #fca5a5;
  border-radius: var(--r);
  padding:       9px 13px;
}

/* ── Status box ── */
#status-box { display: none; }

.status-inner {
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: var(--r);
  padding:       18px 20px;
  box-shadow:    var(--shadow-sm);
}

.status-step {
  display:      flex;
  align-items:  center;
  gap:          12px;
  padding:      10px 0;
  font-size:    13px;
  font-weight:  500;
  color:        var(--muted);
  border-bottom: 1px solid var(--border);
  transition:   color .2s;
}
.status-step:last-child { border-bottom: none; }
.status-step.active { color: var(--accent); }
.status-step.done   { color: var(--success); }
.status-step.error  { color: var(--danger); }

.step-icon {
  font-size: 1.1rem; flex-shrink: 0;
  filter: grayscale(1) opacity(.3); transition: filter .2s;
}
.status-step.active .step-icon,
.status-step.done   .step-icon,
.status-step.error  .step-icon { filter: none; }

.step-left  { flex: 1; }
.step-label { font-size: 13px; font-weight: 600; display: block; }
.step-detail {
  font-size: 11px; color: var(--muted); display: block; margin-top: 2px;
}
.status-step.error .step-detail { color: var(--danger); }

/* ── Result box ── */
#result-box { display: none; }

.result-card {
  background:    var(--surface);
  border:        2px solid var(--accent);
  border-radius: var(--r);
  padding:       18px 20px;
  display:       flex;
  align-items:   center;
  gap:           16px;
  box-shadow:    0 4px 16px rgba(37,99,235,.12);
}
.result-icon { font-size: 2.4rem; flex-shrink: 0; }
.result-info { flex: 1; min-width: 0; }
.result-info h4 {
  font-family:   var(--display);
  font-size:     1rem;
  font-weight:   800;
  white-space:   nowrap;
  overflow:      hidden;
  text-overflow: ellipsis;
  color:         var(--text);
}
.result-info p { font-size: 12px; color: var(--muted); margin-top: 3px; font-weight: 500; }

.result-btns { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }

/* countdown */
.auto-dl-hint {
  display:     flex;
  align-items: center;
  gap:         8px;
  font-size:   12px;
  color:       var(--sub);
  font-weight: 500;
  transition:  opacity .3s;
}
.auto-dl-hint.hidden { opacity: 0; pointer-events: none; }

.countdown-ring { position: relative; width: 20px; height: 20px; flex-shrink: 0; }
.countdown-ring svg { transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--border); stroke-width: 2; }
.ring-fill  {
  fill: none; stroke: var(--accent); stroke-width: 2;
  stroke-linecap: round; stroke-dasharray: 44; stroke-dashoffset: 0;
  transition: stroke-dashoffset .1s linear;
}
.countdown-num {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 8px; font-weight: 700; color: var(--accent);
  transform: rotate(90deg);
}

/* buttons */
.btn-dl {
  display:       block;
  font-family:   var(--display);
  font-size:     14px;
  font-weight:   800;
  padding:       13px 20px;
  background:    var(--accent);
  color:         #fff;
  border:        none;
  border-radius: var(--r);
  cursor:        pointer;
  text-decoration: none;
  text-align:    center;
  transition:    background .15s, box-shadow .15s;
  box-shadow:    0 4px 12px rgba(37,99,235,.3);
}
.btn-dl:hover { background: var(--accent-h); box-shadow: 0 6px 20px rgba(37,99,235,.35); }

.btn-drive-upload {
  font-family:   var(--body);
  font-size:     13px;
  font-weight:   700;
  padding:       12px 20px;
  background:    var(--accent-bg);
  border:        1.5px solid var(--accent);
  color:         var(--accent);
  border-radius: var(--r);
  cursor:        pointer;
  text-align:    center;
  transition:    background .15s;
}
.btn-drive-upload:hover   { background: #dbeafe; }
.btn-drive-upload:disabled { opacity: .6; cursor: not-allowed; }

.btn-share {
  font-family:   var(--body);
  font-size:     13px;
  font-weight:   700;
  padding:       11px 20px;
  background:    none;
  border:        1.5px solid var(--border);
  color:         var(--sub);
  border-radius: var(--r);
  cursor:        pointer;
  text-align:    center;
  transition:    border-color .15s, color .15s;
}
.btn-share:hover { border-color: var(--accent); color: var(--accent); }

.share-panel {
  display:       flex;
  gap:           8px;
  background:    var(--bg);
  border:        1px solid var(--border);
  border-radius: var(--r);
  padding:       10px;
}
.share-input {
  flex:          1;
  background:    var(--surface);
  border:        1.5px solid var(--border);
  color:         var(--sub);
  font-family:   var(--mono);
  font-size:     11px;
  padding:       7px 10px;
  border-radius: 8px;
  outline:       none;
  min-width:     0;
}
.btn-copy {
  font-family:   var(--body);
  font-size:     12px;
  font-weight:   700;
  padding:       7px 16px;
  background:    var(--accent);
  color:         #fff;
  border:        none;
  border-radius: 8px;
  cursor:        pointer;
  white-space:   nowrap;
  transition:    background .15s;
}
.btn-copy:hover { background: var(--accent-h); }

/* share size limit */
.share-size-limit {
  font-size:     12px;
  font-weight:   500;
  color:         var(--sub);
  background:    var(--bg);
  border:        1px solid var(--border);
  border-radius: var(--r);
  padding:       10px 14px;
  line-height:   1.6;
}

/* ── Toast ── */
.toast {
  position:    fixed;
  bottom:      28px;
  left:        50%;
  transform:   translateX(-50%) translateY(80px);
  background:  var(--accent);
  color:       #fff;
  font-family: var(--body);
  font-size:   13px;
  font-weight: 700;
  padding:     12px 28px;
  border-radius: 20px;
  box-shadow:  0 4px 16px rgba(37,99,235,.35);
  transition:  transform .3s, opacity .3s;
  opacity:     0;
  pointer-events: none;
  z-index:     999;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ══════════════════════════════════════
   FOOTER
   ══════════════════════════════════════ */
.page-footer {
  text-align:  center;
  font-size:   12px;
  color:       var(--muted);
  padding-top: 8px;
  border-top:  1px solid var(--border);
}
.page-footer a { color: var(--accent); text-decoration: none; font-weight: 600; }
.page-footer a:hover { text-decoration: underline; }

/* ══════════════════════════════════════
   MOBILE ≤ 699px
   ══════════════════════════════════════ */
@media (max-width: 699px) {
  .page-wrap   { padding: 16px 12px 40px; gap: 16px; }
  .hero        { padding: 20px; }
  .hero-text h1 { font-size: 1.2rem; }
  .opt-row     { grid-template-columns: 1fr 1fr; }
  .grid        { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
  .topbar      { padding: 0 16px; }
}

@media (max-width: 420px) {
  .opt-row    { grid-template-columns: 1fr; }
  .action-row { flex-direction: column; }
  .btn-convert, .btn-add { width: 100%; }
}