/* Magento Cart Rules Agent - Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Initial state - hide main app, show modal */
#mainApp {
    display: none;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 20px 0;
    box-shadow: var(--shadow);
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 24px;
    font-weight: 600;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-logo {
    height: 40px;
    width: 35px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.store-info {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Navigation Tabs */
.nav-tabs {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    margin-bottom: 32px;
}

.nav-tabs .container {
    display: flex;
    gap: 8px;
}

.tab-btn {
    background: none;
    border: none;
    padding: 16px 24px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--background);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Content Areas */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Center values in the Activity Log table */
#activityLog .data-table table tbody td {
    text-align: center;
}
#activityLog .data-table table thead th {
    text-align: center;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.content-header h2 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 0;
}

.content-header .actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

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

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

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

.btn-xs {
    padding: 2px 6px;
    font-size: 11px;
}

.btn-link {
    background: none;
    border: none;
    color: #0066cc;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    font-weight: 500;
}

.btn-link:hover {
    color: #0052a3;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="datetime-local"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group textarea {
    font-family: inherit;
    resize: vertical;

/* Small help icon next to labels */
.help-icon {
    display: inline-block;
    margin-left: 8px;
    background: var(--primary-color);
    color: #fff;
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 50%;
    font-size: 12px;
    cursor: default;
    opacity: 0.95;
}
.help-icon:hover {
    opacity: 1;
}
    min-height: 80px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.form-section {
    background: var(--surface);
    padding: 24px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.form-section h3 {
    font-size: 18px;
    margin-bottom: 20px;
    font-weight: 600;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-bottom: 40px;
}

.search-input {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    width: 300px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

/* Tables */
.data-table {
    width: 100%;
    background: var(--surface);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    overflow-x: auto; /* Enable horizontal scroll for wide tables */
}

.data-table table {
    width: 100%;
    border-collapse: collapse;
    min-width: 900px; /* Reduced minimum width for better responsiveness */
    table-layout: auto;
}

.data-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    vertical-align: top;
}

.data-table th {
    padding: 8px 10px;
    background: var(--background);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Responsive adjustments */
@media (max-width: 1100px) {
    .data-table table { min-width: 750px; }
    .data-table th, .data-table td { font-size: 12px; padding: 6px 8px; }
    .data-table th:nth-child(10), .data-table td:nth-child(10) { width: 100px; }
}

@media (max-width: 800px) {
    .data-table table { min-width: 600px; }
    .data-table th, .data-table td { font-size: 11px; padding: 5px 6px; }
    .data-table th:nth-child(3), .data-table td:nth-child(3) { width: 120px; }
    .data-table th:nth-child(10), .data-table td:nth-child(10) { width: 80px; }
    .data-table td:nth-child(10) button { padding: 4px 6px; font-size: 11px; }
}

@media (max-width: 480px) {
    .data-table table { min-width: 100%; }
    .data-table th, .data-table td { font-size: 11px; padding: 4px 6px; }
    .data-table th:nth-child(3), .data-table td:nth-child(3) { width: 90px; }
    .data-table th:nth-child(10), .data-table td:nth-child(10) { width: 60px; }
    .data-table td:nth-child(10) button { padding: 3px 5px; font-size: 10px; }
}

/* Specific column widths for better layout */
.data-table th:nth-child(1), .data-table td:nth-child(1) { width: 40px; } /* Checkbox */
.data-table th:nth-child(2), .data-table td:nth-child(2) { width: 60px; } /* ID */
.data-table th:nth-child(3), .data-table td:nth-child(3) { width: 25%; } /* Name */
.data-table th:nth-child(4), .data-table td:nth-child(4) { width: 120px; } /* Coupon Code */
.data-table th:nth-child(5), .data-table td:nth-child(5) { width: 120px; } /* Coupon Type */
.data-table th:nth-child(6), .data-table td:nth-child(6) { width: 80px; } /* Discount */
.data-table th:nth-child(7), .data-table td:nth-child(7) { width: 80px; } /* Status */
.data-table th:nth-child(8), .data-table td:nth-child(8) { width: 60px; } /* Uses */
.data-table th:nth-child(9), .data-table td:nth-child(9) { width: 100px; } /* Start Date */
.data-table th:nth-child(10), .data-table td:nth-child(10) { width: 140px; } /* Actions */

/* Center Start and End date columns for better readability */
.data-table th:nth-child(8), .data-table td:nth-child(8),
.data-table th:nth-child(9), .data-table td:nth-child(9) {
    text-align: center;
    vertical-align: middle;
}

/* Schedule table: center Start Date and End Date (columns 2 and 3 in schedules view) */
#schedulesTable .data-table th:nth-child(2),
#schedulesTable .data-table td:nth-child(2),
#schedulesTable .data-table th:nth-child(3),
#schedulesTable .data-table td:nth-child(3) {
    text-align: center;
    vertical-align: middle;
}

/* Center all header and cell values inside the schedules table */
#schedulesTable .data-table th,
#schedulesTable .data-table td {
    text-align: center;
    vertical-align: middle;
}

.data-table th {
    background: var(--background);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-secondary);
    white-space: nowrap;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover {
    background: var(--background);
}

/* Name column styling */
.data-table td:nth-child(3) strong {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

/* Actions column */
.data-table td:nth-child(10) {
    white-space: nowrap;
}

.data-table td:nth-child(10) button {
    margin-right: 4px;
    padding: 4px 8px;
    font-size: 12px;
}

/* Rule Description removed - UI no longer shows description */

/* Rule Coupon Code Display */
.rule-coupon {
    font-size: 12px;
    color: #0066cc;
    margin-top: 4px;
    font-weight: 500;
    line-height: 1.3;
}

/* Rule Actions/Conditions Display */
.rule-actions {
    font-size: 12px;
    color: #006600;
    margin-top: 2px;
    font-weight: 500;
    line-height: 1.3;
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
}

/* Connection modal shows by default (before authentication) */
#connectionModal {
    display: flex;
}

.modal.active {
    display: flex !important;
}

.modal-content {
    background: var(--surface);
    padding: 32px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal-content h2 {
    margin-bottom: 24px;
    font-size: 24px;
    font-weight: 600;
}

.close {
    color: var(--text-secondary);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: var(--text-primary);
}

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

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: var(--surface);
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary-color);
    min-width: 300px;
    animation: slideIn 0.3s ease;
}

