/* =============================================
   Audit / Security Log Page — White Theme
   ============================================= */

/* Filters */
.audit-filters {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-xl);
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-xs);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
}

.filter-group { display: flex; flex-direction: column; gap: 5px; min-width: 150px; flex: 1; }
.filter-group-search { flex: 2; }
.filter-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.07em; }

.filter-select, .filter-date {
  font-size: 13px;
}

.filter-actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}

.btn-filter-apply {
  padding: 9px 18px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  border: none;
  border-radius: var(--r-md);
  color: white;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-filter-apply:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.3); }

.btn-filter-reset {
  padding: 9px 14px;
  background: var(--bg-muted);
  border: 1px solid var(--border-light);
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-filter-reset:hover { background: var(--bg-hover); color: var(--text-primary); }

/* Stats Row */
.audit-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.audit-stat {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: var(--transition);
}
.audit-stat:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }

.astat-val {
  font-size: 28px;
  font-weight: 900;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.astat-red   { color: var(--red); }
.astat-green { color: var(--green); }

.astat-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

/* Table Wrapper */
.audit-table-wrapper {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

/* Audit Table */
.audit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.audit-table thead {
  background: var(--bg-muted);
  border-bottom: 2px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 2;
}

.audit-table th {
  padding: 13px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  user-select: none;
}

.audit-table th.sortable { cursor: pointer; }
.audit-table th.sortable:hover { color: var(--accent); background: var(--accent-light); }
.audit-table th.sorted-asc .sort-icon::after  { content: ' ↑'; }
.audit-table th.sorted-desc .sort-icon::after { content: ' ↓'; }
.sort-icon { opacity: 0.5; }

.audit-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background 0.12s;
}

.audit-table tbody tr:last-child { border-bottom: none; }
.audit-table tbody tr:hover { background: var(--bg-hover); }

.audit-table td {
  padding: 12px 16px;
  vertical-align: middle;
}

/* Row severity */
.row-critical { background: #fff5f5 !important; }
.row-critical:hover { background: #fee2e2 !important; }
.row-warning { background: #fffbf0 !important; }
.row-warning:hover { background: #fef3c7 !important; }

/* New row animation */
.new-row { animation: highlightNew 2s ease forwards; }
@keyframes highlightNew {
  from { background: rgba(99,102,241,0.12); }
  to   { background: transparent; }
}

/* Cells */
.cell-time { white-space: nowrap; }
.date-part {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}
.time-part {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

/* User chip */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--bg-muted);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  padding: 4px 10px 4px 7px;
  white-space: nowrap;
}

.user-chip-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.role-admin { background: linear-gradient(135deg, #9333ea, #e879f9); }
.role-manager { background: linear-gradient(135deg, #2563eb, #60a5fa); }
.role-cashier { background: linear-gradient(135deg, var(--green), #4ade80); }
.role-superadmin { background: linear-gradient(135deg, #dc2626, #f97316); }

/* Action badge */
.action-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.badge-login   { background: var(--blue-bg);   color: #1d4ed8; }
.badge-debt    { background: var(--red-bg);     color: var(--red); }
.badge-payment { background: var(--green-bg);   color: var(--green); }
.badge-update  { background: var(--amber-bg);   color: var(--amber); }
.badge-auth    { background: #f3e8ff;           color: #7c3aed; }
.badge-error   { background: #fef2f2;           color: #be123c; }

/* Detail cell */
.cell-detail {
  max-width: 280px;
}

.cell-detail > div {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.detail-enc {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  color: var(--accent);
  font-weight: 700;
  background: var(--accent-light);
  padding: 2px 7px;
  border-radius: 6px;
  margin-top: 4px;
}

/* Severity badge */
.sev-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: 8px;
  white-space: nowrap;
  letter-spacing: 0.04em;
}
.sev-info     { background: var(--blue-bg);   color: #1d4ed8; }
.sev-normal   { background: var(--green-bg);  color: var(--green); }
.sev-warning  { background: var(--amber-bg);  color: var(--amber); }
.sev-critical { background: var(--red-bg);    color: var(--red); animation: critPulse 1.8s ease infinite; }

@keyframes critPulse {
  0%, 100% { box-shadow: none; }
  50%       { box-shadow: 0 0 0 3px rgba(220,38,38,0.2); }
}

/* Empty state */
.audit-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.3; }
.empty-text { font-size: 14px; font-weight: 500; }

/* Pagination */
.audit-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-muted);
  gap: 12px;
  flex-wrap: wrap;
}

.pagination-info { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }

.pagination-controls { display: flex; gap: 4px; }

.page-btn {
  min-width: 32px; height: 32px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-sm);
  color: var(--text-secondary);
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.page-btn.active {
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}

.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* Responsive */
@media (max-width: 900px) {
  .audit-stats { grid-template-columns: 1fr 1fr; }
  .filter-row { flex-direction: column; }
  .cell-detail { max-width: 160px; }
  .audit-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .audit-table { min-width: 650px; }
}

@media (max-width: 640px) {
  .audit-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .astat-val { font-size: 22px; }
  .audit-filters { padding: 16px; }
  .filter-group { width: 100%; flex: none; min-width: 0; }
  .filter-actions { flex-direction: row; gap: 8px; width: 100%; }
  .btn-filter-apply, .btn-filter-reset { flex: 1; padding: 10px 12px; }
  .audit-pagination { flex-direction: column; align-items: center; padding: 12px; }
  .pagination-info { text-align: center; }
  .pagination-controls { justify-content: center; flex-wrap: wrap; gap: 4px; }
  .cell-detail { max-width: 100px; }
  .audit-table th, .audit-table td { padding: 10px 12px; }
  
  /* Form inputs prevent iOS zoom */
  .form-input,
  .form-select,
  .form-textarea {
    font-size: 16px !important;
  }
  
  /* Filter row */
  .filter-row {
    gap: 10px;
  }
  
  /* Filter label */
  .filter-label {
    font-size: 10px;
    margin-bottom: 4px;
  }
  
  /* Filter select */
  .filter-select,
  .filter-date {
    font-size: 14px !important;
    padding: 10px 12px;
  }
  
  /* Filter actions */
  .filter-actions {
    flex-direction: column;
    gap: 8px;
  }
  
  .btn-filter-apply,
  .btn-filter-reset {
    width: 100%;
    text-align: center;
    justify-content: center;
  }
  
  /* Audit stat */
  .audit-stat {
    padding: 14px 16px;
  }
  
  .astat-label {
    font-size: 10px;
  }
  
  /* User chip */
  .user-chip {
    padding: 3px 8px 3px 6px;
    gap: 5px;
  }
  
  .user-chip-dot {
    width: 6px;
    height: 6px;
  }
  
  .user-chip span:last-child {
    font-size: 11px;
  }
  
  /* Action badge */
  .action-badge {
    font-size: 10.5px;
    padding: 3px 8px;
  }
  
  /* Severity badge */
  .sev-badge {
    font-size: 10px;
    padding: 3px 7px;
  }
  
  /* Time cell */
  .cell-time {
    white-space: nowrap;
  }
  
  .date-part {
    font-size: 11px;
  }
  
  .time-part {
    font-size: 10px;
  }
  
  /* Audit table */
  .audit-table {
    font-size: 12px;
  }
  
  .audit-table th {
    padding: 10px 12px;
    font-size: 10px;
  }
  
  .audit-table td {
    padding: 10px 12px;
  }
  
  /* Pagination */
  .audit-pagination {
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 12px;
  }
  
  .pagination-info {
    text-align: center;
    font-size: 12px;
  }
  
  .pagination-controls {
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
  }
  
  .page-btn {
    min-width: 30px;
    height: 30px;
    font-size: 12px;
  }
  
  /* Empty state */
  .audit-empty {
    padding: 40px 16px;
  }
  
  .empty-icon {
    font-size: 40px;
  }
  
  .empty-text {
    font-size: 13px;
  }
}

@media (max-width: 400px) {
  .audit-filters {
    padding: 14px;
  }
  
  .audit-stats {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  
  .audit-stat {
    padding: 12px 14px;
  }
  
  .astat-val {
    font-size: 20px;
  }
  
  .astat-label {
    font-size: 9px;
  }
  
  .audit-table {
    min-width: 550px;
  }
  
  .audit-table th {
    padding: 8px 10px;
    font-size: 9px;
  }
  
  .audit-table td {
    padding: 8px 10px;
    font-size: 11px;
  }
  
  .cell-detail {
    max-width: 80px;
  }
  
  .cell-detail > div {
    font-size: 11px;
    -webkit-line-clamp: 1;
  }
  
  .user-chip {
    padding: 2px 6px 2px 5px;
    gap: 4px;
  }
  
  .user-chip span:last-child {
    font-size: 10px;
  }
  
  .action-badge {
    font-size: 10px;
    padding: 2px 6px;
  }
  
  .sev-badge {
    font-size: 9px;
    padding: 2px 6px;
  }
  
  .date-part {
    font-size: 10px;
  }
  
  .time-part {
    font-size: 9px;
  }
  
  .page-btn {
    min-width: 28px;
    height: 28px;
    font-size: 11px;
    padding: 4px 8px;
  }
}
