/* =====================================================
   DARK MODE STYLES - Crypto Portfolio Tracker
   Enhanced contrast and full-width layout
   ===================================================== */

/* Dark mode variables - ZWIĘKSZONY KONTRAST */
body.dark-mode {
    --bg-primary: #0f1114;
    --bg-secondary: #1a1d23;
    --bg-card: #242830;
    --text-primary: #ffffff;
    --text-secondary: #d0d3d8;
    --text-muted: #8a8f98;
    --border-color: #3a3f4b;
    --hover-bg: #2d323e;
    --accent-green: #34d399;
    --accent-red: #f87171;
}

/* Body background */
body.dark-mode {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

/* WordPress admin wrapper */
body.dark-mode #wpwrap {
    background-color: var(--bg-primary) !important;
}

body.dark-mode #wpcontent {
    background-color: var(--bg-primary) !important;
}

body.dark-mode #wpbody-content {
    background-color: var(--bg-primary) !important;
}

/* Main content area  */
body.dark-mode .wrap {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    padding: 0 !important;
    margin-right: 40px !important;
}



/* Headings - ZWIĘKSZONY KONTRAST */
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4,
body.dark-mode h5,
body.dark-mode h6 {
    color: var(--text-primary) !important;
}

/* Cards and sections */
body.dark-mode .cpt-metric-card {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4) !important;
}

/* Ensure cards have same padding as light mode */
body.dark-mode .cpt-metric-card {
    padding: 28px 24px !important;
}

/* Ensure metrics grid has same gap */
body.dark-mode .cpt-metrics-grid {
    gap: 24px !important;
    margin-bottom: 32px !important;
}

body.dark-mode [style*="background: #fff"],
body.dark-mode [style*="background:#fff"],
body.dark-mode [style*="background-color: #fff"],
body.dark-mode [style*="background-color:#fff"] {
    background-color: var(--bg-card) !important;
}

/* Quick Actions Cards */
body.dark-mode [style*="background: #f3f4f6"] {
    background-color: var(--bg-secondary) !important;
}

