/* ============================================
   CARDS.CSS - Card Components
   Funky cards, table cards, stat cards
   ============================================ */

/* ============================================
   FUNKY CARDS
   ============================================ */
.funky-card {
  background: var(--pro-bg-elevated);
  border: 1px solid var(--pro-border-color);
  border-radius: 15px;
  padding: 25px;
  margin-bottom: 25px;
  transition: all 0.3s ease;
  position: relative;
  overflow: visible;
  animation: cardSlideIn 0.7s ease-out;
}

@keyframes cardSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.funky-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--user-accent, var(--pro-accent-primary));
  border-radius: 15px 15px 0 0;
  display: none; /* Only show in even-funkyer theme */
}

/* ============================================
   TABLE CARD VARIANT
   Edge-to-edge tables with no padding
   ============================================ */
.funky-card.table-card {
  padding: 0;
  overflow: hidden;
}

.funky-card.table-card::before {
  display: none;
}

.funky-card.table-card .funky-header-actions {
  padding: 16px 20px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--pro-border-color);
  background: var(--pro-bg-secondary);
}

.funky-card.table-card .dataTables_wrapper {
  padding: 0;
}

.funky-card.table-card table.dataTable {
  margin: 0 !important;
  border-radius: 0;
}

.funky-card.table-card table.dataTable thead th:first-child {
  border-top-left-radius: 0;
}

.funky-card.table-card table.dataTable thead th:last-child {
  border-top-right-radius: 0;
}

.funky-card.table-card .dataTables_info,
.funky-card.table-card .dataTables_paginate,
.funky-card.table-card .dataTables_length {
  padding: 12px 20px;
  background: var(--pro-bg-secondary);
  border-top: 1px solid var(--pro-border-color);
}

/* DataTable footer row layout */
.funky-card.table-card .dataTables_wrapper > div:last-child {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 20px;
  background: var(--pro-bg-secondary);
  border-top: 1px solid var(--pro-border-color);
}

/* ============================================
   DATATABLE BUTTONS ROW INSIDE FUNKY-CARD
   Styles the buttons row generated by DataTables dom
   ============================================ */
.funky-card .dataTables_wrapper > .row:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  margin: 0;
  background: var(--pro-bg-secondary);
  border-bottom: 1px solid var(--pro-border-color);
}

.funky-card .dataTables_wrapper > .row:first-child > [class*="col-"] {
  flex: 0 0 auto;
  width: auto;
  padding: 0;
}

.funky-card .dataTables_wrapper > .row:first-child .dt-buttons {
  display: flex !important;
  gap: 8px;
  align-items: center;
}

.funky-card .dataTables_wrapper > .row:first-child .dataTables_length {
  display: flex;
  align-items: center;
  gap: 8px;
}

.funky-card .dataTables_wrapper > .row:first-child .dataTables_length label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--pro-text-secondary);
  font-size: 13px;
}

.funky-card .dataTables_wrapper > .row:first-child .dataTables_length select {
  background: var(--pro-bg-tertiary);
  border: 1px solid var(--pro-border-color);
  border-radius: 6px;
  color: var(--pro-text-primary);
  padding: 6px 28px 6px 12px;
  font-size: 13px;
  height: 32px;
  min-width: 70px;
}

.funky-card .dataTables_wrapper > .row:first-child .dataTables_length select:focus {
  border-color: var(--pro-accent-primary);
  outline: none;
  box-shadow: 0 0 0 2px var(--pro-accent-primary-muted);
}

/* Card Header */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--pro-border-color);
}

.card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--pro-text-primary);
  margin: 0;
}

/* ============================================
   STATS CARDS
   ============================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
  animation: statsFadeInUp 0.6s ease-out;
}

@keyframes statsFadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.stat-card {
  background: var(--pro-bg-elevated);
  border: 1px solid var(--pro-border-color);
  border-radius: 15px;
  padding: 20px;
  position: relative;
  overflow: visible;
  transition: all 0.3s ease;
  cursor: default;
}

.stat-card:hover {
  transform: translateY(-5px);
  border-color: var(--user-accent, var(--pro-accent-primary));
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--user-accent, var(--pro-accent-primary)), var(--pro-accent-info), var(--pro-accent-primary));
  background-size: 200% 100%;
  animation: gradientShift 3s ease infinite;
  border-radius: 15px 15px 0 0;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.stat-card::after {
  content: '';
  position: absolute;
  top: -20px;
  right: -20px;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, var(--user-accent-muted, rgba(47, 129, 247, 0.15)) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}

.stat-icon {
  font-size: 42px;
  margin-bottom: 12px;
  display: block;
  animation: statFloat 3s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px var(--pro-shadow-color, rgba(0, 0, 0, 0.2)));
  position: relative;
  z-index: 1;
}

@keyframes statFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.stat-label {
  font-size: 13px;
  color: var(--pro-text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
  font-weight: 600;
  display: block;
  position: relative;
  z-index: 1;
}

.stat-value {
  font-size: 36px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--user-accent, var(--pro-accent-primary)), var(--pro-accent-info));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
  display: block;
  position: relative;
  z-index: 1;
}

.stat-change {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.stat-change.positive {
  color: var(--pro-accent-success, #10b981);
}

.stat-change.negative {
  color: var(--pro-accent-danger, #ef4444);
}

/* ============================================
   DETAIL ROWS (Modal details)
   ============================================ */
