
/* ==========================================================================
   factura_tu_ticket.dynamic.css
   Modern, dynamic-only CSS for the "Factura tu ticket" page.
   - No HTML changes required.
   - Uses CSS variables, responsive layout, dark mode, reduced motion safe.
   - Provides stateful styles via .is-loading / .is-success / .is-error and [data-status].
   - Includes button system, cards, tables, alerts, skeletons, spinners.
   ========================================================================== */

/* ---------- CSS Variables & Theme ---------------------------------------------------- */
:root {
  --bg: #0b0c10;
  --panel: #0f1117;
  --muted: #97a3b6;
  --text: #0b0b0b;
  --text-weak: #b9c2cf;
  --brand: #ff2a2a;
  --brand-2: #d36d00;
  --ok: #22c55e;
  --warn: #f59e0b;
  --err: #ef4444;
  --border: #1f2937;
  --ring: color-mix(in oklab, var(--brand), white 25%);
  --shadow: 0 10px 20px rgba(2, 6, 23, .35), 0 1px 2px rgba(2, 6, 23, .45);

  --radius-sm: .55rem;
  --radius: .9rem;
  --radius-lg: 1.25rem;

  --gap-1: .5rem;
  --gap: 1rem;
  --gap-2: 1.5rem;
  --gap-3: 2rem;
  --gap-4: 3rem;

  --fw-600: 600;
  --fw-700: 700;
  --fw-800: 800;

  --btn-h: 2.75rem;
  --btn-px: 1rem;
  --btn-gap: .5rem;

  --focus: 2px solid var(--ring);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f7fb;
    --panel: #ffffff;
    --muted: #5f6b7c;
    --text: #707074;
    --text-weak: #f5f6f7;
    --brand: #ff0d00;
    --brand-2: #27130b;
    --ok: #0ea35d;
    --warn: #b45309;
    --err: #b91c1c;
    --border: #e5e7eb;
    --shadow: 0 8px 24px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .12);
  }
}

.page {
  --w: min(1120px, 92vw);
  margin: 3rem auto 5rem;
  width: var(--w);
  display: grid;
  gap: var(--gap-3);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--gap-2);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: .75rem;
}
.brand__title {
  font-size: clamp(1.25rem, 1.6vw + .75rem, 2rem);
  font-weight: var(--fw-800);
  letter-spacing: .2px;
}
.brand__subtitle {
  color: var(--muted);
  font-weight: var(--fw-600);
}

.header .actions {
  display: flex;
  gap: var(--gap);
  align-items: center;
}

/* ---------- Card / Panel --------------------------------------------------------------- */
.card {
  background: linear-gradient(180deg, color-mix(in oklab, var(--panel), transparent 0%), color-mix(in oklab, var(--panel), transparent 0%)) padding-box,
              linear-gradient(180deg, color-mix(in oklab, var(--brand), transparent 70%), transparent) border-box;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: clamp(1rem, 2vw, 1.75rem);
}

.card--inset {
  background: var(--panel);
}

.card__title {
  font-size: 1.05rem;
  font-weight: var(--fw-700);
  margin-bottom: .5rem;
}

.card__desc { color: var(--text-weak); margin-bottom: .75rem;}

/* ---------- Grid areas ----------------------------------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: var(--gap-2);
}
@media (max-width: 920px) {
  .grid { grid-template-columns: 1fr; }
}

/* ---------- Status & Pills ------------------------------------------------------------- */
.status {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  padding: .35rem .65rem;
  border-radius: 999px;
  font-weight: var(--fw-600);
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--panel), white 2%);
}
.status__dot {
  inline-size: .6rem;
  block-size: .6rem;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 4px color-mix(in oklab, currentColor, transparent 85%);
}
.status--ok { color: var(--ok); }
.status--warn { color: var(--warn); }
.status--err { color: var(--err); }

/* data-status API */
[data-status="loading"] .status__dot { background: var(--brand); animation: pulse 1s infinite; }
[data-status="success"] .status { color: var(--ok); }
[data-status="error"] .status { color: var(--err); }

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: .9; }
  50% { transform: scale(1.25); opacity: .65; }
}

