/**
 * Modern Dark Theme CSS
 * 
 * A reusable modern dark theme inspired by Shadcn UI design system.
 * Can be applied to any dashboard or component for a consistent modern look.
 * 
 * Color Palette (Zinc-based):
 * - Background: #0a0a0a (zinc-950)
 * - Card/Container: #18181b (zinc-900)
 * - Border: #27272a (zinc-800)
 * - Hover: #3f3f46 (zinc-700)
 * - Text Primary: #e4e4e7 (zinc-100)
 * - Text Muted: #a1a1aa (zinc-400)
 * - Text Secondary: #d4d4d8 (zinc-300)
 */

/* ============================================
   BASE STYLES
   ============================================ */

/* Page-level scrollbar (html element) for dark theme pages */
html:has(body.modern-dark-theme) {
  scrollbar-width: thin;
  scrollbar-color: #3f3f46 #0a0a0a;
}

html:has(body.modern-dark-theme)::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

html:has(body.modern-dark-theme)::-webkit-scrollbar-track {
  background: #0a0a0a;
}

html:has(body.modern-dark-theme)::-webkit-scrollbar-thumb {
  background: #3f3f46;
  border-radius: 5px;
}

html:has(body.modern-dark-theme)::-webkit-scrollbar-thumb:hover {
  background: #52525b;
}

.modern-dark-theme {
  background: #0a0a0a;
  color: #e4e4e7;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Roboto", sans-serif;
  scrollbar-width: thin;
  scrollbar-color: #3f3f46 #18181b;
}

.modern-dark-theme * {
  scrollbar-width: thin;
  scrollbar-color: #3f3f46 #18181b;
}

.modern-dark-theme *::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.modern-dark-theme *::-webkit-scrollbar-track {
  background: #18181b;
  border-radius: 5px;
}

.modern-dark-theme *::-webkit-scrollbar-thumb {
  background: #3f3f46;
  border-radius: 5px;
}

.modern-dark-theme *::-webkit-scrollbar-thumb:hover {
  background: #52525b;
}

.modern-dark-theme body {
  padding: 0;
  background: #0a0a0a;
  color: #e4e4e7;
}

.modern-dark-theme .content {
  padding: 32px;
  background: #0a0a0a;
  max-width: 1600px;
  margin: 0 auto;
}

.modern-dark-theme .tab-content {
  background: #0a0a0a;
  box-shadow: none;
}

.modern-dark-theme .toolbar {
  background: #18181b;
  box-shadow: none;
}

.modern-dark-theme .btn-primary.btn-sm,
.modern-dark-theme .btn-secondary.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 6px;
}

/* ============================================
   FORMS & INPUTS
   ============================================ */

.modern-dark-theme .filters {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.modern-dark-theme .filter-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modern-dark-theme .filter-group label {
  font-size: 13px;
  font-weight: 500;
  color: #d4d4d8;
  letter-spacing: 0.01em;
}

.modern-dark-theme .filter-group input,
.modern-dark-theme .filter-group select {
  padding: 10px 14px;
  border: 1px solid #27272a;
  border-radius: 8px;
  font-size: 14px;
  background: #18181b;
  color: #e4e4e7;
  transition: all 0.2s ease;
}

.modern-dark-theme .filter-group input:hover,
.modern-dark-theme .filter-group select:hover {
  border-color: #3f3f46;
}

.modern-dark-theme .filter-group input:focus,
.modern-dark-theme .filter-group select:focus {
  outline: none;
  border-color: #a72468;
  box-shadow: 0 0 0 3px rgba(167, 36, 104, 0.1);
}

.modern-dark-theme .filter-group.date-range-group {
  grid-column: 1 / -1;
}

.modern-dark-theme .date-range-inputs {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

.modern-dark-theme .date-input-wrapper {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 8px;
}

.modern-dark-theme .date-input-label {
  font-size: 12px;
  font-weight: 500;
  color: #a1a1aa;
  letter-spacing: 0.01em;
}

.modern-dark-theme .date-input-wrapper input[type="date"] {
  padding: 10px 14px;
  border: 1px solid #27272a;
  border-radius: 8px;
  font-size: 14px;
  background: #18181b;
  color: #e4e4e7;
  transition: all 0.2s ease;
  width: 100%;
}

.modern-dark-theme .date-input-wrapper input[type="date"]:hover {
  border-color: #3f3f46;
}

.modern-dark-theme .date-input-wrapper input[type="date"]:focus {
  outline: none;
  border-color: #a72468;
  box-shadow: 0 0 0 3px rgba(167, 36, 104, 0.1);
}

.modern-dark-theme .filter-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  justify-content: flex-end;
  padding-top: 20px;
  border-top: 1px solid #27272a;
}

/* ============================================
   TABLES
   ============================================ */

.modern-dark-theme .table-container {
  overflow-x: auto;
  margin-bottom: 24px;
  background: #18181b;
  border-radius: 12px;
  border: 1px solid #27272a;
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.3),
    0 2px 4px -1px rgba(0, 0, 0, 0.2);
  padding: 24px;
}

.modern-dark-theme table {
  width: 100%;
  border-collapse: collapse;
}

