/* General styling for AI Forge shortcodes */
.ai-forge-container {
    background-color: #f8f8f8;
    border: 1px solid #ddd;
    padding: 20px;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.ai-forge-container h3 {
    color: #333;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.5em;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.ai-forge-container p {
    color: #555;
    line-height: 1.6;
}

.ai-forge-input-field {
    margin-bottom: 15px;
}

.ai-forge-input-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #444;
}

.ai-forge-input-field input[type="text"],
.ai-forge-input-field input[type="number"],
.ai-forge-input-field textarea,
.ai-forge-input-field select { /* Added select */
    width: calc(100% - 22px); /* Account for padding and border */
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1em;
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
}

.ai-forge-input-field textarea {
    min-height: 100px;
    resize: vertical;
}

.ai-forge-input-field .description {
    font-size: 0.85em;
    color: #777;
    margin-top: 5px;
}

.ai-forge-submit-button {
    background-color: #0073aa; /* WordPress primary blue */
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1em;
    transition: background-color 0.3s ease;
    margin-top: 10px;
}

.ai-forge-submit-button:hover {
    background-color: #005a87;
}

.ai-forge-message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 4px;
    font-weight: bold;
}

.ai-forge-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.ai-forge-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.ai-forge-output {
    margin-top: 20px;
    padding: 15px;
    background-color: #e9e9e9;
    border: 1px solid #ccc;
    border-radius: 4px;
    white-space: pre-wrap; /* Preserve whitespace and line breaks */
    word-wrap: break-word; /* Break long words */
    word-break: break-all; /* Break at any character for very long strings */
    overflow-wrap: break-word; /* Modern word wrapping */
    max-width: 100%; /* Ensure it doesn't exceed container width */
    overflow-x: auto; /* Allow horizontal scroll only if absolutely necessary */
    font-family: monospace; /* For raw text output */
    color: #333;
    font-size: 0.9em; /* Slightly smaller font for better fit */
    line-height: 1.4; /* Better line spacing */
}

/* Specific styling for JSON output */
.ai-forge-output pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-all;
    overflow-wrap: break-word;
    max-width: 100%;
    overflow-x: auto;
    margin: 0;
    padding: 0;
}

/* Specific styling for natural language output */
.ai-forge-nl-output pre {
    background-color: #f0f0f0;
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto; /* Enable horizontal scroll for long lines */
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-all;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* Loading spinner */
.ai-forge-loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: ai-forge-spin 1s linear infinite;
    margin-left: 8px;
}

@keyframes ai-forge-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ai-forge-error {
    color: #dc3232;
    font-weight: bold;
}

/* Styling for output content */
.ai-forge-output-content {
    margin-top: 10px;
}

.ai-forge-output-content p {
    margin: 0 0 15px 0;
    line-height: 1.6;
    color: #333;
}

/* Styling for collapsible details/summary */
.ai-forge-output details {
    margin-top: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #f9f9f9;
}

.ai-forge-output summary {
    padding: 10px 15px;
    background-color: #e9e9e9;
    cursor: pointer;
    font-weight: bold;
    color: #555;
    border-bottom: 1px solid #ddd;
}

.ai-forge-output summary:hover {
    background-color: #e0e0e0;
}

.ai-forge-output details[open] summary {
    border-bottom: 1px solid #ddd;
}

.ai-forge-output details pre {
    margin: 0;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 0 0 4px 4px;
}

/* Credit information styling */
.ai-forge-credit-info {
    display: block;
    margin-top: 8px;
    padding: 5px 8px;
    background-color: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 3px;
    color: #0066cc;
    font-size: 0.85em;
    font-weight: normal;
}

/* AI Forge Marketplace Styling */
.ai-forge-marketplace-controls {
    margin-bottom: 30px;
    padding: 20px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
}

