/* ========================================
   CACHE MODAL STYLES
   Shared styles for cache detail modals
   Used by queries.html and users.html
   Base .modal-overlay defined in style.css
   ======================================== */

/* Modal Content Container */
.modal {
  position: relative;
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 20px 60px var(--shadow-color-strong);
  max-width: 1000px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  z-index: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  background: var(--card-bg);
  z-index: 10;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--muted, #8a8a8a);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.modal-close:hover {
  color: var(--text, #505050);
  background: var(--hover-bg);
}

.modal-content {
  padding: 24px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  padding: 24px;
  border-top: 1px solid var(--border-color);
  background: var(--bg);
}

/* Cache Modal Hero */
.cache-hero {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 28px;
  background: linear-gradient(135deg, rgba(253,108,29,0.05), rgba(253,108,29,0.02));
  border-radius: 12px;
  border: 2px solid rgba(253,108,29,0.15);
  margin-bottom: 24px;
}

.cache-hero-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  color: #f5f5f5;
}

.cache-hero-icon.hero-valid {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #f5f5f5;
}

.cache-hero-icon.hero-expired {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: #f5f5f5;
}

.cache-hero-icon.hero-invalidated {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #f5f5f5;
}

.cache-hero-content {
  flex: 1;
}

.cache-hero-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
}

.cache-hero-subtitle {
  font-size: 13px;
  color: var(--muted, #8a8a8a);
  font-family: monospace;
  word-break: break-all;
  margin-bottom: 8px;
}

.cache-hero-timer {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent, #fd6c1d);
  background: rgba(253,108,29,0.1);
  padding: 6px 12px;
  border-radius: 6px;
}

/* Cache Invalidation Info */
.cache-invalidation-info {
  margin-top: 16px;
  padding: 16px;
  background: rgba(245,158,11,0.1);
  border: 2px solid rgba(245,158,11,0.3);
  border-radius: 10px;
}

.invalidation-label {
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--text, #505050);
  display: flex;
  align-items: center;
  gap: 8px;
}

.invalidation-label i {
  color: #f59e0b;
  font-size: 14px;
}

.invalidation-notes {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(245,158,11,0.2);
  font-size: 13px;
  font-style: italic;
  color: var(--muted, #8a8a8a);
}

/* Cache Stats Grid */
.cache-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.cache-stat-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--card-bg);
  border-radius: 12px;
  border: 2px solid var(--border-color);
  transition: all 0.2s ease;
}

.cache-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--shadow-color-strong);
  border-color: rgba(253,108,29,0.3);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  color: #f5f5f5;
}

