/* ============================================================
   VULCÃO DE SANTA BARBARA SHAKE - VERSION 2.0
   Stylesheet
   ============================================================ */

:root {
  --bg-primary: #111;
  --bg-secondary: #181818;
  --bg-tertiary: #252525;
  --bg-active: #2f3b22;
  --border-color: #333;
  --text-primary: #eee;
  --text-secondary: #aaa;
  --text-tertiary: #888;
  --accent-blue: #4ea3ff;
  --accent-green: #4caf50;
  --accent-orange: #ff9800;
  --accent-red: #f44336;
  --accent-info: #2196f3;
  --sidebar-width: 300px;
  --sidebar-width-collapsed: 60px;
  --transition-speed: 0.3s;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
  width: 100vw;
  position: relative;
}

/* ============================================================
   MOBILE MENU BUTTON
   ============================================================ */
#mobile-menu-btn {
  display: none;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 10000;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 20px;
}

#mobile-menu-btn:hover {
  background: var(--bg-tertiary);
}

/* ============================================================
   SIDEBAR
   ============================================================ */
#sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 10px;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition-speed), width var(--transition-speed);
  z-index: 1000;
}

#sidebar.collapsed {
  width: var(--sidebar-width-collapsed);
  padding: 10px 5px;
}

#sidebar.collapsed > *:not(#sidebar-header) {
  display: none;
}

#sidebar.collapsed #sidebar-toggle {
  margin: 0 auto;
}

#sidebar.mobile-hidden {
  transform: translateX(-100%);
}

#sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

#sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  padding: 5px;
  border-radius: 4px;
}

#sidebar-toggle:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.sidebar-logo-section {
  text-align: center;
  margin-bottom: 10px;
}

.sidebar-logo-section img {
  height: 40px;
  opacity: 0.9;
}

.sidebar-logo-section small {
  display: block;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.app-logo {
  height: 70px;
  opacity: 0.95;
  margin: 10px auto;
  display: block;
}

#sidebar h1 {
  font-size: 16px;
  margin: 0 0 10px 0;
  text-align: center;
}

#sidebar small {
  display: block;
  margin-bottom: 4px;
  color: var(--text-secondary);
  text-align: center;
}

#ultima-atualizacao {
  margin-bottom: 10px;
  text-align: center;
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ============================================================
   COLLAPSIBLE PANELS
   ============================================================ */
.collapsible-panel {
  margin-bottom: 15px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  overflow: hidden;
}

.panel-header {
  background: var(--bg-tertiary);
  padding: 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  transition: background-color 0.2s, color 0.2s;
}

.panel-header:hover {
  background: #2a2a2a;
}

body.light-theme .panel-header:hover {
  background: #424242;
  color: #ffffff;
}

body.light-theme .panel-header:hover h3 {
  color: #ffffff;
}

body.light-theme .panel-header:hover .panel-toggle {
  color: #ffffff;
}

.panel-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.panel-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 12px;
  transition: transform var(--transition-speed);
}

.panel-toggle.expanded {
  transform: rotate(180deg);
}

.panel-content {
  padding: 10px;
  display: none;
}

.panel-content.expanded {
  display: block;
}

/* ============================================================
   SEARCH
   ============================================================ */
#search-container {
  margin-bottom: 15px;
}

#search-input {
  width: 100%;
  padding: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 13px;
}

#search-input:focus {
  outline: none;
  border-color: var(--accent-blue);
}

/* ============================================================
   FILTERS
   ============================================================ */
.filter-group {
  margin-bottom: 15px;
}

.filter-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.filter-range {
  width: 100%;
  margin-bottom: 5px;
}

.filter-value {
  font-size: 11px;
  color: var(--text-tertiary);
  text-align: right;
}

.filter-quick-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
}

.filter-quick-btn {
  padding: 4px 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 11px;
  transition: all 0.2s;
}

.filter-quick-btn:hover {
  background: var(--bg-active);
  border-color: var(--accent-blue);
}

.filter-quick-btn.active {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: white;
}

#clear-filters {
  width: 100%;
  padding: 8px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  cursor: pointer;
  margin-top: 10px;
  font-size: 12px;
}

#clear-filters:hover {
  background: var(--bg-active);
}

#active-filters-badge {
  display: inline-block;
  background: var(--accent-blue);
  color: white;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 10px;
  margin-left: 5px;
}

/* ============================================================
   STATISTICS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 15px;
}

.stat-card {
  background: var(--bg-tertiary);
  padding: 10px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}

.stat-label {
  font-size: 10px;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.stat-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.stat-chart {
  margin-top: 15px;
  height: 150px;
}

/* ============================================================
   EARTHQUAKE LIST
   ============================================================ */
#lista-sismos {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 13px;
}

#lista-sismos li {
  padding: 6px 4px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: background 0.2s;
}

#lista-sismos li:hover {
  background: var(--bg-tertiary);
}

#lista-sismos li.active {
  background: var(--bg-active);
  font-weight: 700;
}

#lista-sismos li.highlight {
  background: rgba(78, 163, 255, 0.2);
}

#lista-sismos .linha1 {
  font-weight: 500;
}

#lista-sismos .linha2 {
  font-size: 11px;
  color: var(--text-secondary);
}

