/* Fixed Prompt Optimizer CSS - Better Color Consistency & Visibility */

.prompt-optimizer-pro {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #ffffff;
    background: radial-gradient(ellipse at top, #1e1b4b 0%, #0f0f23 100%);
    border-radius: 12px;
    min-height: 90vh;
    position: relative;
    overflow: hidden;
}

/* Header Section */
.optimizer-header {
    text-align: center;
    margin-bottom: 40px;
    padding: 40px 30px;
    background: linear-gradient(135deg, #8b5cf6 0%, #06b6d4 100%);
    color: white;
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(139, 92, 246, 0.5);
    position: relative;
    overflow: hidden;
}

.optimizer-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" patternUnits="userSpaceOnUse" width="100" height="100"><circle cx="20" cy="20" r="0.5" fill="white" opacity="0.1"/><circle cx="80" cy="40" r="0.3" fill="white" opacity="0.1"/><circle cx="40" cy="80" r="0.4" fill="white" opacity="0.1"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    animation: float 25s infinite linear;
    z-index: 1;
}

@keyframes float {
    0% { transform: translateY(0px) translateX(0px); }
    100% { transform: translateY(-100px) translateX(-100px); }
}

.optimizer-header > * {
    position: relative;
    z-index: 2;
}

.optimizer-header h2 {
    margin: 0 0 15px 0;
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 800;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    color: #FFFFFF !important;
}

.optimizer-description {
    margin: 0 0 20px 0;
    font-size: clamp(0.9rem, 2vw, 1.1rem);
    opacity: 0.9;
    font-weight: 400;
    color: #e5e7eb !important;
}

.usage-display {
    background: rgba(255,255,255,0.15);
    padding: 12px 20px;
    border-radius: 25px;
    display: inline-block;
    font-size: 0.9rem;
    backdrop-filter: blur(10px);
    color: #f1f5f9;
}

.usage-warning {
    display: block;
    margin-top: 8px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Form Section - Dark Theme */
.optimizer-form-section {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 20px;
    padding: 40px;
    margin-bottom: 30px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.form-group {
    margin-bottom: 30px;
    padding: 1.25rem;
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(148, 163, 184, 0.1);
    border-radius: 12px;
    position: relative;
    
}

.form-group::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, #8b5cf6 50%, transparent 100%);
    border-radius: 12px 12px 0 0;
}

.form-group.focused {
    transform: translateY(-2px);
    transition: transform 0.3s ease;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-bottom: 30px;
}

.form-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #f1f5f9;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.required {
    color: #ef4444;
    margin-left: 4px;
}

/* Enhanced Input Styling - Better Visibility */
.main-textarea,
.secondary-textarea,
.styled-select,
.text-input {
    width: 100%;
    padding: 16px 20px;
    margin: 0.5rem 0;
    background: #0f172a !important; /* Deep navy background */
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 8px;
    color: #ffffff !important; /* Light text color */
    font-size: 16px;
    transition: all 0.3s ease;
    font-family: inherit;
}

.main-textarea {
    min-height: 140px;
    resize: vertical;
    line-height: 1.6;
}

.secondary-textarea {
    min-height: 100px;
    resize: vertical;
}

.main-textarea:focus,
.secondary-textarea:focus,
.styled-select:focus,
.text-input:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
    background: rgba(15, 23, 42, 0.9) !important;
    color: #f8fafc !important;
}

.main-textarea::placeholder,
.secondary-textarea::placeholder,
.text-input::placeholder {
    color: #64748b;
}

