/* ==========================================================================
   DMS DRIVE MANAGER - LAYOUT & APP SHELL
   ========================================================================== */

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--bg-app);
}

/* App Header */
.app-header {
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: #ffbb00;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #08080a;
  box-shadow: 0 0 16px rgba(255, 187, 0, 0.35);
}

.brand-info h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-info p {
  font-size: 11px;
  color: var(--text-muted);
}

/* Header Search & Actions */
.header-center {
  flex: 1;
  max-width: 520px;
  margin: 0 24px;
}

.search-box {
  position: relative;
  width: 100%;
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 38px;
  padding: 0 38px 0 38px;
  background-color: var(--bg-surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 13px;
  transition: all var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-yellow);
  background-color: var(--bg-surface-elevated);
  box-shadow: 0 0 0 3px rgba(255, 187, 0, 0.15);
}

.search-clear-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2px;
}

.search-clear-btn.visible {
  display: flex;
}

.search-clear-btn:hover {
  color: var(--text-primary);
}

/* Header User & Sync Status */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sync-status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  background-color: var(--bg-surface-card);
  border: 1px solid var(--border-subtle);
}

.sync-status-pill:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-highlight);
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-amber);
  position: relative;
}

.sync-status-pill.online .sync-dot {
  background-color: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

.sync-status-pill.offline .sync-dot {
  background-color: var(--accent-amber);
}

/* Sidebar Navigation Section */
.sidebar-nav-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-nav-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.sidebar-nav-tabs .nav-tab-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 10px;
  background-color: var(--bg-surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sidebar-nav-tabs .nav-tab-btn:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-highlight);
  color: var(--text-primary);
}

.sidebar-nav-tabs .nav-tab-btn.active {
  background-color: #ffbb00;
  border-color: #ffbb00;
  color: #08080a;
  font-weight: 800;
  box-shadow: 0 0 14px rgba(255, 187, 0, 0.25);
}

.sidebar-nav-tabs .nav-tab-btn svg {
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.sidebar-nav-tabs .nav-tab-btn:hover svg {
  transform: scale(1.08);
}

/* App Main Container */
.app-body {
  display: flex;
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* Storage & Health Dashboard Sidebar (Always Visible) */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 16px 14px;
  gap: 16px;
  transition: transform var(--transition-normal);
}

.sidebar-dashboard {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-primary);
}

.sidebar-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

/* Storage Gauge Card in Sidebar */
.storage-gauge-card {
  background-color: var(--bg-surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 12px;
}

.storage-gauge-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gauge-donut-wrapper {
  position: relative;
  width: 76px;
  height: 76px;
  flex-shrink: 0;
}

.gauge-donut-svg {
  width: 100%;
  height: 100%;
}

.gauge-donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.gauge-pct {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.gauge-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-top: 2px;
}

.gauge-stats-column {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.gauge-stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.gauge-stat-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  line-height: 1.1;
}

.gauge-stat-val {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

/* Quick Metrics Grid */
.sidebar-metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.metric-pill-card {
  background-color: var(--bg-surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  gap: 8px;
  align-items: center;
  transition: all var(--transition-fast);
}

.metric-pill-card.has-risk {
  border-color: rgba(239, 68, 68, 0.65);
  background-color: rgba(239, 68, 68, 0.08);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.16);
}

.metric-icon {
  font-size: 16px;
  line-height: 1;
}

.metric-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

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

.metric-val {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.metric-sub {
  font-size: 9px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.sidebar-mini-bar-track {
  height: 4px;
  width: 100%;
  background-color: var(--bg-surface-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin: 3px 0 2px 0;
}

.sidebar-mini-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.5s ease;
}

/* Sidebar Drives List */
.sidebar-drives-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-drives-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-drive-item {
  padding: 8px 10px;
  background-color: var(--bg-surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sidebar-drive-item:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-highlight);
  transform: translateY(-1px);
}

.sidebar-drive-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 5px;
}

.sidebar-drive-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.drive-color-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-drive-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-drive-bar-track {
  height: 5px;
  width: 100%;
  background-color: var(--bg-surface-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.sidebar-drive-bar-fill {
  height: 100%;
  background: var(--gradient-safe);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

.sidebar-drive-bar-fill.warning {
  background: var(--gradient-warning);
}

.sidebar-drive-bar-fill.critical {
  background: var(--gradient-critical);
}

.sidebar-drive-meta {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* Floating Filters Popover in Workbench Header */
.workbench-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filters-dropdown-wrapper {
  position: relative;
}

.filters-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background-color: var(--accent-yellow);
  color: #08080a;
  font-size: 10px;
  font-weight: 800;
  margin-left: 4px;
}

#btn-toggle-filters-menu.has-active-filters {
  border-color: var(--accent-yellow);
  box-shadow: 0 0 12px rgba(255, 187, 0, 0.25);
  color: #fff;
}

.filters-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 320px;
  max-width: 380px;
  background: rgba(18, 18, 22, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.65);
  padding: 14px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: popoverFadeIn 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popoverFadeIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.popover-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-primary);
}

.btn-clear-filters {
  background: none;
  border: none;
  color: var(--accent-rose);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

.btn-clear-filters:hover {
  color: #fb7185;
}

.popover-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.popover-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.popover-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.filter-chip {
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-chip:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-highlight);
}

.filter-chip.active {
  background-color: rgba(255, 187, 0, 0.15);
  border-color: #ffbb00;
  color: #ffbb00;
  font-weight: 700;
}

/* Unassigned Projects Section in Workbench */
.unassigned-projects-section {
  margin-bottom: 24px;
  flex-shrink: 0;
}

.unassigned-banner {
  background: rgba(245, 158, 11, 0.05);
  border: 1px dashed rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}

.unassigned-banner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.unassigned-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.project-card.is-unassigned {
  border: 1px dashed rgba(245, 158, 11, 0.35);
  background-color: rgba(245, 158, 11, 0.02);
}

/* Content Area */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 20px 24px 0 24px;
  background-color: var(--bg-app);
  min-height: 0;
}

.view-section {
  display: none;
}

.view-section.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
}

#view-table.view-section.active {
  overflow-y: auto;
  padding-bottom: 24px;
}