.stat-icon.stat-versions { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.stat-icon.stat-size { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.stat-icon.stat-user { background: linear-gradient(135deg, #ec4899, #db2777); }
.stat-icon.stat-ttl { background: linear-gradient(135deg, #fd6c1d, #ff8a44); }

.stat-content { flex: 1; }

.stat-number {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}

.stat-label {
  font-size: 12px;
  color: var(--muted, #8a8a8a);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* Section Headers */
.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--border-color);
}

.section-icon {
  font-size: 20px;
  color: var(--accent, #fd6c1d);
}

.section-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  flex: 1;
}

.version-count-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent, #fd6c1d);
  background: rgba(253,108,29,0.1);
  padding: 4px 10px;
  border-radius: 12px;
}

/* Rule Section */
.cache-rule-section { margin-bottom: 24px; }

.rule-info-card {
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
}

.rule-info-header {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.rule-priority-badge {
  font-size: 12px;
  font-weight: 700;
  color: white;
  background: var(--accent, #fd6c1d);
  padding: 4px 12px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.rule-status-indicator {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.rule-status-indicator.status-enabled {
  background: rgba(16,185,129,0.1);
  color: #10b981;
}

.rule-status-indicator.status-disabled {
  background: rgba(239,68,68,0.1);
  color: #ef4444;
}

.rule-info-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.rule-info-description {
  font-size: 14px;
  color: var(--muted, #8a8a8a);
  margin-bottom: 12px;
  line-height: 1.6;
}

.rule-info-id {
  font-size: 11px;
  font-family: monospace;
  color: var(--muted, #8a8a8a);
  background: var(--bg);
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
}

/* SQL Context */
.cache-sql-section { margin-bottom: 24px; }

.sql-context-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.sql-context-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.context-label {
  font-size: 12px;
  color: var(--muted, #8a8a8a);
  font-weight: 600;
}

.context-value {
  font-size: 13px;
  font-weight: 600;
}

.context-badge {
  background: rgba(253,108,29,0.1);
  color: var(--accent, #fd6c1d);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
}

.sql-query-display {
  background: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px;
}

.sql-query-label {
  font-size: 12px;
  color: var(--muted, #8a8a8a);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.sql-query-code {
  display: block;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}

/* Timeline Chart */
.cache-timeline-section { margin-bottom: 24px; }

.timeline-chart-container {
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  height: 250px;
}

/* Version Timeline */
.versions-section-modern { margin-top: 24px; }

.versions-timeline {
  position: relative;
  padding-left: 32px;
}

.versions-timeline::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(180deg, var(--accent, #fd6c1d), rgba(253,108,29,0.2));
  border-radius: 2px;
}

.version-card {
  position: relative;
  margin-bottom: 20px;
  background: var(--card-bg);
  border: 2px solid var(--border-color);
  border-radius: 12px;
  transition: all 0.3s ease;
}

.version-card:hover {
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  border-color: rgba(253,108,29,0.3);
}

.version-card.version-current {
  border-color: #10b981;
  background: linear-gradient(135deg, rgba(16,185,129,0.05), var(--card-bg));
}

.version-card.version-expired {
  opacity: 0.6;
  border-color: rgba(239,68,68,0.3);
}

.version-card.version-invalidated {
  border-color: rgba(245,158,11,0.5);
  background: linear-gradient(135deg, rgba(245,158,11,0.05), var(--card-bg));
}

.version-card-marker {
  position: absolute;
  left: -32px;
  top: 24px;
  width: 24px;
  height: 24px;
  background: var(--accent, #fd6c1d);
  border: 4px solid var(--card-bg);
  border-radius: 50%;
  box-shadow: 0 2px 8px var(--shadow-color-strong);
}

.version-card.version-current .version-card-marker {
  background: linear-gradient(135deg, #10b981, #059669);
  animation: pulse-marker 2s infinite;
}

@keyframes pulse-marker {
  0%, 100% {
    box-shadow: 0 2px 8px rgba(16,185,129,0.3), 0 0 0 0 rgba(16,185,129,0.4);
  }
  50% {
    box-shadow: 0 2px 8px rgba(16,185,129,0.3), 0 0 0 8px rgba(16,185,129,0);
  }
}

.version-card.version-expired .version-card-marker {
  background: #ef4444;
}

.version-card.version-invalidated .version-card-marker {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.version-card-content { padding: 20px; }

.version-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.version-card-time {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.version-timestamp {
  font-size: 15px;
  font-weight: 700;
}

.version-age {
  font-size: 12px;
  color: var(--muted, #8a8a8a);
  font-weight: 500;
}

.version-status-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-valid {
  background: rgba(16,185,129,0.1);
  color: #10b981;
}

.badge-expired {
  background: rgba(239,68,68,0.1);
  color: #ef4444;
}

.badge-invalidated {
  background: rgba(245,158,11,0.1);
  color: #f59e0b;
}

.version-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.version-metric {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: var(--bg);
  border-radius: 8px;
  font-size: 12px;
}

.metric-icon-small {
  font-size: 16px;
  color: var(--accent, #fd6c1d);
}

.metric-text {
  font-weight: 600;
}

/* Version Invalidation Details */
.version-invalidation-details {
  margin-bottom: 16px;
  padding: 14px;
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: 8px;
}

.invalidation-detail {
  font-size: 12px;
  margin-bottom: 6px;
  color: var(--text, #505050);
  display: flex;
  align-items: center;
  gap: 6px;
}

.invalidation-detail:last-child {
  margin-bottom: 0;
}

.invalidation-detail i {
  color: #f59e0b;
  font-size: 13px;
  width: 16px;
}

/* Expandable Details */
.version-details-expandable {
  margin-top: 12px;
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
}

.version-details-summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent, #fd6c1d);
  list-style: none;
  user-select: none;
  padding: 8px 12px;
  background: rgba(253,108,29,0.05);
  border-radius: 6px;
  transition: all 0.2s ease;
}

.version-details-summary:hover {
  background: rgba(253,108,29,0.1);
}

.version-details-summary::-webkit-details-marker {
  display: none;
}

.version-details-summary::before {
  content: '\f054';
  font-family: 'Font Awesome 5 Free';
  font-weight: 900;
  display: inline-block;
  margin-right: 8px;
  transition: transform 0.2s ease;
}

details[open] .version-details-summary::before {
  transform: rotate(90deg);
}

.response-headers-modern {
  margin-top: 12px;
  background: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 12px;
  max-height: 300px;
  overflow-y: auto;
}

.header-row-modern {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
  padding: 6px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.header-row-modern:hover {
  background: rgba(253,108,29,0.05);
}

.header-key-modern {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent, #fd6c1d);
  min-width: 200px;
}

.header-value-modern {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  word-break: break-all;
  flex: 1;
}

/* Restore Version Button */
.restore-version-btn {
  margin-top: 16px;
  width: 100%;
  padding: 10px 16px;
  background: linear-gradient(135deg, #fd6c1d, #ff8a44) !important;
  color: white !important;
  border: none !important;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.restore-version-btn:hover {
  background: linear-gradient(135deg, #ff8a44, #fd6c1d) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(253, 108, 29, 0.3);
}

.restore-version-btn:active {
  transform: translateY(0);
}

.restore-version-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.restore-version-btn i {
  font-size: 12px;
}

/* Confirmation Dialog */
.confirmation-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 20px 60px var(--shadow-color-strong);
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 2001;
  animation: slideUp 0.3s ease;
}

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

.confirmation-header {
  padding: 32px 32px 16px;
  text-align: center;
}

.confirmation-content {
  padding: 0 32px 24px;
  text-align: center;
}

.confirmation-content h3 {
  margin: 0 0 16px 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--text, #505050);
}

.confirmation-content p {
  margin: 8px 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text, #505050);
}

.confirmation-actions {
  display: flex;
  gap: 12px;
  padding: 24px 32px;
  background: var(--bg);
  border-top: 1px solid var(--border-color);
}

.btn-cancel,
.btn-confirm {
  flex: 1;
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-cancel {
  background: var(--card-bg);
  color: var(--muted, #8a8a8a);
  border: 2px solid var(--border-color-strong);
}

.btn-cancel:hover {
  background: var(--hover-bg);
  border-color: var(--border-color-strong);
  color: var(--text, #505050);
}

.btn-confirm {
  background: linear-gradient(135deg, #fd6c1d, #ff8a44);
  color: white;
}

.btn-confirm:hover {
  background: linear-gradient(135deg, #ff8a44, #fd6c1d);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(253, 108, 29, 0.3);
}

/* Success Toast */
.success-toast {
  position: fixed;
  top: 24px;
  right: 24px;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  padding: 16px 24px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.3);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 600;
  z-index: 3000;
  opacity: 0;
  transform: translateX(400px);
  transition: all 0.3s ease;
}

.success-toast.show {
  opacity: 1;
  transform: translateX(0);
}

.success-toast i {
  font-size: 20px;
}

/* Invalidate Button Active State */
.btn-invalidate-active {
  background: linear-gradient(135deg, #ef4444, #dc2626) !important;
  color: white !important;
  border-color: #ef4444 !important;
}

.btn-invalidate-active:hover {
  background: linear-gradient(135deg, #dc2626, #b91c1c) !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Responsive */
@media (max-width: 768px) {
  .modal { width: 95%; }
  .cache-hero { flex-direction: column; text-align: center; }
  .cache-stats-grid, .sql-context-grid, .version-metrics-grid { grid-template-columns: 1fr; }
  .versions-timeline { padding-left: 24px; }
  .version-card-marker { left: -24px; width: 20px; height: 20px; }
  .header-key-modern { min-width: 120px; }
  .success-toast {
    top: 12px;
    right: 12px;
    left: 12px;
    font-size: 13px;
    padding: 12px 16px;
  }
  .confirmation-dialog {
    width: 95%;
    max-width: none;
  }
  .confirmation-actions { flex-direction: column; }
}
