/**
 * Customer Portal Billing Styles
 */

/* Main container */
.cas-billing {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.cas-billing-header {
    margin-bottom: 30px;
}

.cas-billing-header h1 {
    margin: 0 0 8px 0;
    font-size: 28px;
    font-weight: 600;
    color: #1a1a1a;
}

.cas-billing-subtitle {
    margin: 0;
    color: #666;
    font-size: 16px;
}

/* Cards */
.cas-billing-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 24px;
    overflow: hidden;
}

.cas-billing-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #eee;
}

.cas-billing-card-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
}

/* Status badges */
.cas-status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.cas-status-active {
    background: #d4edda;
    color: #155724;
}

.cas-status-pending {
    background: #fff3cd;
    color: #856404;
}

.cas-status-inactive {
    background: #f8d7da;
    color: #721c24;
}

.cas-status-admin-active {
    background: #ffeeba;
    color: #856404;
}

.cas-price-free {
    color: #f0ad4e;
    font-weight: 600;
}

.cas-admin-active-note {
    color: #f0ad4e;
    font-size: 18px;
}

.cas-admin-active-note .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.cas-status-expired {
    background: #e2e3e5;
    color: #383d41;
}

/* Renewal column */
.cas-property-renewal {
    white-space: nowrap;
}

.cas-renewal-days {
    font-weight: 600;
}

.cas-renewal-active {
    color: #28a745;
}

.cas-renewal-pending {
    color: #856404;
}

.cas-renewal-expired {
    color: #721c24;
    font-weight: 600;
}

/* Filters */
.cas-billing-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 20px 24px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    align-items: flex-end;
}

.cas-filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 180px;
}

.cas-filter-group label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cas-filter-input,
.cas-filter-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    min-width: 180px;
}

.cas-filter-input:focus,
.cas-filter-select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.cas-filter-dropdown {
    position: relative;
}

.cas-filter-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.cas-filter-option {
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.cas-filter-option:hover {
    background: #f0f0f0;
}

.cas-filter-option.selected {
    background: #e3f2fd;
    color: #007bff;
}

#cas-reset-filters {
    align-self: flex-end;
    margin-left: auto;
}

/* Subscription details */
.cas-subscription-details {
    padding: 24px;
}

.cas-subscription-info {
    margin-bottom: 20px;
}

.cas-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.cas-info-row:last-child {
    border-bottom: none;
}

.cas-info-label {
    color: #666;
    font-size: 14px;
}

.cas-info-value {
    font-weight: 600;
    color: #1a1a1a;
}

.cas-info-value.cas-price {
    font-size: 18px;
    color: #007bff;
}

.cas-subscription-actions {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

/* No subscription state */
.cas-no-subscription {
    text-align: center;
    padding: 20px 0;
}

.cas-no-subscription p {
    margin: 0 0 12px 0;
    color: #666;
}

.cas-pricing-info {
    font-size: 16px;
}

/* Properties table */
.cas-properties-table {
    padding: 0;
}

.cas-properties-table table {
    width: 100%;
    border-collapse: collapse;
}

.cas-properties-table th,
.cas-properties-table td {
    padding: 16px 24px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}

.cas-properties-table th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 13px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.cas-properties-table tbody tr:hover {
    background: #f8f9fa;
}

.cas-property-name a {
    color: #1a1a1a;
    text-decoration: none;
    font-weight: 500;
}

.cas-property-name a:hover {
    color: #007bff;
}

.cas-property-price {
    font-weight: 500;
}

.cas-price-inactive {
    color: #999;
}

/* Empty properties */
.cas-empty-properties {
    text-align: center;
    padding: 40px 24px;
    color: #666;
}

.cas-empty-properties .dashicons {
    font-size: 48px;
    width: 48px;
    height: 48px;
    color: #ccc;
    margin-bottom: 12px;
}

/* Pricing card */
.cas-pricing-details {
    padding: 24px;
    text-align: center;
}

.cas-pricing-item {
    margin-bottom: 24px;
}

.cas-pricing-amount {
    display: block;
    font-size: 36px;
    font-weight: 700;
    color: #007bff;
}

.cas-pricing-period {
    display: block;
    font-size: 14px;
    color: #666;
    margin-top: 4px;
}

.cas-pricing-features {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
    max-width: 300px;
    margin: 0 auto;
}

.cas-pricing-features li {
    padding: 8px 0;
    color: #444;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cas-pricing-features .dashicons {
    color: #28a745;
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Buttons */
.cas-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.cas-btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.cas-btn-primary {
    background: #007bff;
    color: #fff;
}

.cas-btn-primary:hover {
    background: #0056b3;
    color: #fff;
}

.cas-btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.cas-btn-secondary:hover {
    background: #e0e0e0;
}

.cas-btn-danger {
    background: #dc3545;
    color: #fff;
}

.cas-btn-danger:hover {
    background: #c82333;
}

.cas-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #ccc;
    color: #888;
}

.cas-btn:disabled .dashicons {
    color: #888;
}

.cas-btn .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Modal */
.cas-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999999 !important;
}

