/* AI Code Generator Plugin Styles */

/* Main Container */
.ai-code-generator-container {
    max-width: 1000px;
    margin: 20px auto;
    padding: 25px;
    background: #ffffff;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    position: relative;
    overflow: hidden;
}

.ai-code-generator-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #007cba 0%, #00a0d2 25%, #0073aa 50%, #005177 75%, #007cba 100%);
    background-size: 200% 100%;
    animation: gradientShift 3s ease-in-out infinite;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 0%; }
    50% { background-position: 100% 0%; }
}

/* Header Styles */
.ai-code-gen-header {
    text-align: center;
    margin-bottom: 35px;
    padding-bottom: 25px;
    border-bottom: 2px solid #f0f2f4;
    position: relative;
}

.ai-code-gen-header h3 {
    color: #2c3e50;
    margin-bottom: 12px;
    font-size: 32px;
    font-weight: 700;
    background: linear-gradient(135deg, #007cba 0%, #00a0d2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.ai-code-gen-header p {
    color: #718096;
    font-size: 16px;
    margin: 0;
    font-weight: 400;
    line-height: 1.5;
}

/* Form Styles */
.ai-code-gen-form {
    margin-bottom: 35px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-bottom: 25px;
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #2d3748;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ai-form-control {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    background-color: #ffffff;
    color: #2d3748;
    resize: vertical;
}

.ai-form-control:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 4px rgba(0, 124, 186, 0.1);
    transform: translateY(-1px);
}

.ai-form-control:hover {
    border-color: #cbd5e0;
}

