/* Estilos generales */
:root {
  --bg: #0f172a;
  --card: #1e293b;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #818cf8;
  --success: #4ade80;
  --danger: #f87171;
  --warning: #fbbf24;
  --border: #334155;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

.card {
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.auth-card { max-width: 440px; margin: 4rem auto; }

h1, h2, h3 { margin-top: 0; }

.subtitle { color: var(--muted); margin-bottom: 1.5rem; }

label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 600;
  color: #cbd5e1;
}

input[type="email"],
input[type="password"],
input[type="text"],
textarea,
input[type="file"] {
  width: 100%;
  padding: 0.75rem 0.9rem;
  margin-bottom: 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0f172a;
  color: var(--text);
  font-size: 16px;
}

.password-field {
  position: relative;
  margin-bottom: 1rem;
}

.password-field input {
  margin-bottom: 0;
  padding-right: 3rem;
}

.password-toggle {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  color: var(--accent);
  background: rgba(56, 189, 248, 0.1);
  outline: none;
}

.eye-icon[hidden] {
  display: none;
}

.field-hint {
  margin: -0.5rem 0 1rem;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
}

.btn-block {
  width: 100%;
  display: block;
  text-align: center;
  margin-bottom: 0.75rem;
}

.btn-block:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.upload-zone {
  margin-bottom: 1rem;
  border: 2px dashed var(--border);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.55);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  overflow: hidden;
}

.upload-zone:hover,
.upload-zone:focus-visible {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.06);
  outline: none;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12);
}

.upload-zone--filled {
  border-style: solid;
  border-color: rgba(74, 222, 128, 0.45);
  background: linear-gradient(135deg, rgba(74, 222, 128, 0.08), rgba(56, 189, 248, 0.06));
}

.upload-zone--filled:hover,
.upload-zone--filled:focus-visible {
  border-color: var(--success);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.15);
}

.upload-zone--loading {
  opacity: 0.7;
  pointer-events: none;
}

.upload-zone--shake {
  animation: upload-shake 0.45s ease;
}

@keyframes upload-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.upload-zone-empty {
  padding: 2rem 1.25rem;
  text-align: center;
}

.upload-zone-icon {
  font-size: 2.5rem;
  line-height: 1;
  margin-bottom: 0.75rem;
  opacity: 0.9;
}

.upload-zone-title {
  margin: 0 0 0.35rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}

.upload-zone-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.4;
}

.upload-zone-filled {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
}

.upload-file-badge {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.35);
  font-size: 1.5rem;
  line-height: 1;
}

.upload-zone--filled .upload-file-badge {
  background: rgba(74, 222, 128, 0.15);
  border-color: rgba(74, 222, 128, 0.35);
}

.upload-file-details {
  flex: 1;
  min-width: 0;
}

.upload-file-name {
  margin: 0 0 0.2rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-file-meta {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.upload-file-change {
  flex-shrink: 0;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(51, 65, 85, 0.8);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.upload-file-change:hover {
  background: #475569;
  border-color: var(--accent);
}

textarea { min-height: 140px; resize: vertical; }

.btn {
  display: inline-block;
  padding: 0.85rem 1.2rem;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  font-size: 1rem;
  min-height: 48px;
}

.btn:hover { transform: translateY(-1px); }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0f172a;
}

.btn-secondary {
  background: #334155;
  color: var(--text);
}

.btn-success { background: #166534; color: #dcfce7; }
.btn-danger { background: #7f1d1d; color: #fee2e2; }
.btn-warning { background: #854d0e; color: #fef3c7; }

.alert {
  padding: 0.9rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
}

.alert-error { background: rgba(248, 113, 113, 0.15); border: 1px solid var(--danger); }
.alert-success { background: rgba(74, 222, 128, 0.12); border: 1px solid var(--success); }
.alert-warning { background: rgba(251, 191, 36, 0.12); border: 1px solid var(--warning); }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.badge-active { background: #14532d; color: #bbf7d0; }
.badge-inactive { background: #7f1d1d; color: #fecaca; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .container {
    padding: 1rem 0.75rem;
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
  .card { padding: 1.25rem; border-radius: 14px; }
  .auth-card { margin: 1rem auto; }

  h1 { font-size: 1.45rem; }
  h2 { font-size: 1.2rem; }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions .btn {
    flex: 1 1 auto;
    text-align: center;
    min-width: 0;
  }

  .download-row {
    flex-direction: column;
    align-items: stretch;
  }

  .download-row .file-ext {
    text-align: left;
    padding-left: 0.25rem;
  }

  .preview {
    max-height: 55vh;
    -webkit-overflow-scrolling: touch;
  }

  textarea {
    min-height: 180px;
  }

  input[type="file"] {
    padding: 0.65rem;
    font-size: 0.95rem;
  }

  .help-tip {
    font-size: 0.88rem;
  }

  .actions {
    flex-direction: column;
  }

  .actions .btn,
  .inline-form .btn {
    width: 100%;
    text-align: center;
  }

  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  td { border: none; padding: 0.5rem 0; }
  tr {
    margin-bottom: 1rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
  }
}

@media (max-width: 480px) {
  .container { padding-top: 0.75rem; }
  .card { padding: 1rem; }
  .btn { padding: 0.9rem 1rem; }
  .topbar-actions {
    flex-direction: column;
  }
  .apk-download-btn {
    max-width: none;
    width: 100%;
  }
}

.preview {
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  max-height: 420px;
  overflow: auto;
  line-height: 1.6;
}

.preview h1, .preview h2, .preview h3 { color: #e2e8f0; }

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

th, td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th { color: #cbd5e1; }

.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.footer-links {
  margin-top: 1.5rem;
  text-align: center;
  color: var(--muted);
}

.admin-access-footer {
  margin-top: 2rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.admin-access-footer a {
  color: var(--muted);
  font-size: 0.9rem;
}

.admin-access-footer a:hover {
  color: var(--accent);
}

.inline-form { display: inline; }

.download-form { margin-top: 0.5rem; }

.download-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.download-row input {
  flex: 1;
  margin-bottom: 0;
}

.file-ext {
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.download-progress-wrap {
  margin-top: 1rem;
}

.download-progress-track {
  width: 100%;
  height: 10px;
  background: #334155;
  border-radius: 999px;
  overflow: hidden;
}

.download-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  transition: width 0.2s ease;
}

.download-status-text {
  margin: 0.75rem 0 0;
  text-align: center;
  font-weight: 700;
  color: #38bdf8;
}

.help-tip {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.92rem;
  line-height: 1.5;
  color: #cbd5e1;
}

.help-tip strong {
  color: #e2e8f0;
}

.help-tip ol {
  margin: 0.5rem 0 0.5rem 1.1rem;
  padding: 0;
}

.help-tip li {
  margin-bottom: 0.35rem;
}

.help-examples {
  margin: 0;
  font-size: 0.85rem;
  color: #94a3b8;
}

.help-examples em {
  color: #7dd3fc;
  font-style: normal;
}

.topbar-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.apk-banner {
  margin-top: 1.5rem;
  padding: 1rem 1.1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(56, 189, 248, 0.08);
  text-align: center;
}

.apk-banner-compact {
  margin-top: 0;
  margin-bottom: 1rem;
}

.apk-banner-text p {
  margin: 0.35rem 0 0.9rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.apk-download-btn {
  width: 100%;
  max-width: 280px;
}

.apk-hint {
  margin: 0.75rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}
