/* public/css/main.css */
:root {
    /* Primary colors */
    --primary-color: #4F46E5;  /* Improved from #5D5CDE for better contrast */
    --primary-hover: #4338CA;  /* Darker for better hover state */
    
    /* Default dark theme variables */
    --bg-primary: #111827;
    --bg-secondary: #1F2937;
    --bg-tertiary: #374151;
    --text-primary: #F9FAFB;
    --text-secondary: #D1D5DB;
    --text-muted: #9CA3AF;
    --border-color: #4B5563;
    --input-bg: #374151;
    
    /* Accent colors with improved contrast */
    --success: #10B981;
    --success-hover: #059669;
    --danger: #EF4444;
    --danger-hover: #DC2626;
    --warning: #F59E0B;
    --warning-hover: #D97706;
    --info: #3B82F6;
    --info-hover: #2563EB;
}

/* Light theme */
[data-theme="light"] {
    --bg-primary: #F9FAFB;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #F3F4F6;
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-muted: #6B7280;
    --border-color: #E5E7EB;
    --input-bg: #F3F4F6;
}

/* Global styles */
body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    transition: background-color 0.3s, color 0.3s;
    line-height: 1.5;
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

/* Focus states for accessibility */
*:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Content area */
.content-with-sidebar {
    transition: margin-left 0.3s ease;
}

/* Strong content overflow prevention */
.prose {
    overflow-wrap: break-word !important;
    word-wrap: break-word !important;
    word-break: break-word !important;
    max-width: 100% !important;
}

.prose pre,
.prose code {
    white-space: pre-wrap !important;
    overflow-x: auto !important;
    max-width: 100% !important;
}

/* Ensure images and tables are constrained */
.prose img,
.prose table {
    max-width: 100% !important;
    height: auto !important;
}

/* Ensure all elements in prose are constrained */
.prose * {
    max-width: 100% !important;
}

/* Improved contrast for inputs */
input, select, textarea {
    border: 1px solid var(--border-color);
    background-color: var(--input-bg) !important;
    color: var(--text-primary) !important;
}

input::placeholder, 
select::placeholder, 
textarea::placeholder {
    color: var(--text-muted);
}

/* Heading styles with improved contrast */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--text-primary);
}

/* Tailwind overrides */
.bg-gray-900 {
    background-color: var(--bg-primary) !important;
}

.bg-gray-800 {
    background-color: var(--bg-secondary) !important;
}

.bg-gray-700 {
    background-color: var(--bg-tertiary) !important;
}

.text-white {
    color: var(--text-primary) !important;
}

.text-gray-300, .text-gray-400 {
    color: var(--text-secondary) !important;
}

/* Animation for loading spinner */
.loading-spinner {
    animation: spin 2s linear infinite;
}

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

/* Theme toggle button styling */
.theme-toggle {
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.theme-toggle:hover {
    background-color: var(--bg-tertiary);
}

.theme-toggle i {
    font-size: 1.25rem;
    color: var(--text-primary);
}

/* Markdown content styling */
.markdown-content h1 {
    font-size: 1.5rem;
    font-weight: bold;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.markdown-content h2 {
    font-size: 1.25rem;
    font-weight: bold;
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
}

.markdown-content h3 {
    font-size: 1.125rem;
    font-weight: bold;
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
}

.markdown-content p {
    margin-bottom: 0.75rem;
}

.markdown-content ul, 
.markdown-content ol {
    margin-left: 1.5rem;
    margin-bottom: 0.75rem;
}

.markdown-content ul {
    list-style-type: disc;
}

.markdown-content ol {
    list-style-type: decimal;
}

.markdown-content blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1rem;
    margin-left: 0;
    margin-right: 0;
    font-style: italic;
}

.markdown-content pre {
    background-color: rgba(0, 0, 0, 0.1);
    padding: 0.5rem;
    border-radius: 0.25rem;
    overflow-x: auto;
    margin-bottom: 0.75rem;
}

.markdown-content code {
    font-family: monospace;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    background-color: rgba(0, 0, 0, 0.1);
}

.markdown-content pre code {
    padding: 0;
    background-color: transparent;
}

/* Flash messages */
.flash-message {
    padding: 1rem;
    border-radius: 0.25rem;
    margin-bottom: 1rem;
}

.flash-success {
    background-color: rgba(16, 185, 129, 0.2);
    border: 1px solid #10B981;
    color: #D1FAE5;
}

.flash-error {
    background-color: rgba(239, 68, 68, 0.2);
    border: 1px solid #EF4444;
    color: #FEE2E2;
}

.flash-info {
    background-color: rgba(59, 130, 246, 0.2);
    border: 1px solid #3B82F6;
    color: #DBEAFE;
}

.flash-warning {
    background-color: rgba(245, 158, 11, 0.2);
    border: 1px solid #F59E0B;
    color: #FEF3C7;
}

/* Card styling */
.card {
    background-color: var(--bg-secondary);
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}

/* Button styling */
.btn {
    display: inline-block;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: all 0.15s ease-in-out;
}

.btn-primary {
    background-color: #4F46E5;
    color: white;
}

.btn-primary:hover {
    background-color: #4338CA;
}

.btn-secondary {
    background-color: #6B7280;
    color: white;
}

.btn-secondary:hover {
    background-color: #4B5563;
}

.btn-danger {
    background-color: #EF4444;
    color: white;
}

.btn-danger:hover {
    background-color: #DC2626;
}

.btn-success {
    background-color: #10B981;
    color: white;
}

.btn-success:hover {
    background-color: #059669;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: fixed;
        z-index: 40;
        transition: transform 0.3s ease-in-out;
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .content-with-sidebar {
        margin-left: 0 !important;
    }
}
