/* Admin Reports — /admin-reports/ styling (Issue #7668 + #7671)
   @author Olivier RAVEAU - Oliv.Ai 🥷 */

.cw-admin-reports-wrap {
    max-width: 1400px;
    margin: 24px auto;
    padding: 0 16px;
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
    color: #2c3e50;
}

/* Issue #7671 — banner H1 hack removed. The real WP page (slug=admin-reports,
   post_id=67451) now provides the title naturally — no need to suppress it. */

/* ============================================================
   CARD SYSTEM (Issue #7671 M9-M11) — 3 cards stacked
   ============================================================ */
.cw-card {
    background: #fff;
    border: 1px solid #e1e5ea;
    border-radius: 8px;
    padding: 18px 22px;
    margin-bottom: 22px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.cw-card h2 {
    margin-top: 0;
    margin-bottom: 14px;
    font-size: 1.15rem;
    color: #34495e;
    border-bottom: 1px solid #eef0f3;
    padding-bottom: 8px;
}

/* Intro card — BLUE (Issue #7671 M9, FIX #6) */
.cw-card-intro {
    background: linear-gradient(135deg, #eaf4fb 0%, #d6e8f5 100%);
    border-color: #b8d8ec;
    color: #1e3a5f;
}
.cw-card-intro p { margin: 0 0 6px; font-size: 0.95rem; line-height: 1.5; }
.cw-card-meta {
    margin-top: 10px;
    font-size: 0.8rem;
    color: #5f6368;
}

/* Config card */
.cw-card-config { background: #fff; }
.cw-config-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 28px;
    margin-bottom: 16px;
}
@media (max-width: 900px) { .cw-config-grid { grid-template-columns: 1fr; } }

.cw-config-block .cw-block-label {
    display: block;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 4px;
    font-size: 0.95rem;
}
.cw-config-block .description {
    color: #5f6368;
    font-size: 0.85rem;
    margin: 4px 0 8px;
}
.cw-reports-textarea {
    width: 100%;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.88rem;
    border: 1px solid #c6cbd2;
    border-radius: 4px;
    padding: 8px;
}

/* Date range inputs (Issue #7671 M12) */
.cw-date-range {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.cw-date-range .cw-date-label {
    font-weight: 600;
    color: #34495e;
    min-width: 36px;
}
.cw-date-range input[type="date"] {
    padding: 6px 10px;
    border: 1px solid #c6cbd2;
    border-radius: 4px;
    font-size: 0.9rem;
}

/* Issue #7671 — DUAL date field: text display "DD/MM/YYYY" + hidden ISO picker */
.cw-date-wrapper {
    position: relative;
    display: inline-block;
}
.cw-date-display {
    padding: 6px 10px;
    border: 1px solid #c6cbd2;
    border-radius: 4px;
    font-size: 0.9rem;
    width: 130px;
    cursor: pointer;
    background: #fff;
}
.cw-date-display:focus {
    outline: 2px solid #2563eb;
    outline-offset: 1px;
}
.cw-date-iso {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;   /* picker is opened programmatically via showPicker() */
}
.cw-date-hint {
    color: #5f6368;
    font-size: 0.78rem;
    margin: 6px 0 0;
}
.cw-date-hint code {
    background: #f4f6f9;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.78rem;
}

/* Issue #7671 — live stats counter for selected date range */
.cw-range-stats {
    margin-top: 10px;
    min-height: 24px;
}
.cw-range-stats-loading { color: #5f6368; font-style: italic; }
.cw-stats-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 3px solid #2563eb;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 0.88rem;
}
.cw-stats-row { margin: 2px 0; line-height: 1.4; }
.cw-stats-row small { color: #5f6368; }

.cw-config-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #eef0f3;
}

/* Issue #7671 — explicit button styling so they POP regardless of theme reset */
#cw-reports-save,
#cw-reports-run-now {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.15s ease, opacity 0.15s ease;
    border: 1px solid transparent;
    text-decoration: none;
    line-height: 1.2;
}
#cw-reports-save {
    /* PRIMARY — blue gradient, save action */
    background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    border-color: #1e40af;
    box-shadow: 0 1px 0 rgba(255,255,255,0.25) inset, 0 1px 3px rgba(37, 99, 235, 0.35);
}
#cw-reports-save:hover {
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.45);
}
#cw-reports-save:active { transform: translateY(0); }