.ai-forge-filter-form {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.ai-forge-filter-form select {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background-color: white;
    font-size: 14px;
    min-width: 150px;
}

.ai-forge-marketplace {
    margin-top: 20px;
}

.ai-forge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.ai-forge-marketplace-card {
    background-color: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.ai-forge-marketplace-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.ai-forge-card-thumbnail {
    position: relative;
    overflow: hidden;
    background-color: #f8f9fa;
}

.ai-forge-card-thumbnail img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.ai-forge-marketplace-card:hover .ai-forge-card-thumbnail img {
    transform: scale(1.05);
}

.ai-forge-card-content {
    padding: 20px;
}

.ai-forge-card-type {
    display: inline-block;
    background-color: #0073aa;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.ai-forge-card-title {
    margin: 0 0 10px 0;
    font-size: 1.3em;
    line-height: 1.3;
}

.ai-forge-card-title a {
    color: #333;
    text-decoration: none;
    transition: color 0.2s ease;
}

.ai-forge-card-title a:hover {
    color: #0073aa;
}

.ai-forge-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 0.85em;
    color: #666;
}

.ai-forge-card-author {
    font-weight: 500;
}

.ai-forge-card-usage {
    color: #888;
}

.ai-forge-card-excerpt {
    color: #555;
    line-height: 1.5;
    margin-bottom: 0;
}

.ai-forge-card-footer {
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-forge-card-pricing {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.ai-forge-card-cost {
    font-size: 1.2em;
    font-weight: bold;
    color: #0073aa;
}

.ai-forge-card-fee-breakdown {
    font-size: 0.8em;
    color: #666;
    margin-top: 2px;
}

.ai-forge-button {
    display: inline-block;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9em;
}

.ai-forge-button-primary {
    background-color: #0073aa;
    color: white;
}

.ai-forge-button-primary:hover {
    background-color: #005a87;
    color: white;
    transform: translateY(-1px);
}

.ai-forge-button-sm {
    padding: 6px 12px;
    font-size: 0.85em;
}

/* Responsive Design */
@media (max-width: 768px) {
    .ai-forge-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .ai-forge-filter-form {
        flex-direction: column;
        align-items: stretch;
    }
    
    .ai-forge-filter-form select {
        min-width: auto;
    }
    
    .ai-forge-card-footer {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .ai-forge-card-pricing {
        align-items: center;
    }
}

/* Loading States and User Feedback */
.ai-forge-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ai-forge-marketplace-card.loading {
    opacity: 0.7;
    pointer-events: none;
}

.ai-forge-marketplace-card.loading .ai-forge-button {
    position: relative;
}

.ai-forge-marketplace-card.loading .ai-forge-button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: ai-forge-spin 1s linear infinite;
}

/* Success/Error States */
.ai-forge-message.success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    padding: 12px;
    border-radius: 4px;
    margin: 10px 0;
}

.ai-forge-message.error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 12px;
    border-radius: 4px;
    margin: 10px 0;
}

/* Marketplace Info Styling */
.ai-forge-marketplace-info {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    margin-top: 30px;
}

.ai-forge-marketplace-info h2 {
    margin-top: 0;
    color: #333;
}

.ai-forge-marketplace-info h3 {
    color: #0073aa;
    margin-top: 20px;
    margin-bottom: 10px;
}

.ai-forge-marketplace-info ul {
    margin-left: 20px;
}

.ai-forge-marketplace-info li {
    margin-bottom: 5px;
}

.ai-forge-marketplace-info code {
    background-color: #e9ecef;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: monospace;
}

/* Dashboard Table Styles (matching Service Forge) */
.ai-forge-dashboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.5em;
    background: #fff;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.ai-forge-dashboard-table th, .ai-forge-dashboard-table td {
    padding: 12px 15px;
    border: 1px solid #e5e5e5;
    text-align: left;
    vertical-align: middle;
}
.ai-forge-dashboard-table thead th {
    background-color: #f9f9f9;
    font-weight: bold;
}
.ai-forge-status-published, .ai-forge-status-private {
    display: inline-block;
    color: #fff;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    text-transform: capitalize;
    font-weight: bold;
}
.ai-forge-status-published {
    background-color: #28a745;
}
.ai-forge-status-private {
    background-color: #6c757d;
}
.ai-forge-edit-link, .ai-forge-tool-link, .ai-forge-workflow-link {
    color: #0073aa;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}
.ai-forge-edit-link:hover, .ai-forge-tool-link:hover, .ai-forge-workflow-link:hover {
    color: #005a87;
    text-decoration: underline;
}