/* CSS baseado no exemplo - Dashboard de Vazão */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --muted: #475569;
  --accent: #2563eb;
  --success: #16a34a;
  --warning: #eab308;
  --danger: #dc2626;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0f1724;
  --card: #0b1220;
  --muted: #94a3b8;
  --accent: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  transition: all 0.3s ease;
}

html,
body {
  height: 100%;
  width: 100%;
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, 'Helvetica Neue', Arial;
  background: var(--bg);
  color: var(--muted);
  overflow: hidden;
}

.wrap {
  max-width: 100%;
  height: 100%;
  margin: 0;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 25px;
  padding: 0 0 20px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand {
  display: flex;
  align-items: center;
  gap: 18px;
}

.logo {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #0891b2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 24px;
  flex-shrink: 0;
}

h1 {
  font-size: 32px;
  margin: 0;
  color: var(--muted);
  font-weight: 600;
}

.sub {
  font-size: 14px;
  color: var(--muted);
  margin-top: 4px;
  opacity: 0.8;
}

.controls {
  display: flex;
  gap: 10px;
}

.controls button {
  border: none;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  background: var(--accent);
  color: white;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.3s ease;
  min-width: 45px;
  min-height: 45px;
}

.controls button:hover {
  opacity: 0.85;
  transform: translateY(-2px);
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 20px;
}

.card {
  background: var(--card);
  border-radius: 15px;
  padding: 20px;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
}

.summary {
  grid-column: span 12;
  display: flex;
  gap: 20px;
}

.summary .card {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.metric .value {
  font-size: 48px;
  font-weight: 700;
  color: var(--muted);
}

.metric .label {
  font-size: 24px;
  color: var(--muted);
}

.main-content {
  grid-column: span 12;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.meters-list-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.meter-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 20px;
  border-radius: 12px;
  background: var(--card);
  border: 2px solid #e2e8f0;
  height: 100%;
}

[data-theme="dark"] .meter-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.meter-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

.meter-name {
  font-weight: 600;
  font-size: 18px;
  color: var(--muted);
}

/* Melhorar contraste dos valores de leitura no modo claro */
[data-theme="light"] .meter-item div[style*="background:rgba"] {
  background: #f1f5f9 !important;
  border: 1px solid #cbd5e1;
}

[data-theme="light"] .meter-item strong[style*="color:#e2e8f0"] {
  color: #1e293b !important;
}

.meter-values {
  display: flex;
  gap: 15px;
}

.footer-content {
  margin-top: 25px;
  font-size: 16px;
  text-align: center;
  color: var(--muted);
  padding: 0 20px;
}

@media (max-width: 900px) {
  .grid {
    grid-template-columns: 1fr;
  }
  .main-content {
    grid-template-columns: 1fr;
  }
  .summary {
    flex-direction: column;
  }
  .footer-content {
    flex-direction: column;
    gap: 15px;
  }
}

/* Modal de Relatórios */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
}

.modal-content {
  background: var(--card);
  border-radius: 20px;
  width: 90vw;
  max-width: 1200px;
  max-height: 90vh;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
  background: rgba(255, 255, 255, 0.1);
  padding: 20px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}

.modal-header h2 {
  color: var(--muted);
  font-size: 1.8rem;
  font-weight: 600;
  margin: 0;
}

.modal-close {
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: var(--danger);
  opacity: 0.8;
  transform: scale(1.1);
}

.modal-body {
  padding: 30px;
  max-height: 70vh;
  overflow-y: auto;
}

/* Filtros */
.filters-container {
  background: rgba(255, 255, 255, 0.05);
  padding: 25px;
  border-radius: 15px;
  margin-bottom: 25px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.filter-item {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 15px;
}

.filter-item:last-child {
  margin-bottom: 0;
}

.filter-item label {
  color: var(--muted);
  font-weight: 600;
  font-size: 1.1rem;
  min-width: 150px;
}

.filter-input {
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 12px 15px;
  color: #ffffff;
  font-size: 1rem;
  flex: 1;
  transition: all 0.3s ease;
}

.filter-input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.15);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.3);
}

.filter-input option {
  background: #1e293b;
  color: #ffffff;
}

