/**
 * Transaction History Table Styles for Average Price Calculator
 *
 * v1.1.0 - Major refactor for a robust, spacious, and responsive table layout.
 * Abandons fragile percentage widths in favor of auto-layout and horizontal scrolling on small screens.
 *
 * @package essentials-child
 */

/* Transaction History Container and Title */
.calc-module-container.average-price-calc-specifics .transaction-history-container {
    /* Styles for the transaction history container */
}

.calc-module-container.average-price-calc-specifics .transaction-history-title {
    color: #28ebcf;
    font-size: 24px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-bottom: 30px;
    padding-bottom: 15px;
    text-align: center;
    position: relative;
    border-bottom: none;
}

.calc-module-container.average-price-calc-specifics .transaction-history-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 90px;
    height: 3px;
    background: linear-gradient(90deg, transparent, #28ebcf, transparent);
}

/* Table Container */
.calc-module-container.average-price-calc-specifics .results-table-scroll-wrapper#apc_transaction-table-container {
    overflow: auto;
    border: none;
    background: none;
    margin: 0;
    padding: 0;
    position: relative;
    width: 100%;
    max-width: 100%;
    box-shadow: none;
    background: transparent;
    cursor: grab; /* Show grab cursor to indicate draggable */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.calc-module-container.average-price-calc-specifics .results-table-scroll-wrapper#apc_transaction-table-container.active-drag {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    cursor: grabbing; /* Show grabbing cursor while dragging */
}

.calc-module-container.average-price-calc-specifics #apc_transaction-table-placeholder {
    text-align: center;
    color: #888;
    font-style: italic;
    padding: 20px;
}

/* --- START: SPACIOUS & ROBUST APC TABLE --- */

/* 1. Set a minimum width on the table and let it size columns automatically */
.calc-module-container.average-price-calc-specifics table#apc_transaction-table.results-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    table-layout: auto; /* Let browser size columns based on content */
    min-width: 800px; /* Enforces a minimum width, enabling horizontal scroll on small screens */
    background-color: rgba(40, 235, 207, 0.05);
    border: 1px solid rgba(40, 235, 207, 0.15);
    border-radius: 8px;
    overflow: hidden;
}

/* 2. Make all cells spacious and prevent wrapping */
.calc-module-container.average-price-calc-specifics table#apc_transaction-table th,
.calc-module-container.average-price-calc-specifics table#apc_transaction-table td {
    padding: 16px 25px; /* VERY SPACIOUS PADDING */
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    text-align: center; /* Default alignment */
    white-space: nowrap; /* Prevents wrapping and ensures clean rows */
    vertical-align: middle;
    line-height: 1.4;
    font-size: 14px;
}

/* 3. Apply professional alignment rules */
/* DATE column - left aligned */
.calc-module-container.average-price-calc-specifics table#apc_transaction-table th:nth-child(1),
.calc-module-container.average-price-calc-specifics table#apc_transaction-table td:nth-child(1) {
    text-align: left !important;
}

/* LOTS, PRICE, COMM. columns - right aligned */
.calc-module-container.average-price-calc-specifics table#apc_transaction-table th:nth-child(4),
.calc-module-container.average-price-calc-specifics table#apc_transaction-table td:nth-child(4),
.calc-module-container.average-price-calc-specifics table#apc_transaction-table th:nth-child(5),
.calc-module-container.average-price-calc-specifics table#apc_transaction-table td:nth-child(5),
.calc-module-container.average-price-calc-specifics table#apc_transaction-table th:nth-child(7),
.calc-module-container.average-price-calc-specifics table#apc_transaction-table td:nth-child(7) {
    text-align: right !important;
}

/* --- Housekeeping rules --- */
.calc-module-container.average-price-calc-specifics table#apc_transaction-table th:not(:last-child),
.calc-module-container.average-price-calc-specifics table#apc_transaction-table td:not(:last-child) { border-right: none; }

.calc-module-container.average-price-calc-specifics table#apc_transaction-table tbody tr:last-child td { border-bottom: none; }

.calc-module-container.average-price-calc-specifics table#apc_transaction-table thead th {
    background-color: rgba(40, 235, 207, 0.1);
    border-bottom-color: rgba(40, 235, 207, 0.25);
    position: sticky;
    top: 0;
    z-index: 5;
}