.toast-success {
    border-left-color: var(--success-color);
}

.toast-error {
    border-left-color: var(--danger-color);
}

.toast-warning {
    border-left-color: var(--warning-color);
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Analytics */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--surface);
    padding: 24px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.stat-card h3 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.stat-card .value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-color);
}

/* Bulk Actions */
.bulk-actions {
    background: var(--surface);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
    align-items: center;
}

.selected-count {
    font-weight: 500;
    margin-right: auto;
}

/* Error Message */
.error-message {
    background: #fee2e2;
    color: #991b1b;
    padding: 12px;
    border-radius: 6px;
    margin-top: 16px;
}

/* Springerpub Coupon Reporting Styles */
.bi-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    padding: 24px 0;
}

.bi-summary-section,
.bi-insights-section,
.bi-metrics-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.bi-summary-section h3,
.bi-insights-section h3,
.bi-metrics-section h3 {
    margin-bottom: 16px;
    color: var(--text-primary);
    font-size: 18px;
}

.bi-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    align-items: stretch;
}

.bi-metric-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 16px;
    border-radius: 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 130px;
    box-sizing: border-box;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.bi-metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.18);
}

.bi-metric-card.revenue {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.bi-metric-card.discount {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.bi-metric-card.orders {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
}

.bi-metric-card.customers {
    background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
}

.bi-metric-card.aov {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
}

.bi-metric-card.coupon-orders {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
}

.bi-metric-card.adoption {
    background: linear-gradient(135deg, #14b8a6 0%, #0f766e 100%);
}

.bi-metric-card.avg-discount {
    background: linear-gradient(135deg, #ec4899 0%, #be185d 100%);
}

.bi-metric-icon {
    font-size: 1.6rem;
    margin-bottom: 6px;
    line-height: 1;
}

.bi-metric-label {
    font-size: 13px;
    opacity: 0.9;
    margin-bottom: 6px;
    font-weight: 500;
    line-height: 1.3;
}

.bi-metric-value {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 2px;
    line-height: 1.1;
    word-break: break-word;
}

.bi-metric-change {
    font-size: 11px;
    opacity: 0.8;
}

/* ─── Product Search Picker ─────────────────────────────── */
.product-search-wrapper {
    position: relative;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    padding: 6px 8px;
    min-height: 42px;
    box-sizing: border-box;
}

.product-search-wrapper:focus-within {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.product-selected-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}

.product-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 13px;
    color: #1e40af;
    max-width: 260px;
}

.product-tag-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 220px;
}

.product-tag-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: #60a5fa;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
    flex-shrink: 0;
}

.product-tag-remove:hover {
    color: #1d4ed8;
}

.product-search-input-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.product-search-input-row input[type="text"] {
    border: none;
    outline: none;
    flex: 1;
    font-size: 14px;
    padding: 4px 2px;
    background: transparent;
    min-width: 160px;
}

.product-search-spinner {
    font-size: 14px;
}

.product-search-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: -1px;
    right: -1px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 260px;
    overflow-y: auto;
    z-index: 1000;
}

