/* Page-specific layouts: sign-in, sheet list, new upload, review, archive, administration. */

@media (max-width: 899px) { .hide-mobile { display: none !important; } }
@media (min-width: 900px) { .hide-desktop { display: none !important; } }
/* Mouse and trackpad: no camera to open, so the camera button and its hint go away. */
.pointer-only { display: none; }
@media (hover: hover) and (pointer: fine) {
  .touch-only { display: none !important; }
  .pointer-only { display: inline; }
}

/* --- sign-in ---------------------------------------------------------- */

.auth { min-height: 100vh; display: grid; }
.auth-brand { display: none; }
.auth-main {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 28px 16px calc(28px + var(--safe-bottom));
}
.auth-theme { position: absolute; top: max(14px, var(--safe-top)); right: 14px; }
.auth-logo { margin: 0 auto 24px; text-align: center; }
.auth-logo img { width: min(240px, 70vw); height: auto; }
.auth-card {
  width: 100%; max-width: 420px; padding: 28px 24px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.auth-card h1 { margin-bottom: 6px; font-size: 1.4rem; }
.auth-card .page-subtitle { margin-bottom: 8px; }
.auth-footer { margin-top: 22px; color: var(--muted); font-size: .82rem; text-align: center; }
.auth-footer a { color: var(--muted); }
.code-input {
  padding-left: calc(14px + .5em) !important;
  font-size: 1.6rem !important; letter-spacing: .5em; text-align: center;
  font-variant-numeric: tabular-nums;
}
.qr { display: block; width: fit-content; margin: 14px auto; padding: 14px; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.qr img { display: block; width: 190px; height: 190px; }
.steps { margin: 14px 0 0; padding-left: 20px; }

@media (min-width: 900px) {
  .auth { grid-template-columns: minmax(380px, 46%) 1fr; }
  .auth-logo { display: none; }
  .auth-brand {
    display: flex; flex-direction: column; justify-content: center; gap: 28px;
    padding: 56px 56px 56px 64px;
    background:
      radial-gradient(900px 500px at 0% 0%, rgba(226, 49, 42, .22), transparent 60%),
      var(--sidebar-bg);
    color: #fff;
  }
  .auth-brand img { width: 260px; height: auto; }
  .auth-brand h2 { margin: 0 0 8px; font-size: 2rem; line-height: 1.15; letter-spacing: -.02em; }
  .auth-brand p { margin: 0; color: rgba(255, 255, 255, .72); font-size: 1.05rem; }
  .auth-points { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
  .auth-points li { display: flex; align-items: center; gap: 14px; color: rgba(255, 255, 255, .9); }
  .auth-points .point-icon {
    display: grid; place-items: center; flex: none;
    width: 42px; height: 42px;
    background: rgba(255, 255, 255, .12); border-radius: 12px;
  }
  .auth-card { padding: 36px 34px; box-shadow: var(--shadow); }
}

/* --- sheet list ------------------------------------------------------- */

.sheet-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin: 0; padding: 0; list-style: none; }
/* minmax(0, 1fr), not 1fr: a grid item will not shrink below its content, and a long
   hospital name pushed the status badge off the screen. */
.sheet-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: var(--text); text-decoration: none;
  transition: border-color .12s, box-shadow .12s, transform .08s;
}
.sheet-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.sheet-card:active { transform: scale(.995); }
.sheet-number {
  display: grid; place-items: center; flex: none;
  width: 54px; height: 54px;
  background: var(--primary-soft); color: var(--primary);
  border-radius: 14px;
  font-size: .95rem; font-weight: 800; line-height: 1.05; text-align: center;
  font-variant-numeric: tabular-nums;
}
.sheet-number small { display: block; font-size: .62rem; font-weight: 700; letter-spacing: .05em; opacity: .75; }
.sheet-number--pending { background: var(--surface-muted); color: var(--muted); }
.sheet-card-body { flex: 1; min-width: 0; }
.sheet-card-title {
  display: -webkit-box; overflow: hidden;
  font-weight: 650;
  -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
  overflow-wrap: anywhere;
}
.sheet-card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 14px; margin-top: 2px; color: var(--muted); font-size: .86rem; }
.sheet-card-meta span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.sheet-card-meta .icon { width: 15px; height: 15px; }
.sheet-card > .icon { color: var(--border-strong); }

