/*
 * Token Manager UI Styling
 * All styles scoped to .pf2e-visioner to avoid conflicts
 */

.pf2e-visioner {
  /* DC and outcome columns */
  .visioner-token-manager table .dc-column,
  .visioner-token-manager table .outcome-column {
    text-align: center;
    white-space: nowrap;
  }

  /* Ensure table allows natural sizing so long labels aren't clipped */
  .visioner-token-manager .visibility-table {
    table-layout: auto;
  }

  .visioner-token-manager .dc-value {
    font-weight: 600;
  }

  .visioner-token-manager .dc-outcome {
    margin-left: 8px;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
  }

  .visioner-token-manager .dc-outcome.success {
    background: var(--visibility-observed-bg-medium);
    color: var(--visibility-observed);
    border: 1px solid var(--visibility-observed);
  }
  .visioner-token-manager .dc-outcome.critical-success {
    background: var(--visibility-observed-bg-strong);
    color: var(--visibility-observed);
    border: 1px solid var(--visibility-observed);
  }
  .visioner-token-manager .dc-outcome.failure {
    background: var(--visibility-undetected-bg);
    color: var(--pf2e-visioner-danger);
    border: 1px solid var(--visibility-undetected);
  }
  .visioner-token-manager .dc-outcome.critical-failure {
    background: var(--visibility-undetected-bg-strong);
    color: var(--pf2e-visioner-danger);
    border: 1px solid var(--visibility-undetected);
  }
  /* Override removal column */
  .visioner-token-manager .override-column {
    text-align: center;
    width: 30px;
  }
  .visioner-token-manager button.remove-override {
    background: transparent;
    border: 1px solid transparent;
    color: var(--pf2e-visioner-danger, #c92a2a);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1;
  }
  .visioner-token-manager button.remove-override:hover {
    background: rgba(255, 0, 0, 0.15);
    border-color: rgba(255, 0, 0, 0.4);
    color: #ff4d4f;
  }
  /* Foundry-hidden token indicator */
  .visioner-token-manager .token-image .token-img-wrapper {
    position: relative;
    display: inline-block;
  }
  .visioner-token-manager .foundry-hidden-indicator {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
    pointer-events: none;
  }
  .visioner-token-manager .timer-badge {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.9);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 0 4px rgba(59, 130, 246, 0.6);
    cursor: pointer;
    transition: all 0.2s ease;
  }
  .visioner-token-manager .timer-badge:hover {
    background: rgba(37, 99, 235, 1);
    transform: scale(1.1);
  }

  /* Active Timers Section */
  .visioner-token-manager .active-timers-section {
    margin-bottom: 12px;
    border: 1px solid rgba(59, 130, 246, 0.4);
    border-radius: 6px;
    background: rgba(59, 130, 246, 0.05);
  }
  .visioner-token-manager .active-timers-section .table-section-header {
    background: rgba(59, 130, 246, 0.15);
    padding: 8px 12px;
    cursor: pointer;
    user-select: none;
  }
  .visioner-token-manager .active-timers-section .table-section-header:hover {
    background: rgba(59, 130, 246, 0.25);
  }
  .visioner-token-manager .active-timers-section .header-left {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .visioner-token-manager .active-timers-section .header-left i {
    color: rgba(59, 130, 246, 0.9);
  }
  .visioner-token-manager .active-timers-section .timer-count {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
  }
  .visioner-token-manager .active-timers-section .collapse-indicator {
    margin-left: auto;
    transition: transform 0.2s ease;
  }
  .visioner-token-manager .active-timers-section[data-collapsed='true'] .collapse-indicator {
    transform: rotate(-90deg);
  }
  .visioner-token-manager .active-timers-section[data-collapsed='true'] .active-timers-content {
    display: none;
  }
  .visioner-token-manager .active-timers-content {
    padding: 8px;
  }
  .visioner-token-manager .active-timers-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
  }
  .visioner-token-manager .active-timers-table th {
    text-align: left;
    padding: 4px 8px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }
  .visioner-token-manager .active-timers-table td {
    padding: 6px 8px;
    vertical-align: middle;
  }
  .visioner-token-manager .timer-row {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  }
  .visioner-token-manager .timer-row:hover {
    background: rgba(59, 130, 246, 0.1);
  }
  .visioner-token-manager .timer-target-name {
    font-weight: 500;
  }
  .visioner-token-manager .timer-display {
    font-family: monospace;
    font-size: 12px;
    color: rgba(59, 130, 246, 0.9);
  }
  .visioner-token-manager .timer-turn-info {
    display: block;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 2px;
  }
  .visioner-token-manager .timer-actions {
    text-align: right;
    width: 40px;
  }
  .visioner-token-manager .cancel-timer-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--pf2e-visioner-danger, #c92a2a);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1;
    transition: all 0.2s ease;
  }
  .visioner-token-manager .cancel-timer-btn:hover {
    background: rgba(255, 0, 0, 0.15);
    border-color: rgba(255, 0, 0, 0.4);
    color: #ff4d4f;
  }

  /* Row Timer Toggle Button */
  .visioner-token-manager .row-timer-toggle {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 4px;
  }
  .visioner-token-manager .row-timer-toggle:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.5);
    color: rgba(59, 130, 246, 0.9);
  }
  .visioner-token-manager .row-timer-toggle.active {
    background: linear-gradient(
      135deg,
      rgba(59, 130, 246, 0.4) 0%,
      rgba(37, 99, 235, 0.5) 100%
    ) !important;
    border-color: rgba(96, 165, 250, 0.9) !important;
    color: #fff !important;
    box-shadow:
      0 0 10px rgba(59, 130, 246, 0.35),
      inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
  }
  .visioner-token-manager .row-timer-toggle.active:hover {
    background: rgba(220, 38, 38, 0.15);
    border-color: rgba(220, 38, 38, 0.5);
    color: rgba(220, 38, 38, 0.9);
  }
  .visioner-token-manager .row-timer-label {
    font-size: 10px;
    font-family: monospace;
  }
  /*
 * Token Manager UI Improvements
 * Modern, compact UI for the token manager
 */

  /* Icon-only tab navigation */

  .visioner-token-manager {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  .visioner-token-manager .icon-tab-navigation {
    position: absolute;
    top: 10px;
    right: 12px;
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    z-index: 3;
  }

  .icon-tab-button {
    background-color: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--color-border-light-primary);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    font-size: 16px;
  }

  .icon-tab-button:hover {
    background-color: rgba(0, 0, 0, 0.3);
    transform: scale(1.05);
  }

  .icon-tab-button.active {
    background-color: var(--pf2e-visioner-primary);
    color: white;
    border-color: var(--pf2e-visioner-primary);
    box-shadow: 0 0 8px var(--color-shadow-highlight);
  }

  /* Compact legend styles */
  .compact-legend {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
    padding: 8px;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    flex-wrap: wrap;
  }

  .compact-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    cursor: default;
    position: relative;
  }

  .compact-legend .legend-item i {
    font-size: 14px;
  }

  .compact-legend .legend-item span {
    font-size: 12px;
    white-space: nowrap;
  }

  .compact-legend .bonus-badge {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: bold;
  }

  /* Adjust the observer info section */
  .observer-info {
    padding-bottom: 0;
  }

  /* Layout: make center content flex so footer never overlaps */
  .visioner-tab-content {
    margin-top: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* allow child overflow area to size correctly */
  }

  /* Scrollable tables area that respects footer height */
  .visioner-token-manager .tab-panel {
    display: none;
  }
  .visioner-token-manager .tab-panel.active {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  .visioner-token-manager .tables-content {
    flex: 1;
    overflow-y: auto;
    padding-right: 2px;
  }

  /* Footer: stick to bottom of the window content without covering rows */
  .visioner-token-manager .sheet-footer {
    position: sticky;
    bottom: 0;
    z-index: 5;
    background: var(--color-bg);
    padding-top: 8px;
    box-shadow: 0 -4px 8px rgba(0, 0, 0, 0.2);
  }
} /* End .pf2e-visioner scope */