/* Tables - ZWIĘKSZONY KONTRAST */
body.dark-mode .wp-list-table,
body.dark-mode table {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

body.dark-mode .wp-list-table th {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

body.dark-mode .wp-list-table td {
    background-color: var(--bg-card) !important;
    color: var(--text-secondary) !important;
    border-color: var(--border-color) !important;
}

body.dark-mode .wp-list-table tbody tr:hover td {
    background-color: var(--hover-bg) !important;
}

/* Text colors - ZWIĘKSZONY KONTRAST */
body.dark-mode [style*="color: #1f2937"],
body.dark-mode [style*="color:#1f2937"] {
    color: var(--text-primary) !important;
}

body.dark-mode [style*="color: #6b7280"],
body.dark-mode [style*="color:#6b7280"] {
    color: var(--text-secondary) !important;
}

body.dark-mode [style*="color: #9ca3af"],
body.dark-mode [style*="color:#9ca3af"] {
    color: var(--text-muted) !important;
}

body.dark-mode [style*="color: #646970"] {
    color: var(--text-secondary) !important;
}

/* Quick Actions */
body.dark-mode .cpt-quick-action {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

body.dark-mode .cpt-quick-action:first-child {
    /* Gradient button - keep it visible */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
}

body.dark-mode .cpt-quick-action:hover {
    background-color: var(--hover-bg) !important;
    transform: translateY(-2px);
}

/* Dashicons in dark mode */
body.dark-mode .cpt-quick-action .dashicons {
    color: var(--text-secondary) !important;
}

body.dark-mode .cpt-quick-action:first-child .dashicons {
    color: white !important;
}

/* Holdings Distribution & Performance sections */
body.dark-mode .cpt-holdings-chart,
body.dark-mode .cpt-performance-chart {
    background-color: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

/* Modal/Placeholder backgrounds */
body.dark-mode [style*="background: linear-gradient(135deg, #f9fafb"],
body.dark-mode [style*="background: linear-gradient(180deg, #f9fafb"] {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-card) 100%) !important;
}

/* Placeholder borders - make them consistent */
body.dark-mode [style*="border: 2px dashed #e5e7eb"] {
    border: 2px dashed var(--border-color) !important;
    border-color: #3a3f4b !important;
}

body.dark-mode [style*="border-radius: 8px"] {
    border-radius: 8px !important;
}

/* Placeholder text */
body.dark-mode [style*="color: #9ca3af; font-size: 14px"] {
    color: var(--text-muted) !important;
}

/* Forms */
body.dark-mode input[type="text"],
body.dark-mode input[type="number"],
body.dark-mode input[type="date"],
body.dark-mode input[type="time"],
body.dark-mode input[type="email"],
body.dark-mode input[type="url"],
body.dark-mode select,
body.dark-mode textarea {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

body.dark-mode input::placeholder {
    color: var(--text-muted) !important;
}

/* Buttons */
body.dark-mode .button,
body.dark-mode button {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

body.dark-mode .button:hover,
body.dark-mode button:hover {
    background-color: var(--hover-bg) !important;
}

body.dark-mode .button-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    border-color: #667eea !important;
    color: white !important;
}

/* Footer info */
body.dark-mode [style*="background: #f6f7f7"] {
    background-color: var(--bg-secondary) !important;
    color: var(--text-secondary) !important;
}

/* Percentage indicators */
body.dark-mode [style*="color: #10b981"] {
    color: var(--accent-green) !important;
}

body.dark-mode [style*="color: #ef4444"] {
    color: var(--accent-red) !important;
}

/* Grid sections - full width */
body.dark-mode .cpt-metrics-grid,
body.dark-mode [style*="display: grid"] {
    width: 100% !important;
}

/* Holdings list items */
body.dark-mode [style*="border-bottom: 1px solid #f3f4f6"] {
    border-bottom: 1px solid var(--border-color) !important;
}

/* Gradient backgrounds for icons - keep visible */
body.dark-mode [style*="background: linear-gradient(135deg, #667eea"],
body.dark-mode [style*="background: linear-gradient(135deg, #10b981"],
body.dark-mode [style*="background: linear-gradient(135deg, #ef4444"] {
    /* Keep original gradient */
}

/* Toggle button specific styling */
.cpt-dark-mode-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.cpt-dark-mode-toggle:hover {
    background-color: rgba(0,0,0,0.1);
}

body.dark-mode .cpt-dark-mode-toggle:hover {
    background-color: rgba(255,255,255,0.1);
}

.cpt-dark-mode-toggle .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

/* Fix for inline styles with #fff */
body.dark-mode [style*="border: 1px solid #e5e7eb"],
body.dark-mode [style*="border: 2px solid #e5e7eb"] {
    border-color: var(--border-color) !important;
}

body.dark-mode [style*="box-shadow: 0 2px 8px rgba(0,0,0,0.08)"] {
    box-shadow: 0 2px 8px rgba(0,0,0,0.4) !important;
}

/* Scrollbar styling for dark mode */
body.dark-mode ::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

body.dark-mode ::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

body.dark-mode ::-webkit-scrollbar-thumb {
    background: var(--bg-secondary);
    border-radius: 6px;
}

body.dark-mode ::-webkit-scrollbar-thumb:hover {
    background: var(--hover-bg);
}


/* =====================================================
   MOBILE DARK MODE FIXES
   ===================================================== */

@media (max-width: 782px) {
/* Fix padding to prevent overflow */
    body.dark-mode .wrap {
        padding: 6px 6px !important; 
    }
    
body.dark-mode .cpt-dashboard-container {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 16px !important; 
    margin-left: 0 !important;
    margin-right: 0 !important;
    overflow-x: hidden !important;
}
    
    /* Fix sections padding */
    body.dark-mode .cpt-dashboard-container > div[style*="padding: 24px"],
    body.dark-mode .cpt-dashboard-container > div[style*="padding: 16px"] {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }
   
    
    /* Fix card sections */
    body.dark-mode .cpt-dashboard-container > div[style*="background"] {
        margin-left: 0 !important;
        margin-right: 0 !important;
        border-radius: 8px !important;
        overflow: hidden !important;
    }
    
    /* Fix metrics cards */
    body.dark-mode .cpt-metric-card {
        padding: 16px !important;
        margin-bottom: 12px !important;
    }
    
    /* Fix Quick Actions grid */
    body.dark-mode div[style*="grid-template-columns: repeat(auto-fit, minmax(160px, 1fr))"] {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    
    body.dark-mode .cpt-quick-action {
        padding: 14px !important;
        justify-content: center !important;
    }
    
    /* Fix Holdings and Performance sections */
    body.dark-mode .cpt-holdings-chart,
    body.dark-mode .cpt-performance-chart {
        padding: 16px !important;
        margin-bottom: 16px !important;
    }
    
    /* Fix placeholder sections */
    body.dark-mode [style*="border: 2px dashed"] {
        min-height: 200px !important;
        padding: 20px !important;
    }
    
    /* Fix tables on mobile */
    body.dark-mode table {
        width: 100% !important;
        max-width: 100% !important;
        display: block !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
    
    body.dark-mode table thead {
        display: none !important;
    }
    
    body.dark-mode table tbody {
        display: block !important;
        width: 100% !important;
    }
    
    body.dark-mode table tbody tr {
        display: block !important;
        margin-bottom: 10px !important;
        padding: 12px !important;
        border: 1px solid var(--border-color) !important;
        border-radius: 8px !important;
        background: var(--bg-card) !important;
    }
    
    body.dark-mode table tbody td {
        display: block !important;
        padding: 6px 0 !important;
        border: none !important;
        text-align: left !important;
    }
    
    body.dark-mode table tbody td::before {
        content: attr(data-label) ": " !important;
        font-weight: 600 !important;
        color: var(--text-muted) !important;
        display: inline-block !important;
        margin-right: 8px !important;
    }
    
    /* Footer info */
    body.dark-mode [style*="background: #f6f7f7; border-radius: 4px"] {
        padding: 12px !important;
        font-size: 11px !important;
        line-height: 1.6 !important;
    }
    
    /* Scrollbar for overflow sections */
    body.dark-mode ::-webkit-scrollbar {
        height: 8px !important;
    }
    
    body.dark-mode ::-webkit-scrollbar-thumb {
        background: var(--border-color) !important;
        border-radius: 4px !important;
    }
}

/* ==================== */
/* STABLECOIN SELECTOR - DARK MODE */
/* ==================== */

/* CSS Variables for stablecoin selector */
:root {
    --cpt-stablecoin-bg: #ffffff;
    --cpt-stablecoin-selected-bg: #f0fdf4;
    --cpt-stablecoin-text: #1f2937;
    --cpt-stablecoin-desc: #6b7280;
    --cpt-border-color: #e5e7eb;
    --cpt-card-bg: #ffffff;
}

.dark-mode {
    --cpt-stablecoin-bg: #374151;
    --cpt-stablecoin-selected-bg: #064e3b;
    --cpt-stablecoin-text: #f3f4f6;
    --cpt-stablecoin-desc: #9ca3af;
    --cpt-border-color: #4b5563;
    --cpt-card-bg: #1f2937;
}

/* Stablecoin option styling */
.dark-mode .stablecoin-option {
    background: var(--cpt-card-bg) !important;
    border-color: var(--cpt-border-color) !important;
}

.dark-mode .stablecoin-option.selected {
    background: var(--cpt-stablecoin-selected-bg) !important;
    border-color: #10b981 !important;
}

.dark-mode .stablecoin-option .stablecoin-name {
    color: var(--cpt-stablecoin-text) !important;
}

.dark-mode .stablecoin-option .stablecoin-desc {
    color: var(--cpt-stablecoin-desc) !important;
}

/* Radio circle in dark mode */
.dark-mode .stablecoin-option .radio-circle {
    border-color: var(--cpt-border-color) !important;
}

.dark-mode .stablecoin-option.selected .radio-circle {
    border-color: #10b981 !important;
}

.dark-mode .stablecoin-option .radio-dot {
    background: var(--cpt-border-color) !important;
}

.dark-mode .stablecoin-option.selected .radio-dot {
    background: #10b981 !important;
}