/* assets/css/features/dropdown_menu/dropdown_menu_style.css */

/* ========================================
   DROPDOWN MENU SYSTEM
   Universal dropdown for cards, charts, and tables
   ======================================== */

/* Dropdown Container */
.dropdown-menu-container {
  position: relative;
  display: inline-block;
}

/* Dropdown Toggle Button */
.dropdown-toggle {
  background: transparent;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  color: var(--myceo-text-secondary);   /* was #6b7280: 3.98:1 on this ground */
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  width: 28px;
  height: 28px;
  position: relative;
}

.dropdown-toggle:hover {
  background-color: rgba(10, 36, 87, 0.08);
  color: var(--myceo-accent-blue);
}

.dropdown-toggle:focus {
  outline: 2px solid rgba(10, 36, 87, 0.2);
  outline-offset: 2px;
}

.dropdown-toggle:active {
  transform: scale(0.95);
}

.dropdown-toggle svg {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
}

/* Active state rotation for chevron icons */
.dropdown-menu-container.active .dropdown-toggle svg {
  transform: rotate(180deg);
}

/* Dropdown Menu */
.dropdown-menu {
  position: absolute;
  background: var(--myceo-surface-1);
  border: 1px solid var(--myceo-border-mid);
  border-radius: 6px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 
              0 2px 4px -1px rgba(0, 0, 0, 0.06);
  min-width: 160px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px) scale(0.95);
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: top right;
  padding: 0.25rem 0;
}

/* Position variations */
.dropdown-menu--bottom-right {
  top: 100%;
  right: 0;
  margin-top: 0.25rem;
}

.dropdown-menu--bottom-left {
  top: 100%;
  left: 0;
  margin-top: 0.25rem;
  transform-origin: top left;
}

.dropdown-menu--top-right {
  bottom: 100%;
  right: 0;
  margin-bottom: 0.25rem;
  transform-origin: bottom right;
}

.dropdown-menu--top-left {
  bottom: 100%;
  left: 0;
  margin-bottom: 0.25rem;
  transform-origin: bottom left;
}

/* Active/Open state */
.dropdown-menu-container.active .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Menu Items */
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 1rem;
  text-align: left;
  background: none;
  border: none;
  color: var(--myceo-text-secondary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  position: relative;
}

.dropdown-item:hover {
  background-color: var(--myceo-surface-1);
  color: var(--myceo-accent-blue);
}

.dropdown-item:focus {
  outline: none;
  background-color: var(--myceo-surface-1);
}

.dropdown-item:active {
  background-color: var(--myceo-border-mid);
  transform: scale(0.98);
}

/* Item with icon */
.dropdown-item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.dropdown-item-icon svg {
  width: 14px;
  height: 14px;
}

.dropdown-item-text {
  flex: 1;
}

/* Disabled state */
.dropdown-item:disabled,
.dropdown-item--disabled {
  opacity: 0.5;
  cursor:not-allowed;
  pointer-events: none;
}

/* Danger/Destructive items */
.dropdown-item--danger {
  color: var(--myceo-status-critical);
}

.dropdown-item--danger:hover {
  background-color: rgba(225, 29, 72, 0.16);
  color: #991b1b;
}

/* Dropdown Divider */
.dropdown-divider {
  height: 1px;
  background-color: var(--myceo-surface-1);
  margin: 0.25rem 0;
}

/* ========================================
   METRIC CARD WITH DROPDOWN
   ======================================== */

.metric-card {
  position: relative;
}

.metric-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.metric-card-header .metric-title {
  flex: 1;
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  /* was #6b7280: 3.98:1 on the dark ground, and later in the cascade than the
     shared .metric-card .metric-title rule, so it quietly won. */
  color: var(--myceo-text-primary);
}

.metric-card-header .dropdown-menu-container {
  margin-left: 0.5rem;
  flex-shrink: 0;
}

/* ========================================
   CHART HEADER WITH DROPDOWN
   ======================================== */

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.chart-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--myceo-text-primary);
}

.chart-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chart-controls .dropdown-menu-container {
  margin-left: 0.25rem;
}

/* ========================================
   TABLE HEADER WITH DROPDOWN
   ======================================== */

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: var(--myceo-surface-1);
  border-radius: 6px 6px 0 0;
}

.table-header h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--myceo-text-primary);
}

/* ========================================
   FULLSCREEN MODE
   ======================================== */

.fullscreen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.fullscreen-container {
  position: relative;
  width: 90vw;
  height: 90vh;
  background: var(--myceo-surface-1);
  border-radius: 8px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1),
              0 10px 10px -5px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  animation: scaleIn 0.3s ease;
}

.fullscreen-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: var(--myceo-surface-1);
  border: 1px solid var(--myceo-border-mid);
  border-radius: 6px;
  padding: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

.fullscreen-close:hover {
  background: var(--myceo-surface-1);
  transform: scale(1.1);
}

.fullscreen-close svg {
  width: 20px;
  height: 20px;
}

.fullscreen-content {
  flex: 1;
  padding: 2rem;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fullscreen-content .chart-container {
  width: 100%;
  height: 100%;
  max-width: 1200px;
}

.fullscreen-content canvas {
  max-height: 100% !important;
}

/* ========================================
   LOADING STATES
   ======================================== */

.dropdown-toggle:disabled {
  opacity: 0.5;
  cursor:not-allowed;
}

.loading .dropdown-toggle {
  pointer-events: none;
}

.loading .dropdown-toggle svg {
  animation: spin 1s linear infinite;
}

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */

.export-success-toast,
.export-error-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 1rem 1.5rem;
  border-radius: 6px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  z-index: 10000;
  font-size: 0.9rem;
  font-weight: 500;
  animation: slideInRight 0.3s ease-out;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.export-success-toast {
  background-color: #10b981;
  color: var(--myceo-text-primary);
}

.export-error-toast {
  background-color: var(--myceo-status-critical);
  color: var(--myceo-text-primary);
}

/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes scaleIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

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

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

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

/* Focus visible for keyboard navigation */
.dropdown-toggle:focus-visible,
.dropdown-item:focus-visible {
  outline: 2px solid var(--myceo-accent-blue);
  outline-offset: 2px;
}

/* Screen reader only text */
.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;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
  .dropdown-toggle {
    width: 32px;
    height: 32px;
  }
  
  .dropdown-toggle svg {
    width: 18px;
    height: 18px;
  }
  
  .dropdown-menu {
    min-width: 140px;
  }
  
  .dropdown-item {
    padding: 0.625rem 0.875rem;
  }
  
  .fullscreen-container {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }
  
  .export-success-toast,
  .export-error-toast {
    right: 10px;
    left: 10px;
    max-width: calc(100vw - 20px);
  }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  .dropdown-menu-container {
    display: none !important;
  }
}

/* ========================================
   DARK MODE SUPPORT (Optional)
   ======================================== */

@media (prefers-color-scheme: dark) {
  .dropdown-menu {
    background: var(--myceo-surface-2);
    border-color: #374151;
  }
  
  .dropdown-item {
    color: var(--myceo-text-primary);
  }
  
  .dropdown-item:hover {
    background-color: #374151;
    color: var(--myceo-text-primary);
  }
  
  .dropdown-divider {
    background-color: #374151;
  }
  
  .fullscreen-container {
    background: var(--myceo-surface-2);
  }
  
  .fullscreen-close {
    background: #374151;
    border-color: #4b5563;
    color: var(--myceo-text-primary);
  }
}