.product-search-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid #f3f4f6;
    outline: none;
}

.product-search-item:last-child {
    border-bottom: none;
}

.product-search-item:hover,
.product-search-item:focus {
    background: #eff6ff;
}

.product-item-selected {
    opacity: 0.5;
    cursor: default;
}

.product-item-sku {
    font-weight: 600;
    color: #1e40af;
    white-space: nowrap;
    font-family: monospace;
}

.product-item-name {
    color: #374151;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.product-item-type {
    font-size: 11px;
    color: #9ca3af;
    white-space: nowrap;
    background: #f3f4f6;
    border-radius: 3px;
    padding: 1px 5px;
    flex-shrink: 0;
}

.product-no-results {
    padding: 10px 12px;
    color: #9ca3af;
    font-size: 13px;
    font-style: italic;
}
/* ─────────────────────────────────────────────────────────── */

/* Exclude toggle */
.exclude-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    margin-bottom: 8px;
    width: fit-content;
}

.exclude-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #ef4444;
    cursor: pointer;
    flex-shrink: 0;
}

.exclude-toggle:has(input:checked) span:first-of-type {
    color: #ef4444;
}

.exclude-hint {
    font-size: 12px;
    color: #6b7280;
    font-weight: 400;
    margin-left: 4px;
}

.exclude-toggle input:checked ~ .exclude-hint {
    color: #b91c1c;
}
/* ─────────────────────────────────────────────────────────── */

.claude-insights {
    background: #f0f9ff;
    border-left: 4px solid #0ea5e9;
    padding: 20px;
    border-radius: 6px;
    line-height: 1.8;
    color: #1e293b;
}

.claude-insights h4 {
    color: #0369a1;
    margin-top: 16px;
    margin-bottom: 8px;
    font-size: 16px;
}

.claude-insights ul,
.claude-insights ol {
    margin-left: 20px;
    margin-bottom: 12px;
}

.claude-insights li {
    margin-bottom: 8px;
}

.claude-insights strong {
    color: #0c4a6e;
}

/* AI Insights Card Grid */
.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

.insight-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.insight-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.insight-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(to right, #f0f9ff, #f8fafc);
    border-bottom: 1px solid #e2e8f0;
    font-weight: 600;
    color: #0369a1;
}

.insight-icon {
    font-size: 18px;
}

.insight-title {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.insight-content {
    padding: 16px;
    font-size: 14px;
    line-height: 1.7;
    color: #334155;
    max-height: 300px;
    overflow-y: auto;
}

/* Daily Revenue (YoY) table styling */
.yoy-table-wrapper {
    overflow-x: auto;
}
.yoy-revenue-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}
.yoy-revenue-table th,
.yoy-revenue-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    vertical-align: middle;
    text-align: center; /* center numeric cells by default */
}
/* Keep Day and Date columns left-aligned for readability */
.yoy-revenue-table td:first-child,
.yoy-revenue-table td:nth-child(2),
.yoy-revenue-table th:first-child,
.yoy-revenue-table th:nth-child(2) {
    text-align: left;
}
.yoy-revenue-table td.currency {
    white-space: nowrap;
}


.insight-content p {
    margin: 0 0 12px 0;
}

.insight-content p:last-child {
    margin-bottom: 0;
}

.insight-content ul {
    margin: 8px 0 12px 0;
    padding-left: 20px;
}

.insight-content li {
    margin-bottom: 6px;
}

.insight-content strong {
    color: #0c4a6e;
}

/* Scrollbar styling for insight content */
.insight-content::-webkit-scrollbar {
    width: 6px;
}