/* Generate Button */
.ai-generate-btn {
    background: linear-gradient(135deg, #007cba 0%, #00a0d2 100%);
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ai-generate-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.ai-generate-btn:hover::before {
    left: 100%;
}

.ai-generate-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0, 124, 186, 0.4);
    background: linear-gradient(135deg, #005177 0%, #007cba 100%);
}

.ai-generate-btn:active {
    transform: translateY(-1px);
}

.ai-generate-btn:disabled {
    background: linear-gradient(135deg, #a0aec0 0%, #cbd5e0 100%);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ai-generate-btn:disabled::before {
    display: none;
}

.loading-spinner {
    animation: spin 1s linear infinite;
    display: inline-block;
}

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

/* Output Container */
.ai-code-output {
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 15px;
    padding: 25px;
    margin-top: 35px;
    border: 1px solid #e2e8f0;
    position: relative;
}

.output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.output-header h4 {
    margin: 0;
    color: #2d3748;
    font-size: 20px;
    font-weight: 700;
}

.output-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.output-actions button {
    padding: 10px 18px;
    border: 2px solid #e2e8f0;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    color: #4a5568;
}

.output-actions button:hover {
    background: #f7fafc;
    border-color: #007cba;
    color: #007cba;
    transform: translateY(-1px);
}

/* Code Tabs */
.code-tabs {
    margin-top: 25px;
}

.tab-buttons {
    display: flex;
    border-bottom: 3px solid #e2e8f0;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 5px;
}

.tab-btn {
    padding: 14px 24px;
    border: none;
    background: none;
    cursor: pointer;
    font-weight: 600;
    color: #718096;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    border-radius: 8px 8px 0 0;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tab-btn.active {
    color: #007cba;
    border-bottom-color: #007cba;
    background: rgba(0, 124, 186, 0.05);
}

.tab-btn:hover {
    color: #007cba;
    background: rgba(0, 124, 186, 0.05);
}

.tab-pane {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.tab-pane.active {
    display: block;
}

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

.tab-pane pre {
    background: #2d3748;
    color: #e2e8f0;
    padding: 25px;
    border-radius: 12px;
    overflow-x: auto;
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
    position: relative;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.1);
}

.tab-pane pre::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 20px;
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
    border-radius: 12px 12px 0 0;
}

.tab-pane code {
    font-family: "Fira Code", "Monaco", "Consolas", "Liberation Mono", "Courier New", monospace;
    font-size: 13px;
    position: relative;
    z-index: 1;
    margin-top: 20px;
    display: block;
}

/* Preview Container */
.preview-container {
    margin-top: 25px;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid #e2e8f0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

#preview-frame {
    width: 100%;
    height: 450px;
    border: none;
    background: white;
}

/* Error Messages */
.ai-error-message {
    background: linear-gradient(135deg, #fed7d7 0%, #feb2b2 100%);
    color: #c53030;
    padding: 18px 22px;
    border-radius: 10px;
    border-left: 5px solid #e53e3e;
    margin-top: 25px;
    animation: shake 0.5s ease-in-out;
    box-shadow: 0 4px 12px rgba(229, 62, 62, 0.15);
}

.ai-error-message p {
    margin: 0;
    font-weight: 500;
    line-height: 1.5;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Dark Theme */
.ai-code-generator-container[data-theme="dark"] {
    background: #1a202c;
    color: #e2e8f0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.ai-code-generator-container[data-theme="dark"] .ai-code-gen-header h3 {
    color: #e2e8f0;
}

.ai-code-generator-container[data-theme="dark"] .ai-form-control {
    background: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
}

.ai-code-generator-container[data-theme="dark"] .ai-form-control:focus {
    border-color: #63b3ed;
    box-shadow: 0 0 0 4px rgba(99, 179, 237, 0.1);
}

.ai-code-generator-container[data-theme="dark"] .ai-code-output {
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    border-color: #4a5568;
}

.ai-code-generator-container[data-theme="dark"] .output-actions button {
    background: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
}

.ai-code-generator-container[data-theme="dark"] .tab-btn {
    color: #a0aec0;
}

.ai-code-generator-container[data-theme="dark"] .tab-btn.active {
    color: #63b3ed;
    border-bottom-color: #63b3ed;
    background: rgba(99, 179, 237, 0.1);
}

/* Responsive Design */
@media (max-width: 768px) {
    .ai-code-generator-container {
        margin: 15px;
        padding: 20px;
    }
    
    .ai-code-gen-header h3 {
        font-size: 26px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .form-row.mobile-stacked {
        grid-template-columns: 1fr;
    }
    
    .output-header {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    
    .output-actions {
        justify-content: center;
        width: 100%;
    }
    
    .output-actions.mobile-stacked {
        flex-direction: column;
    }
    
    .output-actions.mobile-stacked button {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .tab-buttons {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .tab-buttons::-webkit-scrollbar {
        display: none;
    }
    
    .tab-btn {
        flex-shrink: 0;
        white-space: nowrap;
        padding: 12px 18px;
        font-size: 13px;
    }
    
    .tab-pane pre {
        padding: 20px 15px;
        font-size: 13px;
    }
    
    #preview-frame {
        height: 350px;
    }
}

@media (max-width: 480px) {
    .ai-code-generator-container {
        margin: 10px;
        padding: 15px;
    }
    
    .ai-code-gen-header h3 {
        font-size: 22px;
    }
    
    .ai-generate-btn {
        padding: 14px 24px;
        font-size: 15px;
    }
    
    .tab-pane pre {
        padding: 15px 12px;
        font-size: 12px;
    }
    
    .ai-form-control {
        padding: 12px 14px;
        font-size: 14px;
    }
    
    #preview-frame {
        height: 300px;
    }
}

/* Validation Feedback */
.validation-feedback {
    color: #e53e3e;
    font-size: 12px;
    margin-top: 8px;
    padding: 5px 0;
    animation: slideDown 0.3s ease;
}

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

/* Loading States */
.ai-generate-btn.loading {
    pointer-events: none;
    position: relative;
    color: transparent;
}

.ai-generate-btn.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 2px solid transparent;
    border-top: 2px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Accessibility Improvements */
.ai-form-control:focus,
.ai-generate-btn:focus,
.tab-btn:focus,
.output-actions button:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .ai-code-generator-container {
        border: 2px solid #000;
    }
    
    .ai-form-control {
        border-width: 3px;
    }
    
    .tab-btn.active {
        border-bottom-width: 4px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .ai-code-generator-container::before {
        animation: none;
    }
    
    .ai-generate-btn::before {
        display: none;
    }
    
    .loading-spinner {
        animation: none;
    }
    
    .tab-pane {
        animation: none;
    }
    
    .ai-error-message {
        animation: none;
    }
    
    .validation-feedback {
        animation: none;
    }
}

/* Print Styles */
@media print {
    .ai-code-generator-container {
        box-shadow: none;
        border: 2px solid #000;
        margin: 0;
        page-break-inside: avoid;
    }
    
    .ai-code-gen-form,
    .output-actions,
    .ai-generate-btn {
        display: none;
    }
    
    .ai-code-output {
        background: #fff;
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .tab-pane pre {
        background: #f5f5f5;
        color: #000;
        border: 1px solid #000;
    }
    
    .preview-container {
        display: none;
    }
}

/* Custom Scrollbar */
.tab-pane pre::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.tab-pane pre::-webkit-scrollbar-track {
    background: #1a202c;
    border-radius: 4px;
}

.tab-pane pre::-webkit-scrollbar-thumb {
    background: #4a5568;
    border-radius: 4px;
}

.tab-pane pre::-webkit-scrollbar-thumb:hover {
    background: #718096;
}

/* Success Message Animation */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Syntax Highlighting Support */
.tab-pane pre code .token.comment,
.tab-pane pre code .token.prolog,
.tab-pane pre code .token.doctype,
.tab-pane pre code .token.cdata {
    color: #6a9955;
}

.tab-pane pre code .token.punctuation {
    color: #d4d4d4;
}

.tab-pane pre code .token.property,
.tab-pane pre code .token.tag,
.tab-pane pre code .token.boolean,
.tab-pane pre code .token.number,
.tab-pane pre code .token.constant,
.tab-pane pre code .token.symbol,
.tab-pane pre code .token.deleted {
    color: #ce9178;
}

.tab-pane pre code .token.selector,
.tab-pane pre code .token.attr-name,
.tab-pane pre code .token.string,
.tab-pane pre code .token.char,
.tab-pane pre code .token.builtin,
.tab-pane pre code .token.inserted {
    color: #ce9178;
}

.tab-pane pre code .token.operator,
.tab-pane pre code .token.entity,
.tab-pane pre code .token.url,
.tab-pane pre code .language-css .token.string,
.tab-pane pre code .style .token.string {
    color: #d4d4d4;
}

.tab-pane pre code .token.atrule,
.tab-pane pre code .token.attr-value,
.tab-pane pre code .token.keyword {
    color: #569cd6;
}

.tab-pane pre code .token.function,
.tab-pane pre code .token.class-name {
    color: #dcdcaa;
}

.tab-pane pre code .token.regex,
.tab-pane pre code .token.important,
.tab-pane pre code .token.variable {
    color: #d16969;
}

/* Framework-specific styling */
.framework-bootstrap .ai-generate-btn {
    background: linear-gradient(135deg, #7952b3 0%, #563d7c 100%);
}

.framework-bootstrap .ai-generate-btn:hover {
    background: linear-gradient(135deg, #563d7c 0%, #452c5c 100%);
}

.framework-tailwind .ai-generate-btn {
    background: linear-gradient(135deg, #06b6d4 0%, #0891b2 100%);
}

.framework-tailwind .ai-generate-btn:hover {
    background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
}

.framework-react .ai-generate-btn {
    background: linear-gradient(135deg, #61dafb 0%, #21759b 100%);
}

.framework-react .ai-generate-btn:hover {
    background: linear-gradient(135deg, #21759b 0%, #1e6a8c 100%);
}

/* Tooltip styles */
.tooltip {
    position: relative;
    cursor: help;
}

.tooltip::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: #2d3748;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    pointer-events: none;
}

.tooltip::after {
    content: '';
    position: absolute;
    bottom: 115%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #2d3748;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
}

.tooltip:hover::before,
.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Code copy success indicator */
.copy-success {
    position: relative;
}

.copy-success::after {
    content: '✓ Copied!';
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background: #48bb78;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    animation: copyFeedback 2s ease-in-out;
}

@keyframes copyFeedback {
    0%, 100% { opacity: 0; transform: translateX(-50%) translateY(5px); }
    20%, 80% { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Loading placeholder for generated code */
.code-loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    height: 20px;
    border-radius: 4px;
    margin: 10px 0;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Enhanced focus styles for better accessibility */
.ai-form-control:focus-visible,
.ai-generate-btn:focus-visible,
.tab-btn:focus-visible,
.output-actions button:focus-visible {
    outline: 3px solid #007cba;
    outline-offset: 2px;
}

/* Skip to content link for screen readers */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #007cba;
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 1000;
}

.skip-link:focus {
    top: 6px;
}