/* The pages of this web. tokens/base/layout/components come from the stock web; this file is
   E2's own. Phone first; the wide layout starts at 900 px, as in layout.css. */

.hide-mobile { display: none !important; }
@media (min-width: 900px) { .hide-mobile { display: inherit !important; } .show-mobile { display: none !important; } }

/* --- brand ------------------------------------------------------------- */

.brand { display: flex !important; align-items: center; gap: 10px; line-height: 1.15 !important; text-decoration: none; }
.brand img { width: auto; border-radius: 8px; background: #fff; padding: 2px; }
.sidebar-brand.brand img { height: 40px; }
.sidebar-brand.brand span { color: #fff; font-weight: 700; font-size: 1.02rem; }
.sidebar-brand.brand small { display: block; color: var(--sidebar-text); font-weight: 500; font-size: .76rem; }
.topbar-brand.brand img { height: 32px; }
.topbar-brand.brand span { color: var(--text); font-weight: 750; font-size: 1.1rem; }

/* --- BC environment ------------------------------------------------------ */
/* Always on screen. Sandbox is plain; production is red, the only red besides errors. */

.sidebar-env { padding: 6px 10px 12px; margin-top: auto; }
.env-picker label { display: grid; gap: 4px; margin: 0; color: var(--sidebar-text); font-size: .78rem; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.env-picker select { min-height: 38px; padding: 6px 10px; font-weight: 650; }
.sidebar .env-picker select { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .2); color: #fff; }
.sidebar .env-picker select option { color: #000; }
.env-picker--prod select, .sidebar .env-picker--prod select { background: var(--prod) !important; border-color: var(--prod) !important; color: #fff !important; }
.env-picker--compact select { min-height: 36px; width: auto; max-width: 170px; padding-right: 34px; font-size: .9rem; }
.env-tag { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: .8rem; font-weight: 700; }
.env-tag--prod { background: var(--prod); color: #fff; }
.prod-banner {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 16px; padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--prod); color: #fff; font-weight: 650;
}
.prod-banner .icon { flex: none; }

/* --- sign-in (from the stock web) ------------------------------------------ */

.auth { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; background: var(--bg); }
.auth-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: max(14px, var(--safe-top)) 20px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.auth-main { display: flex; justify-content: center; align-items: flex-start; padding: 12vh 16px 32px; }
.auth-form { width: 100%; max-width: 380px; }
.auth-app { margin: 0 0 4px; color: var(--muted); font-size: .85rem; font-weight: 600; letter-spacing: .02em; }
.auth-form h1 { margin: 0 0 20px; font-size: 1.5rem; letter-spacing: -.01em; }
.auth-footer { padding: 16px 20px calc(16px + var(--safe-bottom)); color: var(--muted); font-size: .8rem; text-align: center; }
.btn-microsoft { gap: 12px; }
.btn-microsoft svg { width: 20px; height: 20px; }
.auth-or { margin: 18px 0 10px; color: var(--muted); font-size: .85rem; text-align: center; }
.auth-help { margin-top: 22px; font-size: .86rem; }
.auth-help code { overflow-wrap: anywhere; }

/* --- document list ------------------------------------------------------- */

.doc-tabs { margin-bottom: 14px; }
.doc-tabs .segmented-option { white-space: nowrap; }
.doc-tabs .count { margin-left: 4px; padding: 0 7px; border-radius: 999px; background: var(--surface-muted); color: var(--muted); font-size: .78rem; }
/* minmax(0, 1fr), not the default: a grid item does not shrink below its content, and a long
   file name pushed the card and its badge off a phone's screen (same lesson as the stock web). */
.doc-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin: 0; padding: 0; list-style: none; }
.doc-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.doc-row:hover { border-color: var(--border-strong); }
.doc-row.is-selected { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.doc-row input[type=checkbox] { flex: none; }
.doc-row input[type=checkbox]:disabled { opacity: .35; }
.doc-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.doc-kind {
  flex: none; display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--primary-soft); color: var(--primary);
  font-size: .72rem; font-weight: 800; letter-spacing: .02em;
}
.doc-body { flex: 1; min-width: 0; }
/* Two lines, not one with an ellipsis: on a phone, «LA BOTERIA ...» did not say which invoice. */
.doc-title {
  display: -webkit-box; overflow: hidden; font-weight: 650; overflow-wrap: anywhere;
  -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2;
}
@media (max-width: 899px) {
  .doc-row { gap: 10px; padding: 10px 12px; }
  .doc-link { gap: 10px; }
  .doc-kind { width: 34px; height: 34px; border-radius: 10px; font-size: .66rem; }
  .doc-link .badge { padding: 3px 8px; font-size: .72rem; }
  .doc-tabs { display: flex; max-width: 100%; overflow-x: auto; }
}
.doc-meta { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 2px; color: var(--muted); font-size: .84rem; }
.doc-meta span { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.doc-meta .icon { width: 14px; height: 14px; }
.doc-amount { flex: none; font-variant-numeric: tabular-nums; font-weight: 650; }
.doc-note { color: var(--warn-text); }

.selection-actions {
  position: sticky; bottom: calc(var(--tabbar-height) + var(--safe-bottom) + 8px); z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-top: 14px; padding: 10px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-lg);
}
.selection-actions[hidden] { display: none; }
.selection-actions .grow { flex: 1; }
.selection-actions select { width: auto; min-height: 40px; }
@media (min-width: 900px) { .selection-actions { bottom: 16px; } }

.badge--uploaded { background: var(--ok-bg); color: var(--ok-text); }

/* --- upload ------------------------------------------------------------- */

.type-choice { display: grid; gap: 10px; margin: 0 0 18px; }
@media (min-width: 640px) { .type-choice { grid-template-columns: repeat(3, 1fr); } }
.type-option { position: relative; }
.type-option input { position: absolute; opacity: 0; }
.type-option span {
  display: grid; gap: 2px; height: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); cursor: pointer;
}
.type-option small { color: var(--muted); font-weight: 400; }
.type-option input:checked + span { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 1px var(--primary); }
.type-option input:focus-visible + span { box-shadow: var(--focus-ring); }

.drop-zone {
  display: grid; place-items: center; gap: 8px;
  padding: 34px 16px;
  border: 2px dashed var(--border-strong); border-radius: var(--radius-lg);
  background: var(--surface); color: var(--muted); text-align: center; cursor: pointer;
}
.drop-zone.is-over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.drop-zone .icon { width: 34px; height: 34px; color: var(--primary); }
.drop-zone strong { color: var(--text); }
.drop-zone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.chosen-files { margin: 12px 0 0; padding: 0; list-style: none; color: var(--muted); font-size: .9rem; }
.chosen-files li { padding: 4px 0; border-bottom: 1px solid var(--border); }

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

/* minmax(0, 1fr) on phones too: without it the lines table, which is wider than a phone, widened
   the whole page and pushed the document and the save buttons off the screen. */
.review { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 1100px) {
  .review { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .review-preview { position: sticky; top: 16px; }
}
.review-preview { overflow: hidden; padding: 0; }
.preview-frame { display: block; width: 100%; height: min(78vh, 980px); border: 0; background: var(--surface-muted); }
.preview-image { display: block; max-width: 100%; margin: 0 auto; }
.preview-scroll { max-height: 78vh; overflow: auto; background: var(--surface-muted); }
.preview-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.preview-bar .grow { flex: 1; min-width: 0; overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.preview-pages { display: grid; gap: 6px; padding: 6px; }
@media (min-width: 900px) { .preview-pages { display: none !important; } }
.preview-text { margin: 0; padding: 16px; white-space: pre-wrap; font-size: .85rem; }

.field-grid { display: grid; gap: 4px 14px; }
@media (min-width: 640px) { .field-grid { grid-template-columns: 1fr 1fr; } }
.field-grid label { margin-top: 8px; }
.field-grid .wide { grid-column: 1 / -1; }
.conf-media { background: var(--conf-media-bg) !important; }
.conf-baja { background: var(--conf-baja-bg) !important; }
.conf-nula { background: var(--conf-nula-bg) !important; }
.conf-editado { border-color: var(--primary) !important; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 4px 0 0; color: var(--muted); font-size: .8rem; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 14px; border: 1px solid var(--border-strong); border-radius: 4px; }

.lines-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.lines-table th { padding: 6px 4px; color: var(--muted); font-size: .76rem; font-weight: 650; text-align: left; white-space: nowrap; }
.lines-table td { padding: 2px; vertical-align: top; }
.lines-table input { min-height: 36px; padding: 6px 8px; font-size: .88rem; }
.lines-table .num input { text-align: right; font-variant-numeric: tabular-nums; }
.lines-table .w-desc { min-width: 220px; }
.lines-table .w-num { width: 92px; }
.lines-table .w-short { width: 70px; }
.lines-table .w-ref { width: 120px; }

.review-actions {
  position: sticky; bottom: 0; z-index: 4;
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end;
  margin: 16px -4px 0; padding: 12px 4px calc(12px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.danger-zone { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.danger-zone select { width: auto; }

/* --- BC check and upload ------------------------------------------------- */

.bc-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin: 0; padding: 0; list-style: none; }
.bc-item { padding: 12px 16px; border: 1px solid var(--border); border-left-width: 5px; border-radius: var(--radius); background: var(--surface); }
.bc-item--ready { border-left-color: var(--ok-text); }
.bc-item--blocked { border-left-color: var(--danger-text); }
.bc-item--done { border-left-color: var(--muted); }
.bc-item--uploaded { border-left-color: var(--primary); background: var(--ok-bg); }
.bc-item-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.bc-item-head strong { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.bc-item ul { margin: 6px 0 0; padding-left: 20px; font-size: .9rem; }
.bc-item .problems { color: var(--danger-text); }
.bc-item .warnings { color: var(--muted); }
.progress { height: 10px; overflow: hidden; border-radius: 999px; background: var(--surface-muted); }
.progress > span { display: block; height: 100%; background: var(--primary); transition: width .3s; }
.progress--busy > span { width: 35% !important; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { margin-left: -35%; } to { margin-left: 100%; } }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- log ---------------------------------------------------------------- */

.log-table td { font-size: .88rem; }
.log-table td:first-child { white-space: nowrap; color: var(--muted); }
