/* ==========================================================================
   Transaction Table Styles - WordPress Plugin Style
   ========================================================================== */

/* ==========================================================================
   Transaction Tabs
   ========================================================================== */
.transaction-tabs {
    display: flex;
    gap: 0.25em;
    margin-bottom: 1.5em;
    border-bottom: 2px solid var(--scs-border-gray);
    overflow-x: auto;
}

.transaction-tab {
    padding: 0.5em 1.5em;
    background-color: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--scs-gray);
    white-space: nowrap;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.transaction-tab:hover {
    color: var(--scs-everest-green);
}

.transaction-tab.active {
    color: var(--scs-everest-green);
    border-bottom-color: var(--scs-everest-green);
}

/* Tab required indicators (red text for tabs with required fields) */
.transaction-tab[style*="color: #dc2626"] {
    font-weight: 600;
}

/* ==========================================================================
   Transaction Section - WordPress Style
   ========================================================================== */
.transaction-section {
    margin-bottom: 2em;
    background: #f9f7f4;
    border: 1px solid var(--scs-hakone-gold);
    border-radius: 6px;
    padding: 1.5em;
}

.transaction-section h4,
.transaction-section-title {
    color: var(--scs-everest-green);
    border-bottom: 2px solid var(--scs-hakone-gold);
    padding-bottom: 0.5em;
    margin-bottom: 1em;
    font-size: 1.125rem;
    font-weight: 600;
}

.transaction-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1em;
}

.transaction-section-description {
    font-size: 0.9375rem;
    color: var(--scs-gray);
    margin-bottom: 1em;
    padding: 0.5em 1em;
    background-color: var(--scs-light-gray);
    border-radius: 4px;
    border-left: 3px solid var(--scs-hakone-gold);
}

/* ==========================================================================
   Transaction List / Table Container
   ========================================================================== */
.transaction-list {
    margin-bottom: 1.5em;
    overflow-x: auto;
    width: 100%;
}

.transaction-table-container {
    overflow-x: auto;
    border: 1px solid var(--scs-border-gray);
    border-radius: 6px;
    background-color: var(--scs-white);
}

/* ==========================================================================
   Transaction Table - WordPress Style
   ========================================================================== */
.transaction-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    min-width: 600px;
    display: table !important;
}

.transaction-table thead {
    display: table-header-group !important;
}

.transaction-table tbody {
    display: table-row-group !important;
}

.transaction-table tfoot {
    display: table-footer-group !important;
}

.transaction-table tr {
    display: table-row !important;
}

.transaction-table th,
.transaction-table td {
    display: table-cell !important;
    vertical-align: middle;
    padding: 1em;
    border: 1px solid #ddd;
}

.transaction-table th {
    background: var(--scs-everest-green);
    color: white;
    font-weight: 500;
    text-align: left;
    white-space: nowrap;
}

.transaction-table th:first-child {
    border-top-left-radius: 6px;
}

.transaction-table th:last-child {
    border-top-right-radius: 6px;
    text-align: center;
}

.transaction-table td {
    background: white;
}

.transaction-table tbody tr:hover {
    background-color: rgba(66, 79, 51, 0.02);
}

.transaction-table tbody tr:last-child td {
    border-bottom: none;
}

/* ==========================================================================
   Transaction Row Grid Layout (Alternative to Table)
   ========================================================================== */
.transaction-row-header,
.transaction-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75em;
    margin-bottom: 1em;
    align-items: center;
    padding: 0.6em;
    min-width: max-content;
}

.transaction-row-header {
    font-weight: 600;
    padding: 0.75em 0.5em;
    background: var(--scs-everest-green);
    color: #fff;
    border-radius: 4px;
    margin-bottom: 1em;
}

.transaction-row-header .column-header {
    white-space: normal;
    font-size: 13px;
    line-height: 1.3;
    word-wrap: break-word;
    hyphens: auto;
}

