/* --- TABLE VIEW COMPONENT --- */
/* Custom Table Design adapted to the Coach Dom Design System */

.tv-table-wrapper {
    background-color: transparent;
    border-radius: var(--ze-radius-sm);
    border: var(--ze-border-default);
    padding: var(--ze-space-lg);
    box-shadow: none;
    overflow: visible;
}

/* Toolbar Spacing */
.tv-table-toolbar {
    display: flex;
    gap: var(--ze-space-sm);
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: var(--ze-space-lg);
}

/* Table Styles */
.tv-table-container {
    width: 100%;
    overflow-x: auto;
}

.tv-table-container table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--ze-font-body-md-family);
    font-size: var(--ze-font-body-sm-size);
}

.tv-table-container th {
    text-align: left;
    padding: var(--ze-space-md);
    border-bottom: 2px solid var(--ze-color-primary);
    color: var(--ze-color-on-surface);
    font-family: var(--ze-font-label-md-family);
    font-weight: var(--ze-font-label-md-weight);
    font-size: var(--ze-font-label-sm-size);
    text-transform: uppercase;
    letter-spacing: var(--ze-font-label-md-letter-spacing);
    white-space: nowrap;
}

.tv-table-container td {
    padding: var(--ze-space-md);
    border-bottom: 1px solid var(--ze-color-outline-variant);
    color: var(--ze-color-on-surface);
    vertical-align: middle;
}

.tv-table-container tbody tr {
    transition: background-color 0.2s ease;
}

.tv-table-container tbody tr:hover {
    background-color: var(--ze-color-surface-container);
}

.tv-table-container a {
    color: var(--ze-color-primary);
    text-decoration: underline;
    font-weight: 500;
    transition: color 0.2s ease;
}

.tv-table-container a:hover {
    color: var(--ze-color-on-surface-variant);
    text-decoration: none;
}

/* Pagination */
.tv-pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: var(--ze-space-lg);
    padding-top: var(--ze-space-md);
    border-top: 1px solid var(--ze-color-outline-variant);
    font-family: var(--ze-font-body-md-family);
}

.tv-pagination-dots {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    color: var(--ze-color-on-surface-variant);
    font-size: var(--ze-font-body-sm-size);
    cursor: default;
}

.tv-pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    margin: 0 4px;
    border-radius: var(--ze-radius-sm);
    background-color: transparent;
    border: 1px solid transparent;
    color: var(--ze-color-on-surface);
    font-size: var(--ze-font-body-sm-size);
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

.tv-pagination-link:hover {
    border-color: var(--ze-color-outline-variant);
    background-color: var(--ze-color-surface-container);
}

.tv-pagination-link.is-current {
    border: 1px solid var(--ze-color-on-surface);
    background-color: transparent;
    color: var(--ze-color-on-surface);
}

.tv-pagination-info {
    font-size: var(--ze-font-body-sm-size);
    color: var(--ze-color-on-surface-variant);
}

/* --- INLINE EDITING --- */
.tv-editable-cell {
    position: relative;
    cursor: pointer;
    border: 1px solid transparent;
    padding: 4px 8px; /* Reset padding to standard */
    margin: -5px -9px;
    border-radius: var(--ze-radius-sm);
    transition: all 0.2s ease;
    min-height: 1.2em;
    display: inline-block;
    width: calc(100% + 10px);
    white-space: nowrap; /* Keep icon on same line if possible */
}

.tv-editable-cell::after {
    content: "\f303"; /* FontAwesome Pencil */
    font-family: "Font Awesome 5 Free", "FontAwesome";
    font-weight: 900;
    margin-left: 6px; /* Minimal distance behind text */
    font-size: 10px;
    color: var(--ze-color-primary);
    opacity: 0.3;
    transition: all 0.2s ease;
    pointer-events: none;
    display: inline-block;
    vertical-align: baseline;
}

.tv-editable-cell:hover::after {
    opacity: 1;
    color: var(--ze-color-on-surface);
    transform: translateY(-1px); /* Subtle lift on hover */
}

.tv-editable-cell:focus::after {
    display: none; /* Important: hide during edit so it doesn't look like part of content */
}

.tv-editable-cell:hover {
    background-color: var(--ze-color-surface);
    border: 1px dashed var(--ze-color-outline-variant);
}

.tv-editable-cell:focus {
    outline: none;
    background-color: var(--ze-color-surface);
    border: 1px solid var(--ze-color-on-surface);
    box-shadow: 0 2px 8px rgba(20, 19, 15, 0.1);
    z-index: 10;
    cursor: text;
}

.tv-editable-cell.is-saving {
    opacity: 0.6;
    cursor: wait;
    background-color: var(--ze-color-surface-container);
}

.tv-editable-cell.save-success {
    background-color: var(--ze-color-secondary-container) !important;
    border-color: var(--ze-color-secondary) !important;
}

.tv-editable-cell.save-error {
    background-color: var(--ze-color-error-container) !important;
    border-color: var(--ze-color-error) !important;
}

/* --- TRANSACTION TIMELINE VIEW --- */
.timeline-view-container {
    padding: 0 !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* Header Summary Bar */
.ze-transaction-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--ze-space-md) var(--ze-space-lg);
    background-color: transparent;
    border-bottom: var(--ze-border-default);
    margin-bottom: var(--ze-space-md);
    position: relative;
}