.modern-dark-theme th,
.modern-dark-theme td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid #27272a;
  color: #e4e4e7;
}

.modern-dark-theme th {
  background: transparent;
  font-weight: 600;
  color: #a1a1aa;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 16px;
}

.modern-dark-theme tr {
  transition: background-color 0.15s ease;
}

.modern-dark-theme tr:hover {
  background: #27272a;
}

.modern-dark-theme tbody tr:last-child td {
  border-bottom: none;
}

/* ============================================
   PAGINATION
   ============================================ */

.modern-dark-theme .pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  padding: 16px 0;
}

.modern-dark-theme .pagination-info {
  color: #a1a1aa;
  font-size: 14px;
  font-weight: 500;
}

.modern-dark-theme .pagination-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.modern-dark-theme .pagination-per-page {
  display: flex;
  align-items: center;
}

.modern-dark-theme .per-page-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modern-dark-theme .per-page-label {
  font-size: 13px;
  color: #a1a1aa;
  font-weight: 500;
}

.modern-dark-theme .per-page-select {
  padding: 6px 10px;
  border: 1px solid #27272a;
  border-radius: 8px;
  background: rgba(24, 24, 27, 0.6);
  color: #e4e4e7;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 60px;
}

.modern-dark-theme .per-page-select:hover {
  border-color: #3f3f46;
  background: rgba(39, 39, 42, 0.8);
}

.modern-dark-theme .per-page-select:focus {
  outline: none;
  border-color: #a72468;
  box-shadow: 0 0 0 3px rgba(167, 36, 104, 0.1);
}

.modern-dark-theme .pagination-per-page select,
.modern-dark-theme .pagination-controls select {
  padding: 8px 12px;
  border: 1px solid #27272a;
  border-radius: 8px;
  background: #18181b;
  color: #e4e4e7;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modern-dark-theme .pagination-per-page select:hover,
.modern-dark-theme .pagination-controls select:hover {
  border-color: #3f3f46;
}

.modern-dark-theme .pagination-controls button:not(.pagination-icon-btn) {
  padding: 8px 16px;
  border: 1px solid #27272a;
  background: #18181b;
  color: #e4e4e7;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.modern-dark-theme .pagination-controls .pagination-icon-btn,
.modern-dark-theme .pagination-icon-btn {
  padding: 0 !important;
  width: 36px !important;
  height: 36px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: 1px solid #27272a !important;
  background: rgba(24, 24, 27, 0.9) !important;
  color: #e4e4e7 !important;
  border-radius: 8px !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
  position: relative !important;
  z-index: 1 !important;
  min-width: 36px !important;
}

.modern-dark-theme .pagination-controls .pagination-icon-btn svg,
.modern-dark-theme .pagination-icon-btn svg {
  width: 16px !important;
  height: 16px !important;
  pointer-events: none !important;
  display: block !important;
}

.modern-dark-theme
  .pagination-controls
  .pagination-icon-btn:hover:not(:disabled),
.modern-dark-theme .pagination-icon-btn:hover:not(:disabled) {
  background: rgba(39, 39, 42, 0.95) !important;
  border-color: #3f3f46 !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4) !important;
  transform: translateY(-1px) !important;
}

.modern-dark-theme .pagination-controls .pagination-icon-btn:disabled,
.modern-dark-theme .pagination-icon-btn:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
  background: rgba(24, 24, 27, 0.6) !important;
}

.modern-dark-theme
  .pagination-controls
  button:not(.pagination-icon-btn):hover:not(:disabled) {
  background: #27272a;
  border-color: #3f3f46;
}

.modern-dark-theme
  .pagination-controls
  button:not(.pagination-icon-btn):disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.modern-dark-theme .pagination-controls #pageInfo {
  font-size: 14px;
  font-weight: 500;
  color: #e4e4e7;
  padding: 0 8px;
  min-width: 24px;
  text-align: center;
}

/* ============================================
   ALERTS
   ============================================ */

.modern-dark-theme .alert {
  padding: 14px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  border: 1px solid;
  font-size: 14px;
}

.modern-dark-theme .alert-error {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}

.modern-dark-theme .alert-success {
  background: rgba(34, 197, 94, 0.1);
  color: #86efac;
  border-color: rgba(34, 197, 94, 0.3);
}

/* ============================================
   BUTTONS
   ============================================ */

.modern-dark-theme .btn-primary {
  background: rgba(99, 102, 241, 0.7);
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  font-size: 14px;
  font-weight: 500;
  height: auto;
}

.modern-dark-theme .btn-primary:hover {
  background: rgba(99, 102, 241, 0.85);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
  transform: translateY(-1px);
}

.modern-dark-theme .btn-secondary {
  background: rgba(39, 39, 42, 0.6);
  color: #e4e4e7;
  border: 1px solid #3f3f46;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.modern-dark-theme .btn-secondary:hover {
  background: rgba(39, 39, 42, 0.8);
  border-color: #52525b;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
  transform: translateY(-1px);
}