#cw-reports-run-now {
    /* SECONDARY — green action, "go fetch + send NOW" */
    background: linear-gradient(180deg, #16a34a 0%, #15803d 100%);
    color: #fff;
    border-color: #166534;
    box-shadow: 0 1px 0 rgba(255,255,255,0.25) inset, 0 1px 3px rgba(22, 163, 74, 0.35);
}
#cw-reports-run-now:hover {
    background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(22, 163, 74, 0.45);
}
#cw-reports-run-now:active { transform: translateY(0); }
#cw-reports-run-now:disabled,
#cw-reports-save:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.cw-date-fmt-hint {
    color: #5f6368;
    font-size: 0.78rem;
    font-style: italic;
    margin-left: 4px;
}
.cw-status,
.cw-reports-status {
    margin-left: 8px;
    font-size: 0.88rem;
    font-weight: 500;
}
.cw-status-success { color: #16a34a; }
.cw-status-error   { color: #dc2626; }
.cw-status-info    { color: #2563eb; }

/* History card */
.cw-card-history { padding-bottom: 24px; }
.cw-card-history table { width: 100%; border-collapse: collapse; }
.cw-card-history th,
.cw-card-history td {
    padding: 8px 10px;
    border-bottom: 1px solid #eef0f3;
    text-align: left;
    font-size: 0.9rem;
}
.cw-card-history th {
    background: #f7f9fc;
    font-weight: 600;
    color: #34495e;
}

/* DataTables top + bottom toolbar (Issue #7671 M16) */
.cw-dt-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 12px;
    flex-wrap: wrap;
}
.cw-dt-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    gap: 12px;
    flex-wrap: wrap;
}
.dataTables_length label,
.dataTables_filter label,
.dataTables_info {
    font-size: 0.85rem;
    color: #5f6368;
}
.dataTables_length select {
    padding: 4px 6px;
    border: 1px solid #c6cbd2;
    border-radius: 4px;
    margin: 0 4px;
}
.dataTables_filter input[type="search"] {
    padding: 4px 8px;
    border: 1px solid #c6cbd2;
    border-radius: 4px;
    margin-left: 6px;
}

/* Status + trigger badges */
.cw-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;     /* Issue #7671 — no text wrap inside badges */
    vertical-align: middle;
}
.cw-range-arrow {
    color: #6b7280;
    font-weight: 700;
    font-size: 0.85rem;
    margin: 0 2px;
    white-space: nowrap;
}
.cw-badge-green  { background: #d1fae5; color: #065f46; }
.cw-badge-orange { background: #fed7aa; color: #92400e; }
.cw-badge-red    { background: #fecaca; color: #991b1b; }
.cw-badge-blue   { background: #dbeafe; color: #1e40af; }
.cw-badge-purple { background: #ede9fe; color: #5b21b6; }
.cw-badge-gray   { background: #e5e7eb; color: #374151; }
.cw-badge-mono   { font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* Issue #7671 — recipient column: one badge per email, vertical or wrapped */
.cw-badge-email {
    margin: 1px 2px;
    font-size: 0.75rem;
}
td.cw-col-recipients,
.cw-card-history td:nth-child(3) {
    line-height: 1.6;
    max-width: 320px;
    word-break: break-word;
}

/* Clickable rows (Issue #7671 M17) */
.cw-clickable-rows tbody tr.cw-row-clickable { cursor: pointer; }
.cw-clickable-rows tbody tr.cw-row-clickable:hover {
    background: #f0f7fc;
    transition: background 0.12s ease;
}
.cw-col-download { text-align: center; }
.cw-download-icon {
    text-decoration: none;
    font-size: 1.2rem;
    cursor: pointer;
}
.cw-download-icon:hover { transform: scale(1.15); }

.cw-reports-denied {
    padding: 24px;
    color: #c0392b;
    text-align: center;
    font-weight: 500;
}

/* Sortable headers — Issue #7671 M15 */
.cw-card-history table.dataTable thead .sorting,
.cw-card-history table.dataTable thead .sorting_asc,
.cw-card-history table.dataTable thead .sorting_desc {
    cursor: pointer;
}
