/* Custom CSS for Notes App */

/* Global styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
}

/* Dark mode global styles */
[data-bs-theme="dark"] body {
    background-color: var(--bs-dark);
    color: var(--bs-light);
}

/* Header styles */

/* Note editor styles */
#noteField {
    font-family: 'Hack', 'Monaco', 'Cascadia Code', 'Consolas', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    height: calc(100vh - 160px); /* Fixed height based on viewport minus header space */
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    padding: 1.5rem;
    background: #fafafa;
}

/* Dark mode editor styles */
[data-bs-theme="dark"] #noteField {
    background: #1a1a1a;
    color: #f8f9fa;
}

[data-bs-theme="dark"] #noteField:focus {
    background: #212529;
}

[data-bs-theme="dark"] #noteField:disabled {
    background: #343a40;
    color: #6c757d;
}

/* Main content transitions */
main {
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Ensure container-fluid doesn't create horizontal scroll */
.container-fluid {
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

#noteField:focus {
    background: #ffffff;
}

#noteField:disabled {
    background: #f8f9fa;
    color: #6c757d;
}

/* CodeMirror 6 collaborative editor host integration.
   The #noteField div hosts a CodeMirror EditorView; let the view fill the
   fixed-height host and inherit the editor's monospace look and theming. */
#noteField {
    padding: 0;
}
#noteField .cm-editor {
    height: 100%;
    font-family: 'Hack', 'Monaco', 'Cascadia Code', 'Consolas', 'Courier New', monospace;
    font-size: 14px;
    background: #fafafa;
}
#noteField .cm-editor.cm-focused {
    outline: none;
}
#noteField .cm-scroller {
    overflow: auto;
    line-height: 1.5;
}
#noteField .cm-content {
    padding: 1.25rem 0;
}
#noteField .cm-gutters {
    background: #fafafa;
    border-right: 1px solid rgba(0, 0, 0, 0.075);
}

/* Dark mode for the CodeMirror host. */
[data-bs-theme="dark"] #noteField .cm-editor {
    background: #1a1a1a;
    color: #f8f9fa;
}
[data-bs-theme="dark"] #noteField .cm-gutters {
    background: #1a1a1a;
    color: #6c757d;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}
[data-bs-theme="dark"] #noteField .cm-activeLine,
[data-bs-theme="dark"] #noteField .cm-activeLineGutter {
    background: rgba(255, 255, 255, 0.04);
}
[data-bs-theme="dark"] #noteField .cm-cursor {
    border-left-color: #f8f9fa;
}

/* Auto-resize textarea */
.auto-resize {
    overflow-y: auto;
}

/* Connection status badges */
.badge.bg-success {
    background-color: #28a745 !important;
}

.badge.bg-warning {
    background-color: #ffc107 !important;
    color: #212529 !important;
}

.badge.bg-danger {
    background-color: #dc3545 !important;
}

.badge.bg-secondary {
    background-color: #6c757d !important;
}

/* Save status indicators */
.save-status-saving {
    color: #ffc107;
}

.save-status-saved {
    color: #28a745;
}

.save-status-error {
    color: #dc3545;
}

.save-status-unsaved-delayed {
    color: #ffc107;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.save-status-unsaved-delayed.show {
    opacity: 1;
}

/* Loading overlay */
#loadingOverlay {
    z-index: 10;
    backdrop-filter: blur(2px);
}

/* Responsive design */
@media (max-width: 768px) {
    .container-fluid {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    #noteField {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 1rem;
        height: calc(100vh - 210px); /* Adjusted for mobile */
        max-height: calc(100vh - 210px);
    }
    
    .card-header {
        padding: 1rem;
    }
    
    
    /* Hide note title on mobile */
    #noteTitle {
        display: none;
    }
    
}

/* Card shadows and borders */
.card {
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.card-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

/* Dark mode card styles */
[data-bs-theme="dark"] .card-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.125);
}

[data-bs-theme="dark"] .card {
    border: 1px solid rgba(255, 255, 255, 0.125);
}

/* Scrollbar styles for webkit browsers */
#noteField::-webkit-scrollbar {
    width: 8px;
}

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

#noteField::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

#noteField::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Dark mode scrollbar styles */
[data-bs-theme="dark"] #noteField::-webkit-scrollbar-track {
    background: #2d3748;
    border-radius: 4px;
}

[data-bs-theme="dark"] #noteField::-webkit-scrollbar-thumb {
    background: #4a5568;
    border-radius: 4px;
}

[data-bs-theme="dark"] #noteField::-webkit-scrollbar-thumb:hover {
    background: #718096;
}

/* Focus styles */
.card:focus-within {
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
    border-color: #86b7fe;
}

/* Animation for status changes */
.status-transition {
    transition: all 0.3s ease;
}

/* Pulse animation for connection status */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.pulse {
    animation: pulse 1.5s infinite;
}

/* Typing indicator */
.typing-indicator {
    color: #28a745;
    font-weight: 500;
}

.typing-indicator::after {
    content: '';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* Keyboard shortcut styling */
kbd {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    color: #495057;
    font-size: 0.75em;
    padding: 0.25rem 0.5rem;
}

/* Fixed Left Sidebar styles */
#sidebar {
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    overflow-y: auto;
}

/* Dark mode sidebar shadow */
[data-bs-theme="dark"] #sidebar {
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.3);
}
#sidebar.show {
    display: flex !important;
}

#sidebar .list-group-item {
    border-left: none;
    border-right: none;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s ease;
}

