/* ============================================
   SysTrack - Estilos Principales
   Paleta: Azul profundo + Gris técnico + Cyan acento
   ============================================ */

:root {
  --bg-base:       #0f1117;
  --bg-surface:    #181c25;
  --bg-card:       #1e2330;
  --bg-hover:      #252b3b;
  --border:        #2a3147;
  --border-light:  #323b55;

  --text-primary:  #e8eaf0;
  --text-secondary:#8b93aa;
  --text-muted:    #555f7a;

  --accent:        #3b9eff;
  --accent-dark:   #1a7de0;
  --accent-glow:   rgba(59,158,255,.15);

  --success:       #22c55e;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --info:          #06b6d4;
  --purple:        #a855f7;

  --sidebar-w:     240px;
  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 4px 20px rgba(0,0,0,.4);
  --transition:    .2s ease;
}

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  font-size: 14px;
  line-height: 1.6;
}

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

/* ============================
   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;
  overflow-y: auto;
  z-index: 200;
  transition: transform var(--transition);
  padding-bottom: 1rem;
}

.sidebar-brand {
  display: flex; align-items: center; gap: .75rem;
  padding: 1.25rem 1rem 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: .75rem;
}
.brand-icon {
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: #fff; flex-shrink: 0;
}
.brand-name { font-size: 1rem; font-weight: 700; color: var(--text-primary); display: block; }
.brand-sub  { font-size: .68rem; color: var(--text-muted); display: block; }

.sidebar-section-label {
  font-size: .65rem; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-muted);
  padding: .75rem 1rem .3rem;
}

.sidebar-link {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem 1rem; margin: 1px .5rem;
  border-radius: var(--radius-sm);
  color: var(--text-secondary); text-decoration: none;
  font-size: .85rem; font-weight: 500;
  transition: all var(--transition);
}
.sidebar-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-link.active { background: var(--accent-glow); color: var(--accent); }
.sidebar-link i { font-size: 1rem; width: 18px; text-align: center; }

.sidebar-footer {
  margin-top: auto; padding: 1rem;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: .5rem;
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-name  { font-size: .8rem; font-weight: 600; }
.user-role  { font-size: .7rem; color: var(--text-muted); }
.user-info  { display: flex; align-items: center; gap: .6rem; flex: 1; min-width: 0; }
.btn-logout {
  color: var(--text-muted); font-size: 1rem; padding: .3rem;
  border-radius: var(--radius-sm); transition: color var(--transition);
  text-decoration: none;
}
.btn-logout:hover { color: var(--danger); }

.sidebar-toggle {
  display: none; position: fixed; top: 1rem; left: 1rem; z-index: 300;
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-primary); width: 38px; height: 38px;
  border-radius: var(--radius-sm); font-size: 1.1rem;
  cursor: pointer; align-items: center; justify-content: center;
}

/* ============================
   MAIN CONTENT
   ============================ */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  padding: 2rem;
}

/* ============================
   PAGE HEADER
   ============================ */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.75rem; flex-wrap: wrap; gap: 1rem;
}
.page-title { font-size: 1.4rem; font-weight: 700; }
.page-title span { color: var(--accent); }
.page-subtitle { font-size: .82rem; color: var(--text-secondary); margin-top: .15rem; }

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

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  display: flex; align-items: center; gap: 1rem;
  transition: border-color var(--transition), transform var(--transition);
}
.stat-card:hover { border-color: var(--border-light); transform: translateY(-2px); }
.stat-icon {
  width: 46px; height: 46px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .75rem; color: var(--text-secondary); margin-top: .2rem; }

/* ============================
   TABLE
   ============================ */
.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
  flex-wrap: wrap; gap: .75rem;
}
.table-title { font-weight: 600; font-size: .95rem; }

table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--bg-hover); }
th {
  padding: .75rem 1rem; text-align: left;
  font-size: .75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); white-space: nowrap;
}
td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: .85rem; color: var(--text-secondary);
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--bg-hover); }
td .text-main { color: var(--text-primary); font-weight: 500; }

/* ============================
   BADGES / STATUS
   ============================ */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .25rem .65rem; border-radius: 99px;
  font-size: .72rem; font-weight: 600;
}
.badge::before { content:''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge-success  { background: rgba(34,197,94,.12);  color: var(--success); }
.badge-warning  { background: rgba(245,158,11,.12); color: var(--warning); }
.badge-danger   { background: rgba(239,68,68,.12);  color: var(--danger); }
.badge-info     { background: rgba(6,182,212,.12);  color: var(--info); }
.badge-purple   { background: rgba(168,85,247,.12); color: var(--purple); }
.badge-muted    { background: var(--bg-hover);      color: var(--text-muted); }
.badge-accent   { background: var(--accent-glow);   color: var(--accent); }

/* ============================
   BUTTONS
   ============================ */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem; border-radius: var(--radius-sm);
  font-size: .83rem; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; text-decoration: none;
  transition: all var(--transition); white-space: nowrap;
}
.btn-primary  { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover  { background: var(--accent-dark); }
.btn-secondary{ background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-light); }
.btn-secondary:hover { background: var(--border); }
.btn-danger   { background: rgba(239,68,68,.12); color: var(--danger); border-color: rgba(239,68,68,.3); }
.btn-danger:hover { background: rgba(239,68,68,.22); }
.btn-success  { background: rgba(34,197,94,.12); color: var(--success); border-color: rgba(34,197,94,.3); }
.btn-sm       { padding: .3rem .6rem; font-size: .78rem; }
.btn-icon     { padding: .3rem .45rem; }

