/**
 * Reports Engine Frontend Styles
 *
 * @package ReportsEngine
 */

/* Container */
.reports-engine-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px 0;
}

.reports-engine-container h2 {
    margin-bottom: 20px;
    font-size: 1.5em;
    color: #23282d;
}

/* Reports List */
.reports-list {
    margin-bottom: 30px;
}

.report-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    margin-bottom: 15px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.report-card:hover {
    border-color: #2271b1;
}

.report-info h3 {
    margin: 0 0 5px 0;
    font-size: 1.1em;
    color: #23282d;
}

.report-info p {
    margin: 0;
    color: #666;
    font-size: 0.9em;
}

.report-actions {
    flex-shrink: 0;
    margin-left: 20px;
}

.btn-generate-report {
    background: #2271b1 !important;
    color: #fff !important;
    border-color: #2271b1 !important;
    padding: 8px 20px !important;
    font-size: 14px !important;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-generate-report:hover {
    background: #135e96 !important;
    border-color: #135e96 !important;
}

.btn-generate-report:disabled {
    background: #a0a5aa !important;
    border-color: #a0a5aa !important;
    cursor: not-allowed;
}

/* Reports Sections */
.reports-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

.reports-section h3 {
    margin: 0 0 15px 0;
    font-size: 1.1em;
    color: #23282d;
}

/* Collapsible Header */
.collapsible-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.collapsible-header:hover {
    color: #2271b1;
}

.collapsible-header .toggle-icon {
    font-size: 0.8em;
    transition: transform 0.2s;
}

.collapsible-header .count {
    color: #666;
    font-weight: normal;
    font-size: 0.9em;
}

/* Jobs List */
.reports-jobs-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.report-job-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    border-left: 4px solid #ccc;
    transition: all 0.3s ease;
}

.report-job-row.status-queued {
    border-left-color: #f0ad4e;
}

.report-job-row.status-running {
    border-left-color: #5bc0de;
}

.report-job-row.status-completed {
    border-left-color: #5cb85c;
}

.report-job-row.status-failed {
    border-left-color: #d9534f;
}

.job-info {
    flex: 1;
}

.job-info .job-type {
    display: block;
    font-weight: 500;
    color: #23282d;
    margin-bottom: 3px;
}

.job-info .job-date {
    display: block;
    font-size: 0.85em;
    color: #666;
}

.job-status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 20px;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 500;
    text-transform: uppercase;
}

.status-badge.status-queued {
    background: #fcf8e3;
    color: #8a6d3b;
}

.status-badge.status-running {
    background: #d9edf7;
    color: #31708f;
}

.status-badge.status-completed {
    background: #dff0d8;
    color: #3c763d;
}

.status-badge.status-failed {
    background: #f2dede;
    color: #a94442;
}

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

.btn-download {
    background: #5cb85c !important;
    color: #fff !important;
    border-color: #5cb85c !important;
    text-decoration: none !important;
}

.btn-download:hover {
    background: #449d44 !important;
    border-color: #449d44 !important;
}

.btn-retry {
    background: #f0ad4e !important;
    color: #fff !important;
    border-color: #f0ad4e !important;
}

.btn-retry:hover {
    background: #ec971f !important;
    border-color: #ec971f !important;
}

