/**
 * ConvertyBot Coupon Rules Admin Page Styles
 */

/* Coupon Rules Styles */
.coupon-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 16px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    border-color: rgba(102, 126, 234, 0.2);
}

.stat-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.stat-icon .dashicons {
    font-size: 28px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-content h3 {
    margin: 0 0 5px 0;
    font-size: 32px;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-content p {
    margin: 0;
    color: #64748b;
    font-size: 14px;
    font-weight: 600;
}

.stat-content .stat-subtitle {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: #94a3b8;
    font-weight: 500;
}

/* Revenue Card Special Styling */
.revenue-card {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05) 0%, rgba(5, 150, 105, 0.05) 100%);
    border: 2px solid rgba(16, 185, 129, 0.2);
}

.revenue-card:hover {
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 10px 40px rgba(16, 185, 129, 0.15);
}

.revenue-card .stat-content h3 {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.revenue-icon {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.3) !important;
}

/* Discount Card Styling */
.discount-icon {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    box-shadow: 0 8px 25px rgba(245, 158, 11, 0.3) !important;
}

.rule-type-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rule-type-cart_total {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.rule-type-product {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.rule-type-category {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.conditions-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.conditions-list li {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 2px;
}

.no-conditions {
    color: #94a3b8;
    font-style: italic;
    font-size: 12px;
}

/* Row Actions - Edit & Delete Buttons */
.row-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.row-actions .edit button,
.row-actions .edit-rule {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: none !important;
    padding: 8px 16px !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    font-size: 12px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3) !important;
}

.row-actions .edit button:hover,
.row-actions .edit-rule:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 18px rgba(102, 126, 234, 0.4) !important;
}

.row-actions .delete button,
.row-actions .delete-rule {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    color: white !important;
    border: none !important;
    padding: 8px 16px !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    font-size: 12px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3) !important;
}

.row-actions .delete button:hover,
.row-actions .delete-rule:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 18px rgba(239, 68, 68, 0.4) !important;
}

/* Remove default WordPress button-link styling */
.button-link.edit-rule,
.button-link.delete-rule {
    text-decoration: none !important;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 56px;
    height: 30px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #e2e8f0;
    transition: 0.3s;
    border-radius: 30px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

input:checked + .toggle-slider {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

input:checked + .toggle-slider:before {
    transform: translateX(26px);
}

.no-rules {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.no-rules-icon .dashicons {
    font-size: 64px;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.no-rules h3 {
    color: #1e293b;
    margin-bottom: 12px;
    font-size: 20px;
    font-weight: 700;
}

.no-rules p {
    color: #64748b;
    margin-bottom: 24px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.6;
}

/* Add First Rule Button */
#add-first-rule {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    border: none !important;
    color: white !important;
    padding: 14px 32px !important;
    font-size: 15px !important;
    font-weight: 600 !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3) !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
}

#add-first-rule:hover {
    transform: translateY(-3px) !important;
    box-shadow: 0 12px 35px rgba(102, 126, 234, 0.4) !important;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
}

.modal-content {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: none;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: white;
}

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.modal-close .dashicons {
    color: white;
    font-size: 20px;
    width: 20px;
    height: 20px;
}

#coupon-rule-form {
    padding: 30px;
    overflow-y: auto;
    max-height: calc(90vh - 180px);
}

.form-section {
    margin-bottom: 30px;
    padding-bottom: 25px;
    border-bottom: 2px solid #e2e8f0;
}

.form-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
}

.form-section h3 {
    margin: 0 0 20px 0;
    font-size: 16px;
    font-weight: 700;
    color: #1e293b;
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(102, 126, 234, 0.15);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.section-description {
    color: #64748b;
    font-size: 14px;
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-field {
    margin-bottom: 20px;
}

.form-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #1e293b;
    font-size: 14px;
}

.form-field .required {
    color: #ef4444;
}

.form-field input,
.form-field select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 14px;
    transition: all 0.3s ease;
    background: #ffffff;
}

.form-field input:focus,
.form-field select:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
}

.form-field .description {
    margin: 8px 0 0 0;
    font-size: 12px;
    color: #64748b;
    font-style: italic;
}

.modal-actions {
    padding: 20px 30px;
    border-top: 2px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.03) 0%, rgba(118, 75, 162, 0.03) 100%);
}

/* Modal Save Button */
.modal-actions .button-primary,
#coupon-rule-form .button-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    border: none !important;
    color: white !important;
    padding: 12px 28px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    border-radius: 12px !important;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.35) !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
}

.modal-actions .button-primary:hover,
#coupon-rule-form .button-primary:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.45) !important;
}

/* Modal Cancel Button */
.modal-actions .button-secondary,
.modal-actions #cancel-rule {
    background: #ffffff !important;
    border: 2px solid #e2e8f0 !important;
    color: #475569 !important;
    padding: 10px 24px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    border-radius: 12px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
}

.modal-actions .button-secondary:hover,
.modal-actions #cancel-rule:hover {
    border-color: #667eea !important;
    color: #667eea !important;
    background: rgba(102, 126, 234, 0.05) !important;
    transform: translateY(-1px) !important;
}

/* Visual Picker Styles */
.visual-picker-container {
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.03) 0%, rgba(118, 75, 162, 0.03) 100%);
    padding: 20px;
}

.visual-picker-container .button,
.open-product-picker,
.open-category-picker {
    margin-bottom: 12px;
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: none !important;
    padding: 12px 20px !important;
    border-radius: 10px !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3) !important;
}