/* ---------- Buttons -------------------------------------------------------------------- */
.btn {
  --bgc: var(--panel);
  --fg: var(--text);
  --bdc: var(--border);

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--btn-gap);
  height: var(--btn-h);
  padding: 0 calc(var(--btn-px) + .25rem);
  border-radius: var(--radius);
  border: 1px solid var(--bdc);
  background: linear-gradient(180deg, color-mix(in oklab, var(--bgc), white 4%), var(--bgc));
  color: var(--fg);
  font-weight: var(--fw-700);
  letter-spacing: .15px;
  cursor: pointer;
  text-decoration: none;
  transition: transform .1s ease, box-shadow .2s ease, filter .2s ease, background .25s ease;
  box-shadow: 0 1px 0 rgba(255,255,255,.06) inset, 0 1px 2px rgba(2,6,23,.45);
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.03); }
.btn:active { transform: translateY(0); filter: brightness(.98); }
.btn:focus-visible { outline: var(--focus); outline-offset: 2px; }

.btn--primary { --bgc: color-mix(in oklab, var(--brand), black 10%); --bdc: color-mix(in oklab, var(--brand), black 18%); }
.btn--success { --bgc: color-mix(in oklab, var(--ok), black 8%); --bdc: color-mix(in oklab, var(--ok), black 16%); }
.btn--danger  { --bgc: color-mix(in oklab, var(--err), black 6%); --bdc: color-mix(in oklab, var(--err), black 14%); }
.btn--ghost   { --bgc: transparent; }
.btn--sm { height: 2.25rem; padding-inline: .9rem; border-radius: var(--radius-sm); font-weight: var(--fw-600); }
.btn--icon { width: var(--btn-h); padding: 0; gap: 0; }
.btn .ic { display: inline-block; width: 1.1rem; height: 1.1rem; }

.btn[data-type="xml"]::before,
.btn[data-type="pdf"]::before {
  content: attr(data-type);
  display: inline-block;
  font-size: .75rem;
  line-height: 1;
  padding: .3rem .5rem;
  border-radius: .5rem;
  margin-right: .35rem;
  background: color-mix(in oklab, var(--panel), white 8%);
  color: var(--text-weak);
  border: 1px dashed var(--border);
}

/* ---------- Forms ---------------------------------------------------------------------- */
.field {
  display: grid;
  gap: .45rem;
}
.label {
  font-weight: var(--fw-600);
  color: var(--text-weak);
}
.control {
  display: flex;
  align-items: center;
  gap: .5rem;
}

input[type="text"],
input[type="search"],
input[type="number"],
input[type="date"],
select,
textarea {
  width: 100%;
  height: 2.75rem;
  padding: 0 .85rem;
  color: var(--text);
  background: color-mix(in oklab, var(--panel), white 2%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
textarea { height: auto; min-height: 6.5rem; padding-block: .75rem; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--ring); box-shadow: 0 0 0 4px color-mix(in oklab, var(--ring), transparent 80%); }

.input-group {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .5rem;
}

/* ---------- Table & Key/Value ---------------------------------------------------------- */
.table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: color-mix(in oklab, var(--panel), white 1%);
}
.table thead th {
  text-align: left;
  font-weight: var(--fw-700);
  color: var(--text-weak);
  background: color-mix(in oklab, var(--panel), white 3%);
  border-bottom: 1px solid var(--border);
  padding: .8rem 1rem;
}
.table tbody td {
  padding: .85rem 1rem;
  border-bottom: 1px dashed var(--border);
}
.table tbody tr:hover { background: color-mix(in oklab, var(--panel), white 3%); }

.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .35rem 1rem;
}
.kv dt { color: var(--muted); }
.kv dd { font-weight: var(--fw-700); }

/* ---------- Alerts / Toasts ------------------------------------------------------------ */
.alert {
  padding: .9rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--panel), white 2%);
  display: grid;
  gap: .35rem;
}
.alert--ok { border-color: color-mix(in oklab, var(--ok), transparent 40%); }
.alert--warn { border-color: color-mix(in oklab, var(--warn), transparent 40%); }
.alert--err { border-color: color-mix(in oklab, var(--err), transparent 40%); }

