/* Premium Wallet UI - Light & Dark Mode Support */
:root {
    /* Light Mode Variables */
    --pw-bg-body: #f3f4f6;
    --pw-bg-card: #ffffff;
    --pw-text-primary: #111827;
    --pw-text-secondary: #6b7280;
    --pw-border-color: #e5e7eb;
    --pw-primary: #2563eb;
    --pw-success: #10b981;
    --pw-danger: #ef4444;
    --pw-warning: #f59e0b;
    --pw-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --pw-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --pw-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --pw-radius: 12px;
    --pw-radius-lg: 16px;
    --pw-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark-mode {
    /* Dark Mode Variables - Overrides */
    --pw-bg-body: #0f172a;
    --pw-bg-card: #1e293b;
    --pw-text-primary: #f3f4f6;
    --pw-text-secondary: #94a3b8;
    --pw-border-color: #334155;
    --pw-primary: #60a5fa;
    --pw-success: #34d399;
    --pw-danger: #f87171;
    --pw-warning: #fbbf24;
    --pw-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --pw-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --pw-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

/* Global Page Styles */
body {
    background-color: var(--pw-bg-body) !important;
    color: var(--pw-text-primary) !important;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--pw-text-primary);
    font-weight: 700;
    letter-spacing: -0.025em;
}

/* --- Premium Card Styling --- */
.card {
    background-color: var(--pw-bg-card) !important;
    border: 1px solid var(--pw-border-color) !important;
    border-radius: var(--pw-radius) !important;
    box-shadow: var(--pw-shadow-md);
    transition: var(--pw-transition);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--pw-shadow-lg);
}

.card-header {
    background-color: transparent !important;
    border-bottom: 1px solid var(--pw-border-color) !important;
    padding: 1rem 1.25rem !important;
    font-weight: 600;
    color: var(--pw-text-primary) !important;
}

.card-body {
    padding: 1.25rem !important;
    color: var(--pw-text-secondary);
}

.card-text {
    color: var(--pw-text-secondary) !important;
}

/* Specific Setting Boxes - Tweaks */
.setting-box1, .setting-box2, .setting-box3, .setting-box4 {
    border-top-width: 0 !important; /* Remove old colored top border */
    position: relative;
    overflow: hidden;
}

/* Add colored accent bar via pseudo-element for cleaner look */
.setting-box1::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 4px; background: #f59e0b; }
.setting-box2::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 4px; background: #0d6efd; }
.setting-box3::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 4px; background: #0dcaf0; }
.setting-box4::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 4px; background: #20c997; }


/* --- Summary Box Styling --- */
#summaryBox {
    background: linear-gradient(145deg, var(--pw-bg-card), var(--pw-bg-body));
    border: 1px solid var(--pw-border-color);
    border-radius: var(--pw-radius-lg) !important;
    box-shadow: var(--pw-shadow-lg) !important;
    padding: 2rem !important;
    margin-bottom: 2rem !important;
}

#summaryContent h6 {
    color: var(--pw-text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

#summaryContent .lead {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(to right, var(--pw-primary), var(--pw-success));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent; /* Gradient text effect */
}
/* Fallback for dark mode text if gradient is hard to read */
.dark-mode #summaryContent .lead {
    background: linear-gradient(to right, #60a5fa, #34d399); 
    -webkit-background-clip: text;
    background-clip: text;
}


/* --- Table Styling --- */
.table-responsive {
    border-radius: var(--pw-radius);
    box-shadow: var(--pw-shadow-md);
    background-color: var(--pw-bg-card);
    border: 1px solid var(--pw-border-color);
    overflow: hidden;
}

table.dataTable, table.table {
    margin-bottom: 0 !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    width: 100% !important;
    color: var(--pw-text-primary) !important;
}

/* Header Styling - Uniform Colors */
table.dataTable thead th,
.table thead th {
  background-color: var(--pw-bg-body) !important; /* Uniform background for all headers */
  color: var(--pw-text-secondary) !important;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem; /* Slightly smaller for premium feel */
  letter-spacing: 0.05em;
  padding: 0.75rem 0.5rem !important; /* Compact header padding */
  border-bottom: 1px solid var(--pw-border-color) !important;
  vertical-align: middle;
  white-space: nowrap; /* Prevent wrapping for cleaner headers */
}

/* Fix for specific columns having different backgrounds in legacy CSS */
/* We need high specificity to override .dark-mode .table .col-name from portfolio.css */
body.dark-mode table.dataTable thead th,
body.dark-mode .table thead th {
    background-color: #0c0c0c !important; /* Deep black for premium contrast */
    color: var(--pw-text-secondary) !important;
    border-bottom: 1px solid #333 !important;
}

/* Ensure ALL specific columns get this background in dark mode */
body.dark-mode table.dataTable thead th.col-actions,
body.dark-mode table.dataTable thead th.col-net-amount,
body.dark-mode table.dataTable thead th.col-cost,
body.dark-mode table.dataTable thead th.col-avg,
body.dark-mode table.dataTable thead th.col-live,
body.dark-mode table.dataTable thead th.col-unrealized,
body.dark-mode table.dataTable thead th.col-earned,
body.dark-mode table.dataTable thead th.col-target {
    background-color: #0c0c0c !important; 
    color: var(--pw-text-secondary) !important;
}

