/**
 * CarbonGuru File Analysis Console Styles
 *
 * Companion to file-analysis-console.js and the [carbonguru_file_analysis_console] shortcode.
 * Do NOT modify file-analysis.css — this is a parallel stylesheet.
 *
 * Brand colours (from theme.json):
 *   Primary green  : #067F38  (cg-green-600)
 *   Hover green    : #63BFA2  (cg-green-300)
 *   Dark green     : #056830  (cg-green-700)
 *   Blue links     : #1A4A73  (cg-blue-700)
 *   Hover blue     : #3A7CA5  (cg-blue-500)
 *   Neutral dark   : #4A5568  (cg-neutral-600)
 *   Error red      : #d32f2f
 */

/* ========== Outer wrapper ========== */
.cg-file-console {
    max-width: 820px;
    margin: 2rem auto;
    padding: 2rem;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ========== Header ========== */
.cg-file-console__header {
    margin-bottom: 1.5rem;
}

.cg-file-console__header h2 {
    font-size: 1.75rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 0.5rem 0;
}

.cg-file-console__header p {
    font-size: 1rem;
    color: #666;
    margin: 0;
    line-height: 1.5;
}

/* ========== Collapsible requirements block ========== */
.cg-file-console__requirements {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f9f9f9;
    border-radius: 6px;
}

.cg-file-console__requirements summary {
    cursor: pointer;
    font-weight: 500;
    color: #666;
    user-select: none;
    font-size: 0.9375rem;
}

.cg-file-console__requirements summary:hover {
    color: var(--wp--preset--color--cg-blue-500, #3A7CA5);
}

.cg-file-console__requirements-body {
    margin-top: 1rem;
}

.cg-file-console__requirements-body p {
    font-size: 0.875rem;
    color: #666;
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

.cg-file-console__requirements-body strong {
    color: #1a1a1a;
}

.cg-file-console__requirements-body ul {
    list-style: none;
    padding: 0;
    margin: 0 0 0.75rem 0;
}

.cg-file-console__requirements-body ul li {
    padding: 0.4rem 0;
    font-size: 0.875rem;
    color: #666;
    border-bottom: 1px solid #eee;
    line-height: 1.5;
}

.cg-file-console__requirements-body ul li:last-child {
    border-bottom: none;
}

.cg-file-console__requirements-body code {
    font-family: 'SF Mono', Monaco, 'Courier New', monospace;
    font-size: 0.8125rem;
    background: #f0f0f0;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    color: #1a1a1a;
}

/* ========== Upload form ========== */
.cg-file-console__upload-form {
    margin-bottom: 1.5rem;
}

/* Format-hint dropdown */
.cg-file-console__format-hint {
    margin-bottom: 1.25rem;
}

.cg-file-console__format-hint label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: #1a1a1a;
    font-size: 0.9375rem;
}

.cg-file-console__format-hint select {
    width: 100%;
    max-width: 420px;
    padding: 0.75rem 1rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 0.9375rem;
    background: #f9f9f9;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.cg-file-console__format-hint select:focus {
    outline: none;
    border-color: var(--wp--preset--color--cg-green-600, #067F38);
    background: #ffffff;
}

.cg-file-console__format-hint small {
    display: block;
    margin-top: 0.375rem;
    color: #999;
    font-size: 0.8125rem;
}

/* Drag-and-drop zone */
.cg-file-console__dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    min-height: 140px;
    padding: 2rem;
    background: #f9f9f9;
    border: 2px dashed #ccc;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease;
    margin-bottom: 1rem;
    text-align: center;
}

.cg-file-console__dropzone:hover,
.cg-file-console__dropzone--hover {
    border-color: var(--wp--preset--color--cg-green-600, #067F38);
    background: #f0f9f0;
}

.cg-file-console__dropzone-label {
    font-size: 0.9375rem;
    color: #666;
    pointer-events: none;
}

.cg-file-console__dropzone-label strong {
    color: var(--wp--preset--color--cg-blue-700, #1A4A73);
}

.cg-file-console__dropzone input[type="file"] {
    /* Visually hidden but still accessible */
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.cg-file-console__file-info {
    display: none;
    font-size: 0.875rem;
    color: #1a1a1a;
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    background: #e8f5e9;
    border-radius: 4px;
}

.cg-file-console__file-info--warn {
    background: #fff3e0;
    color: #e65100;
}

/* Upload button */
.cg-file-console__upload-btn {
    display: block;
    margin-left: auto;
    margin-top: 0.75rem;
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--wp--preset--color--cg-white, #ffffff);
    background: var(--wp--preset--color--cg-green-600, #067F38);
    border: none;
    border-radius: 0;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.cg-file-console__upload-btn:hover {
    background: var(--wp--preset--color--cg-green-300, #63BFA2);
}

.cg-file-console__upload-btn:active {
    background: var(--wp--preset--color--cg-green-700, #056830);
}

.cg-file-console__upload-btn:disabled {
    background: #A8B0B9;
    cursor: not-allowed;
}

/* ========== Detection status ========== */
.cg-file-console__detection {
    display: none;
    margin-bottom: 1.25rem;
    padding: 0.875rem 1.25rem;
    background: #e8f5e9;
    border-radius: 6px;
    border-left: 4px solid var(--wp--preset--color--cg-green-600, #067F38);
    font-size: 0.9375rem;
    font-weight: 500;
    color: #1a1a1a;
}

/* ========== Progress section ========== */
.cg-file-console__progress {
    display: none;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    background: #f9f9f9;
    border-radius: 8px;
    border-left: 4px solid var(--wp--preset--color--cg-green-600, #067F38);
}

.cg-file-console__progress h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 1rem 0;
}

.cg-file-console__stages {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* Individual stage chip */
.cg-file-console__stage {
    padding: 0.375rem 0.875rem;
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #999;
    background: #eeeeee;
    border: 1px solid #ddd;
    transition: background-color 0.3s ease, color 0.3s ease;
    white-space: nowrap;
}

.cg-file-console__stage--active {
    background: var(--wp--preset--color--cg-green-600, #067F38);
    color: #ffffff;
    border-color: var(--wp--preset--color--cg-green-600, #067F38);
    position: relative;
    padding-right: 2rem;
}

/* Spinner on active stage */
.cg-file-console__stage--active::after {
    content: '';
    position: absolute;
    right: 0.625rem;
    top: 50%;
    transform: translateY(-50%);
    width: 10px;
    height: 10px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: cg-fic-spin 0.8s linear infinite;
}

.cg-file-console__stage--done {
    background: #c8e6c9;
    color: #2E7D32;
    border-color: #a5d6a7;
}

.cg-file-console__stage--done::before {
    content: '\2713\0020';
}

@keyframes cg-fic-spin {
    to { transform: translateY(-50%) rotate(360deg); }
}

/* Progress counters */
.cg-file-console__progress-counts {
    font-size: 0.875rem;
    color: #666;
    margin-bottom: 0;
}

.cg-file-console__progress-counts strong {
    color: var(--wp--preset--color--cg-green-600, #067F38);
    font-weight: 700;
}

/* ========== Per-item streaming table ========== */
.cg-file-console__item-table {
    display: none;
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.875rem;
    border: 1px solid #eee;
    border-radius: 6px;
    overflow: hidden;
}

.cg-file-console__item-table thead {
    background: #f0f9f0;
}

.cg-file-console__item-table th {
    padding: 0.625rem 0.875rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #666;
    border-bottom: 2px solid #ddd;
}

.cg-file-console__item-table td {
    padding: 0.625rem 0.875rem;
    color: #1a1a1a;
    border-bottom: 1px solid #f0f0f0;
    vertical-align: top;
}

.cg-file-console__item-table tbody tr:hover {
    background: #f5f5f5;
}

.cg-file-console__item-table .cg-fic-col-name {
    font-weight: 500;
}

.cg-file-console__item-table .cg-fic-col-carbon {
    color: var(--wp--preset--color--cg-green-600, #067F38);
    font-weight: 500;
    white-space: nowrap;
}

.cg-file-console__item-table .cg-fic-col-social,
.cg-file-console__item-table .cg-fic-col-offset {
    color: #666;
    white-space: nowrap;
}

/* ========== Completion / actions section ========== */
.cg-file-console__actions {
    display: none;
    margin-top: 2rem;
    padding: 2rem;
    background: #f0f9f0;
    border-radius: 8px;
    text-align: center;
}

.cg-file-console__actions h3 {
    font-size: 1.375rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 0.5rem 0;
}

.cg-file-console__actions p {
    font-size: 0.9375rem;
    color: #666;
    margin: 0 0 1.25rem 0;
}

.cg-file-console__actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    align-items: center;
    margin-top: 1rem;
}

/* Download enriched file button (primary) */
.cg-file-console__download-btn {
    padding: 0.875rem 1.75rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--wp--preset--color--cg-white, #ffffff);
    background: var(--wp--preset--color--cg-green-600, #067F38);
    border: none;
    border-radius: 0;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.2s ease;
}

.cg-file-console__download-btn:hover {
    background: var(--wp--preset--color--cg-green-300, #63BFA2);
    color: #ffffff;
}

.cg-file-console__download-btn:disabled {
    background: #A8B0B9;
    cursor: not-allowed;
}

/* Export row */
.cg-file-console__export-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* Export format dropdown */
.cg-file-console__export-dropdown {
    padding: 0.75rem 1rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 0.9375rem;
    background: #ffffff;
    cursor: pointer;
    transition: border-color 0.2s ease;
    min-width: 120px;
}

.cg-file-console__export-dropdown:focus {
    outline: none;
    border-color: var(--wp--preset--color--cg-green-600, #067F38);
}

.cg-file-console__export-btn {
    padding: 0.75rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--wp--preset--color--cg-white, #ffffff);
    background: var(--wp--preset--color--cg-neutral-600, #4A5568);
    border: none;
    border-radius: 0;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.cg-file-console__export-btn:hover {
    background: #6B7785;
}

.cg-file-console__export-btn:disabled {
    background: #A8B0B9;
    cursor: not-allowed;
}

/* Session link */
.cg-file-console__session-link {
    display: none;
    font-size: 0.9375rem;
    color: var(--wp--preset--color--cg-blue-700, #1A4A73);
    text-decoration: none;
    font-weight: 500;
    padding: 0.75rem 1.25rem;
    border: 2px solid var(--wp--preset--color--cg-blue-700, #1A4A73);
    border-radius: 0;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.cg-file-console__session-link:hover {
    color: var(--wp--preset--color--cg-blue-500, #3A7CA5);
    border-color: var(--wp--preset--color--cg-blue-500, #3A7CA5);
    text-decoration: none;
}

/* ========== Error banner ========== */
.cg-file-console__error {
    display: none;
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    background: #fff5f5;
    border-left: 4px solid #d32f2f;
    border-radius: 6px;
    color: #d32f2f;
    font-size: 0.9375rem;
    line-height: 1.5;
}

/* ========== Sessions list area (embedded block) ========== */
.cg-file-console__session-list {
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid #eee;
}

.cg-file-console__session-list h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 1rem 0;
}

/* ========== Responsive ========== */
@media screen and (max-width: 768px) {
    .cg-file-console {
        padding: 1.5rem;
        margin: 1rem auto;
    }

    .cg-file-console__header h2 {
        font-size: 1.5rem;
    }

    .cg-file-console__stages {
        gap: 0.375rem;
    }

    .cg-file-console__stage {
        font-size: 0.75rem;
        padding: 0.3rem 0.625rem;
    }

    .cg-file-console__stage--active {
        padding-right: 1.75rem;
    }

    .cg-file-console__actions-row {
        flex-direction: column;
        align-items: stretch;
    }

    .cg-file-console__download-btn,
    .cg-file-console__export-btn {
        width: 100%;
        text-align: center;
    }

    .cg-file-console__export-row {
        flex-direction: column;
        align-items: stretch;
    }

    .cg-file-console__export-dropdown {
        width: 100%;
    }

    .cg-file-console__item-table .cg-fic-col-social,
    .cg-file-console__item-table .cg-fic-col-offset {
        display: none;
    }

    .cg-file-console__format-hint select {
        max-width: 100%;
    }
}