/* Cover State Indicator Colors - Professional styling */
.state-indicator.cover-none {
  background: rgba(76, 175, 80, 0.3) !important; /* Subtle green background */
  color: #4caf50 !important; /* Green text */
  border-color: #4caf50 !important; /* Green border */
}

.state-indicator.cover-lesser {
  background: rgba(255, 193, 7, 0.3) !important; /* Subtle yellow background */
  color: #ffc107 !important; /* Yellow text */
  border-color: #ffc107 !important; /* Yellow border */
}

.state-indicator.cover-standard {
  background: rgba(255, 102, 0, 0.3) !important; /* Subtle orange background */
  color: #ff6600 !important; /* Orange text */
  border-color: #ff6600 !important; /* Orange border */
}

.state-indicator.cover-greater {
  background: rgba(244, 67, 54, 0.3) !important; /* Subtle red background */
  color: #f44336 !important; /* Red text */
  border-color: #f44336 !important; /* Red border */
}

/* Visibility State Indicator Colors - Professional styling */
.state-indicator.visibility-avs {
  background: rgba(156, 39, 176, 0.25) !important; /* Subtle purple background */
  color: #9c27b0 !important; /* Purple text */
  border-color: #9c27b0 !important; /* Purple border */
}

.state-indicator.visibility-observed {
  background: rgba(76, 175, 80, 0.25) !important; /* Subtle green background */
  color: #4caf50 !important; /* Green text */
  border-color: #4caf50 !important; /* Green border */
}

.state-indicator.visibility-concealed {
  background: rgba(255, 152, 0, 0.25) !important; /* Subtle orange background */
  color: #ff9800 !important; /* Orange text */
  border-color: #ff9800 !important; /* Orange border */
}

.state-indicator.visibility-hidden {
  background: rgba(255, 152, 0, 0.25) !important; /* Subtle orange background */
  color: #ff9800 !important; /* Orange text */
  border-color: #ff9800 !important; /* Orange border */
}

.state-indicator.visibility-undetected {
  background: rgba(244, 67, 54, 0.25) !important; /* Subtle red background */
  color: #f44336 !important; /* Red text */
  border-color: #f44336 !important; /* Red border */
}

/* AVS Chip Styling */
.avs-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 6px;
  padding: 1px 4px;
  background: var(--visibility-avs);
  color: white;
  border-radius: 8px;
  font-size: 9px;
  font-weight: bold;
  line-height: 1;
  vertical-align: middle;
}

.avs-chip i {
  font-size: 8px;
}

/* Small AVS Tag for Action Dialogs */
.old-visibility-state {
  position: relative;
  display: inline-block;
}

.avs-tag-small {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  background: var(--visibility-avs);
  color: white;
  border-radius: 50%;
  font-size: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  box-shadow: 0 0 0 1px white;
}

.avs-tag-small i {
  font-size: 5px;
}
