/**
 * Utility Classes - Energy Empire
 * Shared utility classes for common patterns
 */

/* ========================================
   LAYOUT UTILITIES
   ======================================== */

/* Flexbox */
.flex { display: flex; }
.flex-inline { display: inline-flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }

/* Alignment */
.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.items-stretch { align-items: stretch; }

.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }

/* Combined shortcuts */
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}
.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.flex-col-center {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Flex grow/shrink */
.flex-1 { flex: 1; }
.flex-auto { flex: auto; }
.flex-none { flex: none; }
.shrink-0 { flex-shrink: 0; }

/* Gap */
.gap-xs { gap: var(--spacing-xs); }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }
.gap-xl { gap: var(--spacing-xl); }

/* ========================================
   SPACING UTILITIES
   ======================================== */

/* Padding */
.p-0 { padding: 0; }
.p-xs { padding: var(--spacing-xs); }
.p-sm { padding: var(--spacing-sm); }
.p-md { padding: var(--spacing-md); }
.p-lg { padding: var(--spacing-lg); }
.p-xl { padding: var(--spacing-xl); }

.px-sm { padding-left: var(--spacing-sm); padding-right: var(--spacing-sm); }
.px-md { padding-left: var(--spacing-md); padding-right: var(--spacing-md); }
.px-lg { padding-left: var(--spacing-lg); padding-right: var(--spacing-lg); }

.py-sm { padding-top: var(--spacing-sm); padding-bottom: var(--spacing-sm); }
.py-md { padding-top: var(--spacing-md); padding-bottom: var(--spacing-md); }
.py-lg { padding-top: var(--spacing-lg); padding-bottom: var(--spacing-lg); }

/* Margin */
.m-0 { margin: 0; }
.m-auto { margin: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }

.mb-xs { margin-bottom: var(--spacing-xs); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }

/* ========================================
   TYPOGRAPHY UTILITIES
   ======================================== */

/* Text alignment */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Text transform */
.text-uppercase { text-transform: uppercase; letter-spacing: 1px; }
.text-capitalize { text-transform: capitalize; }
.text-lowercase { text-transform: lowercase; }

/* Font weight */
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* Font size */
.text-xs { font-size: 10px; }
.text-sm { font-size: 12px; }
.text-base { font-size: 14px; }
.text-lg { font-size: 16px; }
.text-xl { font-size: 20px; }
.text-2xl { font-size: 24px; }

/* Text colors */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent-blue); }
.text-success { color: var(--accent-green); }
.text-warning { color: var(--accent-yellow); }
.text-error { color: var(--accent-red); }

/* Text overflow */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ========================================
   BORDER UTILITIES
   ======================================== */

.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

.border { border: 1px solid var(--border-color); }
.border-none { border: none; }
.border-glow { border-color: var(--border-glow); }

/* ========================================
   VISIBILITY & DISPLAY
   ======================================== */

.hidden { display: none !important; }
.invisible { visibility: hidden; }
.visible { visibility: visible; }

.block { display: block; }
.inline-block { display: inline-block; }
.inline { display: inline; }
.grid { display: grid; }

.opacity-0 { opacity: 0; }
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }
.opacity-100 { opacity: 1; }

/* ========================================
   POSITION UTILITIES
   ======================================== */

.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.top-0 { top: 0; }
.right-0 { right: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }

/* ========================================
   SIZE UTILITIES
   ======================================== */

.w-full { width: 100%; }
.h-full { height: 100%; }
.w-auto { width: auto; }
.h-auto { height: auto; }

.min-w-0 { min-width: 0; }
.min-h-0 { min-height: 0; }

/* ========================================
   TRANSITION UTILITIES
   ======================================== */

.transition-none { transition: none; }
.transition-fast { transition: all var(--duration-fast) ease; }
.transition-normal { transition: all var(--duration-normal) ease; }
.transition-slow { transition: all var(--duration-slow) ease; }

.transition-colors { transition: color var(--duration-normal) ease, background-color var(--duration-normal) ease, border-color var(--duration-normal) ease; }
.transition-transform { transition: transform var(--duration-normal) ease; }
.transition-opacity { transition: opacity var(--duration-normal) ease; }

/* ========================================
   INTERACTION UTILITIES
   ======================================== */

.cursor-pointer { cursor: pointer; }
.cursor-default { cursor: default; }
.cursor-not-allowed { cursor: not-allowed; }

.pointer-events-none { pointer-events: none; }
.pointer-events-auto { pointer-events: auto; }

.select-none { user-select: none; }
.select-text { user-select: text; }

/* ========================================
   OVERFLOW UTILITIES
   ======================================== */

.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-scroll { overflow: scroll; }
.overflow-visible { overflow: visible; }

.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }
.overflow-x-hidden { overflow-x: hidden; }
.overflow-y-hidden { overflow-y: hidden; }

/* ========================================
   SHADOW UTILITIES
   ======================================== */

.shadow-none { box-shadow: none; }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }

.shadow-glow-blue { box-shadow: var(--shadow-glow-blue); }
.shadow-glow-green { box-shadow: var(--shadow-glow-green); }
.shadow-glow-yellow { box-shadow: var(--shadow-glow-yellow); }
.shadow-glow-purple { box-shadow: var(--shadow-glow-purple); }

/* ========================================
   Z-INDEX UTILITIES
   ======================================== */

.z-0 { z-index: 0; }
.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-50 { z-index: 50; }
.z-dropdown { z-index: var(--z-dropdown); }
.z-modal { z-index: var(--z-modal); }
.z-toast { z-index: var(--z-toast); }
.z-tooltip { z-index: var(--z-tooltip); }

