/* assets/css/app.css */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg-base: #080e1a;
  --bg-surface: #0f1929;
  --bg-card: #162032;
  --bg-hover: #1c2a40;
  --border: #1e3048;
  --border-light: #243650;
  --text-primary: #e8f0fe;
  --text-secondary: #7b93b5;
  --text-muted: #3d5470;
  --accent-blue: #38bdf8;
  --accent-purple: #818cf8;
  --accent-green: #34d399;
  --accent-red: #f87171;
  --accent-amber: #fbbf24;
  --accent-pink: #f472b6;
  --gradient-1: linear-gradient(135deg, #0ea5e9, #6366f1);
  --gradient-2: linear-gradient(135deg, #10b981, #0ea5e9);
  --gradient-3: linear-gradient(135deg, #f59e0b, #ef4444);
  --sidebar-w: 260px;
  --radius: 12px;
  --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── LAYOUT ─────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── SIDEBAR ─────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-logo {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo h1 {
  font-size: 1.4rem;
  font-weight: 800;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.sidebar-logo span {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 12px;
  overflow-y: auto;
}

.nav-section-title {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 14px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 2px;
  transition: all 0.15s ease;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(56, 189, 248, 0.12);
  color: var(--accent-blue);
}

.nav-item .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.9;
}

.nav-badge {
  margin-left: auto;
  background: var(--accent-red);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
}

.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--gradient-1);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.user-details strong { display: block; font-size: 0.83rem; }
.user-details span { font-size: 0.72rem; color: var(--text-muted); }

/* ─── MAIN CONTENT ─────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-content {
  padding: 28px;
  flex: 1;
}

/* ─── CARDS ─────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ─── STAT CARDS ─────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-light);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}

.stat-card.blue::before { background: var(--gradient-1); }
.stat-card.green::before { background: var(--gradient-2); }
.stat-card.red::before { background: var(--gradient-3); }
.stat-card.purple::before { background: linear-gradient(135deg, #818cf8, #c084fc); }

.stat-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  margin-bottom: 14px;
}

.stat-icon.blue { background: rgba(56,189,248,0.12); }
.stat-icon.green { background: rgba(52,211,153,0.12); }
.stat-icon.red { background: rgba(248,113,113,0.12); }
.stat-icon.purple { background: rgba(129,140,248,0.12); }
.stat-icon.amber { background: rgba(251,191,36,0.12); }

.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: -1px;
}

.stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.stat-change {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.73rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  margin-top: 6px;
}

.stat-change.up { background: rgba(52,211,153,0.15); color: var(--accent-green); }
.stat-change.down { background: rgba(248,113,113,0.15); color: var(--accent-red); }

/* ─── TABLES ─────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }

th {
  padding: 10px 14px;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: var(--bg-hover); }

.td-primary { color: var(--text-primary); font-weight: 600; }
.td-money { font-family: 'JetBrains Mono', monospace; font-weight: 600; }
.td-money.positive { color: var(--accent-green); }
.td-money.negative { color: var(--accent-red); }

/* ─── BADGES / PILLS ─────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
}

.badge-green { background: rgba(52,211,153,0.15); color: var(--accent-green); }
.badge-red { background: rgba(248,113,113,0.15); color: var(--accent-red); }
.badge-blue { background: rgba(56,189,248,0.15); color: var(--accent-blue); }
.badge-amber { background: rgba(251,191,36,0.15); color: var(--accent-amber); }
.badge-purple { background: rgba(129,140,248,0.15); color: var(--accent-purple); }
.badge-gray { background: rgba(100,116,139,0.15); color: #64748b; }

/* ─── BUTTONS ─────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  text-decoration: none;
  font-family: inherit;
}

.btn-primary {
  background: var(--gradient-1);
  color: white;
}
.btn-primary:hover { opacity: 0.88; transform: translateY(-1px); }

.btn-secondary {
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--border-light); }

.btn-danger {
  background: rgba(248,113,113,0.15);
  color: var(--accent-red);
  border: 1px solid rgba(248,113,113,0.2);
}
.btn-danger:hover { background: rgba(248,113,113,0.25); }

.btn-sm { padding: 5px 11px; font-size: 0.78rem; }
.btn-icon { padding: 7px; width: 32px; height: 32px; justify-content: center; }

/* ─── FORMS ─────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.form-group { margin-bottom: 0; }
.form-group.full { grid-column: 1 / -1; }

label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 9px 13px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-family: inherit;
  transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(56,189,248,0.1);
}

textarea { resize: vertical; min-height: 80px; }

/* ─── MODAL ─────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-backdrop.open { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  width: 90%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-title { font-size: 1.05rem; font-weight: 800; }

.modal-close {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer; font-size: 1.2rem;
  padding: 4px; border-radius: 6px;
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-hover); }

/* ─── CHARTS ─────────────────────────────────── */
.chart-container {
  position: relative;
  height: 240px;
}

/* ─── MISC ─────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-4 { margin-top: 16px; }
.text-right { text-align: right; }
.w-full { width: 100%; }

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { font-size: 0.9rem; }

.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ─── ALERTS ─────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 16px;
}
.alert-success { background: rgba(52,211,153,0.1); border: 1px solid rgba(52,211,153,0.3); color: var(--accent-green); }
.alert-error { background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.3); color: var(--accent-red); }
.alert-warning { background: rgba(251,191,36,0.1); border: 1px solid rgba(251,191,36,0.3); color: var(--accent-amber); }

/* ─── PAGINATION ─────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 20px;
}
.pagination a, .pagination span {
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.pagination a:hover { border-color: var(--accent-blue); color: var(--accent-blue); }
.pagination .active { background: var(--gradient-1); color: white; border-color: transparent; }

/* ─── SCROLLBAR ─────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

/* ─── MOBILE ─────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .menu-toggle { display: flex; }
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 6px;
}

/* ─── NO-SIDEBAR (mobile view / movil.php) ────── */
.main-content.no-sidebar { margin-left: 0; }

/* ─── HOSTING expiry badges ──────────────────── */
.expiry-critical { color: var(--accent-red); font-weight: 700; }
.expiry-warning  { color: var(--accent-amber); font-weight: 600; }
.expiry-ok       { color: var(--accent-green); }

/* ─── TAG CHIPS ──────────────────────────────── */
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 0.7rem; font-weight: 600;
  cursor: default;
}
.tag-chip-remove {
  background: none; border: none; color: inherit;
  cursor: pointer; padding: 0; font-size: 0.8rem; line-height: 1;
  opacity: 0.7;
}
.tag-chip-remove:hover { opacity: 1; }
.tag-selector-wrapper { position: relative; }
.tag-selector-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 200;
  background: var(--bg-card); border: 1px solid var(--border-light);
  border-radius: var(--radius-sm); max-height: 180px; overflow-y: auto;
  display: none;
}
.tag-selector-dropdown.open { display: block; }
.tag-selector-option {
  padding: 8px 12px; cursor: pointer; font-size: 0.85rem;
  display: flex; align-items: center; gap: 8px;
}
.tag-selector-option:hover { background: var(--bg-hover); }
.tag-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.tag-chips-container {
  display: flex; flex-wrap: wrap; gap: 4px;
  min-height: 32px; padding: 4px;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: text;
}
.tag-chips-container input {
  border: none; background: none; color: var(--text-primary);
  outline: none; min-width: 80px; flex: 1;
  font-size: 0.85rem; padding: 2px 4px;
}

/* ─── CREDIT CARD UTILIZATION ────────────────── */
.util-bar-wrap { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.util-bar-fill { height: 100%; border-radius: 3px; transition: width 0.3s ease; }
.util-bar-fill.low  { background: var(--accent-green); }
.util-bar-fill.mid  { background: var(--accent-amber); }
.util-bar-fill.high { background: var(--accent-red); }

/* ─── MOBILE QUICK ENTRY (movil.php) ─────────── */
@media (max-width: 480px) {
  .main-content.no-sidebar .page-content { padding: 12px; }
  .movil-type-btn { font-size: 1rem; padding: 14px 20px; flex: 1; }
  .movil-amount-input { font-size: 2rem; text-align: center; }
  .stats-grid { grid-template-columns: 1fr; }
}