.loading-skeleton {
  padding: 6px 4px;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--bg-tertiary) 50%, var(--bg-secondary) 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  height: 40px;
  border-radius: 4px;
  margin-bottom: 5px;
}

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

/* ============================================================
   GRAPH CONTAINER
   ============================================================ */
#grafico-container {
  flex: 1;
  background: #000;
  position: relative;
  min-width: 0;
}

#grafico {
  width: 100%;
  height: 100%;
}

/* ============================================================
   SETTINGS PANEL
   ============================================================ */
.setting-item {
  margin-bottom: 15px;
}

.setting-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.setting-control {
  width: 100%;
  padding: 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 12px;
}

.setting-control:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.setting-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-switch {
  position: relative;
  width: 40px;
  height: 20px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.3s;
}

.toggle-switch.active {
  background: var(--accent-blue);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  top: 2px;
  left: 2px;
  transition: transform 0.3s;
}

.toggle-switch.active::after {
  transform: translateX(20px);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn:hover {
  background: var(--bg-active);
  border-color: var(--accent-blue);
}

.btn-primary {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: white;
}

.btn-primary:hover {
  background: #3d8fdb;
}

.btn-group {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

/* ============================================================
   MODAL/DIALOG
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 20px;
  max-width: 90%;
  max-height: 90%;
  overflow-y: auto;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: var(--text-primary);
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 12px 16px;
  min-width: 250px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.3s;
}

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

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

.toast.success {
  border-left: 4px solid var(--accent-green);
}

.toast.error {
  border-left: 4px solid var(--accent-red);
}

.toast.info {
  border-left: 4px solid var(--accent-info);
}

.toast.warning {
  border-left: 4px solid var(--accent-orange);
}

/* ============================================================
   FOOTER
   ============================================================ */
.footer-global {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: #000000cc;
  color: #ccc;
  text-align: center;
  padding: 6px 0;
  font-size: 12px;
  backdrop-filter: blur(4px);
  z-index: 9999;
}

.footer-global a {
  color: var(--accent-blue);
  text-decoration: none;
}

.footer-global a:hover {
  text-decoration: underline;
}

/* ============================================================
   LOGOS WATERMARK
   ============================================================ */
#marca-logos {
  position: absolute;
  right: 20px;
  bottom: 65px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  opacity: 0.90;
  pointer-events: none;
  z-index: 50;
}

.marca-logo {
  height: 30px;
  width: auto;
  filter: drop-shadow(0 0 6px rgba(255,255,255,0.35));
  opacity: 0.95;
  object-fit: contain;
}

/* VOSTAZ logo in sidebar - maintain original proportions */
.sidebar-logo-section img[alt="VOSTAZ"] {
  height: auto;
  max-height: 120px;
  width: auto;
  max-width: 480px;
  object-fit: contain;
}

/* IPMA and VOST Portugal logos in watermark - much smaller */
#marca-logos img[alt="IPMA"],
#marca-logos img[alt="VOST Portugal"] {
  height: auto;
  max-height: 30px;
  width: auto;
  max-width: 80px;
  object-fit: contain;
}

/* ============================================================
   RESPONSIVE DESIGN
   ============================================================ */
@media (max-width: 768px) {
  #mobile-menu-btn {
    display: block;
  }

  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 9999;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
  }

  #sidebar.mobile-hidden {
    transform: translateX(-100%);
  }

  #grafico-container {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .modal {
    max-width: 95%;
    margin: 10px;
  }
}

@media (max-width: 480px) {
  #sidebar {
    width: 100%;
    max-width: 320px;
  }

  .footer-global {
    font-size: 10px;
    padding: 4px 0;
  }
}

/* ============================================================
   ACCESSIBILITY
   ============================================================ */
*:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

.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;
}

/* ============================================================
   LIGHT MODE THEME
   ============================================================ */
body.light-theme {
  --bg-primary: #f5f5f5;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f0f0f0;
  --bg-active: #e8f5e9;
  --border-color: #e0e0e0;
  --text-primary: #212121;
  --text-secondary: #616161;
  --text-tertiary: #9e9e9e;
  --accent-blue: #1976d2;
  --accent-green: #388e3c;
  --accent-orange: #f57c00;
  --accent-red: #d32f2f;
  --accent-info: #0288d1;
}

body.light-theme #grafico-container {
  background: #ffffff;
}

body.light-theme .footer-global {
  background: #ffffffcc;
  color: #424242;
}

body.light-theme .marca-logo {
  filter: drop-shadow(0 0 6px rgba(0,0,0,0.2));
}

body.light-theme .modal-overlay {
  background: rgba(255, 255, 255, 0.9);
}

/* High contrast mode */
@media (prefers-contrast: high) {
  :root {
    --bg-primary: #000;
    --bg-secondary: #1a1a1a;
    --text-primary: #fff;
    --border-color: #666;
  }
  
  body.light-theme {
    --bg-primary: #fff;
    --bg-secondary: #f5f5f5;
    --text-primary: #000;
    --border-color: #333;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.spinner {
  border: 3px solid var(--bg-tertiary);
  border-top: 3px solid var(--accent-blue);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.mt-10 {
  margin-top: 10px;
}

.mb-10 {
  margin-bottom: 10px;
}

.sidebar-footer {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 8px;
  text-align: center;
}