.error-message {
    cursor: help;
    font-size: 1.2em;
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #ddd;
    border-top-color: #2271b1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Responsive */
@media (max-width: 600px) {
    .report-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .report-actions {
        margin-left: 0;
        width: 100%;
    }

    .btn-generate-report {
        width: 100%;
        text-align: center;
    }

    .report-job-row {
        flex-wrap: wrap;
        gap: 10px;
    }

    .job-info {
        flex: 1 1 100%;
    }

    .job-status {
        margin: 0;
    }

    .job-actions {
        flex: 1 1 100%;
        justify-content: flex-end;
    }
}

/* Active Reports Animation */
.reports-section.active-reports .report-job-row {
    animation: slideIn 0.3s ease;
}

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

/* WooCommerce Integration - ensure styles work within My Account */
.woocommerce-account .reports-engine-container {
    padding: 0;
}

.woocommerce-account .report-card .button,
.woocommerce-account .report-job-row .button {
    margin: 0;
}

/* Report Parameters */
.report-card {
    flex-wrap: wrap;
}

.report-parameters {
    width: 100%;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.btn-toggle-params {
    background: transparent;
    border: none;
    color: #2271b1;
    cursor: pointer;
    padding: 5px 0;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-toggle-params:hover {
    color: #135e96;
    text-decoration: underline;
}

.btn-toggle-params .toggle-icon {
    font-size: 0.8em;
    transition: transform 0.2s;
}

.params-form {
    margin-top: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 4px;
}

.param-field {
    margin-bottom: 15px;
}

.param-field:last-child {
    margin-bottom: 0;
}

.param-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #23282d;
    font-size: 0.9em;
}

.param-field label .required {
    color: #d9534f;
    margin-left: 2px;
}

.param-field input[type="date"],
.param-field input[type="month"],
.param-field input[type="text"] {
    width: 100%;
    max-width: 250px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.param-field input[type="date"]:focus,
.param-field input[type="month"]:focus,
.param-field input[type="text"]:focus {
    border-color: #2271b1;
    outline: none;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.2);
}

.param-field.param-type-checkbox {
    display: flex;
    flex-direction: column;
}

.param-field .checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    color: #23282d;
    font-size: 0.9em;
}

.param-field .checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.param-description {
    display: block;
    margin-top: 5px;
    font-size: 0.8em;
    color: #666;
    font-style: italic;
}

/* Empty notice */
.reports-empty-notice {
    padding: 20px;
    background: #f8f9fa;
    border: 1px dashed #ddd;
    border-radius: 4px;
    text-align: center;
    color: #666;
}

.reports-empty-notice a {
    color: #2271b1;
}

/* Responsive for parameters */
@media (max-width: 600px) {
    .param-field input[type="date"],
    .param-field input[type="month"],
    .param-field input[type="text"] {
        max-width: 100%;
    }
}

/* Report Summary */
.btn-toggle-summary {
    background: #f0f0f1 !important;
    color: #2271b1 !important;
    border-color: #2271b1 !important;
    margin-left: 8px !important;
}

.btn-toggle-summary:hover {
    background: #2271b1 !important;
    color: #fff !important;
}

.job-summary {
    width: 100%;
    margin-top: 15px;
    padding: 25px;
    background: #ffffff;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.6;
    overflow-x: auto;
    color: #333;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.job-summary h1,
.job-summary h2,
.job-summary h3,
.job-summary h4 {
    margin-top: 1.5em;
    margin-bottom: 0.75em;
    color: #1d2327;
    font-weight: 600;
}

.job-summary h1:first-child,
.job-summary h2:first-child,
.job-summary h3:first-child {
    margin-top: 0;
}

.job-summary table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0 20px 0;
    font-size: 13px;
    background: #fff;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.job-summary th,
.job-summary td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.job-summary th {
    background: #2271b1;
    color: #fff;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: none;
}

.job-summary tbody tr {
    background: #fff;
    transition: background 0.15s ease;
}

.job-summary tbody tr:nth-child(even) {
    background: #f9fafb;
}

.job-summary tbody tr:hover {
    background: #f0f6fc;
}

.job-summary tbody tr:last-child td {
    border-bottom: none;
}

.job-summary ul,
.job-summary ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.job-summary .summary-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin: 1em 0;
}

.job-summary .stat-card {
    flex: 1 1 150px;
    padding: 15px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
}

.job-summary .stat-value {
    font-size: 1.5em;
    font-weight: bold;
    color: #2271b1;
}

.job-summary .stat-label {
    font-size: 0.85em;
    color: #666;
    margin-top: 5px;
}

/* Caminitto report specific styles */
.job-summary .header {
    background: linear-gradient(135deg, #2271b1 0%, #135e96 100%);
    color: white;
    padding: 20px 25px;
    border-radius: 8px;
    margin: -25px -25px 20px -25px;
}

.job-summary .header h1 {
    margin: 0;
    font-size: 1.5em;
    color: white;
    font-weight: 600;
}

.job-summary .header p {
    margin: 8px 0 0 0;
    font-size: 0.95em;
    opacity: 0.9;
    color: rgba(255,255,255,0.9);
}

.job-summary .summary-box {
    background: #f8fafc;
    border-left: 4px solid #2271b1;
    padding: 18px 20px;
    margin: 20px 0;
    border-radius: 0 6px 6px 0;
}

.job-summary .metric {
    display: inline-block;
    margin-right: 35px;
    margin-bottom: 12px;
    vertical-align: top;
}

.job-summary .metric-value {
    font-size: 1.75em;
    font-weight: 700;
    color: #2271b1;
    line-height: 1.2;
}

.job-summary .metric-label {
    font-size: 0.85em;
    color: #666;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.job-summary .section-title {
    font-size: 1em;
    font-weight: 600;
    color: #1d2327;
    margin-top: 25px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #2271b1;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.job-summary .currency {
    color: #16a34a;
    font-weight: 600;
}

.job-summary .nfe-approved {
    color: #16a34a;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.job-summary .nfe-approved strong {
    color: #15803d;
}

.job-summary .nfe-other {
    color: #dc2626;
    font-size: 0.95em;
}

.job-summary .nfe-other strong {
    color: #b91c1c;
}

.job-summary tr:hover {
    background: #f5f7f9;
}

/* Report job row needs to allow summary to expand */
.report-job-row {
    flex-wrap: wrap;
}

.report-job-row .job-summary {
    flex: 1 1 100%;
}