.visual-picker-container .button:hover,
.open-product-picker:hover,
.open-category-picker:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4) !important;
}

.visual-picker-container .button .dashicons,
.open-product-picker .dashicons,
.open-category-picker .dashicons {
    color: white !important;
}

.selected-items-preview {
    min-height: 60px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 12px;
    max-height: 200px;
    overflow-y: auto;
}

.selected-items-preview .no-selection {
    color: #666;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.selected-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    margin-bottom: 8px;
}

.selected-item:last-child {
    margin-bottom: 0;
}

.selected-item img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.selected-item-info {
    flex: 1;
    min-width: 0;
}

.selected-item-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.selected-item-meta {
    font-size: 12px;
    color: #666;
}

.selected-item-remove {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    padding: 4px;
    border-radius: 2px;
    display: flex;
    align-items: center;
}

.selected-item-remove:hover {
    background: #dc3545;
    color: white;
}

/* Picker Modal Styles */
.picker-modal .modal-content {
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.picker-search-filters {
    padding: 20px 24px;
    border-bottom: 2px solid #e2e8f0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.03) 0%, rgba(118, 75, 162, 0.03) 100%);
}

.search-container {
    position: relative;
    margin-bottom: 16px;
}

.search-container input {
    width: 100%;
    padding: 12px 45px 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.search-container input:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
}

.search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #667eea;
    pointer-events: none;
}

.filters-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.filters-container select {
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.filters-container select:focus {
    border-color: #667eea;
    outline: none;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
}

.breadcrumb-container {
    margin-top: 16px;
}

.category-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.breadcrumb-item {
    background: white;
    border: 2px solid #e2e8f0;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    transition: all 0.3s ease;
}

.breadcrumb-item:hover {
    border-color: #667eea;
    color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.breadcrumb-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.picker-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

.products-grid, .categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.product-item, .category-item {
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
    text-align: center;
    position: relative;
}

.product-item:hover, .category-item:hover {
    border-color: #667eea;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.15);
    transform: translateY(-2px);
}

.product-item.selected, .category-item.selected {
    border-color: #667eea;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

.product-item .product-checkbox, .category-item .category-checkbox {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 18px;
    height: 18px;
}

.product-image, .category-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    margin: 0 auto 12px;
    display: block;
    border: 1px solid #ddd;
}

.category-image {
    background: #f5f5f5;
}

.product-name, .category-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
    font-size: 13px;
    line-height: 1.3;
    height: 34px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-meta, .category-meta {
    font-size: 11px;
    color: #666;
    margin-bottom: 2px;
}

.product-price {
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 13px;
}

.stock-status {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.stock-status.instock {
    background: #e8f5e8;
    color: #388e3c;
}

.stock-status.outofstock {
    background: #ffebee;
    color: #d32f2f;
}

.stock-status.onbackorder {
    background: #fff3e0;
    color: #f57c00;
}

.category-count {
    font-size: 11px;
    color: #666;
    margin-top: 4px;
}

.category-item.has-children::after {
    content: '\25B6';
    position: absolute;
    bottom: 8px;
    right: 8px;
    color: #667eea;
    font-size: 12px;
}

.loading-spinner {
    text-align: center;
    padding: 40px;
    color: #666;
    grid-column: 1 / -1;
}

.loading-spinner .dashicons {
    margin-right: 8px;
}

.spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.picker-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    border-top: 2px solid #e2e8f0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.03) 0%, rgba(118, 75, 162, 0.03) 100%);
}

.picker-pagination .button,
#prev-products,
#next-products {
    background: white !important;
    border: 2px solid #e2e8f0 !important;
    color: #475569 !important;
    padding: 8px 16px !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    font-size: 13px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
}

.picker-pagination .button:hover:not(:disabled),
#prev-products:hover:not(:disabled),
#next-products:hover:not(:disabled) {
    border-color: #667eea !important;
    color: #667eea !important;
    background: rgba(102, 126, 234, 0.05) !important;
}

.picker-pagination .button:disabled,
#prev-products:disabled,
#next-products:disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
}

.pagination-info {
    font-size: 14px;
    font-weight: 600;
    color: #475569;
}

.picker-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-top: 2px solid #e2e8f0;
    background: white;
}

.selected-count {
    font-weight: 700;
    color: #1e293b;
    font-size: 14px;
}

.selected-count span {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.picker-actions {
    display: flex;
    gap: 12px;
}

/* Picker Action Buttons */
#clear-product-selection,
#clear-category-selection {
    background: white !important;
    border: 2px solid #e2e8f0 !important;
    color: #475569 !important;
    padding: 10px 20px !important;
    border-radius: 10px !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
}

#clear-product-selection:hover,
#clear-category-selection:hover {
    border-color: #ef4444 !important;
    color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.05) !important;
}

#confirm-product-selection,
#confirm-category-selection {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    border: none !important;
    color: white !important;
    padding: 10px 24px !important;
    border-radius: 10px !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3) !important;
}

#confirm-product-selection:hover,
#confirm-category-selection:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4) !important;
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 95%;
        margin: 20px;
    }

    .filters-container {
        grid-template-columns: 1fr;
    }

    .products-grid, .categories-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }

    .picker-footer {
        flex-direction: column;
        gap: 12px;
    }

    .picker-actions {
        width: 100%;
        justify-content: center;
    }
}
