/* ============================================
   Coupons Dashboard – Mood Pricing v2.9.0
   ============================================ */

/* ---- Page Header ---- */
.coupons-dashboard {
    padding: 0;
    opacity: 1 !important;
    animation: none !important;
}

.cpn-header {
    background: linear-gradient(135deg, #ffffff 0%, #faf8f5 100%);
    padding: 1.25rem 1.5rem;
    border-radius: var(--radius, 0.75rem);
    border: 1px solid var(--border, #e5e7eb);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.cpn-title {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-main, #141414);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cpn-title i {
    color: #667eea;
    font-size: 1.125rem;
}

.cpn-subtitle {
    font-size: 0.8125rem;
    color: var(--text-muted, #6b7280);
    margin: 0.25rem 0 0;
}

.cpn-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.cpn-badge {
    font-size: 0.7rem;
    color: var(--text-muted, #6b7280);
    background: #f9fafb;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    border: 1px solid #e5e7eb;
}

.cpn-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

.cpn-btn-outline {
    background: #fff;
    color: #374151;
    border-color: #d1d5db;
}

.cpn-btn-outline:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.cpn-btn-primary {
    background: #667eea;
    color: #fff;
}

.cpn-btn-primary:hover {
    background: #5a6fd6;
}

/* ---- Filters Section ---- */
.cpn-filters {
    background: #fff;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: var(--radius, 0.75rem);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.cpn-filters-row {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

.cpn-filter-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted, #6b7280);
    margin-bottom: 0.375rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.cpn-filter-group label i {
    margin-right: 0.25rem;
}

.cpn-date-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cpn-date-sep {
    font-size: 0.75rem;
    color: var(--text-muted, #6b7280);
}

.cpn-input {
    padding: 0.4375rem 0.625rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.8125rem;
    color: var(--text-main, #141414);
    background: #fff;
    transition: border-color 0.15s;
}

.cpn-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102,126,234,0.12);
}

.cpn-date-presets {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.cpn-preset {
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s;
}

.cpn-preset:hover {
    background: #e5e7eb;
}

.cpn-preset-active {
    background: #667eea;
    color: #fff;
    border-color: #667eea;
}

.cpn-preset-active:hover {
    background: #5a6fd6;
}

.cpn-filter-search {
    flex: 1;
    min-width: 180px;
}

.cpn-filter-search .cpn-input {
    width: 100%;
}

/* ---- KPI Row ---- */
.cpn-kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.cpn-kpi {
    background: #fff;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: var(--radius, 0.75rem);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: box-shadow 0.2s;
}

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

.cpn-kpi-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.cpn-kpi-purple { background: #ede9fe; color: #7c3aed; }
.cpn-kpi-red { background: #fee2e2; color: #ef4444; }
.cpn-kpi-green { background: #d1fae5; color: #10b981; }
.cpn-kpi-orange { background: #ffedd5; color: #f97316; }
.cpn-kpi-blue { background: #dbeafe; color: #3b82f6; }
.cpn-kpi-teal { background: #ccfbf1; color: #14b8a6; }

.cpn-kpi-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.cpn-kpi-value {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-main, #141414);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cpn-kpi-label {
    font-size: 0.6875rem;
    color: var(--text-muted, #6b7280);
    margin-top: 0.125rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* ---- Chart Cards ---- */
.cpn-charts-row {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.cpn-charts-single {
    grid-template-columns: 1fr;
}

.cpn-chart-card {
    background: #fff;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: var(--radius, 0.75rem);
    overflow: hidden;
}

.cpn-chart-header {
    padding: 0.875rem 1.125rem 0;
}

.cpn-chart-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main, #141414);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.cpn-chart-header h3 i {
    color: #9ca3af;
    font-size: 0.8125rem;
}

.cpn-chart-body {
    padding: 0.75rem 1rem 1rem;
    position: relative;
}

/* ---- Table Card ---- */
.cpn-table-card {
    background: #fff;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: var(--radius, 0.75rem);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.cpn-table-header {
    padding: 0.875rem 1.125rem;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cpn-table-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main, #141414);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.cpn-table-header h3 i {
    color: #9ca3af;
}

.cpn-table-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

#cpnTableCount {
    font-size: 0.75rem;
    color: var(--text-muted, #6b7280);
}

.cpn-table-wrap {
    overflow-x: auto;
}

.cpn-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.cpn-table thead th {
    background: #f9fafb;
    padding: 0.625rem 0.75rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-muted, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    border-bottom: 1px solid #e5e7eb;
    user-select: none;
}

.cpn-sortable {
    cursor: pointer;
    transition: color 0.15s;
}

.cpn-sortable:hover {
    color: #667eea !important;
}

.cpn-sortable i {
    font-size: 0.625rem;
    margin-left: 0.25rem;
    opacity: 0.5;
}

.cpn-table tbody td {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid #f3f4f6;
    color: var(--text-main, #141414);
}

.cpn-row {
    cursor: pointer;
    transition: background 0.1s;
}

.cpn-row:hover {
    background: #f8f7ff;
}

.cpn-col-code {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cpn-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    background: #f3f4f6;
    border-radius: 50%;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted, #6b7280);
    flex-shrink: 0;
}

.cpn-code-name {
    color: #374151;
    font-weight: 600;
    white-space: nowrap;
}

.cpn-col-num {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
}

.cpn-col-discount {
    color: #ef4444;
    font-weight: 500;
}

.cpn-col-revenue {
    color: #10b981;
    font-weight: 500;
}

.cpn-pct-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.cpn-badge-green { background: #d1fae5; color: #065f46; }
.cpn-badge-orange { background: #ffedd5; color: #9a3412; }
.cpn-badge-red { background: #fee2e2; color: #991b1b; }

/* Footer */
.cpn-footer-row td {
    background: #f9fafb;
    border-top: 2px solid #e5e7eb;
    padding: 0.625rem 0.75rem;
    font-weight: 600;
}

.cpn-loading-cell {
    text-align: center;
    padding: 3rem !important;
    color: var(--text-muted, #6b7280);
}

.cpn-error-cell {
    color: #dc2626 !important;
}

/* ---- Pagination ---- */
.cpn-pagination {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.cpn-page-btn {
    min-width: 1.75rem;
    height: 1.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: all 0.15s;
    padding: 0 0.375rem;
}

.cpn-page-btn:hover:not(:disabled) {
    background: #f3f4f6;
    border-color: #9ca3af;
}

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

.cpn-page-active {
    background: #667eea !important;
    color: #fff !important;
    border-color: #667eea !important;
}

.cpn-page-dots {
    font-size: 0.75rem;
    color: #9ca3af;
    padding: 0 0.25rem;
}

/* ---- Modal ---- */
.cpn-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.cpn-modal {
    background: #fff;
    border-radius: 0.75rem;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
    width: 90%;
    max-width: 900px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.cpn-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e5e7eb;
}

.cpn-modal-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 700;
    color: #667eea;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cpn-modal-close {
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: #f3f4f6;
    border-radius: 50%;
    cursor: pointer;
    color: #374151;
    font-size: 0.875rem;
    transition: all 0.15s;
}

.cpn-modal-close:hover {
    background: #e5e7eb;
}

.cpn-modal-kpis {
    display: flex;
    gap: 1rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid #f3f4f6;
    background: #fafbfc;
    flex-wrap: wrap;
}

.cpn-modal-kpi {
    display: flex;
    flex-direction: column;
    min-width: 100px;
}

.cpn-modal-kpi-val {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main, #141414);
}

.cpn-modal-kpi-lbl {
    font-size: 0.6875rem;
    color: var(--text-muted, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.cpn-text-red { color: #ef4444; }
.cpn-text-blue { color: #667eea; }

.cpn-modal-body {
    overflow: auto;
    flex: 1;
}

.cpn-detail-table {
    font-size: 0.75rem;
}

.cpn-detail-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .cpn-header {
        flex-direction: column;
        align-items: stretch;
    }

    .cpn-header-actions {
        justify-content: flex-end;
    }

    .cpn-filters-row {
        flex-direction: column;
    }

    .cpn-kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .cpn-modal {
        width: 95%;
        max-height: 90vh;
    }
}

@media (max-width: 480px) {
    .cpn-kpi-row {
        grid-template-columns: 1fr;
    }
}
