/* Variables and Theme */
:root {
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-hover: #4f46e5;
    --bg-gradient-start: #f9fafb;
    --bg-gradient-end: #f3f4f6;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --card-bg: #ffffff;
    --sidebar-bg: rgba(255, 255, 255, 0.9);
    --border-color: rgba(229, 231, 235, 0.5);
    --toast-success: rgba(16, 185, 129, 0.9);
    --toast-error: rgba(239, 68, 68, 0.9);
    --toast-info: rgba(59, 130, 246, 0.9);
    --blur-effect: 10px;
    --sidebar-width: 300px;
    --transition-speed: 0.3s;
    --border-radius-sm: 0.25rem;
    --border-radius: 0.5rem;
    --border-radius-lg: 1rem;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.dark-theme {
    --accent-primary: #818cf8;
    --accent-secondary: #a78bfa;
    --accent-hover: #6366f1;
    --bg-gradient-start: #111827;
    --bg-gradient-end: #1f2937;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --card-bg: rgba(31, 41, 55, 0.7);
    --sidebar-bg: rgba(17, 24, 39, 0.9);
    --border-color: rgba(75, 85, 99, 0.5);
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body, html {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    color: var(--text-primary);
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

#app {
    display: flex;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

/* Utility Classes */
.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(var(--blur-effect));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
}

.icon {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.gradient-text {
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gradient-button {
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: all var(--transition-speed);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.gradient-button:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.text-button {
    background: transparent;
    border: none;
    color: var(--accent-primary);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius-sm);
    transition: background-color var(--transition-speed);
}

.text-button:hover {
    background-color: rgba(99, 102, 241, 0.1);
}

.full-width {
    width: 100%;
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    backdrop-filter: blur(var(--blur-effect));
    padding: 1.5rem;
    box-sizing: border-box;
    overflow-y: auto;
    transition: transform var(--transition-speed) ease-in-out;
    position: fixed;
    height: 100%;
    z-index: 1000;
    box-shadow: var(--shadow);
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-toggle {
    position: fixed;
    left: 1rem;
    top: 1rem;
    z-index: 1001;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    font-size: 1.5rem;
}

.app-title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stats-box {
    padding: 1rem;
    margin-bottom: 2rem;
}

.stats-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-section {
    margin-bottom: 2rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.sidebar-title {
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Projects Styles */
.projects-list {
    margin-bottom: 1rem;
}

.project-item {
    margin-bottom: 0.75rem;
    border-radius: var(--border-radius);
    overflow: hidden;
}

.project-header {
    padding: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(99, 102, 241, 0.1);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color var(--transition-speed);
}

.project-header:hover {
    background: rgba(99, 102, 241, 0.2);
}

.project-header.active {
    background: rgba(99, 102, 241, 0.3);
}

.project-title {
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.project-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.project-note-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.2);
    padding: 0.1rem 0.5rem;
    border-radius: 1rem;
}

.project-notes {
    margin-left: 1rem;
    padding: 0.5rem 0;
    display: none;
}

.project-notes.expanded {
    display: block;
}

.project-note {
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: var(--border-radius-sm);
    margin-bottom: 0.25rem;
    transition: all var(--transition-speed);
}

.project-note:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
}

/* Projects Grid in Modal */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    padding: 1rem 0;
}

.project-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all var(--transition-speed);
    position: relative;
    overflow: hidden;
}

.project-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.project-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    display: block;
}

.project-card-title {
    font-weight: bold;
    margin-bottom: 0.5rem;
    padding-left: 0.5rem;
}

.project-card-count {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.project-card-notes {
    margin-top: 0.75rem;
    max-height: 100px;
    overflow-y: auto;
}

.project-card-note {
    padding: 0.25rem 0.5rem;
    margin-bottom: 0.25rem;
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-secondary);
}

/* Tags Styles */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.tag {
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
    cursor: pointer;
    transition: background-color var(--transition-speed);
}

.tag:hover {
    background: rgba(99, 102, 241, 0.2);
}

.tag.active {
    background: var(--accent-primary);
    color: white;
}

/* Version Settings */
.version-settings {
    padding: 1rem;
    border-radius: var(--border-radius);
    background: rgba(99, 102, 241, 0.05);
}

.version-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.version-select {
    width: 100%;
    padding: 0.5rem;
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

/* Main Content */
.main-content {
    flex-grow: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-speed) ease-in-out;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.main-content.full-width {
    margin-left: 0;
}

/* Header */
.header {
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(5px);
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid var(--border-color);
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.search-container {
    position: relative;
    width: 250px;
}

.search-input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    backdrop-filter: blur(5px);
}

.search-icon {
    position: absolute;
    width: 16px;
    height: 16px;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    fill: var(--text-secondary);
}

.word-count {
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.8rem;
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
}

.author-input {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem;
    outline: none;
}

.theme-toggle {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color var(--transition-speed);
}

.theme-toggle:hover {
    background: rgba(99, 102, 241, 0.1);
}

/* Notes Container */
.notes-container {
    padding: 2rem;
    overflow-y: auto;
    flex-grow: 1;
}

/* Note Styles */
.note {
    background: var(--card-bg);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-lg);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
}

.note:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
}

.note-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.note-project {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.note-title-container {
    flex-grow: 1;
}

.note-title {
    width: 100%;
    background: transparent;
    color: var(--text-primary);
    border: none;
    font-size: 1.2rem;
    font-weight: bold;
    outline: none;
    padding: 0.25rem 0;
}

.note-controls {
    display: flex;
    gap: 0.5rem;
}

.icon-button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    background: rgba(99, 102, 241, 0.1);
    color: var(--accent-primary);
    cursor: pointer;
    transition: background-color var(--transition-speed);
}

.icon-button:hover {
    background: rgba(99, 102, 241, 0.2);
}

.icon-button.delete {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.icon-button.delete:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* Formatting Menu */
.formatting-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: rgba(99, 102, 241, 0.05);
    border-radius: var(--border-radius);
}

.formatting-menu button {
    padding: 0.25rem 0.5rem;
    border-radius: var(--border-radius-sm);
    background: rgba(255, 255, 255, 0.5);
    color: var(--text-primary);
    font-size: 0.8rem;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all var(--transition-speed);
}

.formatting-menu button:hover {
    background: var(--accent-primary);
    color: white;
}

.note-content {
    width: 100%;
    min-height: 150px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    outline: none;
    font-family: inherit;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.note-content[contenteditable="true"] {
    cursor: text;
    resize: vertical;
    overflow-y: auto;
}

.note-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.note-meta {
    display: flex;
    gap: 1rem;
}

.note-versions {
    cursor: pointer;
    color: var(--accent-primary);
    text-decoration: underline;
}

/* Add Note Button */
.add-note-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-xl);
    z-index: 100;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    z-index: 1000;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    margin-bottom: 0.75rem;
    backdrop-filter: blur(var(--blur-effect));
    color: white;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow);
    transform: translateY(100px);
    opacity: 0;
    transition: all var(--transition-speed) ease;
    max-width: 350px;
}

