/**
 * CarbonGuru Content Paste Widget Styles
 *
 * Follows CarbonGuru brand guidelines from theme.json
 * - Buttons: CG Green 600 (#067F38)
 * - Links: CG Blue 700 (#1A4A73)
 * - Carbon values: CG Green 600 (#067F38)
 */

/* Widget Container */
.cg-content-paste-widget {
    max-width: 800px;
    margin: 2rem auto;
    padding: 2rem;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Widget Header */
.cg-widget-header {
    margin-bottom: 1.5rem;
}

.cg-widget-header h3 {
    font-size: 1.75rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 0.5rem 0;
}

.cg-widget-description {
    font-size: 1rem;
    color: #666;
    margin: 0;
    line-height: 1.5;
}

/* Input Section */
.cg-input-section {
    margin-bottom: 1.5rem;
}

.cg-content-input {
    width: 100%;
    padding: 1rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    color: #1a1a1a;
    background: #f9f9f9;
    border: 2px solid #ddd;
    border-radius: 6px;
    resize: vertical;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

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

.cg-content-input::placeholder {
    color: #999;
}

/* Content Feedback */
.cg-content-feedback {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: #666;
}

.cg-char-count {
    color: #999;
}

.cg-detected-geo {
    font-weight: 500;
    color: #666;
}

.cg-detected-geo.cg-detected {
    color: var(--wp--preset--color--cg-green-600, #067F38);
}

/* Optional Context */
.cg-optional-context {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f9f9f9;
    border-radius: 6px;
}

.cg-optional-context summary {
    cursor: pointer;
    font-weight: 500;
    color: #666;
    user-select: none;
}

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

.cg-context-fields {
    margin-top: 1rem;
}

.cg-source-name {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    color: #1a1a1a;
    background: #ffffff;
    border: 2px solid #ddd;
    border-radius: 6px;
    transition: border-color 0.2s ease;
}

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

/* Widget Actions */
.cg-widget-actions {
    display: flex;
    justify-content: flex-end;
}

.cg-submit-content {
    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-submit-content:hover:not(:disabled) {
    background: var(--wp--preset--color--cg-green-300, #63BFA2);
}

.cg-submit-content:active:not(:disabled) {
    background: var(--wp--preset--color--cg-green-700, #056830);
}

.cg-submit-content:disabled {
    background: var(--wp--preset--color--cg-neutral-400, #A8B0B9);
    cursor: not-allowed;
}

.cg-button-spinner {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.cg-button-spinner .spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: cg-spin 0.6s linear infinite;
}

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

/* Processing Section (shown during analysis) */
.cg-processing-section {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #f9f9f9;
    border-radius: 8px;
    border-left: 4px solid var(--wp--preset--color--cg-green-600, #067F38);
}

.cg-processing-header h4 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 0.75rem 0;
}

.cg-processing-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #ddd;
}

.cg-status-message {
    font-size: 0.9375rem;
    color: #666;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cg-status-message::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--wp--preset--color--cg-green-600, #067F38);
    border-top-color: transparent;
    border-radius: 50%;
    animation: cg-spin 0.8s linear infinite;
}

.cg-items-count {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--wp--preset--color--cg-green-600, #067F38);
}

.cg-items-count .count {
    font-weight: 700;
}

/* Live Items List (progressive display) */
.cg-items-list-live {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
}

.cg-live-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem;
    background: #ffffff;
    border-radius: 6px;
    border: 1px solid #eee;
    animation: cg-slideIn 0.3s ease-out;
}

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

.cg-live-item-number {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #ffffff;
    background: var(--wp--preset--color--cg-green-600, #067F38);
    border-radius: 50%;
}

.cg-live-item-content {
    flex: 1;
    min-width: 0;
}

.cg-live-item-name {
    font-weight: 500;
    color: #1a1a1a;
    font-size: 0.9375rem;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cg-live-item-details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: #666;
}

.cg-live-item-price {
    color: #1a1a1a;
    font-weight: 500;
}

.cg-live-item-carbon {
    color: var(--wp--preset--color--cg-green-600, #067F38);
    font-weight: 500;
}

.cg-live-item-status {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.cg-live-item-status.analyzing {
    color: var(--wp--preset--color--cg-blue-500, #3A7CA5);
}

.cg-live-item-status.complete {
    color: var(--wp--preset--color--cg-green-600, #067F38);
}

.cg-live-item-status.error {
    color: var(--wp--preset--color--cg-critical, #E5484D);
}

/* Result Container */
.cg-result-container {
    margin-top: 2rem;
    padding: 2rem;
    background: #f9f9f9;
    border-radius: 8px;
}

/* Duplicate Notice */
.cg-duplicate-notice {
    text-align: center;
}

.cg-duplicate-notice h4 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 0.5rem 0;
}

.cg-duplicate-info {
    font-size: 1rem;
    color: #666;
    margin: 0 0 1.5rem 0;
}

.cg-duplicate-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.cg-duplicate-actions .wp-element-button {
    min-width: 200px;
}

/* Success Result */
.cg-success-result {
    text-align: center;
}

.cg-result-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 1.5rem 0;
}

/* Items List (simple numbered format like extension) */
.cg-items-list {
    margin-bottom: 1.5rem;
    text-align: left;
}

.cg-item-row {
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
}

.cg-item-row:last-child {
    border-bottom: none;
}

.cg-item-link {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem;
    color: var(--wp--preset--color--cg-blue-700, #1A4A73);
    text-decoration: none;
    font-size: 0.9375rem;
    line-height: 1.4;
}

.cg-item-link:hover {
    color: var(--wp--preset--color--cg-blue-500, #3A7CA5);
    text-decoration: underline;
}

.cg-item-num {
    color: #666;
    margin-right: 0.25rem;
}

.cg-item-name {
    font-weight: 500;
}

.cg-item-price {
    color: #1a1a1a;
}

.cg-item-separator {
    color: #999;
    margin: 0 0.125rem;
}

.cg-item-carbon {
    color: var(--wp--preset--color--cg-green-600, #067F38);
    font-weight: 500;
}

.cg-result-summary {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.cg-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: #ffffff;
    border-radius: 6px;
}

.cg-result-label {
    font-weight: 500;
    color: #666;
}

.cg-result-value {
    font-weight: 600;
    color: #1a1a1a;
    font-size: 1.125rem;
}

.cg-result-actions {
    display: flex;
    justify-content: center;
}

/* Error Result */
.cg-error-result {
    text-align: center;
}

.cg-error-result h4 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--wp--preset--color--cg-critical, #E5484D);
    margin: 0 0 0.5rem 0;
}

.cg-error-message {
    font-size: 1rem;
    color: #666;
    margin: 0 0 1.5rem 0;
}

/* Button Styles - Following CG Theme Guidelines */
.wp-element-button {
    display: inline-block;
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    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;
}

.wp-element-button:hover {
    background: var(--wp--preset--color--cg-green-300, #63BFA2);
    color: var(--wp--preset--color--cg-white, #ffffff);
}

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

.cg-button-secondary {
    background: var(--wp--preset--color--cg-neutral-600, #4A5568);
}

.cg-button-secondary:hover {
    background: var(--wp--preset--color--cg-neutral-500, #6B7785);
}

/* Responsive Design */
@media (max-width: 768px) {
    .cg-content-paste-widget {
        padding: 1.5rem;
        margin: 1rem auto;
    }

    .cg-widget-header h3 {
        font-size: 1.5rem;
    }

    .cg-content-input {
        font-size: 0.9375rem;
    }

    .cg-result-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .cg-duplicate-actions {
        width: 100%;
    }

    .cg-duplicate-actions .wp-element-button,
    .wp-element-button {
        width: 100%;
        min-width: auto;
    }
}
