/**
 * SMS Reports Styles
 * 
 * @package TextMe\Features
 * @since 2.0.0
 */

.textme-sms-reports-page {
    margin: 20px 20px 0 2px;
}

.textme-sms-reports-container {
    max-width: 100%;
    background: #fff;
    padding: 20px;
    border: 1px solid #ccd0d4;
    box-shadow: 0 1px 1px rgba(0,0,0,.04);
}

.textme-sms-reports-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 20px;
}


/* Filters Section */
.textme-sms-reports-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: end;
    padding: 20px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 20px;
}

.textme-sms-filter-group {
    display: flex;
    flex-direction: column;
}

.textme-sms-filter-group label {
    font-weight: 600;
    margin-bottom: 5px;
    color: #333;
}

.textme-sms-filter-group input {
    padding: 0 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.textme-sms-filter-group input:focus {
    border-color: #0073aa;
    outline: none;
    box-shadow: 0 0 0 1px #0073aa;
}

#textme-load-reports {
    padding: 0 12px;
    height: auto;
    align-self: flex-end;
}

.textme-btn-spinner {
    display: flex;
    align-items: center;
    gap: 8px;
}

.textme-btn-spinner .spinner {
    float: none;
    margin: 0;
}

/* Tools Section */
.textme-sms-reports-tools {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #ddd;
    margin-bottom: 20px;
}

.textme-sms-search-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.textme-sms-search-group input {
    width: 300px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.textme-sms-export-group {
    display: flex;
    gap: 10px;
}

/* Summary Statistics */
.textme-sms-reports-summary {
    margin-bottom: 20px;
}

.textme-summary-stats {
    display: flex;
    gap: 30px;
    padding: 15px 20px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
}

.textme-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.textme-stat-label {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 5px;
}

.textme-stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #333;
}

.textme-stat-delivered {
    color: #46b450;
}

.textme-stat-failed {
    color: #dc3232;
}

.textme-stat-pending {
    color: #ffb900;
}

/* Table Styles */
.textme-sms-reports-table-container {
    overflow-x: auto;
    margin-bottom: 20px;
}

#textme-reports-table {
    width: 100%;
    background: #fff;
}

#textme-reports-table th,
#textme-reports-table td {
    padding: 12px 8px;
    text-align: left;
    border-bottom: 1px solid #ddd;
    word-wrap: break-word;
}

#textme-reports-table th {
    background: #f1f1f1;
    font-weight: 600;
    position: relative;
    cursor: pointer;
    user-select: none;
}

.textme-sortable:hover {
    background: #e8e8e8;
}

.textme-sort-arrow {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.3;
}

.textme-sort-arrow:before {
    content: '↕';
    font-size: 14px;
}

.textme-sortable.asc .textme-sort-arrow:before {
    content: '↑';
    opacity: 1;
}

.textme-sortable.desc .textme-sort-arrow:before {
    content: '↓';
    opacity: 1;
}

/* Status styling */
.textme-status-delivered {
    color: #46b450;
    font-weight: 600;
}

.textme-status-failed {
    color: #dc3232;
    font-weight: 600;
}

.textme-status-pending {
    color: #ffb900;
    font-weight: 600;
}

/* Phone number styling */
.textme-phone-number {
    font-family: monospace;
    font-size: 13px;
}

/* External ID styling */
.textme-external-id {
    font-family: monospace;
    font-size: 13px;
    color: #0073aa;
}

/* Pagination */
.textme-sms-reports-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-top: 1px solid #ddd;
}

.textme-pagination-info {
    display: flex;
    align-items: center;
    gap: 20px;
    color: #666;
    font-size: 14px;
}

.textme-pagination-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.textme-pagination-selector label {
    font-weight: 600;
    color: #333;
}

.textme-pagination-selector select {
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: #fff;
    font-size: 14px;
}

.textme-pagination-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

#textme-page-numbers {
    display: flex;
    gap: 5px;
}

.textme-page-btn {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    border-radius: 3px;
    text-decoration: none;
    color: #333;
}

.textme-page-btn:hover {
    background: #f0f0f0;
}

.textme-page-btn.current {
    background: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

/* Loading States */
.textme-sms-reports-loading {
    text-align: center;
    padding: 60px 20px;
}

.textme-loading-content {
    max-width: 400px;
    margin: 0 auto;
}

.textme-loading-content .spinner {
    float: none;
    margin: 0 auto 20px;
}

.textme-loading-progress {
    margin-top: 20px;
}

.textme-progress-bar {
    width: 100%;
    height: 20px;
    background: #f0f0f0;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
}

.textme-progress-fill {
    height: 100%;
    background: #0073aa;
    transition: width 0.3s ease;
}

.textme-progress-text {
    font-size: 14px;
    color: #666;
}

/* Error State */
.textme-sms-reports-error {
    text-align: center;
    padding: 40px 20px;
}

.textme-retry-btn {
    margin-top: 10px;
}

/* Empty State */
.textme-sms-reports-empty {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.textme-empty-state h3 {
    margin-bottom: 10px;
    color: #333;
}

/* ==========================================================================
   jQuery UI Datepicker – scoped to plugin via #ui-datepicker-div
   ========================================================================== */

#ui-datepicker-div.ui-datepicker {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    padding: 10px;
    width: 280px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 13px;
    z-index: 100100 !important;
}

/* Header – month/year navigation */
#ui-datepicker-div .ui-datepicker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 4px 10px;
    border-bottom: 1px solid #eee;
    margin-bottom: 8px;
    background: none;
    border-radius: 0;
}

