/**
 * Custom CSS - Additional styles for TextEdit application
 * Enhances TailwindCSS with custom animations and utilities
 */

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

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

.dark ::-webkit-scrollbar-track {
    background: #374151;
}

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

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

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

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

/* Line clamp utility for text truncation */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-clamp: 2; /* Standard property for compatibility */
}

/* Smooth focus transitions */
input:focus,
textarea:focus {
    transition: all 0.2s ease-in-out;
}

/* Custom button hover effects */
.btn-hover-scale {
    transition: transform 0.2s ease-in-out;
}

.btn-hover-scale:hover {
    transform: scale(1.05);
}


/* Active document indicator */
.document-item.active {
    background: linear-gradient(90deg, #059669 0%, transparent 100%);
}

/* Textarea auto-resize */
.auto-resize {
    resize: none;
    overflow: hidden;
}

/* Loading animation */
.loading-spinner {
    animation: spin 1s linear infinite;
}

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

/* Fade in animation */
.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

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

/* Slide in animation */
.slide-in-right {
    animation: slideInRight 0.3s ease-out;
}

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

/* Pulse animation for notifications */
.pulse-once {
    animation: pulseOnce 0.6s ease-in-out;
}

@keyframes pulseOnce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* Custom focus ring */
.focus-ring {
    transition: box-shadow 0.2s ease-in-out;
}

.focus-ring:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}

/* Tag input styling */
.tag-input {
    border: 2px dashed #d1d5db;
    transition: border-color 0.2s ease-in-out;
}

.tag-input:focus {
    border-color: #059669;
    border-style: solid;
}

.dark .tag-input {
    border-color: #4b5563;
}

.dark .tag-input:focus {
    border-color: #059669;
}

/* Search input highlight */
.search-highlight {
    background: linear-gradient(90deg, #fef3c7, #fbbf24);
    color: #92400e;
    padding: 0 2px;
    border-radius: 2px;
}

.dark .search-highlight {
    background: linear-gradient(90deg, #451a03, #92400e);
    color: #fbbf24;
}

/* Empty state illustration */
.empty-state-icon {
    opacity: 0.6;
    transition: opacity 0.3s ease-in-out;
}

.empty-state-icon:hover {
    opacity: 0.8;
}


/* Status indicators */
.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-shared {
    background-color: #3b82f6;
}

.status-private {
    background-color: #6b7280;
}

.status-searchable {
    background-color: #059669;
}

/* Document list item styling - Card Layout */
.document-item {
    position: relative;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.document-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.dark .document-item:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

/* Document title styling */
.document-title {
    cursor: pointer;
    transition: color 0.2s ease-in-out;
}

.document-title:hover {
    color: #059669;
}

.dark .document-title:hover {
    color: #10b981;
}

/* Document content inline editing */
.document-content {
    cursor: text;
    transition: all 0.2s ease-in-out;
    min-height: 60px;
    padding: 8px;
    border-radius: 6px;
}

.document-content:hover {
    background-color: #f9fafb;
    border: 1px dashed #d1d5db;
}

.dark .document-content:hover {
    background-color: #374151;
    border: 1px dashed #6b7280;
}

.document-content.editing {
    background-color: #ffffff;
    border: 2px solid #059669;
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}

.dark .document-content.editing {
    background-color: #1f2937;
    border: 2px solid #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Inline editor textarea */
.inline-editor {
    width: 100%;
    min-height: 60px;
    padding: 8px;
    border: none;
    outline: none;
    background: transparent;
    resize: vertical;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    color: inherit;
}

/* Document metadata */
.document-meta {
    font-size: 0.75rem;
    color: #6b7280;
    transition: color 0.2s ease-in-out;
}

.dark .document-meta {
    color: #9ca3af;
}

/* Line clamp utilities for text truncation */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-4 {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Mobile responsive optimizations */
@media (max-width: 1023px) {
    /* Ensure mobile panels take full width */
    #documentsPanel {
        width: 100% !important;
    }
    
    /* Touch-friendly button sizing */
    .mobile-touch-target {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Mobile document list optimization */
    #documentList {
        max-height: none;
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
        padding: 1rem !important;
    }
    
    /* Larger touch targets for mobile */
    .document-item {
        padding: 16px;
    }
    
    .document-content {
        min-height: 100px;
        padding: 12px;
    }
}

/* Tablet responsive adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    #documentList {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Responsive text sizing */
@media (max-width: 640px) {
    .responsive-text {
        font-size: 0.875rem;
    }
    
    /* Smaller padding on mobile */
    .mobile-padding {
        padding: 1rem;
    }
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    .print-only {
        display: block !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .document-item:hover {
        border: 2px solid currentColor;
    }
    
    button:focus {
        outline: 3px solid currentColor;
        outline-offset: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Custom selection colors */
::selection {
    background-color: #059669;
    color: white;
}

.dark ::selection {
    background-color: #10b981;
    color: white;
}

/* Prevent flash of unstyled content during initialization */
.app-loading #welcomeScreen {
    opacity: 0;
    transition: opacity 0.1s ease-in-out;
}

.app-loading #editorInterface {
    opacity: 0;
    transition: opacity 0.1s ease-in-out;
}

/* Show content after app is ready */
.app-ready #welcomeScreen,
.app-ready #editorInterface {
    opacity: 1;
}