.insight-content::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.insight-content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.insight-content::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.bi-metrics-table {
    overflow-x: auto;
}

.bi-metrics-table table {
    width: 100%;
    border-collapse: collapse;
}

.bi-metrics-table thead {
    background: #f1f5f9;
    border-bottom: 2px solid var(--border);
}

.bi-metrics-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
}

.bi-metrics-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.bi-metrics-table tbody tr:hover {
    background: #f8fafc;
}

.loading-skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    height: 100px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Responsive */
@media (max-width: 768px) {
    .header .container {
        flex-direction: column;
        gap: 16px;
    }

    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .nav-tabs .container {
        overflow-x: auto;
    }

    .bi-summary-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .bi-metric-card {
        min-height: 110px;
        padding: 16px 12px;
    }

    .bi-metric-value {
        font-size: 22px;
    }
}

@media (max-width: 480px) {
    .bi-summary-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .bi-metric-card {
        min-height: 100px;
        padding: 14px 10px;
    }

    .bi-metric-value {
        font-size: 20px;
    }

    .bi-metric-label {
        font-size: 11px;
    }
}

/* Chat loading animation */
@keyframes pulse {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1); }
}

/* Date picker styling */
input[type="date"] {
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

input[type="date"]:hover {
    border-color: #0073aa;
    box-shadow: 0 2px 4px rgba(0, 115, 170, 0.1);
}

input[type="date"]:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.15);
}

/* Webkit date picker icon styling */
input[type="date"]::-webkit-calendar-picker-indicator {
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%230073aa'%3E%3Cpath d='M19 4h-1V2h-2v2H8V2H6v2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 16H5V10h14v10zM9 14H7v-2h2v2zm4 0h-2v-2h2v2zm4 0h-2v-2h2v2zm-8 4H7v-2h2v2zm4 0h-2v-2h2v2zm4 0h-2v-2h2v2z'/%3E%3C/svg%3E") no-repeat center;
    width: 20px;
    height: 20px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* Date filter container */
.date-filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 10px;
}

.date-filter-label {
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
}