.transaction-row {
    padding: 0.5em;
    background: #fff;
    border-radius: 4px;
}

.column-header {
    padding: 0.4em;
    min-width: 0;
}

.transaction-cell {
    padding: 0.4em;
    position: relative;
    min-width: 0;
}

/* ==========================================================================
   Table Inputs - WordPress Style
   ========================================================================== */
.transaction-table input,
.transaction-table select {
    width: 100%;
    padding: 1em !important;
    border: 2px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    box-sizing: border-box;
}

.transaction-field {
    width: 100%;
    padding: 1em !important;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    box-sizing: border-box;
}

.transaction-field.currency-field {
    padding-left: 1.5em;
}

.transaction-field:focus {
    border-color: #0073aa;
    outline: none;
}

.transaction-field[readonly] {
    background: #f0f0f0;
    cursor: not-allowed;
}

.transaction-table input[type="date"] {
    min-width: 140px;
}

.transaction-table input[type="number"] {
    text-align: right;
    min-width: 100px;
}

.transaction-table input[type="checkbox"] {
    width: auto;
    min-width: auto;
}

/* ==========================================================================
   Calculated Fields
   ========================================================================== */
.transaction-table .calculated-field {
    background-color: var(--scs-light-gray);
    border: 1px solid var(--scs-border-gray);
    padding: 0.5rem;
    font-weight: 500;
    text-align: right;
    border-radius: 4px;
    min-width: 100px;
}

/* ==========================================================================
   Row Actions / Delete Button
   ========================================================================== */
.transaction-table .row-actions,
.transaction-table .transaction-actions {
    width: 50px;
    text-align: center;
    white-space: nowrap;
}

.row-delete-btn,
.delete-row-btn,
.transaction-table .delete-row-btn {
    padding: 0.25em 0.75em;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
    transition: background 0.2s;
}

.row-delete-btn:hover,
.delete-row-btn:hover,
.transaction-table .delete-row-btn:hover {
    background: #c82333;
}

.row-delete-btn:disabled,
.delete-row-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ==========================================================================
   Totals Row
   ========================================================================== */
.transaction-table tfoot tr {
    background-color: var(--scs-light-gray);
    font-weight: 600;
}

.transaction-table tfoot td {
    padding: 0.5em 1em;
    border-top: 2px solid var(--scs-border-gray);
    border-bottom: none;
}

.transaction-table tfoot .total-label {
    text-align: right;
    font-weight: 600;
    color: var(--scs-everest-green);
}

.transaction-table tfoot .total-value {
    text-align: right;
    font-weight: 600;
    color: var(--scs-everest-green);
}

/* ==========================================================================
   Add Row Button - WordPress Style
   ========================================================================== */
.add-row-container {
    margin-top: 1em;
}

.add-row-btn,
.add-transaction-btn {
    padding: 0.75em 1.5em;
    background: var(--scs-everest-green);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
    transition: background-color 0.2s;
}

.add-row-btn:hover,
.add-transaction-btn:hover {
    background: #36402a;
}

.add-row-btn svg {
    width: 16px;
    height: 16px;
}

/* ==========================================================================
   Balance Check Section
   ========================================================================== */
.balance-check-container {
    margin-top: 2em;
    padding: 1.5em;
    background-color: var(--scs-light-gray);
    border-radius: 6px;
    border: 1px solid var(--scs-border-gray);
}

.balance-check-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--scs-everest-green);
    margin-bottom: 1em;
}

.balance-check-formula {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5em;
    padding: 1em;
    background-color: var(--scs-white);
    border: 1px solid var(--scs-border-gray);
    border-radius: 4px;
    margin-bottom: 1em;
}

.formula-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 100px;
}

.formula-label {
    font-size: 0.75rem;
    color: var(--scs-gray);
    margin-bottom: 0.25em;
}