.main-textarea.error,
.secondary-textarea.error {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

/* Enhanced Select Dropdown - Better Visibility */
.styled-select {
    cursor: pointer;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%238b5cf6" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6,9 12,15 18,9"></polyline></svg>');
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px;
    appearance: none;
}

.styled-select option {
    background: #1e293b !important;
    color: #FFFFFF !important;
    padding: 10px;
}

/* Help Text and Counters */
.help-text {
    margin-top: 8px;
    font-size: 0.9rem;
    color: #94a3b8;
    line-height: 1.5;
}

.char-counter {
    margin-top: 6px;
    font-size: 0.85rem;
    color: #94a3b8;
    text-align: right;
}

.char-counter.over-limit {
    color: #fca5a5;
    font-weight: 600;
}

/* Enhanced Button Styling */
.optimize-button {
    width: 100%;
    padding: 18px 30px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 15px 35px rgba(16, 185, 129, 0.4);
}

.optimize-button:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 20px 40px rgba(16, 185, 129, 0.5);
}

.optimize-button:disabled {
    background: #475569;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

.optimize-button::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;
}

.optimize-button:hover::before {
    left: 100%;
}

/* Results Section - Dark Theme */
.results-section {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 20px;
    padding: 40px;
    margin-bottom: 30px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border-left: 5px solid #8b5cf6;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid rgba(148, 163, 184, 0.2);
}

.results-header h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #f1f5f9;
}

.results-actions {
    display: flex;
    gap: 12px;
}

.action-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.copy-btn,
.download-btn {
    background: rgba(71, 85, 105, 0.5);
    color: #cbd5e1;
    border: 2px solid rgba(148, 163, 184, 0.2);
}

.copy-btn:hover,
.download-btn:hover {
    background: rgba(71, 85, 105, 0.8);
    border-color: #8b5cf6;
    transform: translateY(-1px);
}

.outline-btn {
    background: transparent;
    color: #8b5cf6;
    border: 2px solid #8b5cf6;
}

.outline-btn:hover {
    background: #8b5cf6;
    color: white;
}

.action-btn.success {
    background: #10b981;
    color: white;
    border-color: #10b981;
}

.optimized-output {
    margin-bottom: 25px;
}

.result-textarea {
    width: 100%;
    min-height: 200px;
    max-height: 500px;
    padding: 20px;
    border: 2px solid rgba(148, 163, 184, 0.3);
    border-radius: 12px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 14px;
    line-height: 1.7;
    resize: vertical;
    background: rgba(15, 23, 42, 0.6) !important;
    color: #cbd5e1 !important;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.result-textarea:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
    color: #f1f5f9 !important;
}

.improvement-stats {
    background: rgba(59, 130, 246, 0.1);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.stat-label {
    font-weight: 600;
    color: #94a3b8;
    font-size: 0.9rem;
}

.stat-value {
    font-weight: 700;
    color: #f1f5f9;
    font-size: 1rem;
}

.usage-tip {
    background: rgba(245, 158, 11, 0.1);
    border-radius: 12px;
    padding: 20px;
    border-left: 4px solid #f59e0b;
}

.usage-tip h4 {
    margin: 0 0 15px 0;
    color: #fbbf24;
    font-weight: 700;
}

.usage-tip ol {
    margin: 0;
    padding-left: 20px;
}

.usage-tip li {
    margin-bottom: 8px;
    color: #fde68a;
}

/* Loading Section */
.loading-section {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 20px;
    padding: 50px 40px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    margin-bottom: 30px;
}

.loading-content {
    max-width: 400px;
    margin: 0 auto;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(71, 85, 105, 0.5);
    border-top: 4px solid #8b5cf6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 25px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading-title {
    margin: 0 0 10px 0;
    color: #f1f5f9;
    font-weight: 700;
    font-size: 1.25rem;
}

#loading-message {
    margin: 0 0 25px 0;
    color: #94a3b8;
    font-size: 1rem;
}

