/* Enhanced Mermaid Diagram Editor Styles */

/* Mermaid container styling */
.mermaid-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-height: 200px;
}

.mermaid-container svg {
    max-width: 100%;
    max-height: 100%;
    height: auto;
    width: auto;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
    transition: transform 0.2s ease-in-out;
}

.mermaid-container svg:hover {
    transform: scale(1.02);
}

/* Dark mode Mermaid adjustments */
.dark .mermaid-container svg {
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

/* Enhanced scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Dark mode scrollbar */
.dark ::-webkit-scrollbar-track {
    background: #374151;
}

.dark ::-webkit-scrollbar-thumb {
    background: #6b7280;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Smooth transitions for all elements */
* {
    transition: background-color 0.2s ease-in-out, 
                color 0.2s ease-in-out, 
                border-color 0.2s ease-in-out,
                box-shadow 0.2s ease-in-out;
}

/* Enhanced textarea styling */
textarea {
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    line-height: 1.6;
    tab-size: 2;
    font-size: 14px;
    letter-spacing: 0.025em;
}

textarea:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Enhanced button styling */
button {
    transition: all 0.2s ease-in-out;
    font-weight: 500;
}

button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* Loading animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.loading {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Enhanced focus styles */
input:focus,
textarea:focus,
select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    border-color: #2563eb;
}

.dark input:focus,
.dark textarea:focus,
.dark select:focus {
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    border-color: #3b82f6;
}

/* Template card animations */
.template-card {
    transition: all 0.2s ease-in-out;
    border-radius: 8px;
    overflow: hidden;
}

.template-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.dark .template-card:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

/* Status indicator styling */
.status-indicator {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-success {
    background-color: #dcfce7;
    color: #166534;
}

.status-error {
    background-color: #fef2f2;
    color: #991b1b;
}

.status-warning {
    background-color: #fefce8;
    color: #a16207;
}

.dark .status-success {
    background-color: #14532d;
    color: #bbf7d0;
}

.dark .status-error {
    background-color: #7f1d1d;
    color: #fecaca;
}

.dark .status-warning {
    background-color: #713f12;
    color: #fde047;
}

/* Enhanced modal styling */
.modal-backdrop {
    backdrop-filter: blur(8px);
    background-color: rgba(0, 0, 0, 0.6);
}

.modal-content {
    animation: modalSlideIn 0.2s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Syntax highlighting for code blocks */
.syntax-highlight .keyword {
    color: #7c3aed;
    font-weight: 600;
}

.syntax-highlight .string {
    color: #059669;
}

.syntax-highlight .arrow {
    color: #dc2626;
    font-weight: 600;
}

.syntax-highlight .node {
    color: #2563eb;
    font-weight: 500;
}

/* Error and success messages */
.message-error {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border-left: 4px solid #ef4444;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 8px 0;
}

.message-success {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border-left: 4px solid #22c55e;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 8px 0;
}

.message-warning {
    background: linear-gradient(135deg, #fefce8 0%, #fef3c7 100%);
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 8px 0;
}

.dark .message-error {
    background: linear-gradient(135deg, #7f1d1d 0%, #991b1b 100%);
    color: #fecaca;
}

.dark .message-success {
    background: linear-gradient(135deg, #14532d 0%, #166534 100%);
    color: #bbf7d0;
}

.dark .message-warning {
    background: linear-gradient(135deg, #713f12 0%, #a16207 100%);
    color: #fde047;
}

/* Render progress indicator */
.render-progress {
    height: 2px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #ec4899);
    background-size: 200% 200%;
    animation: gradient 2s ease infinite;
}

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

/* Responsive design improvements */
@media (max-width: 768px) {
    .desktop-only {
        display: none;
    }
    
    .mobile-stack {
        flex-direction: column;
    }
    
    .mobile-full-width {
        width: 100% !important;
    }
    
    .template-card {
        margin-bottom: 12px;
    }
    
    /* Adjust text sizes for mobile */
    .text-responsive {
        font-size: 14px;
    }
    
    /* Stack buttons vertically on mobile */
    .mobile-button-stack {
        flex-direction: column;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .text-responsive {
        font-size: 12px;
    }
    
    .px-responsive {
        padding-left: 12px;
        padding-right: 12px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .mermaid-container svg {
        filter: contrast(1.2) brightness(1.1);
    }
    
    button {
        border-width: 2px;
    }
    
    .template-card {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .template-card:hover {
        transform: none;
    }
    
    button:hover:not(:disabled) {
        transform: none;
    }
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    .mermaid-container {
        page-break-inside: avoid;
    }
    
    .mermaid-container svg {
        max-width: 100% !important;
        height: auto !important;
        page-break-inside: avoid;
    }
    
    /* Ensure good contrast for printing */
    .mermaid-container svg {
        filter: none;
    }
}

/* Custom utility classes */
.text-shadow-sm {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.border-dashed {
    border-style: dashed;
}

.bg-gradient-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.bg-gradient-success {
    background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
}

.bg-gradient-error {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 100%);
}

/* Accessibility improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus visible for keyboard navigation */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Custom selection colors */
::selection {
    background-color: rgba(37, 99, 235, 0.2);
    color: inherit;
}

.dark ::selection {
    background-color: rgba(59, 130, 246, 0.3);
}