.security-details-grid,
.client-details-grid {
  display: grid;
  gap: 15px;
}

.detail-row {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 15px;
  padding: 12px;
  background: var(--pro-bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--pro-border-color);
}

.detail-label {
  font-weight: 600;
  color: var(--user-accent, var(--pro-accent-primary));
}

.detail-value {
  color: var(--pro-text-primary);
  word-break: break-word;
}

/* Full width detail row for config */
.detail-row.full-width {
  grid-template-columns: 1fr;
}

.detail-row.full-width .detail-label {
  margin-bottom: 10px;
}

/* ============================================
   RESPONSIVE
   ============================================ */

/* Tablet (768px - 1024px) */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .stats-row {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 15px;
  }
  
  .stat-card {
    padding: 20px;
  }
  
  .stat-icon {
    font-size: 36px;
  }
  
  .stat-value {
    font-size: 30px;
  }
}

/* Mobile (768px) */
@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .stats-row {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 20px;
  }
  
  .stat-card {
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 15px;
  }
  
  .stat-card::after {
    display: none;
  }
  
  .stat-card::before {
    animation: none;
    background: linear-gradient(90deg, var(--user-accent, var(--pro-accent-primary)), var(--pro-accent-info));
  }
  
  .stat-icon {
    font-size: 32px;
    margin-bottom: 0;
    animation: none;
    flex-shrink: 0;
  }
  
  .stat-content {
    flex: 1;
  }
  
  .stat-label {
    font-size: 11px;
    margin-bottom: 5px;
  }
  
  .stat-value {
    font-size: 26px;
  }
  
  .funky-card {
    padding: 18px;
    border-radius: 12px;
    animation-duration: 0.4s;
  }
}

/* Mobile Portrait (0 - 576px) */
@media (max-width: 576px) {
  .stats-row {
    gap: 10px;
    margin-bottom: 15px;
  }
  
  .stat-card {
    padding: 15px;
    border-radius: 12px;
  }
  
  .stat-icon {
    font-size: 28px;
  }
  
  .stat-label {
    font-size: 10px;
    letter-spacing: 0.5px;
  }
  
  .stat-value {
    font-size: 22px;
  }
  
  .funky-card {
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
  }
}

/* Ultra-wide screens (1400px+) */
@media (min-width: 1400px) {
  .stats-row {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 25px;
  }
  
  .stat-card {
    padding: 30px;
  }
  
  .stat-icon {
    font-size: 48px;
  }
  
  .stat-value {
    font-size: 42px;
  }
}

/* Focus styles for keyboard navigation */
.stat-card:focus-visible {
  outline: 3px solid var(--user-accent, var(--pro-accent-primary));
  outline-offset: 3px;
}

/* ============================================
   WELCOME BANNER
   Theme-aware gradient banner for dashboard
   ============================================ */
.welcome-banner {
  background: linear-gradient(135deg, var(--pro-accent-primary) 0%, var(--pro-accent-purple) 100%);
  color: white;
  margin-bottom: 2rem;
}

.welcome-banner .welcome-content {
  padding: 2rem;
}

.welcome-banner h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.5rem;
  color: white;
}

.welcome-banner p {
  margin: 0;
  opacity: 0.9;
  font-size: 1.1rem;
  color: white;
}

/* Print styles */
@media print {
  .stats-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    page-break-inside: avoid;
  }

  .stat-card {
    border: 1px solid var(--pro-border-color);
    box-shadow: none;
    animation: none;
  }

  .stat-card::before,
  .stat-card::after {
    display: none;
  }
}

/* ============================================
   HIGH CONTRAST MODE
   ============================================ */

@media (prefers-contrast: high) {
  .card,
  .funky-card {
    border-width: 2px;
    box-shadow: none !important;
  }

  .card::before,
  .funky-card::before {
    display: none; /* Remove gradient accent bars */
  }

  .card-header {
    border-bottom-width: 2px;
  }

  .card-footer {
    border-top-width: 2px;
  }

  .card:focus-within {
    outline: 3px solid;
    outline-offset: 2px;
  }
}

/* ============================================
   BOOTSTRAP CARD THEME OVERRIDES
   Using --pro-* variables for theme consistency
   ============================================ */

.card {
  background-color: var(--pro-bg-secondary);
  border-color: var(--pro-border);
  color: var(--pro-text-primary);
}

.card-header {
  background-color: var(--pro-bg-tertiary);
  border-bottom-color: var(--pro-border);
}

.card-footer {
  background-color: var(--pro-bg-tertiary);
  border-top-color: var(--pro-border);
}