.ze-transaction-header-date {
    font-family: var(--ze-font-body-md-family);
    font-size: var(--ze-font-body-sm-size);
    color: var(--ze-color-on-surface-variant);
    font-weight: 500;
}

.ze-transaction-header-sum {
    font-family: var(--ze-font-label-md-family);
    font-size: 20px;
    font-weight: 700;
    position: relative;
    padding-bottom: 6px;
}

/* Accent line under the total sum */
.ze-transaction-header-sum::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 5%;
    width: 90%;
    height: 3px;
    border-radius: 2px;
}

.ze-transaction-header-sum.sum-positive {
    color: #00bfa5;
}
.ze-transaction-header-sum.sum-positive::after {
    background-color: #00bfa5;
}

.ze-transaction-header-sum.sum-negative {
    color: var(--ze-color-on-surface);
}
.ze-transaction-header-sum.sum-negative::after {
    background-color: var(--ze-color-outline-variant);
}

.ze-transaction-header-action .ze-header-today-btn {
    font-family: var(--ze-font-body-md-family);
    font-size: var(--ze-font-body-sm-size);
    color: #00bfa5;
    text-decoration: none;
    font-weight: 600;
    transition: opacity 0.2s ease;
}

.ze-transaction-header-action .ze-header-today-btn:hover {
    opacity: 0.8;
}

/* Timeline Layout */
.ze-transaction-timeline {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.ze-transaction-group {
    margin-bottom: 2px;
}

.ze-transaction-group-header {
    background-color: #161616;
    color: #8e8e93;
    font-family: var(--ze-font-body-md-family);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 16px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Dark theme integration */
[data-theme="light"] .ze-transaction-group-header {
    background-color: #f2f2f7;
    color: #8e8e93;
}

.ze-transaction-group-items {
    display: flex;
    flex-direction: column;
}

.ze-transaction-item-link {
    text-decoration: none !important;
    color: inherit !important;
    display: block;
}

.ze-transaction-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background-color: transparent;
    transition: background-color 0.2s ease;
}

[data-theme="light"] .ze-transaction-item {
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.ze-transaction-item:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

[data-theme="light"] .ze-transaction-item:hover {
    background-color: rgba(0, 0, 0, 0.02);
}

/* Logo and Icons */
.ze-transaction-logo-wrapper,
.ze-transaction-icon-wrapper {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
    flex-shrink: 0;
    overflow: hidden;
}

.ze-transaction-logo-wrapper {
    background-color: #ffffff;
    padding: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.ze-transaction-logo {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.ze-transaction-icon-wrapper {
    background-color: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] .ze-transaction-icon-wrapper {
    background-color: rgba(0, 0, 0, 0.05);
}

.ze-transaction-icon {
    font-size: 22px;
    color: var(--ze-color-on-surface-variant);
}

/* Content Details */
.ze-transaction-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevents overflow of long text */
}

.ze-transaction-title {
    font-family: var(--ze-font-body-md-family);
    font-size: 15px;
    font-weight: 500;
    color: var(--ze-color-on-surface);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ze-transaction-subtitle {
    display: flex;
    align-items: center;
    margin-top: 4px;
}

.ze-category-name {
    font-family: var(--ze-font-body-md-family);
    font-size: 13px;
    color: #8e8e93;
}

/* Inline choice badge mockup */
.ze-category-select-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    background-color: rgba(0, 150, 136, 0.15);
    color: #00bfa5;
    font-family: var(--ze-font-body-md-family);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
    transition: background-color 0.2s ease;
}

.ze-category-select-badge:hover {
    background-color: rgba(0, 150, 136, 0.25);
}

.ze-badge-icon {
    font-size: 12px !important;
}

.ze-badge-close {
    font-size: 12px;
    margin-left: 2px;
    color: #00bfa5;
    font-weight: 400;
}

/* Transaction Amount Indicators */
.ze-transaction-amount {
    font-family: var(--ze-font-label-md-family);
    font-size: 16px;
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
    margin-left: 16px;
}

.ze-transaction-amount.amount-positive {
    color: #34c759; /* Apple Green for positive amounts */
}

.ze-transaction-amount.amount-negative {
    color: var(--ze-color-on-surface); /* Apple standard color for expenses in dark mode */
}

.ze-transaction-amount.amount-neutral {
    color: var(--ze-color-on-surface-variant);
}

/* Mobile Responsiveness Rules */
@media (max-width: 768px) {
    .ze-transaction-header {
        padding: var(--ze-space-sm) var(--ze-space-md);
    }
    
    .ze-transaction-header-sum {
        font-size: 18px;
    }
    
    .ze-transaction-item {
        padding: 10px 12px;
    }
    
    .ze-transaction-logo-wrapper,
    .ze-transaction-icon-wrapper {
        width: 36px;
        height: 36px;
        margin-right: 12px;
    }
    
    .ze-transaction-title {
        font-size: 14px;
    }
    
    .ze-category-name,
    .ze-category-select-badge {
        font-size: 12px;
    }
    
    .ze-transaction-amount {
        font-size: 15px;
        margin-left: 12px;
    }
}
