/**
 * Custom Styles for AcehCMS
 * Additional styles beyond Tailwind CSS
 */

/* === Root Variables === */
:root {
  --primary-color: #dc2626;
  --secondary-color: #2563eb;
  --success-color: #16a34a;
  --warning-color: #eab308;
  --danger-color: #dc2626;
  --info-color: #0891b2;
  --gray-color: #6b7280;

  --transition-speed: 0.3s;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

/* === Global Resets === */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: #1f2937;
  background-color: #f3f4f6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* === Iframe Mode === */
body.iframe-mode {
  background-color: transparent;
  padding: 0;
  margin: 0;
}

body.iframe-mode .header,
body.iframe-mode .footer,
body.iframe-mode .breadcrumb {
  display: none;
}

body.iframe-mode .container {
  max-width: 100%;
  padding: 0;
}

/* === Scrollbar Styling === */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* === Animations === */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes slide-in {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slide-out {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fade-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-slide-in {
  animation: slide-in 0.3s ease-out;
}

.animate-slide-out {
  animation: slide-out 0.3s ease-in;
}

.animate-fade-in {
  animation: fade-in 0.3s ease-out;
}

.animate-fade-out {
  animation: fade-out 0.3s ease-in;
}

/* === Loading States === */
.loading-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* === Status Indicators === */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.status-dot.critical {
  background-color: var(--danger-color);
  box-shadow: 0 0 8px rgba(220, 38, 38, 0.5);
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.warning {
  background-color: var(--warning-color);
  box-shadow: 0 0 8px rgba(234, 179, 8, 0.5);
}

.status-dot.normal {
  background-color: var(--success-color);
  box-shadow: 0 0 8px rgba(22, 163, 74, 0.5);
}

.status-dot.offline {
  background-color: var(--gray-color);
}

/* === Card Hover Effects === */
.card-hover {
  transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

/* === Map Styles === */
.leaflet-container {
  height: 100%;
  width: 100%;
  border-radius: 8px;
}

.custom-marker {
  background: none;
  border: none;
}

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background-color: rgba(37, 99, 235, 0.6);
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background-color: rgba(37, 99, 235, 0.8);
  color: white;
  font-weight: bold;
}

/* === Chart Container === */
.chart-container {
  position: relative;
  width: 100%;
  height: 300px;
}

canvas {
  max-width: 100%;
  height: auto !important;
}

/* === Table Enhancements === */
table {
  border-collapse: collapse;
  width: 100%;
}

table thead {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: #f9fafb;
}

table tbody tr {
  transition: background-color 0.2s;
}

/* === Custom Tooltip === */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip .tooltip-text {
  visibility: hidden;
  background-color: #1f2937;
  color: white;
  text-align: center;
  padding: 6px 12px;
  border-radius: 6px;
  position: absolute;
  z-index: 1;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.3s;
  white-space: nowrap;
  font-size: 12px;
}

.tooltip .tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -5px;
  border-width: 5px;
  border-style: solid;
  border-color: #1f2937 transparent transparent transparent;
}

.tooltip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* === Badge Styles === */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 9999px;
  line-height: 1;
}

.badge-critical {
  background-color: #fee2e2;
  color: #991b1b;
}

.badge-warning {
  background-color: #fef3c7;
  color: #92400e;
}

.badge-normal {
  background-color: #d1fae5;
  color: #065f46;
}

.badge-info {
  background-color: #dbeafe;
  color: #1e40af;
}

/* === Progress Bar === */
.progress-bar {
  width: 100%;
  height: 8px;
  background-color: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background-color: var(--primary-color);
  transition: width 0.5s ease-in-out;
}

/* === Grid Layouts === */
.grid-auto-fit {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

.grid-auto-fill {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}

/* === Responsive Utilities === */
@media (max-width: 640px) {
  .hide-mobile {
    display: none !important;
  }
}

@media (min-width: 641px) {
  .show-mobile {
    display: none !important;
  }
}

/* === Print Styles === */
@media print {
  .no-print {
    display: none !important;
  }

  body {
    background: white;
  }

  .card, .table-container {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

/* === Accessibility === */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* === Focus States === */
*:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--secondary-color);
}

/* === Update Indicator === */
.update-indicator {
  position: fixed;
  top: 20px;
  right: 20px;
  background: white;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 1000;
  animation: slide-in 0.3s ease-out;
}

.update-indicator.hidden {
  display: none;
}

.update-indicator .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #e5e7eb;
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* === Header Styles (when not in iframe) === */
.page-header {
  background: linear-gradient(135deg, var(--primary-color) 0%, #991b1b 100%);
  color: white;
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
}

.page-header h1 {
  font-size: 1.875rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.page-header p {
  opacity: 0.9;
  font-size: 0.875rem;
}

/* === Footer === */
.page-footer {
  background: white;
  border-top: 1px solid #e5e7eb;
  padding: 1.5rem;
  text-align: center;
  color: #6b7280;
  font-size: 0.875rem;
  margin-top: 2rem;
}

/* === Container === */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* === Utility Classes === */
.transition-all {
  transition: all var(--transition-speed) ease;
}

.hover-scale:hover {
  transform: scale(1.05);
}

.hover-lift:hover {
  transform: translateY(-2px);
}

.glass-effect {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* === Dark mode support (future enhancement) === */
@media (prefers-color-scheme: dark) {
  /* Dark mode styles can be added here */
}
