/* ===========================================================
   Duoloon Exchange — sistema de diseño responsive
   =========================================================== */

:root {
  --brand:        #4f46e5;
  --brand-600:    #4338ca;
  --brand-700:    #3730a3;
  --success:      #059669;
  --success-600:  #047857;
  --danger:       #dc2626;
  --danger-bg:    #fef2f2;
  --danger-border:#fecaca;

  --bg:      #eef2f7;
  --surface: #ffffff;
  --text:    #0f172a;
  --muted:   #64748b;
  --border:  #e2e8f0;

  --radius:    16px;
  --radius-sm: 10px;
  --shadow:    0 10px 30px -12px rgba(2, 6, 23, .25);
  --shadow-sm: 0 1px 3px rgba(2, 6, 23, .08);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  padding: clamp(16px, 4vw, 48px) 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  line-height: 1.55;
  background:
    radial-gradient(1100px 520px at 100% -10%, #e0e7ff 0, transparent 60%),
    radial-gradient(900px 480px at -10% 0%, #ede9fe 0, transparent 55%),
    var(--bg);
}

/* ---------- Layout ---------- */
.page,
.container {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 24px);
}

.container + .container { margin-top: 24px; }

/* ---------- Tipografía ---------- */
h1 {
  font-size: clamp(1.6rem, 4.5vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -.02em;
  margin: 0 0 .35em;
}
h2 { font-size: clamp(1.2rem, 3.5vw, 1.5rem); font-weight: 600; }
h4 { font-size: 1.15rem; font-weight: 600; margin: 0; }
p  { color: var(--muted); margin: 0 0 1rem; }

.text-center { text-align: center; }
.muted { color: var(--muted); }

/* ---------- Encabezado de la app ---------- */
.app-header {
  max-width: 860px;
  margin: 0 auto clamp(20px, 4vw, 32px);
  padding: 0 clamp(16px, 4vw, 24px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--brand-700);
}
.brand-badge {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), #7c3aed);
  color: #fff; font-weight: 800;
  box-shadow: var(--shadow-sm);
}

/* ---------- Tarjetas ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(20px, 4vw, 32px);
}
.card + .card { margin-top: 24px; }
.card-title { margin: 0 0 4px; }
.card-sub { margin: 0 0 20px; color: var(--muted); font-size: .95rem; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  font: inherit;
  font-weight: 600;
  line-height: 1;
  color: #fff;
  background: var(--brand);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: transform .05s ease, background-color .15s ease, box-shadow .15s ease;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--brand-600); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid rgba(79, 70, 229, .35); outline-offset: 2px; }

.btn-primary { background: var(--brand); }
.btn-primary:hover { background: var(--brand-600); }

.btn-success { background: var(--success); }
.btn-success:hover { background: var(--success-600); }

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow: none;
}
.btn-ghost:hover { background: #f8fafc; }

.btn-block { display: flex; width: 100%; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: clamp(20px, 4vw, 28px);
}

/* ---------- Formularios ---------- */
.form-group { margin-bottom: 16px; }

label,
.form-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  font-size: .92rem;
  color: var(--text);
}

.form-control {
  display: block;
  width: 100%;
  padding: 11px 14px;
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
  -webkit-appearance: none;
  appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .15);
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
}

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

/* ---------- Tablas ---------- */
.table-wrap { width: 100%; overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: .95rem;
}
.table th,
.table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table thead th {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  background: #f8fafc;
}
.table tbody tr:last-child td { border-bottom: none; }
.table-striped tbody tr:nth-child(odd) { background: #fafbff; }
.table-bordered,
.table-bordered th,
.table-bordered td { border: 1px solid var(--border); }
.table td:not(:first-child) { font-variant-numeric: tabular-nums; }

/* ---------- Alertas ---------- */
.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: .92rem;
}
.alert-danger {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  z-index: 1050;
  padding: 16px;
  overflow-y: auto;
}
.modal-card {
  background: var(--surface);
  width: 100%;
  max-width: 460px;
  margin: clamp(24px, 8vh, 64px) auto;
  border-radius: var(--radius);
  padding: clamp(20px, 5vw, 28px);
  box-shadow: var(--shadow);
  animation: modal-in .18s ease-out;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.modal-close {
  font-size: 1.6rem;
  line-height: 1;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
}
.modal-close:hover { color: var(--text); }
.modal-card hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0 18px;
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Utilidades ---------- */
.mt-3 { margin-top: 16px; }
.is-hidden { display: none !important; }

pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: .85rem;
  white-space: pre-wrap;
  word-break: break-word;
}

a { color: var(--brand); }

/* ===========================================================
   Responsive — tablas apiladas en pantallas pequeñas
   =========================================================== */
@media (max-width: 700px) {
  .grid-2 { grid-template-columns: 1fr; }

  .btn-row .btn { flex: 1 1 auto; }

  .table.responsive thead { display: none; }
  .table.responsive,
  .table.responsive tbody,
  .table.responsive tr,
  .table.responsive td { display: block; width: 100%; }

  .table.responsive tr {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    padding: 6px 14px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
  }
  .table.responsive.table-striped tbody tr:nth-child(odd) { background: var(--surface); }

  .table.responsive td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    border: none;
    border-bottom: 1px dashed var(--border);
    padding: 10px 0;
    text-align: right;
  }
  .table.responsive tr td:last-child { border-bottom: none; }
  .table.responsive td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
    text-align: left;
  }
}