.toast {
  position: fixed;
  inset: auto 1rem 1rem auto;
  min-width: 260px;
  z-index: 1000;
  animation: slide-in .25s ease both;
}
@keyframes slide-in {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ---------- Downloads list ------------------------------------------------------------- */
.downloads {
  display: grid;
  gap: .75rem;
}
.download {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: .85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: color-mix(in oklab, var(--panel), white 3%);
}
.download__meta { display: grid; gap: .2rem; }
.download__title { font-weight: var(--fw-700); }
.download__hint { color: var(--muted); font-size: .9rem; }

/* Make XML green and PDF brand for quick scan */
[data-type="xml"].download { border-left: 4px solid var(--ok); }
[data-type="pdf"].download { border-left: 4px solid var(--brand); }

/* ---------- QR & Media ----------------------------------------------------------------- */
.qr {
  display: grid;
  place-items: center;
  width: min(220px, 45vw);
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  background:
    conic-gradient(from 0deg at 50% 50%, color-mix(in oklab, var(--brand), transparent 90%) 0 25%, transparent 0 100%)
    , color-mix(in oklab, var(--panel), white 4%);
  padding: .75rem;
}
.qr img, .qr canvas { width: 100%; height: 100%; object-fit: contain; border-radius: .5rem; }

/* ---------- Skeletons & Loading -------------------------------------------------------- */
.skeleton {
  position: relative;
  overflow: hidden;
  background: linear-gradient(90deg,
    color-mix(in oklab, var(--panel), white 6%) 25%,
    color-mix(in oklab, var(--panel), white 10%) 37%,
    color-mix(in oklab, var(--panel), white 6%) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.35s infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.spinner {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  border: 2px solid color-mix(in oklab, var(--brand), transparent 75%);
  border-top-color: var(--brand);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(1turn); } }

/* Apply loading states generically */
.is-loading .btn { pointer-events: none; opacity: .65; }
.is-loading .spinner { display: inline-block; }
.is-loading .download { filter: grayscale(.35) opacity(.8); }

/* ---------- Utility classes ------------------------------------------------------------ */
.row { display: flex; gap: var(--gap); align-items: center; }
.row.wrap { flex-wrap: wrap; }
.col { display: grid; gap: var(--gap); }

.center { display: grid; place-items: center; }
.hidden { display: none !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: .5rem !important; }
.mt-2 { margin-top: 1rem !important; }
.mt-3 { margin-top: 1.5rem !important; }
.mt-4 { margin-top: 2rem !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: .5rem !important; }
.mb-2 { margin-bottom: 1rem !important; }
.mb-3 { margin-bottom: 1.5rem !important; }
.mb-4 { margin-bottom: 2rem !important; }

.w-100 { width: 100% !important; }
.text-weak { color: var(--text-weak) !important; }
.text-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; }

/* ---------- Page-specific suggestions (non-breaking) ----------------------------------- */
/* These selectors are likely present in your factura_tu_ticket.php; if not, they do nothing. */

#estado-factura, .estado-factura {
  display: flex; align-items: center; gap: .75rem; margin-block: .5rem 1rem;
}
#estado-factura .badge, .estado-factura .badge {
  padding: .25rem .6rem; border-radius: 999px; border: 1px solid var(--border); color: var(--text-weak);
  background: color-mix(in oklab, var(--panel), white 4%);
}

#uuid, .uuid { font-weight: var(--fw-700); letter-spacing: .25px; }
#uuid code, .uuid code { font-weight: var(--fw-700); }

.acciones, .actions-row { display: flex; flex-wrap: wrap; gap: .6rem; }

/* Buttons that already exist with .btn-descargar or .descargar-xml/pdf */
.btn-descargar, .descargar, .descargar-xml, .descargar-pdf {
  composes: btn;
}
.descargar-xml { composes: btn btn--success; }
.descargar-pdf { composes: btn btn--primary; }

/* Fallback if 'composes' isn't supported, apply styles by grouping */
.btn-descargar, .descargar, .descargar-xml, .descargar-pdf,
a[href*="tipo=xml"], a[data-tipo="xml"],
a[href*="tipo=pdf"], a[data-tipo="pdf"] {
  display: inline-flex; align-items: center; gap: .55rem; height: var(--btn-h);
  padding: 0 calc(var(--btn-px) + .1rem); border-radius: var(--radius); border: 1px solid var(--border);
  background: linear-gradient(180deg, color-mix(in oklab, var(--panel), white 4%), var(--panel));
  color: var(--text); font-weight: var(--fw-700); text-decoration: none; box-shadow: 0 1px 0 rgba(255,255,255,.06) inset;
}
a[href*="tipo=xml"], a[data-tipo="xml"] { border-color: color-mix(in oklab, var(--ok), transparent 30%); }
a[href*="tipo=pdf"], a[data-tipo="pdf"] { border-color: color-mix(in oklab, var(--brand), transparent 30%); }