.modern-dark-theme .btn-danger {
  background: rgba(239, 68, 68, 0.6);
  color: white;
  transition: all 0.2s ease;
  border: none;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.modern-dark-theme .btn-danger:hover {
  background: rgba(239, 68, 68, 0.75);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
  transform: translateY(-1px);
}

.modern-dark-theme .btn-view {
  background: rgba(99, 102, 241, 0.6);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.modern-dark-theme .btn-view:hover {
  background: rgba(99, 102, 241, 0.75);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
  transform: translateY(-1px);
}

.modern-dark-theme .btn-save {
  background: rgba(6, 28, 47, 0.5);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  position: relative;
}

.modern-dark-theme .btn-save:hover:not(:disabled) {
  background: rgba(6, 28, 47, 0.7);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
  transform: translateY(-1px);
}

.modern-dark-theme .btn-user {
  background: rgba(167, 36, 104, 0.5);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  position: relative;
}

.modern-dark-theme .btn-user:hover {
  background: rgba(167, 36, 104, 0.7);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
  transform: translateY(-1px);
}

.modern-dark-theme .btn-logout {
  background: rgba(167, 36, 104, 0.5);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  position: relative;
}

.modern-dark-theme .btn-logout:hover {
  background: rgba(167, 36, 104, 0.7);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
  transform: translateY(-1px);
}

.modern-dark-theme .btn-danger.btn-sm,
.modern-dark-theme .btn-view.btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 6px;
}

/* Icon-only small buttons (no text, only svg) */
.modern-dark-theme .btn-danger.btn-sm:has(svg:only-child),
.modern-dark-theme .btn-view.btn-sm:has(svg:only-child) {
  padding: 0;
  width: 36px;
  height: 36px;
  margin: 0 auto;
  border-radius: 8px;
}

/* ============================================
   TOOLTIPS
   ============================================ */

.modern-dark-theme [data-tooltip]::after,
.modern-dark-theme .btn-save::after,
.modern-dark-theme .btn-user::after,
.modern-dark-theme .btn-logout::after {
  content: attr(data-tooltip) attr(data-email);
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 12px;
  background: #18181b;
  color: #e4e4e7;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 1000;
  border: 1px solid #27272a;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

.modern-dark-theme [data-tooltip]::before,
.modern-dark-theme .btn-save::before,
.modern-dark-theme .btn-user::before,
.modern-dark-theme .btn-logout::before {
  content: "";
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid #18181b;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 1001;
}

.modern-dark-theme [data-tooltip]:hover::after,
.modern-dark-theme [data-tooltip]:hover::before,
.modern-dark-theme .btn-save:hover::after,
.modern-dark-theme .btn-save:hover::before,
.modern-dark-theme .btn-user:hover::after,
.modern-dark-theme .btn-user:hover::before,
.modern-dark-theme .btn-logout:hover::after,
.modern-dark-theme .btn-logout:hover::before {
  opacity: 1;
}

/* ============================================
   MODALS
   ============================================ */

.modern-dark-theme .modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
}

.modern-dark-theme .modal-content {
  background: #18181b;
  margin: 5% auto;
  padding: 32px;
  border-radius: 16px;
  width: 90%;
  max-width: 800px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow:
    0 20px 25px -5px rgba(0, 0, 0, 0.5),
    0 10px 10px -5px rgba(0, 0, 0, 0.3);
  border: 1px solid #27272a;
  color: #e4e4e7;
  scrollbar-width: thin;
  scrollbar-color: #3f3f46 #18181b;
}

.modern-dark-theme .modal-content::-webkit-scrollbar {
  width: 10px;
}

.modern-dark-theme .modal-content::-webkit-scrollbar-track {
  background: #18181b;
  border-radius: 5px;
}

.modern-dark-theme .modal-content::-webkit-scrollbar-thumb {
  background: #3f3f46;
  border-radius: 5px;
}

.modern-dark-theme .modal-content::-webkit-scrollbar-thumb:hover {
  background: #52525b;
}

.modern-dark-theme .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  border-bottom: 1px solid #27272a;
  padding-bottom: 16px;
}

.modern-dark-theme .modal-header h2 {
  margin: 0;
  color: #e4e4e7;
  font-size: 20px;
  font-weight: 600;
}

.modern-dark-theme .close {
  font-size: 24px;
  font-weight: 400;
  cursor: pointer;
  color: #a1a1aa;
  border: none;
  background: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.modern-dark-theme .close:hover {
  color: #e4e4e7;
  background: #27272a;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.modern-dark-theme .loading {
  text-align: center;
  padding: 32px;
  color: #a1a1aa;
  font-size: 14px;
}

.modern-dark-theme .event-detail {
  font-size: 13px;
  color: #a1a1aa;
}

.modern-dark-theme .formula-name {
  font-weight: 500;
  color: #e4e4e7;
}

.modern-dark-theme .event-detail-content {
  font-family:
    "SF Mono", "Monaco", "Inconsolata", "Fira Code", "Courier New", monospace;
  background: #0a0a0a;
  padding: 20px;
  border-radius: 8px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 13px;
  line-height: 1.6;
  color: #e4e4e7;
  border: 1px solid #27272a;
}

.modern-dark-theme .actions-cell {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
}
