/* ===== THEME VARIABLES ===== */
:root {
  /* Light theme (default) */
  --bg-primary: #f9fafb;
  --bg-secondary: rgba(255, 255, 255, 0.95);
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-nav: rgba(255, 255, 255, 0.92);
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --border-color: rgba(255, 255, 255, 0.8);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  --nav-border: rgba(0, 0, 0, 0.1);
  --hover-bg: rgba(255, 255, 255, 0.95);
  --card-hover-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] {
  /* Dark theme - Actually dark colors */
  --bg-primary: #0f172a;
  --bg-secondary: rgba(15, 23, 42, 0.95);
  --bg-card: rgba(30, 41, 59, 0.85);
  --bg-nav: rgba(15, 23, 42, 0.95);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --border-color: rgba(255, 255, 255, 0.15);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --nav-border: rgba(255, 255, 255, 0.1);
  --hover-bg: rgba(30, 41, 59, 0.95);
  --card-hover-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

/* ===== BASE THEME APPLICATIONS ===== */
* {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
}

body {
  background-color: var(--bg-primary) !important;
  color: var(--text-primary) !important;
}

/* ===== ENHANCED DASHBOARD CARDS ===== */
.grid.grid-cols-1.sm\\:grid-cols-4.gap-4.mb-6 > div {
    background: var(--bg-card) !important;
    backdrop-filter: blur(20px) !important;
    border-radius: 20px !important;
    border: 1.5px solid var(--border-color) !important;
    box-shadow: var(--shadow) !important;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.grid.grid-cols-1.sm\\:grid-cols-4.gap-4.mb-6 > div:hover {
    background: var(--hover-bg) !important;
    transform: translateY(-8px) scale(1.02) !important;
    box-shadow: var(--card-hover-shadow) !important;
}

/* ===== ENHANCED POOL CARDS ===== */
#poolGrid > * {
    background: var(--bg-card) !important;
    backdrop-filter: blur(20px) !important;
    border: 1.5px solid var(--border-color) !important;
    border-radius: 20px !important;
    box-shadow: var(--shadow) !important;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

#poolGrid > *:hover {
    background: var(--hover-bg) !important;
    transform: translateY(-8px) scale(1.02) !important;
    box-shadow: var(--card-hover-shadow) !important;
}

/* ===== ENHANCED STATUS DOTS ===== */
.pool-miner-status-dot {
    position: relative !important;
    border: 2px solid var(--border-color) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    animation: statusPulse 2s ease-in-out infinite !important;
}

.pool-miner-status-dot[style*="#EF4444"] {
    background: linear-gradient(135deg, #ef4444, #dc2626) !important;
    animation: none !important;
}

/* ===== ENHANCED BUTTONS ===== */
.action-btn {
    position: relative !important;
    overflow: hidden !important;
    transition: all 0.3s ease !important;
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

.action-btn::before {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: -100% !important;
    width: 100% !important;
    height: 100% !important;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent) !important;
    transition: left 0.5s !important;
}

.action-btn:hover::before {
    left: 100% !important;
}

.action-btn:hover {
    box-shadow: 0 8px 25px rgba(34, 197, 94, 0.25) !important;
    transform: translateY(-2px) !important;
}

/* ===== ANIMATIONS ===== */
@keyframes statusPulse {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
        transform: scale(1.1);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 40px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

/* ===== ENHANCED MODALS ===== */
#poolRunModal > div,
#addConfigModal > div,
#logsModal > div,
#rewardsModal > div,
#earningsModal > div,
#ppsModal > div,
#stakeModal > div,
#joinPoolModal > div,
#firmwareModal > div {
    background: var(--bg-secondary) !important;
    backdrop-filter: blur(40px) !important;
    border: 1.5px solid var(--border-color) !important;
    box-shadow: var(--shadow) !important;
    color: var(--text-primary) !important;
}

#poolRunModal input,
#addConfigModal input,
#addConfigModal select,
#logsModal input,
.modal input,
.modal select {
    background: var(--bg-card) !important;
    border: 1.5px solid var(--border-color) !important;
    color: var(--text-primary) !important;
    transition: all 0.3s ease !important;
}

#poolRunModal input:focus,
#addConfigModal input:focus,
.modal input:focus {
    background: var(--bg-secondary) !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
    border-color: #3b82f6 !important;
    transform: translateY(-1px) !important;
}

/* ===== GLASS EFFECTS ===== */
.backdrop-blur-nav {
    backdrop-filter: blur(30px) saturate(180%) !important;
    background: var(--bg-nav) !important;
    border-bottom: 1px solid var(--nav-border) !important;
}

/* ===== TEXT COLOR OVERRIDES ===== */
.text-gray-500,
.text-gray-400,
.text-gray-600 {
  color: var(--text-secondary) !important;
}

.text-gray-900,
.text-gray-800,
.text-gray-700,
.text-gray-900 {
  color: var(--text-primary) !important;
}

/* ===== FORM ELEMENTS ===== */
input, select, textarea {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-color) !important;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-secondary) !important;
  opacity: 0.7;
}

