/* index.css - "Pro Max" Style for Usina Management */

:root {
  /* Core Colors (Identidade Palette) */
  --bg-background: #EEE9DF; /* Palladian */
  --bg-surface: #ffffff;
  --bg-surface-hover: #F8F6F2;

  --text-primary: #1B2632; /* Abyssal Anchorfish Blue */
  --text-secondary: #2C3B4D; /* Blue Fantastic */
  --text-muted: #79838E;

  --border-color: #C9C1B1; /* Oatmeal */
  --border-hover: #1B2632; /* Abyssal */

  --primary: #A35139; /* Truffle Trouble */
  --primary-hover: #8C442E;
  --primary-light: #FBECE8;

  /* Semantic Colors (Sophisticated matching) */
  --success: #2D6B5E; /* Elegant Pine Green */
  --success-light: #E6F0ED;
  --warning: #FFB162; /* Burning Flame */
  --warning-light: #FFF5EB;
  --danger: #A82525; /* Crimson Red, distinct from Truffle */
  --danger-light: #FCE8E8;

  /* Dimensions */
  --header-height: 60px;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* Reset & Base */
* {
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-background);
  color: var(--text-primary);
  margin: 0;
  font-size: 12px;
  /* Compact base */
  line-height: 1.4;
}

/* Utilities */
.hidden {
  display: none !important;
}

.flex {
  display: flex;
}

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

.justify-between {
  justify-content: space-between;
}

.gap-2 {
  gap: 0.5rem;
}

.gap-4 {
  gap: 1rem;
}

.w-full {
  width: 100%;
}

.flex-col {
  flex-direction: column;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  outline: none;
  text-decoration: none;
}

.btn--primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 1px 2px rgba(14, 165, 233, 0.3);
}

.btn--primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn--secondary {
  background: white;
  color: var(--text-secondary);
  border-color: var(--border-color);
}

.btn--secondary:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.btn--danger {
  background: white;
  color: var(--danger);
  border-color: var(--danger-light);
}

.btn--danger:hover {
  background: var(--danger-light);
  border-color: var(--danger);
}

.btn--sm {
  padding: 0.2rem 0.4rem;
  font-size: 10px;
}

.btn--lg {
  padding: 0.75rem 1.25rem;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.btn--outline {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-color);
}

.btn--outline:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.btn--success {
  background: var(--success);
  color: white;
  border-color: var(--success);
  box-shadow: 0 1px 3px rgba(45, 107, 94, 0.3);
}

.btn--success:hover {
  background: #1f4f45;
  border-color: #1f4f45;
}

/* Inputs */
.form-control {
  width: 100%;
  padding: 0.4rem 0.6rem;
  font-size: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
  outline: none;
}

/* Layout Grid */
.app-layout {
  display: grid;
  grid-template-rows: var(--header-height) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* Header */
.app-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
}

.brand {
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary);
}

.nav-links {
  display: flex;
  gap: 0.5rem;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 12px;
}

