/**
 * SndCore Tier Admin CSS
 * 
 * Provides WordPress admin styling for the subscription tier management interface.
 * Includes responsive design, modal styles, and consistent WordPress admin theming.
 */

/* Main tier management container */
.snd-tier-management {
    background: #fff;
    padding: 20px;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    margin-top: 20px;
}

/* Header section with actions */
.snd-tier-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #ddd;
    flex-wrap: wrap;
    gap: 15px;
}

.snd-tier-header .button-primary {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.snd-bulk-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.snd-bulk-actions select {
    min-width: 120px;
}

.snd-search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.snd-search-box input {
    padding-right: 30px;
    min-width: 200px;
}

.snd-search-box .dashicons {
    position: absolute;
    right: 8px;
    color: #666;
    pointer-events: none;
}

/* Table styling */
.snd-tier-table-container {
    margin-bottom: 30px;
    overflow-x: auto;
}

#snd-tier-table {
    width: 100%;
    background: #fff;
}

#snd-tier-table th,
#snd-tier-table td {
    padding: 12px 8px;
    vertical-align: middle;
}

#snd-tier-table .column-cb {
    width: 2.2em;
}

#snd-tier-table .column-drag {
    width: 40px;
    text-align: center;
    cursor: move;
}

#snd-tier-table .column-name {
    min-width: 150px;
}

#snd-tier-table .column-description {
    min-width: 200px;
}

#snd-tier-table .column-price {
    min-width: 100px;
}

#snd-tier-table .column-enabled {
    min-width: 80px;
}

#snd-tier-table .column-actions {
    min-width: 120px;
}

/* Align action buttons neatly */
#snd-tier-table td.column-actions,
#snd-tier-table td.tier-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

#snd-tier-table td.column-actions .button,
#snd-tier-table td.tier-actions .button {
    margin: 0; /* remove baseline offset */
    vertical-align: middle;
}

.drag-handle {
    cursor: move;
    color: #666;
    font-size: 16px;
}

.drag-handle:hover {
    color: #0073aa;
}

.tier-key {
    font-size: 12px;
    color: #666;
    font-style: italic;
}

/* Status badges */
.snd-status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.snd-status-badge.enabled {
    background: #46b450;
    color: #fff;
}

.snd-status-badge.disabled {
    background: #dc3232;
    color: #fff;
}

/* Sortable placeholder */
.snd-tier-placeholder {
    background: #f0f0f0 !important;
    border: 2px dashed #ddd !important;
    visibility: visible !important;
    height: 50px !important;
}

.snd-tier-placeholder td {
    border: none !important;
}

/* Tier preview section */
.snd-tier-preview {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 20px;
    margin-top: 20px;
}

.snd-tier-preview h3 {
    margin-top: 0;
    color: #23282d;
}

#snd-tier-preview-container {
    margin-top: 15px;
}

.tier-preview-card {
    margin: 0 auto;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.tier-preview-card .tier-badge {
    display: inline-block;
    background: #dc3232;
    color: #fff;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 10px;
}

.tier-preview-card .tier-price {
    font-size: 18px;
    font-weight: 600;
    margin: 10px 0;
}

.tier-preview-card .tier-status {
    font-size: 12px;
    opacity: 0.7;
    margin-top: 10px;
}

/* Modal styles */
.snd-modal {
    position: fixed;
    z-index: 100000;

    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
}

.snd-modal-content {
    background-color: #fff;
    margin: 5% auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.snd-modal-content label {
    color: #5eacbf !important;
}


.snd-modal-header {
    background: #f1f1f1;
    padding: 15px 20px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.snd-modal-header h2 {
    margin: 0;
    color: #0c74dd; /* ensure visible in admin */
}

.snd-modal-close {
    color: #666;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.snd-modal-close:hover {
    color: #dc3232;
}

.snd-modal-body {
    padding: 20px;
}

.snd-modal-footer {
    background: #f1f1f1;
    padding: 15px 20px;
    border-top: 1px solid #ddd;
    text-align: right;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Form styling */
.snd-form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.snd-form-group {
    flex: 1;
    min-width: 0;
}

/* Align the stacked color pickers as a right column */
.snd-color-column-right {
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-self: flex-start;
    min-width: 240px;
}

/* Make color labels readable on dark backgrounds */
.snd-color-column-right label {
    color: #666;
    font-weight: 500;
    text-align: center; /* center label under control */
    display: block;
    margin-top: 6px;
}

/* WooCommerce product field tweaks */
.snd-wc-product-group {
        padding: 8px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 10px;
}
.snd-wc-product-group select {
    width: auto;
    min-width: 280px;
}
.snd-wc-product-group label {
    margin: 0;
    white-space: nowrap;
}

.snd-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #23282d;
}

.wrap .button, .form-table .button, .snd-settings-table .button, .snd-table .button, .widefat .button, #snd-settings-form .button {
    display: flex;
    align-items: center;
    font-size: 12px;
    padding: 0 10px;
}

/* Subtle label color when inside right color column to avoid heavy contrast */
.snd-color-column-right .snd-form-group label {
    color: #888;
    font-weight: 600;
    font-size: 11px;
}

.snd-color-column-right .snd-form-group button {
    font-size: 10px !important;
}    

.snd-form-group input,
.snd-form-group textarea,
.snd-form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 14px;
}

.snd-form-group input:focus,
.snd-form-group textarea:focus,
.snd-form-group select:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 1px #0073aa;
    outline: none;
}