/* Action buttons styling */
.calc-module-container.average-price-calc-specifics table#apc_transaction-table .action-buttons-container {
    display: flex;
    justify-content: center;
    align-items: center;
}
.calc-module-container.average-price-calc-specifics table#apc_transaction-table .action-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    margin: 0 5px;
    font-size: 18px;
    line-height: 1;
    color: #0e0e0e;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    vertical-align: middle;
}
.calc-module-container.average-price-calc-specifics table#apc_transaction-table .edit-icon-btn {
    background-color: #a2cdff;
}
.calc-module-container.average-price-calc-specifics table#apc_transaction-table .delete-icon-btn {
    background-color: #e28743;
}
.calc-module-container.average-price-calc-specifics table#apc_transaction-table .action-icon-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}
.calc-module-container.average-price-calc-specifics table#apc_transaction-table .action-icon-btn:active {
    transform: translateY(0px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
/* --- END: SPACIOUS & ROBUST APC TABLE --- */

/* --- START: MODAL DIALOG STYLES --- */
/* Modal dialog buttons styling */
.calc-module-container.average-price-calc-specifics .modal-actions button {
    display: inline-block;
    padding: 10px 20px !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    border: none !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    cursor: pointer !important;
    font-size: 13px !important;
    line-height: 1.4 !important;
    transition: all 0.3s ease !important;
    font-family: 'Montserrat', sans-serif !important;
    width: auto !important;
    height: auto !important;
    min-height: 38px !important;
    min-width: 60px !important;
    position: static !important;
    vertical-align: middle !important;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    text-align: center;
    color: #0e0e0e;
    background: #ccc;
    margin: 0 5px;
}

/* Confirm button - orange gradient */
.calc-module-container.average-price-calc-specifics .modal-confirm-btn {
    background: linear-gradient(145deg, #e28743, #c86a2a) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 10px rgba(226, 135, 67, 0.2) !important;
}

.calc-module-container.average-price-calc-specifics .modal-confirm-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(226, 135, 67, 0.3) !important;
}

/* Cancel button - improved border and hover effect */
.calc-module-container.average-price-calc-specifics .modal-cancel-btn {
    background: rgba(224, 224, 224, 0.15) !important;
    color: #e0e0e0 !important;
    border: 2px solid #e0e0e0 !important;
    box-shadow: none !important;
}

.calc-module-container.average-price-calc-specifics .modal-cancel-btn:hover {
    background-color: rgba(255, 255, 255, 0.25) !important;
    color: #fff !important;
    border-color: #fff !important;
}

/* Danger action button (for delete confirmation) */
.calc-module-container.average-price-calc-specifics .danger-action {
    background: linear-gradient(145deg, #e28743, #c86a2a) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 10px rgba(226, 135, 67, 0.2) !important;
}

.calc-module-container.average-price-calc-specifics .danger-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(226, 135, 67, 0.3) !important;
}

/* Responsive styles for modal buttons */
@media (max-width: 480px) {
    .calc-module-container.average-price-calc-specifics .modal-actions button {
        font-size: 12px;
        padding: 8px 15px !important;
        min-height: 34px !important;
    }
}
/* Modal box styling - orange theme with neon glow (only for delete confirmation) */
.calc-module-container.average-price-calc-specifics #apc-delete-confirm-modal-box {
    border: 2px solid #e28743 !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4), 0 0 20px rgba(226, 135, 67, 0.3), 0 0 40px rgba(226, 135, 67, 0.15) !important;
    animation: deleteModalGlow 1.5s ease-in-out infinite alternate;
}

.calc-module-container.average-price-calc-specifics #apc-delete-confirm-modal-box .modal-title {
    color: #e28743 !important;
    text-shadow: 0 0 5px rgba(226, 135, 67, 0.3) !important;
}

/* Animation for the delete modal neon glow effect */
@keyframes deleteModalGlow {
    from {
        box-shadow: 0 10px 30px rgba(0,0,0,0.4), 0 0 20px rgba(226, 135, 67, 0.3), 0 0 40px rgba(226, 135, 67, 0.15);
    }
    to {
        box-shadow: 0 10px 30px rgba(0,0,0,0.4), 0 0 25px rgba(226, 135, 67, 0.4), 0 0 50px rgba(226, 135, 67, 0.2);
    }
}

/* --- END: MODAL DIALOG STYLES --- */

/* --- START: EDIT MODE STYLES --- */
/* Visual indicator for edit mode */
.calc-module-container.average-price-calc-specifics .calculator-form.edit-mode {
    position: relative;
    border: 2px solid #a2cdff;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
    background: linear-gradient(145deg, rgba(162, 205, 255, 0.05), rgba(130, 180, 240, 0.08));
    box-shadow: 0 0 15px rgba(162, 205, 255, 0.15);
    transition: all 0.3s ease;
}

.calc-module-container.average-price-calc-specifics .calculator-form.edit-mode::before {
    content: 'EDIT MODE';
    position: absolute;
    top: -12px;
    right: 20px;
    background: linear-gradient(145deg, #a2cdff, #7ab0f5);
    color: white;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 1;
}

/* Highlight the update button in edit mode */
.calc-module-container.average-price-calc-specifics .calculator-form.edit-mode .calculator-button#apc_addTradeBtn,
.calc-module-container.average-price-calc-specifics .calculator-form.edit-mode .calculator-button.primary-action#apc_addTradeBtn {
    background: #a2cdff !important;
    box-shadow: 0 4px 10px rgba(162, 205, 255, 0.2) !important;
    animation: editButtonPulse 2s infinite;
}

@keyframes editButtonPulse {
    0% {
        box-shadow: 0 4px 10px rgba(162, 205, 255, 0.2);
    }
    50% {
        box-shadow: 0 4px 15px rgba(162, 205, 255, 0.4);
    }
    100% {
        box-shadow: 0 4px 10px rgba(162, 205, 255, 0.2);
    }
}
/* --- END: EDIT MODE STYLES --- */

/* --- START: NOTIFICATION STYLES --- */
/* Make the "add second trade" prompt more visible */
.calc-module-container.average-price-calc-specifics #apc_add-second-trade-prompt {
    font-size: 14px;
    color: #ffffff;
    font-weight: 500;
    text-align: center;
    margin: 15px 0;
    padding: 12px 20px;
    background-color: rgba(40, 235, 207, 0.1);
    border: 1px solid rgba(40, 235, 207, 0.3);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    animation: pulseNotification 2s infinite;
}

@keyframes pulseNotification {
    0% {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    50% {
        box-shadow: 0 2px 12px rgba(40, 235, 207, 0.3);
    }
    100% {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
}
/* --- END: NOTIFICATION STYLES --- */

/* --- START: CALCULATE AVERAGE BUTTON STYLES --- */
/* Make the Calculate Average Price button span the full width */
.calc-module-container.average-price-calc-specifics .calculator-inputs > .form-group.action-buttons {
    grid-column: 1 / -1;
    width: 100%;
}
/* --- END: CALCULATE AVERAGE BUTTON STYLES --- */