.toast.visible {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--toast-success);
}

.toast.error {
    background: var(--toast-error);
}

.toast.info {
    background: var(--toast-info);
}

.toast-icon {
    font-size: 1.2rem;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.toast-message {
    font-size: 0.8rem;
    opacity: 0.9;
}

.toast-close {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity var(--transition-speed);
}

.toast-close:hover {
    opacity: 1;
}

.toast input {
    width: 100%;
    padding: 0.5rem;
    margin-top: 0.5rem;
    border: none;
    border-radius: var(--border-radius-sm);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-speed);
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    transform: translateY(-50px);
    transition: transform var(--transition-speed);
    box-shadow: var(--shadow-xl);
}

.modal.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-primary);
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

/* Version History */
.version-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.version-item {
    padding: 1rem;
    border-radius: var(--border-radius);
    background: rgba(99, 102, 241, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.version-info {
    display: flex;
    flex-direction: column;
}

.version-number {
    font-weight: bold;
    color: var(--accent-primary);
}

.version-date {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.version-actions {
    display: flex;
    gap: 0.5rem;
}

/* Responsive adaptations */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
    }
    
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .note-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .note-title {
        width: 100%;
        margin-bottom: 1rem;
    }
    
    .header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    .header-left, .header-right {
        width: 100%;
    }
    
    .search-container {
        width: 100%;
    }
    
    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }
    
    .projects-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}
