/* ========================================
   StageShow Box Office - Core CSS
   ======================================== */

/* Import modular CSS files */
@import url('analytics.css');
@import url('forms.css');

/* ============================================================================
   CSS VARIABLES
   ============================================================================ */

:root {
    --ssbox-primary-color: #741f11;
    --ssbox-primary-hover: #a22b18;
    --ssbox-secondary-color: #782F40;
    --ssbox-border-color: #ddd;
    --ssbox-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3);
    --ssbox-border-radius: 3px;
    --ssbox-transition: background 0.2s, color 0.2s;
    
    /* Attendance colors */
    --ssbox-attendance-none: #ffe5e5;
    --ssbox-attendance-partial: #fff5e5;
    --ssbox-attendance-full: #e5ffe5;
    --ssbox-attendance-none-border: #dc3545;
    --ssbox-attendance-partial-border: #ffc107;
    --ssbox-attendance-full-border: #28a745;
    
    /* Mobile breakpoints */
    --ssbox-mobile: 767px;
    --ssbox-tablet: 768px;
    --ssbox-small-mobile: 480px;
}

/* ============================================================================
   ATTENDANCE CONTROLS
   ============================================================================ */

/* Note: Attendance styles are now handled in forms.css to avoid duplication */

/* ============================================================================
   LAYOUT COMPONENTS
   ============================================================================ */


   
.ssbox-main {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 0 24px 0;
    box-sizing: border-box;
}

.ssbox-flex-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 10px;
}

.ssbox-flex-col {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.ssbox-title {
    margin: 0 0 8px 0;
    font-size: 2rem;
    font-weight: bold;
}

.ssbox-align-right {
    text-align: right;
}

.ssbox-attended-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-left: 10px;
    margin-top: 0;
    margin-bottom: 0;
}

.ssbox-attended-label {
    font-weight: bold;
    font-size: 18px;
    color: #222;
    margin-bottom: 2px;
    line-height: 1.2;
}

.ssbox-breakdown {
    font-size: 16px;
    font-weight: normal;
    color: #444;
    white-space: normal;
    margin-top: 0;
    line-height: 1.1;
}

/* ============================================================================
   ERROR STYLES
   ============================================================================ */

.ssbox-error {
    color: #d63638;
    font-weight: bold;
    padding: 10px;
    background-color: #fef7f0;
    border: 1px solid #d63638;
    border-radius: 4px;
    margin: 15px 0;
}

/* ============================================================================
   DESKTOP STYLES
   ============================================================================ */