.loading-progress {
    width: 100%;
    height: 6px;
    background: rgba(71, 85, 105, 0.5);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(135deg, #8b5cf6 0%, #06b6d4 100%);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

/* Error Section */
.error-section {
    background: rgba(239, 68, 68, 0.1);
    border: 2px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 30px;
}

.error-content {
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.error-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.error-text {
    flex: 1;
}

.error-text h4 {
    margin: 0 0 8px 0;
    color: #fca5a5;
    font-weight: 700;
}

.error-text p {
    margin: 0;
    color: #fecaca;
}

/* Features Section */
.features-section {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.5) 0%, rgba(71, 85, 105, 0.3) 100%);
    border-radius: 20px;
    padding: 40px;
    margin-top: 40px;
}

.features-section h3 {
    text-align: center;
    margin: 0 0 30px 0;
    color: #f1f5f9;
    font-weight: 700;
    font-size: 1.5rem;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
}

.feature-card {
    background: rgba(15, 23, 42, 0.6);
    padding: 25px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 35px rgba(139, 92, 246, 0.2);
}

.feature-icon {
    font-size: 2.5rem;
    margin-bottom: 15px;
    display: block;
}

.feature-card h4 {
    margin: 0 0 10px 0;
    color: #f1f5f9;
    font-weight: 700;
    font-size: 1.1rem;
}

.feature-card p {
    margin: 0;
    color: #94a3b8;
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .prompt-optimizer-pro {
        margin: 0 -15px;
        border-radius: 0;
    }
    
    .optimizer-form-section,
    .results-section {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 2rem;
    }
}

@media (max-width: 768px) {
    .prompt-optimizer-pro {
        padding: 15px;
        margin: 0 -20px;
        border-radius: 0;
    }
    
    .optimizer-header {
        padding: 30px 20px;
    }
    
    .optimizer-header h2 {
        font-size: 2rem;
    }
    
    .optimizer-form-section,
    .results-section {
        padding: 25px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .results-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .results-actions {
        flex-direction: column;
    }
    
    .stat-grid {
        grid-template-columns: 1fr;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
    
    .loading-content {
        padding: 0 10px;
    }
}

@media (max-width: 480px) {
    .optimizer-header h2 {
        font-size: 1.75rem;
    }
    
    .optimizer-description {
        font-size: 1rem;
    }
    
    .optimize-button {
        padding: 16px 24px;
        font-size: 16px;
    }
    
    .main-textarea,
    .secondary-textarea,
    .styled-select,
    .text-input {
        padding: 14px 16px;
        font-size: 16px;
    }
    
    .action-btn {
        padding: 12px 16px;
        font-size: 14px;
        width: 100%;
        justify-content: center;
    }
    
    .form-group {
        padding: 1rem;
        margin-bottom: 1rem;
    }
}

/* Animation for smooth transitions */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.results-section {
    animation: fadeInUp 0.5s ease-out;
}

.error-section {
    animation: fadeInUp 0.4s ease-out;
}

/* Enhanced scrollbar styling */
.prompt-optimizer-pro ::-webkit-scrollbar {
    width: 8px;
}

.prompt-optimizer-pro ::-webkit-scrollbar-track {
    background: rgba(30, 41, 59, 0.5);
    border-radius: 4px;
}

.prompt-optimizer-pro ::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #8b5cf6, #06b6d4);
    border-radius: 4px;
}

.prompt-optimizer-pro ::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #7c3aed, #0891b2);
}

/* Focus states for better accessibility */
.prompt-optimizer-pro button:focus,
.prompt-optimizer-pro select:focus,
.prompt-optimizer-pro textarea:focus,
.prompt-optimizer-pro input:focus {
    outline: 2px solid #8b5cf6;
    outline-offset: 2px;
}

/* Selection styling */
.prompt-optimizer-pro ::selection {
    background: rgba(139, 92, 246, 0.3);
    color: #f1f5f9;
}

/* Print styles */
@media print {
    .prompt-optimizer-pro {
        background: white;
        color: black;
        box-shadow: none;
    }
    
    .results-actions,
    .loading-section,
    .optimize-button {
        display: none !important;
    }
    
    .optimizer-form-section,
    .results-section {
        background: white;
        border: 1px solid #ccc;
        box-shadow: none;
    }
    
    .optimizer-header {
        background: #f5f5f5;
        color: black;
    }
}