/* Compact tag styles for “Factura generada”, “Pendiente”, etc. */
.tag {
  display: inline-grid;
  place-items: center;
  padding: .35rem .6rem;
  border-radius: .65rem;
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--panel), white 4%);
  color: var(--text-weak);
  font-weight: var(--fw-700);
  text-transform: uppercase;
  letter-spacing: .4px;
  font-size: .75rem;
}
.tag--ok { color: var(--ok); border-color: color-mix(in oklab, var(--ok), transparent 40%); }
.tag--warn { color: var(--warn); border-color: color-mix(in oklab, var(--warn), transparent 40%); }
.tag--err { color: var(--err); border-color: color-mix(in oklab, var(--err), transparent 40%); }

/* ---------- Footer / small print ------------------------------------------------------- */
.smallprint {
  color: var(--muted);
  font-size: .92rem;
}

/* ---------- Nice micro-interactions ---------------------------------------------------- */
.card:hover { border-color: color-mix(in oklab, var(--ring), transparent 60%); }
a:hover { text-decoration: none; }

/* ---------- Print tidy (for PDF views of the page) ------------------------------------- */
@media print {
  :root { --bg: #ffffff; --panel: #ffffff; --text: #000; --border: #d1d5db; }
  body { background: #fff; }
  .btn, .toast { display: none !important; }
  .card { box-shadow: none; border-color: var(--border); }
}


/* === Appended Footer Styles (from user) === */

/*******************************/
/********* Footer CSS **********/
/*******************************/
.footer {
    position: relative;
    margin-top: 45px;
    padding-top: 90px;
    background: rgb(5, 5, 5);
}

.footer .footer-contact,
.footer .footer-link,
.footer .footer-newsletter {
    position: relative;
    margin-bottom: 45px;
    color: #fff;
}

.footer .footer-contact h2,
.footer .footer-link h2,
.footer .footer-newsletter h2 {
    position: relative;
    margin-bottom: 30px;
    padding-bottom: 10px;
    font-size: 22px;
    font-weight: 700;
    color: #b80000;
}

.footer .footer-contact h2::after,
.footer .footer-link h2::after,
.footer .footer-newsletter h2::after {
    position: absolute;
    content: "";
    width: 45px;
    height: 2px;
    bottom: 0;
    left: 0;
    background: #fff;
}

.footer .footer-link a {
    display: block;
    margin-bottom: 10px;
    color: #fff;
    transition: .3s;
}

.footer .footer-link a::before {
    position: relative;
    content: "\f105";
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    margin-right: 10px;
    color: #b80000;
}

.footer .footer-link a:hover {
    color: #b80000;
    letter-spacing: 1px;
}

.footer .footer-contact p i {
    width: 25px;
    color: #b80000;
}

.footer .footer-social {
    position: relative;
    margin-top: 20px;
    display: flex;
}

.footer .footer-social a {
    display: inline-block;
    margin-right: 5px;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #b80000;
    border-radius: 35px;
    font-size: 16px;
    color: #ffffff;
}

.footer .footer-social a:hover {
    background: #fff;
}

.footer .footer-social a:last-child {
    margin: 0;
}

.footer .footer-newsletter .form {
    position: relative;
    width: 100%;
}

.footer .footer-newsletter input {
    height: 60px;
    background: transparent;
    border: 1px solid #b80000;
    border-radius: 5px;
}

.footer .footer-newsletter .btn {
    position: absolute;
    top: 8px;
    right: 8px;
    height: 44px;
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 700;
}

.footer .copyright {
    position: relative;
    width: 100%;
    padding: 30px 0;
    text-align: center;
    background: #ffffff;
}

.footer .copyright p {
    margin: 0;
    display: inline-block;
    color: #000;
}

.footer .copyright p a {
    color: #b80000;
}

.footer .copyright p a:hover {
    color: #fff;
}