@media screen and (min-width: 768px) {
    /* Hide mobile view and force desktop table view */
    .ssbox-mobile-cards-container {
        display: none !important;
    }
    
    /* Force table display with correct layout */
    .tablepress.tablepress-id-1.dataTable,
    .ssbox-table {
        display: table !important;
        table-layout: fixed !important;
        width: 100% !important;
        border-collapse: collapse !important;
        max-width: 100% !important;
    }

    /* Reset and enforce TablePress base styles */
    .tablepress > :not(caption) > * > * {
        padding: var(--padding) !important;
        text-align: left !important;
        vertical-align: middle !important;
        box-sizing: border-box !important;
        border: none !important;
        border-bottom: 1px solid #ddd !important;
    }

    /* Preserve TablePress header styling */
    .tablepress thead th,
    .tablepress tfoot th {
        background-color: #d9edf7 !important;
        font-weight: 700 !important;
        vertical-align: middle !important;
        border: none !important;
        border-bottom: 1px solid #ddd !important;
    }

    /* Preserve TablePress row styling */
    .tablepress tbody tr {
        background-color: #ffffff !important;
    }

    .tablepress tbody tr:nth-child(even) {
        background-color: #f9f9f9 !important;
    }

    /* Ensure borders and backgrounds work on iPad */
    @supports (-webkit-touch-callout: none) {
        .tablepress tbody tr {
            border: 1px solid #ddd !important;
            background-color: #ffffff !important;
        }

        .tablepress tbody tr:nth-child(even) {
            background-color: #f9f9f9 !important;
        }

        .tablepress tbody td {
            border: 1px solid #ddd !important;
        }

        /* Stronger selector for header styling on iPad */
        html body .tablepress thead th {
            border: none !important;
            border-bottom: 1px solid #ddd !important;
            background-color: #d9edf7 !important;
        }
    }
    
    /* Preserve row striping */
    .tablepress > :where(tbody.row-striping) > :nth-child(even) > * {
        background-color: var(--even-bg-color) !important;
        color: var(--even-text-color) !important;
    }

    /* Preserve borders */
    .tablepress > :where(thead) + tbody > tr > *,
    .tablepress > tbody > * ~ tr > * {
        border-top: 1px solid var(--border-color) !important;
    }

    /* Cell text handling */
    .tablepress.tablepress-id-1.dataTable th,
    .tablepress.tablepress-id-1.dataTable td,
    .ssbox-table th,
    .ssbox-table td {
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        color: var(--text-color) !important;
        vertical-align: middle !important;
    }

    /* Column width specifications for desktop/iPad view */
    .tablepress.tablepress-id-1.dataTable th,
    .tablepress.tablepress-id-1.dataTable td,
    .ssbox-table th,
    .ssbox-table td {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Attendance label styling for desktop/tablet */
    .stageshow-boxoffice-attended-label {
        margin: 16px 0 8px 0 !important;
        font-size: 18px !important;
        font-weight: bold !important;
        color: #333 !important;
        text-align: center !important;
        display: block !important;
    }

    /* First Name column */
    .tablepress.tablepress-id-1.dataTable th.ssbox-col-firstname,
    .tablepress.tablepress-id-1.dataTable td.ssbox-col-firstname,
    .ssbox-table th.ssbox-col-firstname,
    .ssbox-table td.ssbox-col-firstname {
        width: 90px !important;
    }

    /* Last Name column */
    .tablepress.tablepress-id-1.dataTable th.ssbox-col-lastname,
    .tablepress.tablepress-id-1.dataTable td.ssbox-col-lastname,
    .ssbox-table th.ssbox-col-lastname,
    .ssbox-table td.ssbox-col-lastname {
        width: 100px !important;
    }

    /* Email column */
    .tablepress.tablepress-id-1.dataTable th.ssbox-col-email,
    .tablepress.tablepress-id-1.dataTable td.ssbox-col-email,
    .ssbox-table th.ssbox-col-email,
    .ssbox-table td.ssbox-col-email {
        width: 180px !important;
        padding:0px !important;
    }

    /* Attended column - space for controls */
    .tablepress.tablepress-id-1.dataTable th.ssbox-col-attended,
    .tablepress.tablepress-id-1.dataTable td.ssbox-col-attended,
    .ssbox-table th.ssbox-col-attended,
    .ssbox-table td.ssbox-col-attended {
        width: 105px !important;
    }

    /* Quantity column */
    .tablepress.tablepress-id-1.dataTable th.ssbox-col-qty,
    .tablepress.tablepress-id-1.dataTable td.ssbox-col-qty,
    .ssbox-table th.ssbox-col-qty,
    .ssbox-table td.ssbox-col-qty {
        width: 40px !important;
    }

    /* Type column */
    .tablepress.tablepress-id-1.dataTable th.ssbox-col-type,
    .tablepress.tablepress-id-1.dataTable td.ssbox-col-type,
    .ssbox-table th.ssbox-col-type,
    .ssbox-table td.ssbox-col-type {
        width: 50px !important;
    }

    /* Sale Date column */
    .tablepress.tablepress-id-1.dataTable th.ssbox-col-date,
    .tablepress.tablepress-id-1.dataTable td.ssbox-col-date,
    .ssbox-table th.ssbox-col-date,
    .ssbox-table td.ssbox-col-date {
        width: 80px !important;
    }
}

/* ============================================================================
   768px BREAKPOINT ATTENDED CONTROLS ADJUSTMENT
   ============================================================================ */

@media screen and (min-width: 768px) and (max-width: 1023px) {
    /* iPad specific TablePress styles */
    .tablepress.tablepress-id-1.dataTable,
    .ssbox-table {
        font-size: 15px !important;
    }

    /* Ensure proper padding and alignment for iPad */
    .tablepress > :not(caption) > * > * {
        padding: 8px !important;
        vertical-align: middle !important;
    }

    /* Keep row striping on iPad */
    .tablepress > :where(tbody.row-striping) > :nth-child(even) > * {
        background-color: var(--even-bg-color) !important;
    }

    /* Specific iPad column constraints */
    .tablepress td,
    .tablepress th {
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }
    
    .tablepress tbody tr td {
        max-width: none !important;
        vertical-align: middle !important;
    }

    /* Attendance cell styles moved to forms.css to avoid duplication */
    
    /* Constrain other table columns to prevent width expansion */
    .tablepress.tablepress-id-1.dataTable {
        table-layout: fixed !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .tablepress.tablepress-id-1.dataTable th,
    .tablepress.tablepress-id-1.dataTable td {
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
        max-width: 130px !important;
        font-size: 15px !important;
    }
    
    /* Email column specific constraints */
    .tablepress.tablepress-id-1.dataTable td.ssbox-col-email {
        max-width: 100px !important;
        word-break: break-all !important;
    }
    
    /* Name column constraints */
    .tablepress.tablepress-id-1.dataTable td.ssbox-col-firstname {
        max-width: 80px !important;
    }

    /* Attended column constraints */
    .tablepress.tablepress-id-1.dataTable td.ssbox-col-attended {
        max-width: 100px !important;
        padding: 2px !important;
    }
    
    /* Quantity column constraints */
    .tablepress.tablepress-id-1.dataTable td.ssbox-col-qty {
        max-width: 20px !important;
    }

    /* Type column constraints */
    .tablepress.tablepress-id-1.dataTable td.ssbox-col-type {
        max-width: 30px !important;
    }

    /* Sale Date column constraints */
    .tablepress.tablepress-id-1.dataTable td.ssbox-col-date {
        max-width: 100px !important;
    }    
}

/* ============================================================================
   GLOBAL OVERRIDES
   ============================================================================ */

/* Override global mobile line-height for this module */
body.mobile-device-detected .box-office-test,
body.is-mobile-device .box-office-test {
    line-height: normal !important;
}

/* Table alignment overrides */
.tablepress td.ssbox-align-right,
.tablepress th.ssbox-align-right,
td.ssbox-align-right,
th.ssbox-align-right {
    text-align: right !important;
}

/* Transition effects */
.ssbox-mobile-cards-container,
.tablepress.tablepress-id-1.dataTable {
    transition: opacity 0.3s ease;
}

/* Sortable attendance table headers (desktop) */
.box-office-test .tablepress thead th.ssbox-sortable {
    cursor: pointer;
    user-select: none;
    padding-right: 1.4em !important;
    position: relative;
}

.box-office-test .tablepress thead th.ssbox-sortable::after {
    content: '\2195';
    position: absolute;
    right: 0.35em;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.45;
    font-size: 0.85em;
    line-height: 1;
}

.box-office-test .tablepress thead th.ssbox-sort-asc::after {
    content: '\2191';
    opacity: 0.85;
}

.box-office-test .tablepress thead th.ssbox-sort-desc::after {
    content: '\2193';
    opacity: 0.85;
}