#ui-datepicker-div .ui-datepicker-title {
    display: flex;
    gap: 4px;
    align-items: center;
    font-weight: 600;
}

#ui-datepicker-div .ui-datepicker-title select {
    padding: 2px 4px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 13px;
    background: #fff;
    cursor: pointer;
}

/* Prev / Next arrows */
#ui-datepicker-div .ui-datepicker-prev,
#ui-datepicker-div .ui-datepicker-next {
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    background: #f0f0f0;
    border: 1px solid #ddd;
    transition: background 0.15s;
}

#ui-datepicker-div .ui-datepicker-prev:hover,
#ui-datepicker-div .ui-datepicker-next:hover {
    background: #0073aa;
    border-color: #0073aa;
}

#ui-datepicker-div .ui-datepicker-prev:hover .ui-icon,
#ui-datepicker-div .ui-datepicker-next:hover .ui-icon {
    filter: brightness(0) invert(1);
}

#ui-datepicker-div .ui-datepicker-prev .ui-icon,
#ui-datepicker-div .ui-datepicker-next .ui-icon {
    background-image: none;
    text-indent: 0;
    width: auto;
    height: auto;
    margin: 0;
    position: static;
    font-size: 0;
}

#ui-datepicker-div .ui-datepicker-prev .ui-icon::after {
    content: '\2039';
    font-size: 18px;
    line-height: 1;
    color: #333;
}

#ui-datepicker-div .ui-datepicker-next .ui-icon::after {
    content: '\203A';
    font-size: 18px;
    line-height: 1;
    color: #333;
}

#ui-datepicker-div .ui-datepicker-prev:hover .ui-icon::after,
#ui-datepicker-div .ui-datepicker-next:hover .ui-icon::after {
    color: #fff;
}

/* Day grid – calendar table */
#ui-datepicker-div table.ui-datepicker-calendar {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

#ui-datepicker-div table.ui-datepicker-calendar th {
    padding: 6px 0;
    text-align: center;
    font-weight: 600;
    font-size: 12px;
    color: #666;
    border: none;
    background: none;
    cursor: default;
}

#ui-datepicker-div table.ui-datepicker-calendar td {
    padding: 1px;
    text-align: center;
    border: none;
    background: none;
}

#ui-datepicker-div table.ui-datepicker-calendar td a,
#ui-datepicker-div table.ui-datepicker-calendar td span {
    display: block;
    padding: 6px 0;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    text-align: center;
    transition: background 0.15s, color 0.15s;
}

#ui-datepicker-div table.ui-datepicker-calendar td a:hover {
    background: #f0f0f0;
    color: #0073aa;
}

/* Today */
#ui-datepicker-div td.ui-datepicker-today a {
    background: #e8f4fc;
    font-weight: 600;
    color: #0073aa;
}

/* Selected / active day */
#ui-datepicker-div td.ui-datepicker-current-day a {
    background: #0073aa;
    color: #fff;
    font-weight: 600;
}

/* Disabled / other-month days */
#ui-datepicker-div td.ui-datepicker-other-month span,
#ui-datepicker-div td.ui-datepicker-unselectable span {
    color: #ccc;
}

/* Prev/Next disabled state */
#ui-datepicker-div .ui-datepicker-prev.ui-state-disabled,
#ui-datepicker-div .ui-datepicker-next.ui-state-disabled {
    opacity: 0.4;
    cursor: default;
}

#ui-datepicker-div .ui-datepicker-prev.ui-state-disabled:hover,
#ui-datepicker-div .ui-datepicker-next.ui-state-disabled:hover {
    background: #f0f0f0;
    border-color: #ddd;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media screen and (max-width: 782px) {

    .textme-sms-reports-page {
        margin: 10px 0 0;
    }

    .textme-sms-reports-container {
        padding: 12px;
    }

    /* Filters – stack vertically, full width inputs */
    .textme-sms-reports-filters {
        flex-direction: column;
        gap: 10px;
        padding: 12px;
    }

    .textme-sms-filter-group {
        width: 100%;
    }

    .textme-sms-filter-group input {
        width: 100%;
        box-sizing: border-box;
    }

    #textme-load-reports {
        width: 100%;
        text-align: center;
    }

    /* Tools – stack search and export */
    .textme-sms-reports-tools {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .textme-sms-search-group {
        width: 100%;
    }

    .textme-sms-search-group input {
        width: 100%;
        flex: 1;
        box-sizing: border-box;
    }

    .textme-sms-export-group {
        justify-content: flex-end;
    }

    /* Summary stats – wrap into 2×2 grid */
    .textme-summary-stats {
        flex-wrap: wrap;
        gap: 12px;
        justify-content: space-around;
        padding: 12px;
    }

    .textme-stat-item {
        min-width: 40%;
    }

    /* Table – horizontal scroll with minimum column widths */
    .textme-sms-reports-table-container {
        margin: 0 -12px;
        padding: 0 12px;
    }

    #textme-reports-table {
        min-width: 700px;
        table-layout: auto;
    }

    #textme-reports-table th,
    #textme-reports-table td {
        padding: 8px 6px;
        font-size: 12px;
        white-space: nowrap;
        overflow: visible;
    }

    /* Pagination – stack info and controls */
    .textme-sms-reports-pagination {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .textme-pagination-info {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    .textme-pagination-controls {
        justify-content: center;
        flex-wrap: wrap;
    }
}