/* Order Details Report Section */
.bi-order-details-section {
    margin-top: 32px;
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.bi-order-details-section .section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.bi-order-details-section .section-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.bi-order-details-section .section-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-select-small {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    background: white;
}

.order-details-wrapper {
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
}

.order-details-data {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.order-details-data thead {
    background: #f1f5f9;
    position: sticky;
    top: 0;
    z-index: 10;
}

.order-details-data th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.order-details-data td {
    padding: 8px 12px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.order-details-data tbody tr:hover {
    background: #f8fafc;
}

.order-details-data .coupon-cell {
    color: #0369a1;
    font-weight: 500;
}

.order-details-data .product-name {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.order-details-data code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: monospace;
}

.order-details-data .currency {
    text-align: right;
    font-family: monospace;
}

.order-details-data .discount {
    color: #dc2626;
}

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    text-transform: capitalize;
}

.status-complete {
    background: #d1fae5;
    color: #065f46;
}

.status-processing {
    background: #dbeafe;
    color: #1e40af;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-canceled {
    background: #fee2e2;
    color: #991b1b;
}

/* Marketing Details - YoY Section */
.marketing-container {
    padding: 20px 0;
}

.yoy-summary-section,
.yoy-table-section {
    margin-bottom: 32px;
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.yoy-summary-section h3,
.yoy-table-section h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.yoy-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.yoy-summary-card {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 16px;
    border-left: 4px solid var(--border);
}

.yoy-summary-card.revenue {
    border-left-color: #0ea5e9;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
}

.yoy-summary-card.positive {
    border-left-color: #22c55e;
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
}

.yoy-summary-card.negative {
    border-left-color: #ef4444;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}

.yoy-summary-card.orders {
    border-left-color: #8b5cf6;
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
}

.yoy-card-label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.yoy-card-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.yoy-card-subtitle {
    font-size: 13px;
    color: #6b7280;
}

.yoy-table-wrapper {
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

.yoy-revenue-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.yoy-revenue-table thead {
    background: #f1f5f9;
    position: sticky;
    top: 0;
    z-index: 10;
}

.yoy-revenue-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.yoy-revenue-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.yoy-revenue-table tbody tr:hover {
    background: #f8fafc;
}

.yoy-revenue-table .currency {
    text-align: right;
    font-family: monospace;
}

.yoy-revenue-table .percent {
    text-align: right;
    font-weight: 500;
}

.yoy-revenue-table .positive {
    color: #22c55e;
}

.yoy-revenue-table .negative {
    color: #ef4444;
}

/* Chart Section */
.yoy-chart-section {
    margin-bottom: 32px;
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.yoy-chart-section h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.chart-container {
    position: relative;
    height: 400px;
    width: 100%;
}

/* Header Actions Group */
.header-actions-group {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* Month Selector */
.month-selector-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.month-selector-wrapper label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.month-selector {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: white;
    color: var(--text-primary);
    cursor: pointer;
    min-width: 150px;
}

.month-selector:hover {
    border-color: var(--primary);
}

.month-selector:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

/* Responsive Grid Styles */
@media (max-width: 1400px) {
    .data-table table {
        min-width: 900px;
    }
    
    .data-table th:nth-child(3), .data-table td:nth-child(3) { width: 22%; } /* Name */
    .data-table th:nth-child(4), .data-table td:nth-child(4) { width: 100px; } /* Coupon Code */
}

@media (max-width: 1200px) {
    .data-table table {
        min-width: 800px;
    }
    
    .data-table th:nth-child(3), .data-table td:nth-child(3) { width: 20%; } /* Name */
    .data-table th:nth-child(4), .data-table td:nth-child(4) { width: 100px; } /* Coupon Code */
    .data-table th:nth-child(5), .data-table td:nth-child(5) { width: 100px; } /* Coupon Type */
    
    .rule-actions {
        display: none; /* Hide action conditions on smaller screens */
    }
}

@media (max-width: 768px) {
    .data-table {
        border-radius: 4px;
    }
    
    .data-table table {
        min-width: 700px;
        font-size: 13px;
    }
    
    .data-table th,
    .data-table td {
        padding: 10px 12px;
    }
    
    .data-table th:nth-child(1), .data-table td:nth-child(1) { width: 35px; } /* Checkbox */
    .data-table th:nth-child(2), .data-table td:nth-child(2) { width: 50px; } /* ID */
    .data-table th:nth-child(3), .data-table td:nth-child(3) { width: 18%; } /* Name */
    .data-table th:nth-child(4), .data-table td:nth-child(4) { width: 90px; } /* Coupon Code */
    .data-table th:nth-child(5), .data-table td:nth-child(5) { display: none; } /* Hide Coupon Type */
    .data-table th:nth-child(6), .data-table td:nth-child(6) { width: 70px; } /* Discount */
    .data-table th:nth-child(7), .data-table td:nth-child(7) { width: 70px; } /* Status */
    .data-table th:nth-child(8), .data-table td:nth-child(8) { display: none; } /* Hide Uses */
    .data-table th:nth-child(9), .data-table td:nth-child(9) { display: none; } /* Hide Start Date */
    .data-table th:nth-child(10), .data-table td:nth-child(10) { width: 110px; } /* Actions */
    
    .data-table td:nth-child(10) button {
        padding: 3px 6px;
        font-size: 11px;
        margin-right: 2px;
    }
    
    .data-table th {
        font-size: 11px;
        padding: 8px 12px;
    }
    
    /* Rule description styling removed */
}

/* Hide scrollbar but keep scrolling */
.data-table::-webkit-scrollbar {
    height: 8px;
}

.data-table::-webkit-scrollbar-track {
    background: var(--background);
}

.data-table::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.data-table::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ── Rules table pagination ─────────────────────────────── */
.rules-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 10px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
    gap: 8px;
}

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

.rules-page-label {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}

.rules-page-btn {
    padding: 4px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--background);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.8125rem;
    transition: background 0.15s, border-color 0.15s;
}

.rules-page-btn:hover:not(:disabled) {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.rules-page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Rule Detail Panel – full-width two-column layout ─────────────────── */
.rule-detail-form {
    width: 100%;
    max-width: 100%;
}

.rule-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
    margin-bottom: 20px;
}

.rule-detail-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.rule-detail-col .form-section {
    margin-bottom: 0;
}

#ruleDetailPanel .content-header {
    flex-wrap: wrap;
    gap: 12px;
}

@media (max-width: 900px) {
    .rule-detail-grid {
        grid-template-columns: 1fr;
    }
}