.nav-links a:hover,
.nav-links a.active {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.main-content {
  display: grid;
  grid-template-columns: 260px 1fr 360px;
  /* Sidebar, Table, Details (fixed 360px) */
  background: var(--bg-background);
  overflow: hidden;
}

/* Sidebar Filters */
.filters-panel {
  background: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.filter-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Stats Row in Sidebar */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  margin-bottom: 1rem;
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding: 0.25rem;
}

.sidebar-actions .btn {
  height: 38px;
}

.sidebar-actions .btn--lg {
  height: 44px;
}

.sidebar-action-pair {
  display: flex;
  gap: 0.5rem;
}

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

.stat-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-label {
  font-size: 10px;
  color: var(--text-muted);
}

/* Center Table */
.table-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.table-header-bar {
  padding: 0.5rem 1rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.table-wrapper {
  flex: 1;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

th {
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 5;
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--border-color);
  color: var(--text-secondary);
  font-weight: 600;
  white-space: nowrap;
  resize: horizontal;
  overflow: auto;
}

td {
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
}

tr:hover td {
  background: var(--bg-surface-hover);
  cursor: pointer;
}

/* Info Icons na Tabela */
.info-icon-group {
  display: flex;
  gap: 3px;
  justify-content: flex-start;
  align-items: center;
}
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-surface-hover);
  opacity: 0.4;
}
.info-icon.active-socio { color: #1d4ed8; background: #dbeafe; opacity: 1; }
.info-icon.active-fab { color: #6b21a8; background: #f3e8ff; opacity: 1; }
.info-icon.active-oport { color: #c2410c; background: #ffedd5; opacity: 1; }
.info-icon.active-lic { color: #15803d; background: #dcfce7; opacity: 1; }


tr.selected td {
  background: var(--primary-light);
}

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
}

.status-operacao {
  background: var(--success-light);
  color: var(--success);
}

.status-manutencao {
  background: var(--warning-light);
  color: var(--warning);
}

.status-desativada {
  background: var(--danger-light);
  color: var(--danger);
}

/* Right Details Panel */
.details-panel {
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.detail-header h2 {
  margin: 0;
  font-size: 18px;
  color: var(--text-primary);
}

.detail-header .meta {
  font-size: 12px;
  color: var(--text-muted);
}

/* Unified Section Card (V3) */
.detail-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-top: 1.5rem;
  overflow: hidden;
  border-left: 4px solid #cbd5e1; /* Default */
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.detail-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
}

.detail-section-header h3 {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* Parent Card Category Colors */
.section-socios { border-left-color: #3b82f6; }
.section-socios .detail-section-header h3 { color: #1e40af; }

.section-equip { border-left-color: #8b5cf6; }
.section-equip .detail-section-header h3 { color: #5b21b6; }

.section-oport { border-left-color: #f59e0b; }
.section-oport .detail-section-header h3 { color: #92400e; }

.section-licen { border-left-color: #10b981; }
.section-licen .detail-section-header h3 { color: #065f46; }

.section-outor { border-left-color: #06b6d4; }
.section-outor .detail-section-header h3 { color: #155e75; }

/* Sub-Item List Content */
.detail-section .content {
    padding: 0;
}

/* Standardized Detail Cards as List Rows */
.detail-card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 1rem;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.detail-card:last-child {
  border-bottom: none;
}

.detail-card:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-hover);
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

.detail-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.detail-card-title {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.3;
}

.detail-card-meta {
  font-size: 10px;
  color: var(--text-muted);
}

.detail-card-body {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.125rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.dt-label {
  color: var(--text-secondary);
}

.dt-value {
  font-weight: 500;
  color: var(--text-primary);
  text-align: right;
}

/* Uber Style Details Card */
.uber-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  margin-top: 1rem;
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-lg);
}

.uber-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.uber-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.uber-title-group h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.uber-meta {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.6rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.uber-hero-section {
  padding: 1.25rem 0;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.hero-power-group {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
}

.hero-number {
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.03em;
}

.hero-unit {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
}

.uber-tech-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.uber-tech-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.uber-tech-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.uber-tech-value {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
}

.uber-coords-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.coord-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.uber-obs-box {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--bg-surface-hover);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 12px;
  color: #475569;
  line-height: 1.6;
}

.uber-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

.btn-uber {
  flex: 1;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 0.5rem;
  font-size: 11px;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
}

.btn-uber--danger {
  background: var(--danger-light);
  color: var(--danger);
  flex: 0 0 40px; /* Mantem o da lixeira menor */
}

.btn-uber:hover {
  filter: brightness(0.9);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 1rem;
}

.empty-icon {
  font-size: 2rem;
  opacity: 0.5;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--bg-primary);
  color: white;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  font-size: 12px;
  background: #334155;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideIn 0.3s ease;
}

.toast--success {
  border-left: 3px solid var(--success);
}

.toast--error {
  border-left: 3px solid var(--danger);
}

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

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  width: 600px;
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-weight: 600;
  font-size: 16px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-background);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

/* Searchable Select */
.searchable-select {
  position: relative;
  width: 100%;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  max-height: 250px;
  overflow-y: auto;
  z-index: 1000;
  list-style: none;
  padding: 4px 0;
  margin: 2px 0 0 0;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.search-results li {
  padding: 0.6rem 1rem;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  margin: 0 4px;
}

.search-results li:hover {
  background: var(--bg-surface-hover);
  color: var(--primary);
}

.search-results li.no-results {
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  padding: 1rem;
}

/* Accordion Filters */
.accordion-filters {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.filter-category {
  background: transparent;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: all 0.2s;
}

.filter-category[open] {
  background: var(--bg-surface-hover);
  border-color: var(--border-color);
  padding-bottom: 0.5rem;
}

.filter-category-title {
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.5rem 0.25rem;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-category-title i {
  color: var(--primary);
  width: 14px;
  text-align: center;
}

.filter-category-title:hover {
  color: var(--primary);
}

.filter-category-content {
  padding: 0 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* Esconde o marcador nativo do details */
details > summary {
  list-style: none;
}
details > summary::-webkit-details-marker {
  display: none;
}