.snd-form-group .description {
    margin-top: 5px;
    font-size: 12px;
    color: #666;
    font-style: italic;
}

/* Toggle switch */
.snd-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.snd-toggle input[type="checkbox"] {
    display: none;
}

.snd-toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background-color: #ccc;
    border-radius: 24px;
    transition: 0.3s;
}

.snd-toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    top: 2px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
}

.snd-toggle input:checked + .snd-toggle-slider {
    background-color: #0073aa;
}

.snd-toggle input:checked + .snd-toggle-slider:before {
    transform: translateX(20px);
}

/* Image upload section */
.snd-image-upload {
    border: 2px dashed #ddd;
    border-radius: 4px;
    padding: 20px;
    text-align: center;
    background: #f9f9f9;
}

.snd-image-preview {
    margin-bottom: 15px;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.snd-image-preview img {
    max-width: 150px;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.snd-image-upload .button {
    margin: 0 5px;
}

/* Color picker integration */
.wp-picker-container {
    margin-top: 5px;
}

.wp-picker-input-wrap {
    width: 100%;
}

.wp-picker-input-wrap input {
    width: calc(100% - 40px);
}

/* Loading overlay */
.snd-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.8);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.snd-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: snd-spin 1s linear infinite;
}

@keyframes snd-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Notice styles */
.notice {
    margin: 15px 0;
    animation: snd-slide-down 0.3s ease-out;
}

@keyframes snd-slide-down {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive design */
@media screen and (max-width: 768px) {
    .snd-tier-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .snd-bulk-actions,
    .snd-search-box {
        justify-content: center;
    }
    
    .snd-form-row {
        flex-direction: column;
        gap: 15px;
    }
    
    .snd-modal-content {
        width: 95%;
        margin: 2% auto;
    }
    
    .snd-modal-footer {
        flex-direction: column-reverse;
        gap: 10px;
    }
    
    .snd-modal-footer .button {
        width: 100%;
        justify-content: center;
    }
    
    #snd-tier-table .column-description {
        display: none;
    }
    
    #snd-tier-table .column-actions .button {
        font-size: 12px;
        padding: 4px 8px;
    }
}

@media screen and (max-width: 480px) {
    #snd-tier-table .column-price {
        display: none;
    }
    
    .snd-tier-header .button-primary span {
        display: none;
    }
    
    .snd-search-box input {
        min-width: 150px;
    }
}

/* Dark mode support (for future WordPress versions) */
@media (prefers-color-scheme: dark) {
    .snd-tier-management {
        background: #1e1e1e;
        border-color: #3c434a;
        color: #f0f0f0;
    }
    
    .snd-tier-preview {
        background: #2c2c2c;
        border-color: #3c434a;
    }
    
    .snd-modal-content {
        background: #1e1e1e;
        border-color: #3c434a;
        color: #f0f0f0;
    }
    
    .snd-modal-header,
    .snd-modal-footer {
        background: #2c2c2c;
        border-color: #3c434a;
    }
    
    .snd-form-group input,
    .snd-form-group textarea,
    .snd-form-group select {
        background: #2c2c2c;
        border-color: #3c434a;
        color: #f0f0f0;
    }
    
    .snd-image-upload {
        background: #2c2c2c;
        border-color: #3c434a;
    }
}

/* WordPress admin compatibility */
.wp-admin .snd-tier-management .button {
    text-decoration: none;
    border: 1px solid #0073aa;
    background: #0073aa;
    color: #fff;
    display: inline-block;
    text-align: center;
    cursor: pointer;
    padding: 0 10px;
    line-height: 28px;
    height: 30px;
    margin: 0;
    border-radius: 3px;
    white-space: nowrap;
    box-sizing: border-box;
}

.wp-admin .snd-tier-management .button:hover {
    background: #005a87;
    border-color: #005a87;
}

.wp-admin .snd-tier-management .button-secondary {
    background: #f7f7f7;
    border-color: #cccccc;
    color: #555;
}

.wp-admin .snd-tier-management .button-secondary:hover {
    background: #fafafa;
    border-color: #999;
}

/* Accessibility improvements */
.snd-tier-management *:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.screen-reader-text {
    clip: rect(1px, 1px, 1px, 1px);
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
}

/* Animation for tier row interactions */
.snd-tier-row {
    transition: background-color 0.2s ease;
}

.snd-tier-row:hover {
    background-color: #f9f9f9;
}

.snd-tier-row.ui-sortable-helper {
    background-color: #fff;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    border-left: 4px solid #0073aa;
}

/* Tier management specific dashicons */
.snd-tier-management .dashicons {
    vertical-align: middle;
}

.snd-tier-management .dashicons-menu {
    font-size: 18px;
}

.snd-tier-management .dashicons-plus-alt {
    font-size: 16px;
}

/* Form validation styles */
.snd-form-group input.error,
.snd-form-group textarea.error,
.snd-form-group select.error {
    border-color: #dc3232;
    box-shadow: 0 0 0 1px #dc3232;
}

.snd-form-group .error-message {
    color: #dc3232;
    font-size: 12px;
    margin-top: 5px;
    display: block;
}