/* Override ticket modal styles for billing modal */
#cas-modal-overlay .cas-modal,
#cas-modal-deactivate.cas-modal {
    display: block !important;
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    width: 90% !important;
    height: auto !important;
    max-width: 400px !important;
    min-width: auto !important;
    background: #fff !important;
    border-radius: 16px !important;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2) !important;
    z-index: 10000000 !important;
    padding: 0 !important;
}

.cas-modal-content {
    padding: 24px;
}

.cas-modal-content h3 {
    margin: 0 0 16px 0;
    font-size: 20px;
    font-weight: 600;
}

.cas-modal-content p {
    margin: 0 0 24px 0;
    color: #666;
    line-height: 1.6;
}

.cas-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Spinner */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.dashicons.spin {
    animation: spin 1s linear infinite;
}

/* Checkbox Column */
.cas-col-select {
    width: 40px;
    text-align: center;
}

/* Custom Checkbox Styling */
.cas-checkbox-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
}

.cas-checkbox {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.cas-checkbox-custom {
    width: 20px;
    height: 20px;
    border: 2px solid #ccc;
    border-radius: 4px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.cas-checkbox:checked + .cas-checkbox-custom {
    background: #007bff;
    border-color: #007bff;
}

.cas-checkbox:checked + .cas-checkbox-custom::after {
    content: '';
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

.cas-checkbox:indeterminate + .cas-checkbox-custom {
    background: #007bff;
    border-color: #007bff;
}

.cas-checkbox:indeterminate + .cas-checkbox-custom::after {
    content: '';
    width: 10px;
    height: 2px;
    background: white;
}

.cas-checkbox-wrapper:hover .cas-checkbox-custom {
    border-color: #007bff;
}

.cas-select-all-wrapper {
    margin: 0;
}

/* Bulk Actions */
.cas-bulk-actions {
    padding: 20px 24px;
    background: #f8f9fa;
    border-top: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.cas-bulk-actions .cas-btn {
    min-width: 280px;
}

.cas-bulk-actions .cas-btn .dashicons {
    margin-right: 4px;
}

.cas-bulk-activate-count {
    font-weight: 600;
}

.cas-bulk-info {
    margin: 0 0 0 20px;
    color: #666;
    font-size: 14px;
}

/* ================================
   Pricing Breakdown Mini-Table
   ================================ */

.cas-pricing-breakdown {
    width: 100%;
    margin-top: 16px;
}

.cas-pricing-default {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    border-radius: 10px;
    border-left: 4px solid #2196f3;
}

.cas-pricing-default .cas-pricing-icon {
    font-size: 20px;
}

.cas-pricing-default .cas-pricing-text {
    color: #1565c0;
    font-size: 14px;
}

.cas-pricing-table-container {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.cas-pricing-table-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: #f0f0f0;
    color: #333;
}

.cas-pricing-table-header .cas-pricing-icon {
    font-size: 18px;
}

.cas-pricing-table-header .cas-pricing-title {
    font-weight: 600;
    font-size: 14px;
}

.cas-pricing-table {
    width: 100%;
    border-collapse: collapse;
}

.cas-pricing-table thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.cas-pricing-table tbody td {
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid #f0f0f0;
}

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

.cas-pricing-table tbody tr:hover {
    background: #f8f9fa;
}

.cas-pricing-table .cas-property-cell {
    font-weight: 500;
    color: #333;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cas-pricing-table .cas-price-cell {
    font-weight: 600;
    color: #2196f3;
    white-space: nowrap;
}

.cas-pricing-table .cas-tier-cell {
    color: #666;
    font-size: 12px;
}

.cas-pricing-table .cas-tier-change {
    color: #28a745;
    font-weight: 600;
}

.cas-pricing-table tr.cas-tier-changed {
    background: linear-gradient(90deg, rgba(40, 167, 69, 0.05) 0%, transparent 100%);
}

.cas-pricing-table tr.cas-tier-changed .cas-tier-cell {
    position: relative;
}

.cas-pricing-table tr.cas-tier-changed .cas-tier-cell::before {
    content: '✨';
    margin-right: 4px;
}

.cas-pricing-table tfoot td {
    padding: 14px 16px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-top: 2px solid #e0e0e0;
}

.cas-pricing-table .cas-pricing-total-row td:first-child {
    color: #333;
}

.cas-pricing-table .cas-pricing-total-row td:nth-child(2) {
    color: #28a745;
    font-size: 16px;
}

/* Responsive adjustments for pricing breakdown */
@media (max-width: 768px) {
    .cas-bulk-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .cas-bulk-actions .cas-btn {
        width: 100%;
        justify-content: center;
    }

    .cas-pricing-breakdown {
        margin-top: 12px;
    }

    .cas-pricing-default {
        flex-direction: row;
        text-align: left;
    }

    .cas-pricing-table .cas-property-cell {
        max-width: 120px;
    }

    .cas-pricing-table thead th,
    .cas-pricing-table tbody td,
    .cas-pricing-table tfoot td {
        padding: 10px 12px;
    }
}

/* Pricing Tiers Display */
.cas-pricing-tagline {
    font-size: 14px;
    color: #666;
    font-weight: normal;
}

.cas-pricing-tiers {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    margin-bottom: 24px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.cas-tier-item {
    flex: 1;
    min-width: 160px;
    background: transparent;
    border: none;
    border-right: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 0;
    padding: 24px 16px;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
}

.cas-tier-item:last-child {
    border-right: none;
}

.cas-tier-item:hover {
    background: rgba(255, 255, 255, 0.8);
    transform: none;
}

.cas-tier-item.cas-tier-current {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-right-color: rgba(40, 167, 69, 0.2);
    box-shadow: inset 0 0 0 2px #28a745;
    margin: -1px;
    padding: 25px 17px;
    border-radius: 12px;
    z-index: 1;
}

.cas-tier-icon {
    font-size: 28px;
    margin-bottom: 8px;
    display: block;
}

.cas-tier-name {
    font-size: 15px;
    font-weight: 700;
    color: #333;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cas-tier-subtitle {
    font-size: 11px;
    color: #888;
    margin-bottom: 10px;
    font-style: italic;
}

.cas-tier-range {
    font-size: 12px;
    color: #666;
    margin-bottom: 12px;
    background: rgba(255, 255, 255, 0.6);
    padding: 4px 10px;
    border-radius: 12px;
    display: inline-block;
}

.cas-tier-item.cas-tier-current .cas-tier-range {
    background: rgba(255, 255, 255, 0.8);
    color: #155724;
}

.cas-tier-price {
    margin-bottom: 4px;
}

.cas-tier-amount {
    font-size: 26px;
    font-weight: 800;
    color: #2c3e50;
    display: block;
}

.cas-tier-item.cas-tier-current .cas-tier-amount {
    color: #155724;
}

.cas-tier-period {
    font-size: 11px;
    color: #888;
    display: block;
}

.cas-tier-discount {
    font-size: 11px;
    color: #28a745;
    font-weight: 600;
    margin-top: 6px;
}

.cas-tier-badge-current {
    position: absolute;
    top: 8px;
    right: 8px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

/* Savings display */
.cas-savings-row .cas-savings {
    color: #28a745;
    font-weight: 600;
}

.cas-next-tier-message {
    margin-top: 16px;
    padding: 12px 16px;
    background: #e3f2fd;
    border-radius: 8px;
    color: #1565c0;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cas-next-tier-message .dashicons {
    color: #1976d2;
}

.cas-tier-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
}

/* Responsive */
@media (max-width: 992px) {
    .cas-pricing-tiers {
        flex-wrap: wrap;
    }

    .cas-tier-item {
        min-width: 140px;
        flex: 1 1 calc(33.333% - 1px);
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    }

    .cas-tier-item:nth-child(3) {
        border-right: none;
    }
}

@media (max-width: 768px) {
    .cas-billing {
        padding: 16px;
    }

    .cas-billing-header h1 {
        font-size: 24px;
    }

    .cas-billing-card-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .cas-properties-table {
        overflow-x: auto;
    }

    .cas-properties-table table {
        min-width: 500px;
    }

    .cas-modal {
        width: 95%;
        margin: 20px;
    }

    .cas-info-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .cas-pricing-tiers {
        flex-direction: column;
        border-radius: 12px;
    }

    .cas-tier-item {
        flex: 1 1 100%;
        border-right: none;
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
        padding: 20px;
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        text-align: left;
    }

    .cas-tier-item:last-child {
        border-bottom: none;
    }

    .cas-tier-item.cas-tier-current {
        margin: 0;
        padding: 20px;
        border-radius: 0;
    }

    .cas-tier-icon {
        font-size: 24px;
        margin-bottom: 0;
        margin-right: 12px;
        order: 1;
    }

    .cas-tier-name {
        order: 2;
        flex: 1;
        margin-bottom: 0;
    }

    .cas-tier-subtitle {
        display: none;
    }

    .cas-tier-range {
        order: 3;
        margin-bottom: 0;
        margin-left: auto;
    }

    .cas-tier-price {
        order: 4;
        margin-bottom: 0;
        margin-left: 16px;
        text-align: right;
    }

    .cas-tier-amount {
        font-size: 20px;
    }

    .cas-tier-discount {
        order: 5;
        margin-left: 8px;
        margin-top: 0;
    }

    .cas-tier-badge-current {
        top: auto;
        bottom: 8px;
        right: 8px;
    }

    .cas-next-tier-message {
        flex-direction: column;
        text-align: center;
    }
}