/* Light mode defaults for these columns */
table.dataTable thead th.col-actions, 
table.dataTable thead th.col-net-amount,
table.dataTable thead th.col-cost,
table.dataTable thead th.col-avg,
table.dataTable thead th.col-live,
table.dataTable thead th.col-unrealized,
table.dataTable thead th.col-earned,
table.dataTable thead th.col-target {
    background-color: var(--pw-bg-body) !important;
    color: var(--pw-text-secondary) !important;
}

/* Body Cell Styling - Compact Rows (Matching Header Size) */
table.dataTable tbody td, .table tbody td {
    padding: 0.75rem 0.5rem !important; /* Matched to header padding */
    border-bottom: 1px solid var(--pw-border-color) !important;
    vertical-align: middle;
    background-color: var(--pw-bg-card) !important;
    color: var(--pw-text-primary);
    font-size: 0.9rem;
    font-weight: 500;
}

/* Footer (totals row) — mirror body styling so it stays readable in dark mode */
table.dataTable tfoot td, .table tfoot td {
    padding: 0.75rem 0.5rem !important;
    border-top: 1px solid var(--pw-border-color) !important;
    vertical-align: middle;
    background-color: var(--pw-bg-card) !important;
    color: var(--pw-text-primary) !important;
    font-size: 0.9rem;
}

/* Allow Asset Name to have different weight/color if needed, but keeping simple for now */
table.dataTable tbody td:first-child, .table tbody td:first-child {
    font-weight: 600;
    color: var(--pw-text-primary);
}

/* Hover Rows */
table.dataTable tbody tr:hover td, .table-hover tbody tr:hover td {
    background-color: var(--pw-bg-body) !important; /* Contrast on hover */
    transition: background-color 0.2s;
}

/* Remove last border */
table.dataTable tbody tr:last-child td {
    border-bottom: none !important;
}

/* --- Table Buttons (Buy/Sell) --- */
table .btn-sm, .table .btn-sm {
    padding: 0.25rem 0.5rem !important; /* Reduced padding */
    font-size: 0.75rem !important; /* Smaller font text */
    line-height: 1.2;
    border-radius: 6px !important;
    min-width: 50px; /* Ensure buttons aren't too squashed */
}

/* --- Column Colors --- */
.text-profit { color: var(--pw-success) !important; font-weight: 600; }
.text-loss { color: var(--pw-danger) !important; font-weight: 600; }
.text-muted { color: var(--pw-text-secondary) !important; }

/* --- Form Elements (Search/Select) --- */
.dataTables_filter input, .dataTables_length select {
    background-color: var(--pw-bg-body) !important;
    border: 1px solid var(--pw-border-color) !important;
    color: var(--pw-text-primary) !important;
    border-radius: 8px !important;
    padding: 0.5rem 1rem !important;
}

/* --- Buttons --- */
.btn {
    border-radius: 8px !important;
    padding: 0.5rem 1rem !important;
    font-weight: 600 !important;
    transition: var(--pw-transition) !important;
    box-shadow: var(--pw-shadow-sm);
    border: none !important;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--pw-shadow-md);
    opacity: 0.9;
}

.btn-primary { background-color: var(--pw-primary) !important; color: white !important; }
.btn-success { background-color: var(--pw-success) !important; color: white !important; }
.btn-danger { background-color: var(--pw-danger) !important; color: white !important; }
.btn-secondary, .btn-outline-secondary { 
    background-color: var(--pw-bg-body) !important; 
    color: var(--pw-text-secondary) !important; 
    border: 1px solid var(--pw-border-color) !important;
}
.btn-secondary:hover { background-color: var(--pw-border-color) !important; }

/* Add/Reset Button Gradient Enhancements */
.btn-add-crypto {
    background: linear-gradient(135deg, var(--pw-success), #059669) !important;
}
.btn-reset-portfolio {
    background: linear-gradient(135deg, var(--pw-danger), #dc2626) !important;
}

/* --- Chart Container --- */
.chart-container {
    background-color: var(--pw-bg-card);
    border-radius: var(--pw-radius);
    padding: 1.5rem;
    box-shadow: var(--pw-shadow-md);
    border: 1px solid var(--pw-border-color);
    margin-bottom: 2rem !important;
}

/* Period Select */
#periodSelect {
    background-color: var(--pw-bg-card) !important;
    border-color: var(--pw-border-color) !important;
    color: var(--pw-text-primary) !important;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {
    #summaryContent .d-flex {
        flex-direction: column;
        align-items: center;
    }
    #summaryContent div {
        margin-bottom: 1rem;
        width: 100%;
        border-bottom: 1px solid var(--pw-border-color);
        padding-bottom: 0.5rem;
    }
    #summaryContent div:last-child {
        border-bottom: none;
    }
    
    .chart-container {
        padding: 1rem;
    }

    /* Column Toggles Overrides for Mobile */
    /* When table has class 'show-col-X', properly display the hidden column */
    table.show-col-net-amount .col-net-amount,
    table.show-col-cost .col-cost,
    table.show-col-avg .col-avg,
    table.show-col-live .col-live,
    table.show-col-unrealized .col-unrealized,
    table.show-col-earned .col-earned,
    table.show-col-target .col-target {
        display: table-cell !important;
    }
}
