/* Mobile-first responsive design with dark mode support */

/* Base styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    min-height: 100vh;
}

/* Dark mode specific styles */
[data-bs-theme="dark"] {
    background-color: #0d1117;
}

[data-bs-theme="dark"] body {
    background-color: #0d1117;
    color: #c9d1d9;
}

/* Header styles */
header {
    padding: 0.75rem;
    margin: -0.5rem -0.75rem 1rem;
    border-bottom: 1px solid rgba(48, 54, 61, 0.5);
}

[data-bs-theme="dark"] header {
    background-color: #161b22;
    border-bottom: 1px solid #30363d;
}

/* Balance cards */
.balance-card {
    transition: transform 0.2s, border-color 0.2s;
    cursor: pointer;
    height: 100%;
    min-height: 90px;
}

[data-bs-theme="dark"] .balance-card {
    background-color: #161b22;
}

.balance-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    filter: brightness(1.1);
}

[data-bs-theme="dark"] .balance-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    filter: brightness(1.2);
}

.balance-card .card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #495057;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

[data-bs-theme="dark"] .balance-card .card-title {
    color: #8b949e;
}

.balance-card .h5 {
    font-size: 1.125rem;
    font-weight: 700;
}

/* Table improvements for mobile */
.table {
    font-size: 0.875rem;
}

[data-bs-theme="dark"] .table {
    --bs-table-bg: #0d1117;
    --bs-table-color: #c9d1d9;
    --bs-table-border-color: #30363d;
    --bs-table-striped-bg: #161b22;
    --bs-table-hover-bg: #1c2128;
}

.table th {
    font-weight: 600;
    border-top: none;
    padding: 0.5rem 0.25rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #6c757d;
}

[data-bs-theme="dark"] .table th {
    color: #8b949e;
    border-color: #30363d;
}

.table td {
    padding: 0.5rem 0.25rem;
    vertical-align: middle;
}

[data-bs-theme="dark"] .table td {
    border-color: #30363d;
}

/* Modal improvements */
.modal-content {
    border: none;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

[data-bs-theme="dark"] .modal-content {
    background-color: #161b22;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
}

.modal-header {
    border-bottom: 1px solid #e9ecef;
    padding: 1rem;
}

[data-bs-theme="dark"] .modal-header {
    border-bottom: 1px solid #30363d;
}

.modal-body {
    padding: 1rem;
}

.form-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.25rem;
}

[data-bs-theme="dark"] .form-label {
    color: #c9d1d9;
}

.form-control, .form-select {
    font-size: 0.875rem;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #0d1117;
    border-color: #30363d;
    color: #c9d1d9;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: #0d1117;
    border-color: #58a6ff;
    color: #c9d1d9;
}

/* Button styles */
.btn-sm {
    font-size: 0.875rem;
    padding: 0.375rem 0.75rem;
}

[data-bs-theme="dark"] .btn-primary {
    --bs-btn-bg: #238636;
    --bs-btn-border-color: #238636;
    --bs-btn-hover-bg: #2ea043;
    --bs-btn-hover-border-color: #2ea043;
}

[data-bs-theme="dark"] .btn-outline-secondary {
    --bs-btn-color: #8b949e;
    --bs-btn-border-color: #30363d;
    --bs-btn-hover-bg: #30363d;
    --bs-btn-hover-border-color: #30363d;
}

.btn-link {
    font-size: 0.75rem;
    text-decoration: none;
}

[data-bs-theme="dark"] .btn-link {
    color: #58a6ff;
}

.btn-link:hover {
    text-decoration: underline;
}

/* Status badges */
.text-danger {
    color: #dc3545 !important;
}

[data-bs-theme="dark"] .text-danger {
    color: #f85149 !important;
}

.text-success {
    color: #28a745 !important;
}

[data-bs-theme="dark"] .text-success {
    color: #3fb950 !important;
}

.text-warning {
    color: #ffc107 !important;
}

[data-bs-theme="dark"] .text-warning {
    color: #d29922 !important;
}

[data-bs-theme="dark"] .text-muted {
    color: #8b949e !important;
}

/* Tab Navigation Styles */
.nav-pills .nav-link {
    color: #495057;
    border-radius: 0.375rem;
}

[data-bs-theme="dark"] .nav-pills .nav-link {
    color: #8b949e;
}

.nav-pills .nav-link.active {
    background-color: #238636;
    border-color: #238636;
}

[data-bs-theme="dark"] .nav-pills .nav-link.active {
    background-color: #0d1117;
    border: 1px solid #202834;
    color: white;
}

.nav-pills .nav-link:hover {
    background-color: rgba(35, 134, 54, 0.1);
    color: #0d1117;
}

[data-bs-theme="dark"] .nav-pills .nav-link:hover {
    background-color: #1c2431;
    color: white;
}

/* Chart Container Styles */
.chart-container {
    position: relative;
    height: 400px;
    width: 100%;
    padding: 1rem;
}

#charts-tab {
    min-height: 450px;
}

/* Responsive chart adjustments */
@media (max-width: 576px) {
    .chart-container {
        height: 300px;
        padding: 0.5rem;
    }

    .nav-pills .nav-link {
        font-size: 0.875rem;
        padding: 0.5rem 1rem;
    }
}

/* Mobile table row styles */
.mobile-row-details {
    border-top: none !important;
}

.mobile-row-details td {
    padding-top: 0.25rem !important;
    padding-bottom: 0.75rem !important;
    border-top: none !important;
}

[data-bs-theme="dark"] .mobile-row-details td {
    border-top: none !important;
}


/* Responsive adjustments */
@media (max-width: 576px) {
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .table {
        font-size: 0.75rem;
    }

    .table th,
    .table td {
        padding: 0.375rem 0.125rem;
    }

    /* Mobile-specific table styling - remove internal borders */
    .mobile-row td {
        border-bottom: none !important;
        padding-bottom: 0.125rem !important;
    }

    .mobile-row-details td {
        border-bottom: 1px solid #dee2e6 !important;
        margin-bottom: 0.5rem !important;
    }

    [data-bs-theme="dark"] .mobile-row-details td {
        border-bottom: 1px solid #30363d !important;
    }

    .balance-card .h5 {
        font-size: 1rem;
    }

    .btn-sm {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
}

@media (min-width: 768px) {
    .container-fluid {
        max-width: 960px;
        margin: 0 auto;
    }

    header {
        padding: 1rem;
        margin: -0.5rem -1rem 1.5rem;
    }

    .balance-card .card-body {
        padding: 1rem !important;
    }

    .balance-card .h5 {
        font-size: 1.5rem;
    }

    .table {
        font-size: 0.9375rem;
    }

    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
    }
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Custom scrollbar for tables */
.table-responsive {
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

.table-responsive::-webkit-scrollbar {
    width: 6px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
}

[data-bs-theme="dark"] .table-responsive::-webkit-scrollbar-track {
    background: #161b22;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

[data-bs-theme="dark"] .table-responsive::-webkit-scrollbar-thumb {
    background: #30363d;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #555;
}

[data-bs-theme="dark"] .table-responsive::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}

/* Amount display styles */
.original-amount {
    opacity: 0.4;
    font-size: 0.9em;
}

[data-bs-theme="dark"] .original-amount {
    opacity: 0.4;
}

/* Print styles */
@media print {
    .btn,
    .modal {
        display: none !important;
    }

    .balance-card {
        break-inside: avoid;
    }
}