.formula-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--scs-dark-gray);
    padding: 0.5em 1em;
    background-color: var(--scs-light-gray);
    border-radius: 4px;
    min-width: 80px;
    text-align: center;
}

.formula-operator {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--scs-gray);
    padding: 0 0.25em;
}

.balance-check-holdings {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1em;
}

.holdings-field {
    display: flex;
    flex-direction: column;
}

.holdings-field label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--scs-dark-gray);
    margin-bottom: 0.25em;
}

.holdings-field input {
    padding: 0.5rem;
    font-size: 0.9375rem;
    text-align: right;
}

/* Balance Check Status */
.balance-check-status {
    display: flex;
    align-items: center;
    gap: 0.5em;
    padding: 0.5em 1em;
    border-radius: 4px;
    margin-top: 1em;
}

.balance-check-status.valid {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--scs-success-green);
}

.balance-check-status.invalid {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--scs-red);
}

.balance-check-status .status-icon {
    font-size: 1.25rem;
}

.balance-check-status .status-text {
    font-weight: 500;
}

/* ==========================================================================
   Transaction Validation Styles - WordPress Style
   ========================================================================== */

/* Field error highlighting */
.transaction-field.field-error {
    border: 2px solid #dc2626 !important;
    background-color: #fef2f2 !important;
}

.error-message {
    color: #dc2626;
    font-size: 11px;
    display: block;
    margin-top: 2px;
    font-weight: 500;
}

/* ==========================================================================
   Floating Validate Button - WordPress Style
   ========================================================================== */
.validate-transactions-btn {
    position: fixed;
    bottom: 80px;
    right: 20px;
    z-index: 1000;
    padding: 12px 24px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    font-size: 14px;
}

.validate-transactions-btn:hover {
    background: #1d4ed8;
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.validate-transactions-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   Validation Popup Modal - WordPress Style
   ========================================================================== */
.validation-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.validation-popup {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    max-width: 700px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.validation-popup-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fef2f2;
}

.validation-popup-header.success {
    background: #f0fdf4;
}

.validation-popup-title {
    font-size: 20px;
    font-weight: 700;
    color: #dc2626;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.validation-popup-title.success {
    color: #16a34a;
}

.validation-popup-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #6b7280;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.validation-popup-close:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.validation-popup-content {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.validation-summary {
    margin-bottom: 20px;
    padding: 12px 16px;
    background: #fef2f2;
    border-left: 4px solid #dc2626;
    border-radius: 4px;
    font-size: 14px;
    color: #991b1b;
}

.validation-summary.success {
    background: #f0fdf4;
    border-left-color: #16a34a;
    color: #166534;
}

.validation-tab-group {
    margin-bottom: 24px;
}

.validation-tab-header {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e5e7eb;
}

.validation-error-item {
    padding: 12px;
    margin-bottom: 8px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.validation-error-item:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.validation-error-row {
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 4px;
}

.validation-error-field {
    font-size: 14px;
    color: #1f2937;
    font-weight: 500;
}

.validation-error-message {
    font-size: 13px;
    color: #dc2626;
    margin-top: 4px;
}

.validation-popup-footer {
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    background: #f9fafb;
}

.validation-popup-button {
    padding: 10px 20px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.validation-popup-button:hover {
    background: #1d4ed8;
}

/* Success icon and error icon styling */
.validation-icon {
    font-size: 24px;
}

/* ==========================================================================
   Error Modal - WordPress Style
   ========================================================================== */
.reflex-error-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.reflex-error-modal.show {
    opacity: 1;
    visibility: visible;
}

.reflex-error-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.reflex-error-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -48%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.reflex-error-header {
    padding: 30px 30px 20px;
    text-align: center;
    border-bottom: 1px solid #e5e7eb;
}

.reflex-error-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    background: #fee2e2;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reflex-error-icon svg {
    width: 32px;
    height: 32px;
    color: #dc2626;
}

.reflex-error-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: #1f2937;
}