@media (max-width: 559px) { .sheet-card > .icon { display: none; } }
@media (min-width: 1100px) {
  .sheet-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* --- new sheet: upload photos ----------------------------------------- */

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 30px 20px;
  background: var(--surface);
  border: 2px dashed var(--border-strong); border-radius: var(--radius-lg);
  text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone.is-dragging { background: var(--primary-soft); border-color: var(--primary); }
.dropzone.is-disabled { opacity: .5; pointer-events: none; }
.dropzone-icon {
  display: grid; place-items: center;
  width: 72px; height: 72px;
  background: var(--primary-soft); color: var(--primary); border-radius: 50%;
}
.dropzone-icon .icon { width: 34px; height: 34px; }
.dropzone-title { margin: 0; font-size: 1.1rem; font-weight: 700; }
.dropzone-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; width: 100%; }
.dropzone input[type=file] { display: none; }
.camera-button { min-height: 56px; padding: 12px 26px; font-size: 1.05rem; }
@media (max-width: 559px) { .dropzone-actions > * { flex: 1 1 100%; } }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; margin-top: 16px; }
.thumbs:empty { display: none; }
.thumb { position: relative; animation: pop-in .18s ease-out; }
.thumb img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--surface-muted); border-radius: 12px; }
.thumb button {
  position: absolute; top: 5px; right: 5px;
  display: grid; place-items: center;
  width: 30px; height: 30px; padding: 0;
  background: rgba(15, 17, 24, .72); color: #fff;
  border: 0; border-radius: 99px;
  cursor: pointer;
}
.thumb button .icon { width: 16px; height: 16px; }
@keyframes pop-in { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
.photo-count { margin: 12px 2px 0; font-weight: 650; }
progress { width: 100%; height: 10px; margin-top: 14px; overflow: hidden; border-radius: 99px; accent-color: var(--primary); }

/* Sticky bar with the main actions; on a phone it sits above the tab bar. */
.action-bar {
  position: sticky; bottom: calc(var(--tabbar-height) + var(--safe-bottom));
  z-index: 5;
  display: flex; gap: 10px;
  margin: 18px -16px 0; padding: 12px 16px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-top: 1px solid var(--border);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.no-tabbar .action-bar { bottom: 0; padding-bottom: calc(12px + var(--safe-bottom)); }
/* The first button is the real action and takes the spare room; the rest take what they need. */
.action-bar .btn { flex: 0 0 auto; padding-left: 14px; padding-right: 14px; white-space: nowrap; }
.action-bar .btn:first-child { flex: 1 1 auto; }
@media (min-width: 900px) {
  .action-bar, .no-tabbar .action-bar {
    bottom: 18px; margin: 22px 0 0; padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
  }
  .action-bar .btn:first-child { flex: 0 1 auto; padding-left: 22px; padding-right: 22px; }
  .action-bar .spacer { flex: 1; }
}

/* --- review ----------------------------------------------------------- */

.items { display: grid; gap: 12px; }
.item {
  display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 14px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: opacity .15s;
}
.item.has-warning { border-color: var(--warn-border); box-shadow: inset 4px 0 0 var(--warn-border), var(--shadow-sm); }
.item:has(.remove-toggle input:checked) { opacity: .45; }
.item-photo { width: 80px; height: 80px; object-fit: cover; border-radius: 10px; cursor: zoom-in; display: block; }
.item-photo--none {
  display: grid; place-items: center;
  width: 80px; height: 80px;
  border: 1.5px dashed var(--border-strong); border-radius: 10px;
  color: var(--muted); font-size: .75rem; text-align: center;
}
.item-fields { display: grid; grid-template-columns: 1fr 1.4fr; gap: 2px 10px; }
.item-fields label { margin: 6px 0 0; font-size: .74rem; }
.item-fields input { min-height: 42px; padding: 8px 10px; }
.item-fields .span-2 { grid-column: span 2; }
.item-note { display: flex; gap: 6px; margin-top: 8px; font-size: .86rem; }
.item-note .icon { width: 16px; height: 16px; margin-top: 2px; }
.item-note--warning { color: var(--warn-text); font-weight: 600; }
.item-foot { display: flex; justify-content: flex-end; margin-top: 6px; }
.remove-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 0; padding: 6px 10px;
  color: var(--muted); border-radius: var(--radius-sm);
  font-size: .84rem; font-weight: 600; cursor: pointer;
}
.remove-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.remove-toggle .icon { width: 17px; height: 17px; }
.remove-toggle:hover { background: var(--danger-bg); color: var(--danger-text); }
.remove-toggle:has(input:checked) { background: var(--danger-bg); color: var(--danger-text); }
@media (min-width: 900px) { .items { grid-template-columns: 1fr 1fr; } }

.more-details { margin-top: 14px; padding-top: 4px; border-top: 1px solid var(--border); }
.more-details > summary {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 0;
  color: var(--muted); font-size: .9rem; font-weight: 600;
  cursor: pointer; list-style: none;
}
.more-details > summary::-webkit-details-marker { display: none; }
.more-details > summary .icon { width: 18px; height: 18px; transition: transform .15s; }
.more-details[open] > summary .icon { transform: rotate(90deg); }

.viewer {
  position: fixed; inset: 0; z-index: 40;
  display: none; align-items: center; justify-content: center;
  padding: var(--safe-top) 0 var(--safe-bottom);
  background: rgba(5, 6, 12, .92);
  cursor: zoom-out;
}
.viewer.is-open { display: flex; }
.viewer img { max-width: 96vw; max-height: 90vh; border-radius: 8px; }

.waiting { padding: 40px 20px; text-align: center; }
.spinner {
  width: 46px; height: 46px; margin: 0 auto 16px;
  border: 4px solid var(--border); border-top-color: var(--red); border-radius: 50%;
  animation: spin .9s linear infinite;
}
.waiting strong { display: block; margin-bottom: 4px; font-size: 1.08rem; }

.done-card { padding: 28px 20px 22px; text-align: center; }
.done-mark {
  display: grid; place-items: center;
  width: 68px; height: 68px; margin: 0 auto 12px;
  background: var(--ok-bg); color: var(--ok-text); border-radius: 50%;
}
.done-mark .icon { width: 36px; height: 36px; stroke-width: 2.4; }
.done-card h1 { margin-bottom: 6px; }
.done-card .btn-row { justify-content: center; margin-top: 22px; }
.done-card .btn-row > .btn { flex: 0 1 auto; }

/* --- archive ---------------------------------------------------------- */

.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; margin-bottom: 16px; color: var(--muted); font-size: .92rem; }
.breadcrumbs a { color: var(--muted); font-weight: 600; text-decoration: none; }
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs .icon { width: 16px; height: 16px; }
.breadcrumbs [aria-current] { color: var(--text); font-weight: 700; }