/* ========================================
   BACKGROUND UTILITIES
   ======================================== */

.bg-dark { background-color: var(--bg-dark); }
.bg-darker { background-color: var(--bg-darker); }
.bg-panel { background-color: var(--bg-panel); }
.bg-panel-hover { background-color: var(--bg-panel-hover); }
.bg-transparent { background-color: transparent; }

/* ========================================
   ANIMATION UTILITIES
   (Keyframes defined in animations.css)
   ======================================== */

.animate-none { animation: none; }

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus visible */
.focus-ring:focus-visible {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

/* ========================================
   REDUCED MOTION
   ======================================== */

@media (prefers-reduced-motion: reduce) {
  .transition-fast,
  .transition-normal,
  .transition-slow,
  .transition-colors,
  .transition-transform,
  .transition-opacity {
    transition: none;
  }

  .animate-spin,
  .animate-pulse,
  .animate-bounce {
    animation: none;
  }
}

/* ========================================
   BASE COMPONENT CLASSES
   Reusable patterns for common UI elements
   ======================================== */

/* Base Card/Item - Foundation for all clickable items */
.item-base {
  background: var(--bg-panel-hover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  cursor: pointer;
  transition: all var(--duration-normal) ease;
  position: relative;
  overflow: hidden;
}

.item-base:hover {
  border-color: var(--accent-blue);
  background: rgba(0, 191, 255, 0.05);
}

.item-base.affordable {
  border-color: var(--accent-green);
}

.item-base.affordable:hover {
  background: rgba(0, 255, 136, 0.1);
  box-shadow: var(--shadow-glow-green);
}

.item-base.purchased,
.item-base.owned {
  border-color: var(--accent-yellow);
  background: rgba(255, 215, 0, 0.1);
  cursor: default;
}

.item-base.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.item-base.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* Card Header Pattern */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-sm);
}

/* Card with Icon Pattern */
.card-with-icon {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.card-icon {
  width: 48px;
  height: 48px;
  background: var(--bg-dark);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.card-info {
  flex: 1;
  min-width: 0;
}

/* Base Button Variants */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-normal) ease;
  background: var(--bg-panel-hover);
  color: var(--text-primary);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
}

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

.btn-primary:hover {
  box-shadow: var(--shadow-glow-blue);
}

.btn-success {
  background: var(--gradient-green);
  border-color: var(--accent-green);
  color: white;
}

.btn-success:hover {
  box-shadow: var(--shadow-glow-green);
}

.btn-warning {
  background: var(--gradient-gold);
  border-color: var(--accent-yellow);
  color: var(--bg-dark);
}

.btn-warning:hover {
  box-shadow: var(--shadow-glow-yellow);
}

.btn-danger {
  background: linear-gradient(135deg, #ff4757 0%, #c0392b 100%);
  border-color: var(--accent-red);
  color: white;
}

.btn-purple {
  background: var(--gradient-purple);
  border-color: var(--accent-purple);
  color: white;
}

.btn-purple:hover {
  box-shadow: var(--shadow-glow-purple);
}

.btn-sm {
  padding: var(--spacing-xs) var(--spacing-sm);
  font-size: 12px;
}

.btn-lg {
  padding: var(--spacing-md) var(--spacing-lg);
  font-size: 16px;
}

.btn:disabled,
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Base Badge */
.badge-base {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: var(--radius-xl);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-success {
  background: rgba(0, 255, 136, 0.2);
  color: var(--accent-green);
  border: 1px solid var(--accent-green);
}

.badge-warning {
  background: rgba(255, 215, 0, 0.2);
  color: var(--accent-yellow);
  border: 1px solid var(--accent-yellow);
}

.badge-danger {
  background: rgba(255, 71, 87, 0.2);
  color: var(--accent-red);
  border: 1px solid var(--accent-red);
}

.badge-info {
  background: rgba(0, 212, 255, 0.2);
  color: var(--accent-blue);
  border: 1px solid var(--accent-blue);
}

/* Progress Bar Base */
.progress-base {
  height: 8px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width var(--duration-normal) ease;
  background: var(--gradient-blue);
}

.progress-fill.success { background: var(--gradient-green); }
.progress-fill.warning { background: var(--gradient-gold); }
.progress-fill.danger { background: linear-gradient(135deg, #ff4757 0%, #c0392b 100%); }
.progress-fill.purple { background: var(--gradient-purple); }

/* Tab Base */
.tab-base {
  display: flex;
  gap: var(--spacing-xs);
  padding: var(--spacing-sm);
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-md);
}

.tab-item {
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  font-size: 13px;
  color: var(--text-secondary);
  background: transparent;
  border: none;
}

.tab-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.tab-item.active {
  background: var(--accent-blue);
  color: white;
}

/* Panel Base */
.panel-base {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}

.panel-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent-yellow);
}

/* List Base */
.list-base {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.list-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-sm);
  border-radius: var(--radius-sm);
  transition: background var(--duration-fast) ease;
}

.list-item:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* Notification Dot */
.notification-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 10px;
  height: 10px;
  background: var(--accent-red);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-dark);
}

/* Tooltip Base */
.tooltip-base {
  position: absolute;
  background: var(--bg-darker);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 12px;
  color: var(--text-primary);
  z-index: var(--z-tooltip);
  pointer-events: none;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
}

/* Divider */
.divider {
  height: 1px;
  background: var(--border-color);
  margin: var(--spacing-md) 0;
}

.divider-vertical {
  width: 1px;
  height: 100%;
  background: var(--border-color);
  margin: 0 var(--spacing-md);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-xl);
  text-align: center;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: var(--spacing-md);
  opacity: 0.5;
}

.empty-state-text {
  font-size: 14px;
}
