/* Custom styles for Hedger */

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
}

/* Compact navbar */
.navbar {
    padding: 0.25rem 1rem;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-brand {
    font-weight: 600;
    font-size: 1rem;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

.navbar-nav .nav-link {
    padding: 0.25rem 0.5rem;
}

.card {
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.table th {
    border-top: none;
    font-weight: 600;
    color: #495057;
}

.badge {
    font-size: 0.75em;
}

footer {
    margin-top: auto;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .display-4 {
        font-size: 2rem;
    }
    
    .table-responsive {
        font-size: 0.875rem;
    }
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Custom button styles */
.btn {
    border-radius: 0.375rem;
    font-weight: 500;
}

/* Form styles */
.form-control:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Transactions page styles */
.dropdown-menu {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.dropdown-menu .dropdown-header {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-form {
    min-width: 200px;
}

th .dropdown button {
    opacity: 0.5;
    transition: opacity 0.2s;
}

th:hover .dropdown button {
    opacity: 1;
}

th .dropdown button.text-primary {
    opacity: 1;
}

.table th {
    white-space: nowrap;
    vertical-align: middle;
}

.badge a {
    text-decoration: none;
}

.badge a:hover {
    opacity: 0.8;
}

.filter-form .nav-tabs {
    font-size: 0.875rem;
}

.filter-form .nav-tabs .nav-link {
    padding: 0.25rem 0.5rem;
}

.filter-form .form-check {
    padding-left: 1.5rem;
}

.filter-form .form-check-label {
    cursor: pointer;
}

.table-sm td, .table-sm th {
    padding: 0.25rem;
    font-size: 0.875rem;
}

#perPageSelect {
    width: auto !important;
    min-width: 70px;
}

.filter-dropdown-menu {
    min-width: 250px;
}

.filter-values-list {
    max-height: 200px;
    overflow-y: auto;
}

/* Column selector drag and drop */
.column-item {
    cursor: move;
    transition: background-color 0.2s;
    user-select: none;
}

.column-item:hover {
    background-color: #f8f9fa;
}

.column-item.dragging {
    opacity: 0.5;
}

/* Sticky table header - make table scrollable with fixed header */
.table-responsive {
    max-height: calc(100vh - 200px); /* Viewport height minus navbar and controls */
    min-height: 400px; /* Ensure dropdowns are fully visible even with few rows */
    overflow-y: auto;
    position: relative;
}

.table-responsive .table thead th {
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
    background-color: #f8f9fa !important;
    box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.1) !important;
}

.table tfoot td {
    position: sticky;
    bottom: 0;
    z-index: 10;
    background-color: #f8f9fa;
    box-shadow: 0 -2px 2px -1px rgba(0, 0, 0, 0.1);
}

/* Positions table - compact columns */
.table th,
.table td {
    white-space: nowrap;
    padding: 0.5rem 0.75rem;
}

/* Symbol column - fixed width for normal symbols */
.table th[data-column="symbol"],
.table td[data-column="symbol"] {
    width: 120px;
    max-width: 120px;
    white-space: normal;
}

/* Numeric columns - compact width */
.table th[data-column="quantity"],
.table td[data-column="quantity"],
.table th[data-column="current_price"],
.table td[data-column="current_price"],
.table th[data-column="avg_cost_basis"],
.table td[data-column="avg_cost_basis"],
.table th[data-column="fx_rate_to_base"],
.table td[data-column="fx_rate_to_base"] {
    width: 100px;
    text-align: right;
}

/* Value columns - slightly wider */
.table th[data-column="amount_in_position_currency"],
.table td[data-column="amount_in_position_currency"],
.table th[data-column="amount_in_base_currency"],
.table td[data-column="amount_in_base_currency"],
.table th[data-column="total_cost"],
.table td[data-column="total_cost"],
.table th[data-column="unrealized_pnl_base"],
.table td[data-column="unrealized_pnl_base"],
.table th[data-column="realized_pnl_base"],
.table td[data-column="realized_pnl_base"] {
    width: 120px;
    text-align: right;
}

/* Status and badges - minimal */
.table th[data-column="status"],
.table td[data-column="status"],
.table th[data-column="broker"],
.table td[data-column="broker"] {
    width: 80px;
    text-align: center;
}

/* Asset class - compact */
.table th[data-column="asset_class"],
.table td[data-column="asset_class"] {
    width: 80px;
}

/* Date columns - compact */
.table th[data-column="first_trade_date"],
.table td[data-column="first_trade_date"],
.table th[data-column="last_trade_date"],
.table td[data-column="last_trade_date"] {
    width: 100px;
}

/* Alternating row backgrounds */
.table tbody tr:nth-child(odd) {
    background-color: #ffffff;
}
.table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}
.table tbody tr:hover {
    background-color: #e9ecef !important;
}
/* Keep closed positions slightly darker */
.table tbody tr.table-secondary:nth-child(odd) {
    background-color: #e9ecef;
}
.table tbody tr.table-secondary:nth-child(even) {
    background-color: #dee2e6;
}

/* Sortable columns */
.sortable {
    cursor: pointer;
    user-select: none;
}
.sortable:hover {
    background-color: rgba(0,0,0,0.05);
}
