/* ── Container ─────────────────────────────────────────────────── */
.audit-logs-container {
  padding: 20px;
  max-width: 1200px;
  margin: 0 auto;
}

.audit-header { margin-bottom: 16px; }
.audit-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.audit-header h2  { margin: 0 0 4px 0; color: #333; font-size: 26px; }
.audit-description { margin: 0; color: #666; font-size: 13px; }

.audit-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* ── Statistics ─────────────────────────────────────────────────── */
.stats-toggle-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 10px;
}
.btn-stats-toggle {
  padding: 6px 14px;
  background: #f0f4f8;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  color: #444;
}
.btn-stats-toggle:hover { background: #e2e8f0; }
.stats-days-select { font-size: 13px; }

.audit-stats {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.stats-loading { color: #888; font-size: 13px; padding: 8px 0; }

.stats-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.stat-card {
  flex: 1;
  min-width: 100px;
  background: white;
  border-radius: 8px;
  padding: 12px 16px;
  text-align: center;
  border: 1px solid #e2e8f0;
}
.stat-number { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label  { font-size: 11px; color: #666; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-total  .stat-number { color: #1976d2; }
.stat-failed .stat-number { color: #c62828; }
.stat-success .stat-number { color: #2e7d32; }
.stat-period  .stat-number { color: #555; font-size: 20px; }

.stats-details {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}
.stats-col { flex: 1; min-width: 180px; }
.stats-col h4 { margin: 0 0 8px 0; font-size: 12px; text-transform: uppercase; color: #888; letter-spacing: 0.5px; }

.stat-bar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
}
.stat-bar-label  { font-size: 13px; color: #444; }
.stat-bar-count  { font-size: 13px; font-weight: 600; color: #333; flex-shrink: 0; }

/* Mini bar chart */
.stats-chart-col { flex: 2; min-width: 220px; }
.mini-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 80px;
  background: #f0f4f8;
  border-radius: 6px;
  padding: 6px 6px 0;
}
.chart-bar-wrap {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: flex-end;
}
.chart-bar {
  width: 100%;
  background: #1976d2;
  border-radius: 2px 2px 0 0;
  position: relative;
  min-height: 4px;
  overflow: hidden;
}
.chart-bar-failed {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #e53935;
}

/* ── Filters ─────────────────────────────────────────────────────── */
.audit-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.filter-select {
  padding: 8px 12px;
  border: 1.5px solid #d0d7de;
  border-radius: 6px;
  font-size: 13px;
  background: white;
  cursor: pointer;
}
.filter-select:focus { outline: none; border-color: #1976d2; }
.filter-input {
  padding: 8px 12px;
  border: 1.5px solid #d0d7de;
  border-radius: 6px;
  font-size: 13px;
  background: white;
  min-width: 140px;
}
.filter-input:focus { outline: none; border-color: #1976d2; }
.filter-date { min-width: 130px; }

.btn-refresh {
  padding: 8px 14px;
  background: #1976d2;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
.btn-refresh:hover:not(:disabled) { background: #1565c0; }
.btn-refresh:disabled { background: #bdbdbd; cursor: not-allowed; }

.btn-reset {
  padding: 8px 12px;
  background: white;
  color: #666;
  border: 1.5px solid #d0d7de;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.btn-reset:hover { background: #f5f5f5; }

.btn-export {
  padding: 8px 16px;
  background: #2e7d32;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}
.btn-export:hover:not(:disabled) { background: #1b5e20; }
.btn-export:disabled { background: #bdbdbd; cursor: not-allowed; }

.auto-refresh-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #555;
  cursor: pointer;
  white-space: nowrap;
}

/* ── Results bar ─────────────────────────────────────────────────── */
.audit-results-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #666;
  margin-bottom: 10px;
}
.limit-select { padding: 4px 8px; font-size: 13px; }

/* ── Badges ──────────────────────────────────────────────────────── */
.audit-badge {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.badge-create       { background: #e8f5e9; color: #2e7d32; }
.badge-update       { background: #e3f2fd; color: #1565c0; }
.badge-delete       { background: #ffebee; color: #c62828; }
.badge-restore      { background: #fff3e0; color: #e65100; }
.badge-login        { background: #f3e5f5; color: #6a1b9a; }
.badge-logout       { background: #fce4ec; color: #880e4f; }
.badge-login-failed { background: #ffcdd2; color: #b71c1c; font-weight: 700; }
.badge-import       { background: #e0f7fa; color: #00695c; }
.badge-export       { background: #e8f5e9; color: #1b5e20; }
.badge-bulk-update  { background: #e8eaf6; color: #283593; }
.badge-bulk-delete  { background: #fbe9e7; color: #bf360c; }
.badge-password     { background: #fff8e1; color: #f57f17; }
.badge-default      { background: #f5f5f5; color: #616161; }

.status-code {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  font-family: monospace;
}
.status-ok           { background: #e8f5e9; color: #2e7d32; }
.status-redirect     { background: #fff3e0; color: #e65100; }
.status-error        { background: #ffebee; color: #c62828; }
.status-server-error { background: #f3e5f5; color: #6a1b9a; }

.duration-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  background: #f5f5f5;
  color: #777;
  font-family: monospace;
}

/* ── Log list ────────────────────────────────────────────────────── */
.audit-empty {
  text-align: center;
  padding: 40px;
  background: #f9f9f9;
  border-radius: 8px;
  color: #888;
}
.audit-error { text-align: center; padding: 20px; }
.audit-error p { color: #d32f2f; margin: 0; }

.audit-list { display: flex; flex-direction: column; gap: 8px; }

.audit-item {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  transition: box-shadow 0.15s;
}
.audit-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.audit-item-failed { border-left: 4px solid #e53935; }

.audit-item-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  flex-wrap: wrap;
  background: #fafafa;
  border-bottom: 1px solid #f0f0f0;
}
.audit-time { margin-left: auto; color: #999; font-size: 12px; white-space: nowrap; }
.expand-toggle { color: #aaa; font-size: 11px; cursor: pointer; padding: 0 4px; }

.audit-resource {
  padding: 3px 8px;
  background: #f0f0f0;
  border-radius: 4px;
  font-size: 12px;
  color: #555;
}

.audit-item-body {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 8px 14px;
  font-size: 13px;
  align-items: center;
}
.audit-admin        { color: #333; }
.audit-resource-name { color: #555; }
.audit-ip           { color: #999; font-family: monospace; font-size: 12px; }
.audit-failed-badge { color: #c62828; font-weight: 600; font-size: 12px; }

/* ── Expanded detail ─────────────────────────────────────────────── */
.audit-item-detail {
  padding: 10px 14px 14px;
  border-top: 1px dashed #e0e0e0;
  background: #fefefe;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.detail-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
}
.detail-label {
  font-weight: 600;
  color: #888;
  font-size: 11px;
  text-transform: uppercase;
  min-width: 70px;
  flex-shrink: 0;
}
.detail-row code {
  font-family: monospace;
  background: #f0f0f0;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 12px;
}
.detail-ua-full {
  color: #aaa;
  cursor: help;
  font-size: 12px;
}
.detail-error { color: #c62828; }
.detail-error .detail-label { color: #c62828; }

.meta-tag {
  display: inline-block;
  background: #e8eaf6;
  color: #283593;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 12px;
  margin-right: 6px;
}

/* ── Diff table ──────────────────────────────────────────────────── */
.detail-diff { margin-top: 4px; }
.diff-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 6px;
}
.diff-table th {
  background: #f0f0f0;
  padding: 5px 10px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  color: #666;
  border: 1px solid #e0e0e0;
}
.diff-table td { padding: 5px 10px; border: 1px solid #e8e8e8; vertical-align: top; }
.diff-field  { font-weight: 600; color: #444; font-family: monospace; white-space: nowrap; background: #fafafa; }
.diff-before { color: #c62828; background: #fff5f5; font-family: monospace; word-break: break-all; }
.diff-after  { color: #2e7d32; background: #f5fff5; font-family: monospace; word-break: break-all; }

/* ── Pagination ──────────────────────────────────────────────────── */
.audit-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
}
.btn-page {
  padding: 7px 14px;
  border: 1.5px solid #d0d7de;
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-size: 13px;
  color: #333;
}
.btn-page:hover:not(:disabled) { background: #f0f4f8; border-color: #1976d2; }
.btn-page:disabled { color: #bbb; cursor: not-allowed; border-color: #eee; }
.page-info { font-size: 13px; color: #666; padding: 0 8px; }


.audit-header {
  margin-bottom: 24px;
}

.audit-header h2 {
  margin: 0 0 8px 0;
  color: #333;
  font-size: 28px;
}

.audit-description {
  margin: 0;
  color: #666;
  font-size: 14px;
}

.audit-loading,
.audit-error {
  text-align: center;
  padding: 40px 20px;
}

.audit-error p {
  color: #d32f2f;
  margin: 0;
}

.audit-filters {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-select {
  padding: 10px 14px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 14px;
  background: white;
  cursor: pointer;
  transition: border-color 0.2s;
}

.filter-select:focus {
  outline: none;
  border-color: #1976d2;
}

.btn-refresh {
  padding: 10px 16px;
  background: #1976d2;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
}

.btn-refresh:hover:not(:disabled) {
  background: #1565c0;
}

.btn-refresh:disabled {
  background: #bdbdbd;
  cursor: not-allowed;
}

.audit-empty {
  text-align: center;
  padding: 40px;
  background: #f5f5f5;
  border-radius: 8px;
  color: #666;
}

.audit-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.audit-item {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 16px;
  transition: box-shadow 0.2s;
}

.audit-item:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.audit-item-header {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.audit-badge {
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-create {
  background: #e8f5e9;
  color: #2e7d32;
}

.badge-update {
  background: #e3f2fd;
  color: #1565c0;
}

.badge-delete {
  background: #ffebee;
  color: #c62828;
}

.badge-restore {
  background: #fff3e0;
  color: #e65100;
}

.badge-login {
  background: #f3e5f5;
  color: #6a1b9a;
}

.badge-logout {
  background: #fce4ec;
  color: #880e4f;
}

.badge-login-failed {
  background: #ffcdd2;
  color: #b71c1c;
  font-weight: 700;
}

.badge-default {
  background: #f5f5f5;
  color: #616161;
}

.audit-resource {
  padding: 4px 10px;
  background: #f5f5f5;
  border-radius: 4px;
  font-size: 13px;
  color: #666;
}

.audit-time {
  margin-left: auto;
  color: #999;
  font-size: 13px;
}

.audit-item-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
}

.audit-admin {
  color: #333;
}

.audit-resource-name {
  color: #666;
}

.audit-ip {
  color: #888;
  font-family: monospace;
  font-size: 13px;
}

.audit-error-message {
  color: #d32f2f;
  font-weight: 500;
}

.audit-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
  padding: 16px;
  background: white;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}

.btn-page {
  padding: 8px 16px;
  background: #1976d2;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
}

.btn-page:hover:not(:disabled) {
  background: #1565c0;
}

.btn-page:disabled {
  background: #bdbdbd;
  cursor: not-allowed;
}

.page-info {
  color: #666;
  font-size: 14px;
}

@media (max-width: 768px) {
  .audit-item-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .audit-time {
    margin-left: 0;
  }

  .audit-filters {
    flex-direction: column;
  }

  .filter-select,
  .btn-refresh {
    width: 100%;
  }
}