/* ============================
   FORMS
   ============================ */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 1.25rem; }
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group.span-2 { grid-column: span 2; }
label { font-size: .8rem; font-weight: 500; color: var(--text-secondary); }
.form-control {
  background: var(--bg-hover);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  padding: .55rem .85rem;
  border-radius: var(--radius-sm);
  font-size: .85rem; font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-control::placeholder { color: var(--text-muted); }
select.form-control option { background: var(--bg-card); }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-actions {
  display: flex; gap: .75rem; justify-content: flex-end;
  padding-top: 1.25rem; border-top: 1px solid var(--border);
  margin-top: 1.25rem;
}

/* ============================
   SEARCH + FILTERS
   ============================ */
.search-bar {
  position: relative;
}
.search-bar i {
  position: absolute; left: .75rem; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}
.search-bar input {
  padding-left: 2.25rem;
}
.filter-row {
  display: flex; gap: .75rem; flex-wrap: wrap;
}

/* ============================
   MODAL
   ============================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7); backdrop-filter: blur(3px);
  z-index: 500; display: none; align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  width: min(580px, 95vw);
  max-height: 90vh; overflow-y: auto;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity:0; transform:scale(.96) translateY(10px); } to { opacity:1; transform:none; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem;
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.2rem; }

/* ============================
   TOAST
   ============================ */
.alert-toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 999;
  display: flex; align-items: center; gap: .6rem;
  padding: .75rem 1.25rem; border-radius: var(--radius);
  font-size: .85rem; font-weight: 500;
  box-shadow: var(--shadow); animation: slideIn .3s ease;
  max-width: 380px;
}
@keyframes slideIn { from { opacity:0; transform:translateX(20px); } }
.alert-toast.success { background: rgba(34,197,94,.15); border:1px solid rgba(34,197,94,.3); color: var(--success); }
.alert-toast.error   { background: rgba(239,68,68,.15);  border:1px solid rgba(239,68,68,.3);  color: var(--danger); }
.alert-toast.info    { background: rgba(6,182,212,.15);  border:1px solid rgba(6,182,212,.3);  color: var(--info); }

/* ============================
   PASSWORD VAULT
   ============================ */
.vault-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}
.vault-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem;
  transition: border-color var(--transition);
}
.vault-card:hover { border-color: var(--border-light); }
.vault-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: .75rem; }
.vault-type-icon {
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}
.vault-field { margin-bottom: .5rem; }
.vault-label { font-size: .68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.vault-value { font-size: .82rem; color: var(--text-secondary); font-family: 'JetBrains Mono', monospace; }
.vault-password { filter: blur(5px); transition: filter .2s; cursor: pointer; }
.vault-password.revealed { filter: none; }

/* ============================
   EMPTY STATE
   ============================ */
.empty-state {
  text-align: center; padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 1rem; display: block; }
.empty-state p { font-size: .9rem; }

/* ============================
   TAGS
   ============================ */
.category-tag {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .75rem; color: var(--text-secondary);
}
.category-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}

/* ============================
   PROGRESS BAR
   ============================ */
.progress-bar {
  background: var(--bg-hover); border-radius: 99px; height: 6px; overflow: hidden;
}
.progress-fill { height: 100%; border-radius: 99px; transition: width .5s ease; }



/* ============================
   RESPONSIVE
   ============================ */
/* ============================
   RESPONSIVE MEJORADO
   ============================ */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .sidebar-toggle { display: flex; }
  .main-content { margin-left: 0; padding: 1rem; padding-top: 4rem; }
  .form-group.span-2 { grid-column: span 1; }

  /* Page header */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: .75rem;
  }
  .page-header > a.btn,
  .page-header > button.btn {
    width: 100%;
    justify-content: center;
    min-height: 40px;
    font-size: .9rem;
  }

  /* Filtros */
  .filter-row {
    flex-direction: column;
    gap: .6rem;
  }
  .filter-row .search-bar { width: 100%; }
  .filter-row .search-bar input { width: 100%; }
  .filter-row select.form-control { width: 100% !important; }
  
  /* Fila inferior: botón filtrar + botón X lado a lado */
  .filter-row .btn-primary { flex: 1; justify-content: center; }
  .filter-row .btn-secondary { flex-shrink: 0; }
  .filter-row > .btn-primary,
  .filter-row > .btn-secondary {
    display: inline-flex;
  }

  /* Agrupa los dos botones finales del filtro */
  .filter-row {
    flex-wrap: wrap;
  }
  .filter-row > .btn {
    min-width: 0;
  }
  .filter-row > .btn-primary {
    flex: 1 1 auto;
  }
  .filter-row > a.btn-secondary {
    flex: 0 0 auto;
    width: auto !important;
  }

  /* Tabla scroll horizontal */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table { min-width: 600px; }

  /* Ocultar columnas menos críticas */
  th:nth-child(4), td:nth-child(4),
  th:nth-child(5), td:nth-child(5) {
    display: none;
  }

  /* Stats, vault, form */
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .vault-grid { grid-template-columns: 1fr; }
  .form-grid  { grid-template-columns: 1fr; }

  .form-actions {
    flex-direction: column-reverse;
  }
  .form-actions .btn {
    width: 100%;
/* Tablets (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
  :root { --sidebar-w: 200px; }

  .main-content { padding: 1.25rem; }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .page-title { font-size: 1.2rem; }
}

/* ============================
   UTILITIES
   ============================ */
.text-accent  { color: var(--accent); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger  { color: var(--danger); }
.text-muted   { color: var(--text-muted); }
.font-mono    { font-family: 'JetBrains Mono', monospace; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.ms-auto { margin-left: auto; }

.app-footer {
  width: 100%;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 1rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}