.reflex-error-body {
    padding: 30px;
}

.reflex-error-message {
    font-size: 16px;
    line-height: 1.6;
    color: #4b5563;
    margin: 0 0 24px;
    text-align: center;
}

.reflex-error-suggestions {
    background: #f9fafb;
    border-left: 4px solid #3b82f6;
    padding: 16px 20px;
    margin-bottom: 24px;
    border-radius: 4px;
}

.reflex-error-suggestions h4 {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.reflex-error-suggestions ul {
    margin: 0;
    padding: 0 0 0 20px;
    list-style: disc;
}

.reflex-error-suggestions li {
    margin: 8px 0;
    font-size: 14px;
    line-height: 1.5;
    color: #6b7280;
}

.reflex-error-reference {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
}

/* ==========================================================================
   Empty State
   ========================================================================== */
.transaction-empty {
    text-align: center;
    padding: 3em;
    color: var(--scs-gray);
}

.transaction-empty-icon {
    font-size: 3rem;
    margin-bottom: 1em;
    opacity: 0.5;
}

.transaction-empty-text {
    margin-bottom: 1em;
}

/* ==========================================================================
   Column Type Specific Styles
   ========================================================================== */

/* Currency Input */
.currency-input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.currency-symbol {
    position: absolute;
    left: 8px;
    color: var(--scs-gray);
    font-weight: 500;
    z-index: 1;
}

.currency-input-container input {
    padding-left: 1.5rem;
}

/* Number Format */
input.number-format-decimal-dot,
input.number-format-currency {
    font-variant-numeric: tabular-nums;
}

input.number-format-decimal-comma {
    font-variant-numeric: tabular-nums;
}

/* Date Column */
.date-column input {
    min-width: 150px;
}

/* Select Column */
.select-column select {
    min-width: 120px;
}

/* Checkbox Column */
.checkbox-column {
    text-align: center;
}

.checkbox-column input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Ensure proper column widths */
.transaction-table td:has(input[type="date"]) {
    min-width: 140px;
}

.transaction-table td:has(input[type="number"]) {
    min-width: 120px;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */
@media (max-width: 768px) {
    .transaction-tabs {
        padding-bottom: 0.5em;
    }

    .transaction-tab {
        padding: 0.25em 1em;
        font-size: 0.875rem;
    }

    .transaction-section {
        padding: 1em;
    }

    .transaction-section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5em;
    }

    .transaction-row-header,
    .transaction-row {
        grid-template-columns: 1fr;
        gap: 0.25em;
    }

    .column-header {
        display: none;
    }

    .transaction-cell::before {
        content: attr(data-label);
        font-weight: 600;
        display: block;
        margin-bottom: 0.25em;
    }

    .balance-check-formula {
        flex-direction: column;
    }

    .formula-item {
        width: 100%;
    }

    .formula-operator {
        transform: rotate(90deg);
        padding: 0.25em 0;
    }

    .validate-transactions-btn {
        bottom: 60px;
        right: 15px;
        padding: 10px 20px;
        font-size: 13px;
    }

    .validation-popup {
        max-width: 95%;
        max-height: 90vh;
    }

    .validation-popup-header {
        padding: 16px 20px;
    }

    .validation-popup-title {
        font-size: 18px;
    }

    .validation-popup-content {
        padding: 20px;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
    .transaction-table-container {
        overflow: visible;
        border: 1px solid #000;
    }

    .transaction-table {
        min-width: auto;
    }

    .transaction-table th {
        background-color: #333 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .row-delete-btn,
    .delete-row-btn,
    .add-row-btn,
    .add-transaction-btn,
    .validate-transactions-btn {
        display: none;
    }

    .transaction-table input,
    .transaction-table select {
        border: none;
        padding: 0;
        background: transparent;
    }

    .validation-popup-overlay,
    .reflex-error-modal {
        display: none !important;
    }
}