#sidebar .list-group-item.active {
    background-color: color-mix(in srgb, var(--bs-primary) 10%, white 90%);
    color: var(--bs-white);
    border-color: var(--bs-primary);
}

/* Light mode active item */
[data-bs-theme="light"] #sidebar .list-group-item.active {
    background-color: color-mix(in srgb, var(--bs-primary) 10%, white 90%);
    color: var(--bs-white);
}

/* Dark mode active item */
[data-bs-theme="dark"] #sidebar .list-group-item.active {
    background-color: color-mix(in srgb, var(--bs-primary) 10%, rgb(0, 0, 0) 90%);
    color: var(--bs-white);
}

/* Sidebar section headers */
#sidebar .bg-body-secondary {
    border-bottom: 1px solid var(--bs-border-color);
}

#sidebar .bg-body-secondary .text-muted {
    color: var(--bs-secondary) !important;
    font-weight: 600;
}

/* Light mode sidebar text colors */
[data-bs-theme="light"] #sidebar .text-muted {
    color: #495057 !important;
}

[data-bs-theme="light"] #sidebar .bg-body-secondary .text-muted {
    color: #495057 !important;
}

/* Dark mode sidebar text colors */
[data-bs-theme="dark"] #sidebar .text-muted {
    color: #adb5bd !important;
}

[data-bs-theme="dark"] #sidebar .bg-body-secondary .text-muted {
    color: #adb5bd !important;
}

/* Sidebar list items hover effects */
#sidebar .list-group-item:hover:not(.active) {
    background-color: var(--bs-gray-100);
}

[data-bs-theme="dark"] #sidebar .list-group-item:hover:not(.active) {
    background-color: var(--bs-gray-800);
}

/* Note item specific styles */
.note-item {
    padding: 0.75rem 1rem;
}

.note-item .fw-medium {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    color: var(--bs-body-color);
}

.note-item small {
    font-size: 0.75rem;
    color: var(--bs-secondary);
}

/* Light mode note item text */
[data-bs-theme="light"] .note-item .fw-medium {
    color: #212529;
}

[data-bs-theme="light"] .note-item small {
    color: #6c757d;
}

/* Dark mode note item text */
[data-bs-theme="dark"] .note-item .fw-medium {
    color: #f8f9fa;
}

[data-bs-theme="dark"] .note-item small {
    color: #adb5bd;
}

/* Action button styling */
.note-item .btn-link {
    border: none !important;
    box-shadow: none !important;
    color: var(--bs-secondary);
    transition: color 0.2s ease;
}

.note-item .btn-link:hover {
    color: #ffc107;
}

.note-item .btn-link:focus {
    box-shadow: 0 0 0 0.125rem rgba(255, 193, 7, 0.25);
}

/* Light mode action buttons */
[data-bs-theme="light"] .note-item .btn-link {
    color: #6c757d;
}

/* Dark mode action buttons */
[data-bs-theme="dark"] .note-item .btn-link {
    color: #adb5bd;
}

/* Trash button specific styling */
.note-item .btn-link.text-danger {
    color: var(--bs-secondary) !important;
    opacity: 0.6;
}

.note-item .btn-link.text-danger:hover {
    color: var(--bs-danger) !important;
    opacity: 1;
}

.note-item .btn-link.text-danger:focus {
    box-shadow: 0 0 0 0.125rem rgba(220, 53, 69, 0.25);
}

/* Light mode trash button */
[data-bs-theme="light"] .note-item .btn-link.text-danger {
    color: #6c757d !important;
}

[data-bs-theme="light"] .note-item .btn-link.text-danger:hover {
    color: #dc3545 !important;
}

/* Dark mode trash button */
[data-bs-theme="dark"] .note-item .btn-link.text-danger {
    color: #adb5bd !important;
}

[data-bs-theme="dark"] .note-item .btn-link.text-danger:hover {
    color: #dc3545 !important;
}

/* Developer info section */
#developerInfo .form-control {
    background-color: #f8f9fa;
    font-size: 0.875rem;
}

/* Dark mode developer info */
[data-bs-theme="dark"] #developerInfo .form-control {
    background-color: var(--bs-gray-800);
    color: var(--bs-light);
    border-color: var(--bs-gray-600);
}
#developerInfo .btn-outline-secondary {
    transition: all 0.2s ease;
}

#developerInfo .btn-success {
    background-color: #28a745;
    border-color: #28a745;
    color: white;
}

#developerInfo .btn-danger {
    background-color: #dc3545;
    border-color: #dc3545;
    color: white;
}

/* Fixed sidebar responsive behavior */
@media (max-width: 768px) {
    #sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    #sidebar.show {
        transform: translateX(0);
    }
    
    /* Don't adjust main content margin on mobile when sidebar is visible */
    main {
        margin-left: 0 !important;
    }
}


.btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Collapsible section icons */
[data-bs-toggle="collapse"] .bi-chevron-down {
    transition: transform 0.3s ease;
}

[data-bs-toggle="collapse"][aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

/* Smooth transitions for all interactive elements */
.list-group-item,
.card,
.btn,
.badge {
    transition: all 0.2s ease;
}

/* Copy feedback animations */
@keyframes copySuccess {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.btn-success {
    animation: copySuccess 0.3s ease;
}

/* Focus styles for accessibility */
.btn:focus,
.list-group-item:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    #sidebar,
    .navbar,
    #developerInfo {
        display: none !important;
    }
    
    main {
        margin-left: 0 !important;
    }
    
    #noteField {
        height: auto !important;
        max-height: none !important;
        background: white !important;
        border: 1px solid #000 !important;
    }
}