.file-row { display: flex; align-items: center; gap: 6px; padding-right: 10px; }
.file-row .row-link { flex: 1; min-width: 0; }
.file-tile {
  display: grid; place-items: center; flex: none;
  width: 48px; height: 48px;
  border-radius: 12px;
  font-size: .72rem; font-weight: 800;
}
.file-tile--folder { background: var(--warn-bg); color: var(--warn-text); }
.file-tile--pdf { background: var(--danger-bg); color: var(--danger-text); }
.file-tile--image { object-fit: cover; border: 1px solid var(--border); }
.file-name { min-width: 0; overflow-wrap: anywhere; }
.file-meta { display: block; color: var(--muted); font-size: .84rem; }
.file-size { flex: none; color: var(--muted); font-size: .84rem; white-space: nowrap; }
@media (max-width: 640px) { .file-size { display: none; } }

/* --- administration --------------------------------------------------- */

.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-bottom: 20px; }
.user-card { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 18px; }
.user-card.is-inactive { opacity: .62; }
.user-card-head { display: flex; align-items: center; gap: 12px; }
.user-card-head .avatar { width: 46px; height: 46px; font-size: 1.1rem; }
.user-card-head strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card-head span { color: var(--muted); font-size: .88rem; }
.user-card-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.user-card-actions { display: flex; gap: 2px; margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); }
.user-card-actions .spacer { flex: 1; }

.cell-note { display: block; color: var(--muted); font-size: .82rem; }
.min-w-field { min-width: 120px; }
.min-w-wide { min-width: 260px; }
.pre-wrap { white-space: pre-wrap; }