.btn-generate, .btn-clear {
  background: linear-gradient(135deg, var(--accent), #0891b2);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-right: 10px;
}

.btn-generate:hover {
  opacity: 0.85;
  transform: translateY(-2px);
}

.btn-clear {
  background: linear-gradient(135deg, var(--danger), #c0392b);
}

.btn-clear:hover {
  opacity: 0.85;
  transform: translateY(-2px);
}

.btn-export {
  background: linear-gradient(135deg, var(--success), #229954);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-right: 10px;
}

.btn-export:hover {
  opacity: 0.85;
  transform: translateY(-2px);
}

.btn-export:disabled {
  background: #95a5a6;
  cursor: not-allowed;
  transform: none;
}

/* Resumo do Período */
.period-summary {
  background: rgba(255, 255, 255, 0.05);
  padding: 25px;
  border-radius: 15px;
  margin-bottom: 25px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.period-summary h3 {
  color: var(--accent);
  font-size: 1.4rem;
  margin-bottom: 20px;
  font-weight: 600;
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

.stat-item {
  background: rgba(255, 255, 255, 0.1);
  padding: 15px;
  border-radius: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-label {
  color: var(--muted);
  font-weight: 500;
}

.stat-value {
  color: var(--accent);
  font-weight: 700;
  font-size: 1.1rem;
}

/* Dados Container */
.data-container {
  background: rgba(255, 255, 255, 0.05);
  padding: 25px;
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.data-container h3 {
  color: var(--accent);
  font-size: 1.4rem;
  margin-bottom: 20px;
  font-weight: 600;
}

.table-wrapper {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.05);
}

.data-table th {
  background: rgba(6, 182, 212, 0.2);
  color: #ffffff;
  padding: 15px;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid rgba(6, 182, 212, 0.3);
}

.data-table td {
  padding: 12px 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--muted);
}

.data-table tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Loading */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 50px;
  color: var(--muted);
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top: 4px solid var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-container p {
  font-size: 1.1rem;
  font-weight: 500;
}

/* Sistema de Alertas no Topo do Modal */
.status-alert-container {
  position: relative;
  z-index: 1001;
  margin: 0;
  padding: 0;
}

.status-alert {
  background: rgba(6, 182, 212, 0.95);
  backdrop-filter: blur(10px);
  border: 2px solid var(--accent);
  border-radius: 0 0 15px 15px;
  padding: 15px 20px;
  margin: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  animation: slideDown 0.3s ease-out;
  position: relative;
  overflow: hidden;
}

.status-alert::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #0891b2, var(--accent));
  animation: progressBar 2s ease-in-out infinite;
}

.status-alert-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.status-alert-icon {
  font-size: 1.2rem;
  min-width: 24px;
  text-align: center;
}

.status-alert-message {
  color: white;
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.3;
}

.status-alert-close {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.status-alert-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

/* Animações */
@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(-100%);
    opacity: 0;
  }
}

@keyframes progressBar {
  0% { transform: translateX(-100%); }
  50% { transform: translateX(0%); }
  100% { transform: translateX(100%); }
}

.status-alert.fade-out {
  animation: slideUp 0.3s ease-in forwards;
}

/* Ajustes de cores para o Tema Claro (modal e formulários) */
[data-theme="light"] .modal-overlay {
  background: rgba(0, 0, 0, 0.35);
}

[data-theme="light"] .modal-content {
  background: var(--card);
  border: 1px solid rgba(6, 182, 212, 0.08);
}

[data-theme="light"] .modal-header {
  background: rgba(0, 0, 0, 0.03);
  color: var(--muted);
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

[data-theme="light"] .modal-body {
  background: transparent;
}

[data-theme="light"] .filters-container {
  background: rgba(0,0,0,0.03);
  border: 1px solid rgba(0,0,0,0.06);
}

[data-theme="light"] .filter-input {
  background: #ffffff;
  border: 1px solid #dbeafe;
  color: var(--muted);
}

[data-theme="light"] .filter-input:focus {
  box-shadow: 0 0 10px rgba(6,182,212,0.15);
}

[data-theme="light"] .data-table th {
  background: rgba(6, 182, 212, 0.12);
  color: #083344;
}

[data-theme="light"] .data-table td {
  color: var(--muted);
}

[data-theme="light"] .meter-item {
  background: #ffffff;
  border: 1px solid #e6eef8;
}

[data-theme="light"] .meter-item div[style*="background:rgba"] {
  background: #f8fafc !important;
  border: 1px solid #e6eef8;
}

[data-theme="light"] .meter-item strong[style*="color:#e2e8f0"] {
  color: #0f1724 !important;
}