/* ===== QUICK ACTION BUTTONS ===== */
#terminalBtn,
#earningsBtn,
#calcBtn,
#openStakeModal {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-color) !important;
}

#terminalBtn:hover,
#earningsBtn:hover,
#calcBtn:hover,
#openStakeModal:hover {
  background: var(--hover-bg) !important;
  border-color: var(--text-secondary) !important;
}

/* ===== PLAN CARD ===== */
.plan-card, .pool-card {
  border: 2px solid var(--border-color) !important;
  border-radius: 0.5rem;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
}

.plan-card:hover, .pool-card:hover {
  border-color: #93c5fd !important;
  box-shadow: var(--shadow) !important;
}

.plan-card.selected, .pool-card.selected {
  border-color: #3b82f6 !important;
  background-color: rgba(59, 130, 246, 0.1) !important;
  box-shadow: var(--shadow) !important;
}

.input-field:focus {
  outline: none;
  ring: 2px;
  ring-color: #3b82f6;
  ring-opacity: 0.2;
  border-color: #3b82f6 !important;
}

/* ===== THEME TOGGLE ===== */
#themeToggle {
  transition: all 0.3s ease;
  background: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
}

#themeToggle:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow) !important;
}

/* ===== FOOTER ===== */
footer {
  background: var(--bg-nav) !important;
  border-color: var(--nav-border) !important;
}

/* ===== RESPONSIVE ENHANCEMENTS ===== */
@media (max-width: 768px) {
    .grid.grid-cols-1.sm\\:grid-cols-4.gap-4.mb-6 > div:hover {
        transform: translateY(-4px) scale(1.01) !important;
    }
    
    #poolGrid > *:hover {
        transform: translateY(-4px) scale(1.01) !important;
    }
}

/* ===== PERFORMANCE ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== DARK MODE SPECIFIC FIXES ===== */
[data-theme="dark"] .bg-white {
  background-color: var(--bg-card) !important;
}

[data-theme="dark"] .border-gray-200,
[data-theme="dark"] .border-gray-300 {
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .bg-gray-50 {
  background-color: var(--bg-secondary) !important;
}

[data-theme="dark"] .hover\\:bg-gray-50:hover {
  background-color: var(--hover-bg) !important;
}

[data-theme="dark"] .text-gray-300 {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .hover\\:text-white:hover {
  color: var(--text-primary) !important;
}

/* Ensure modal close buttons are visible */
[data-theme="dark"] .text-gray-500 {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .hover\\:text-gray-700:hover {
  color: var(--text-primary) !important;
}


/* ===== MODAL CONTENT THEME FIXES ===== */
[data-theme="dark"] .bg-blue-50,
[data-theme="dark"] .bg-green-50,
[data-theme="dark"] .bg-yellow-50,
[data-theme="dark"] .bg-white {
  background-color: var(--bg-secondary) !important;
}

[data-theme="dark"] .border-blue-200,
[data-theme="dark"] .border-green-200,
[data-theme="dark"] .border-yellow-200,
[data-theme="dark"] .border-blue-300,
[data-theme="dark"] .border-green-300 {
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .text-blue-800,
[data-theme="dark"] .text-green-800,
[data-theme="dark"] .text-yellow-800,
[data-theme="dark"] .text-blue-700,
[data-theme="dark"] .text-green-700 {
  color: var(--text-primary) !important;
}

[data-theme="dark"] .text-gray-700,
[data-theme="dark"] .text-gray-600 {
  color: var(--text-secondary) !important;
}

[data-theme="dark"] .bg-blue-600,
[data-theme="dark"] .bg-green-600 {
  background-color: #2563eb !important; /* Keep blue/green for numbers */
}

[data-theme="dark"] .font-mono.bg-blue-100 {
  background-color: rgba(59, 130, 246, 0.2) !important;
  color: var(--text-primary) !important;
}

/* Specific fixes for the guide sections */
[data-theme="dark"] .border-gray-200 {
  border-color: var(--border-color) !important;
}

[data-theme="dark"] .text-green-600 {
  color: #10b981 !important; /* Keep brand green */
}

/* Update the info boxes in dark mode */
[data-theme="dark"] .bg-white.border-blue-300 {
  background-color: rgba(30, 41, 59, 0.8) !important;
  border-color: rgba(59, 130, 246, 0.3) !important;
}

[data-theme="dark"] .bg-white.border-green-300 {
  background-color: rgba(30, 41, 59, 0.8) !important;
  border-color: rgba(16, 185, 129, 0.3) !important;
}

/* Ensure all common utility classes are themed */
[data-theme="dark"] .bg-gray-100 { background-color: var(--bg-secondary) !important; }
[data-theme="dark"] .text-gray-800 { color: var(--text-primary) !important; }
[data-theme="dark"] .border-gray-300 { border-color: var(--border-color) !important; }


[data-theme="dark"] .modal-content {
  background: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
}

[data-theme="dark"] .modal input,
[data-theme="dark"] .modal select {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-color) !important;
}