/* Section Headers */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
  flex-shrink: 0;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* View Mode Toggle (Grade / Lista) - Clean Flat Theme */
.view-mode-toggle {
  display: inline-flex;
  align-items: center;
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 3px;
}

.view-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

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

.view-mode-btn.active {
  background-color: #ffbb00;
  color: #08080a;
  border-color: #ffbb00;
  font-weight: 800;
}

/* Project Card Actions Row (Align REMOVER to the left, others to right - Slim & Compact) */
.project-card-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-top: 3px;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  width: 100%;
}

.project-card-actions-row .actions-left {
  display: flex;
  align-items: center;
}

.project-card-actions-row .actions-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

/* ==========================================================================
   DRIVES LIST VIEW LAYOUT (Estrutura Master-Detail Limpa e Intuitiva)
   ========================================================================== */

.drives-list-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 24px;
}

.drive-list-card {
  background-color: var(--bg-surface-card);
  border: 1px solid var(--border-default);
  border-left: 5px solid var(--drive-color, #ffbb00);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.drive-list-card:hover {
  border-color: var(--border-highlight);
}

.drive-list-card.drag-target-over {
  border-color: #ffbb00;
  background-color: rgba(255, 187, 0, 0.02);
  box-shadow: 0 0 0 1px #ffbb00;
}

/* Header do Drive na Lista */
.drive-list-card-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.drive-list-info-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 240px;
  flex: 1;
}

.drive-list-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.drive-list-title-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.drive-list-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.drive-list-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drive-list-notes {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 380px;
}

/* Gráfico de Uso de Armazenamento Central */
.drive-list-meter-block {
  flex: 1.4;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 240px;
  max-width: 400px;
}

.drive-list-meter-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

.drive-list-meter-header strong {
  color: var(--text-primary);
}

.drive-list-meter-track {
  height: 7px;
  width: 100%;
  background-color: var(--bg-surface-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.drive-list-meter-fill {
  height: 100%;
  background: #ffbb00;
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.drive-list-meter-fill.warning {
  background: #f59e0b;
}

.drive-list-meter-fill.critical {
  background: #ef4444;
}

/* Ações e Contagem do Drive */
.drive-list-actions-block {
  display: flex;
  align-items: center;
  gap: 8px;
}

.drive-list-badge-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  background-color: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

/* Tabela de Subprojetos dentro do Drive */
.drive-subprojects-container {
  width: 100%;
  overflow-x: auto;
}

.drive-subprojects-table {
  width: 100%;
  border-collapse: collapse;
}

.drive-subprojects-table th {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 10px 16px;
  background-color: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
}

.drive-subprojects-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
  background-color: transparent;
  transition: background-color var(--transition-fast);
}

.drive-subprojects-table tr:last-child td {
  border-bottom: none;
}

.drive-subprojects-table tr.subproject-table-row {
  cursor: grab;
}

.drive-subprojects-table tr.subproject-table-row:hover td {
  background-color: var(--bg-surface-hover);
}

.drive-subprojects-table tr.subproject-table-row.is-dragging {
  opacity: 0.35;
}

.subproject-name-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.subproject-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.subproject-client {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.subproject-size-badge {
  font-family: monospace;
  font-size: 12px;
  font-weight: 700;
  color: #ffbb00;
  background-color: rgba(255, 187, 0, 0.1);
  padding: 3px 8px;
  border-radius: 4px;
  display: inline-block;
  white-space: nowrap;
}

.subproject-actions-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.drive-list-empty-state {
  padding: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  background-color: rgba(0, 0, 0, 0.15);
}

/* Responsive tweaks */
@media (max-width: 900px) {
  .app-sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
  }

  .app-sidebar.open {
    transform: translateX(0);
  }

  .header-center {
    display: none;
  }
}
