/* CSS Variables for theming */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --border-color: #e5e7eb;
    --border-focus: #4f46e5;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: 150ms ease;
}

/* Reset and Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header Styles */
.app-header {
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1600px;
    margin: 0 auto;
    gap: 1rem;
    flex-wrap: wrap;
}

.logo-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.app-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Search Container */
.search-container {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 300px;
}

.search-container input {
    width: 100%;
    padding: 0.625rem 1rem 0.625rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    background-color: var(--bg-secondary);
    transition: all var(--transition);
}

.search-container input:focus {
    outline: none;
    border-color: var(--border-focus);
    background-color: var(--bg-primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--border-color);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: var(--danger-hover);
}

/* Main Content Layout */
.main-content {
    display: flex;
    flex: 1;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* Notes Sidebar */
.notes-sidebar {
    width: 320px;
    background-color: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.notes-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.notes-list-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.notes-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background-color: var(--bg-tertiary);
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
}

.notes-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

/* Note Item in List */
.note-item {
    padding: 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 0.5rem;
    border: 1px solid transparent;
}

.note-item:hover {
    background-color: var(--bg-secondary);
}

.note-item.active {
    background-color: var(--primary-light);
    border-color: var(--primary-color);
}

.note-item-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.note-item-preview {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.note-item-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.empty-state span {
    font-size: 0.875rem;
}

.empty-state.hidden {
    display: none;
}

/* Note Editor */
.note-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
    min-width: 0;
}

.editor-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
    padding: 2rem;
}

.editor-placeholder svg {
    margin-bottom: 1rem;
    opacity: 0.4;
}

.editor-placeholder h3 {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.editor-placeholder p {
    font-size: 0.875rem;
}

.editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.editor-container.hidden {
    display: none;
}

.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    gap: 1rem;
    flex-wrap: wrap;
}

.note-title-input {
    flex: 1;
    font-size: 1.25rem;
    font-weight: 600;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    min-width: 200px;
}

.note-title-input::placeholder {
    color: var(--text-muted);
}

.editor-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.save-status {
    font-size: 0.8125rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.save-status.saving {
    color: var(--warning-color);
}

.save-status.saved {
    color: var(--success-color);
}

.note-content-input {
    flex: 1;
    padding: 1.5rem;
    border: none;
    outline: none;
    resize: none;
    font-size: 1rem;
    line-height: 1.75;
    color: var(--text-primary);
    font-family: inherit;
    background: transparent;
}

.note-content-input::placeholder {
    color: var(--text-muted);
}

.editor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* App Footer */
.app-footer {
    background-color: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 1rem;
    text-align: center;
}

.app-footer p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.app-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color var(--transition);
}

.app-footer a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Modal Styles */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    max-width: 400px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    animation: modalFadeIn 150ms ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-content h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.modal-content p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Scrollbar Styling */
.notes-list::-webkit-scrollbar {
    width: 6px;
}

.notes-list::-webkit-scrollbar-track {
    background: transparent;
}

.notes-list::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 3px;
}

.notes-list::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-muted);
}

/* Responsive Styles */
@media (max-width: 900px) {
    .main-content {
        flex-direction: column;
    }

    .notes-sidebar {
        width: 100%;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .note-editor {
        min-height: 50vh;
    }

    .btn-text {
        display: none;
    }

    .btn {
        padding: 0.625rem;
    }

    .search-container {
        min-width: 150px;
    }
}

@media (max-width: 600px) {
    .header-content {
        flex-direction: column;
        align-items: stretch;
    }

    .logo-title {
        justify-content: center;
    }

    .header-actions {
        justify-content: center;
    }

    .search-container {
        max-width: none;
        order: 1;
        width: 100%;
    }

    .editor-header {
        flex-direction: column;
        align-items: stretch;
    }

    .editor-actions {
        justify-content: space-between;
    }

    .note-title-input {
        text-align: center;
    }

    .editor-footer {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
}

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

button:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .app-header,
    .notes-sidebar,
    .editor-actions,
    .app-footer {
        display: none !important;
    }

    .note-editor {
        padding: 0;
    }

    .note-content-input {
        border: none;
    }
}
