/* Master Stylesheet for Personal Finance App */

:root {
    --bg-body: #f8f9fa;
    --bg-card: #ffffff;
    --text-main: #212529;
    --text-muted: #6c757d;
    --border-color: rgba(0, 0, 0, 0.1);
    --border-light: #f0f0f0;
    --shadow-color: rgba(0, 0, 0, 0.05);
}

[data-bs-theme="dark"] {
    --bg-body: #212529;
    --bg-card: #2c3034;
    --text-main: #f8f9fa;
    --text-muted: #adb5bd;
    --border-color: rgba(255, 255, 255, 0.1);
    --border-light: #373b3e;
    --shadow-color: rgba(0, 0, 0, 0.25);
}

/* Global Styles */
body {
    background-color: var(--bg-body);
    color: var(--text-main);
}

/* Utility Classes */
.cursor-pointer {
    cursor: pointer;
}

/* Dashboard Styles */
.spark-dot:hover {
    opacity: 1 !important;
    r: 5;
}

/* Horizontal Scroll for Widgets */
.widget-scroll-container {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 1rem;
    gap: 1rem;
    -webkit-overflow-scrolling: touch;
    /* Smooth scroll on iOS */
}

.widget-card-wrapper {
    flex: 0 0 auto;
    width: 85%;
    /* Mobile: 1 card + peek */
}

@media (min-width: 768px) {
    .widget-card-wrapper {
        width: 19%;
        /* Desktop: ~5 cards */
    }
}

/* Transactions Styles - Responsive Table */
@media (max-width: 768px) {
    .table-responsive table {
        background: transparent !important;
    }

    .table-responsive thead {
        display: none;
    }

    .table-responsive tbody tr {
        display: block;
        margin-bottom: 0.5rem;
        background: var(--bg-card) !important;
        /* Override striped rows */
        border: 1px solid var(--border-color);
        border-radius: 0.5rem;
        box-shadow: 0 1px 2px var(--shadow-color);
        padding: 0.5rem;
        /* Compact padding */
    }

    .table-responsive td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        border: none;
        padding: 0.25rem 0;
        /* Compact row spacing */
        border-bottom: 1px solid var(--border-light);
    }

    .table-responsive td:last-child {
        border-bottom: none;
        justify-content: flex-end;
        padding-top: 0.5rem;
    }

    .table-responsive td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        font-size: 0.8rem;
        margin-right: 1rem;
    }

    /* Hide empty labels if needed */
    .table-responsive td[data-label="Actions"]::before {
        display: none;
    }
}

/* Portfolio Styles - Responsive Table (Shared with Transactions but kept for clarity/specificity if needed) */
/* Note: The styles are identical to transactions, so we can rely on the shared media query above. */
/* If specific portfolio overrides are needed, add them here. */

/* Planning Styles - Responsive Table */
@media (max-width: 768px) {

    /* Reuse shared table styles where possible, add specific overrides */
    .table-responsive td form {
        width: 100%;
        justify-content: flex-end;
    }

    .table-responsive td form input {
        width: auto !important;
        max-width: 120px;
    }

    /* Hide tfoot on mobile as it doesn't fit the card layout well */
    .table-responsive tfoot {
        display: none;
    }
}

/* Accounts Styles - Responsive Table */
@media (max-width: 768px) {

    /* Force table to not be like tables anymore */
    #accountsTable,
    #accountsTable tbody,
    #accountsTable th,
    #accountsTable td,
    #accountsTable tr {
        display: block;
    }

    /* Hide table headers (but not display: none;, for accessibility) */
    #accountsTable thead {
        display: none;
    }

    #accountsTable tr {
        margin-bottom: 1rem;
        border: 1px solid var(--border-color);
        border-radius: 0.5rem;
        background-color: var(--bg-card);
        box-shadow: 0 0.125rem 0.25rem var(--shadow-color);
    }

    #accountsTable td {
        /* Behave  like a "row" */
        border: none;
        border-bottom: 1px solid var(--border-light);
        position: relative;
        padding-left: 50%;
        text-align: right;
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }

    #accountsTable td:last-child {
        border-bottom: 0;
    }

    #accountsTable td:before {
        /* Now like a table header */
        position: absolute;
        /* Top/left values mimic padding */
        top: 0.5rem;
        left: 1rem;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: bold;
        content: attr(data-label);
        color: var(--text-muted);
    }

    /* Adjust actions column */
    #accountsTable td:last-child {
        text-align: center;
        padding-left: 0;
    }

    #accountsTable td:last-child:before {
        display: none;
    }
}