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

:root {
    --ferrari-red: #FF2800;
    --bg-black: #000;
    --bg-dark: #2c2c2c;
    --bg-darker: #1a1a1a;
    --border-dark: #3a3a3a;
    --text-primary: #e0e0e0;
    --text-secondary: #d0d0d0;
    --text-muted: #888;
    --text-placeholder: #444;
    --hover-bg: #3a3a3a;
    --active-bg: #454545;
    
    --font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    
    --title-size: 25px;
    --h1-size: 22px;
    --h2-size: 20px;
    --body-size: 18px;
    --ui-size: 15px;
    
    --transition-fast: 0.2s ease-out;
    --transition-smooth: 0.3s ease-out;
    --transition-slow: 0.5s ease-out;
}

body {
    font-family: var(--font-family);
    background: var(--bg-black);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app {
    display: flex;
    height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: 280px;
    background: var(--bg-dark);
    border-right: 1px solid var(--border-dark);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    transition: margin-left var(--transition-smooth);
    position: relative;
    z-index: 10;
}

.sidebar.hidden {
    margin-left: -280px;
}

/* Sidebar Header */
.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-dark);
    display: flex;
    gap: 12px;
    align-items: center;
}

.back-btn {
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    color: var(--ferrari-red);
    font-size: 18px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.back-btn:hover {
    background: rgba(255, 40, 0, 0.1);
    transform: scale(1.05);
}

.back-btn:active {
    transform: scale(0.95);
}

.search-wrap {
    flex: 1;
    display: flex;
    justify-content: center;
}

.search-wrap.has-back {
    justify-content: flex-start;
}

.search-box {
    background: var(--border-dark);
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-smooth);
    min-width: fit-content;
    position: relative;
    overflow: hidden;
}

.search-box:hover,
.search-box.active {
    background: var(--active-bg);
    box-shadow: 0 0 0 2px rgba(255, 40, 0, 0.2);
}

.search-wrap:not(.has-back) .search-box:hover,
.search-wrap:not(.has-back) .search-box.active {
    width: 100%;
}

.search-wrap.has-back .search-box:hover,
.search-wrap.has-back .search-box.active {
    flex: 1;
}

.search-text {
    color: var(--ferrari-red);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.search-box:hover .search-text,
.search-box.active .search-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.search-input {
    width: 0;
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font-family);
    outline: none;
    text-align: center;
    transition: all var(--transition-smooth);
}

.search-box:hover .search-input,
.search-box.active .search-input {
    width: 100%;
    opacity: 1;
}

.search-input::placeholder {
    color: var(--text-muted);
    text-align: center;
}

/* Notes List */
.notes-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.folder-item,
.note-item {
    padding: 14px 16px;
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer;
    font-size: var(--ui-size);
    transition: all var(--transition-fast);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.folder-item::before,
.note-item::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 40, 0, 0.1);
    transform: translate(-50%, -50%);
    transition: width var(--transition-smooth), height var(--transition-smooth);
}

.folder-item:hover::before,
.note-item:hover::before {
    width: 200%;
    height: 200%;
}

.folder-item:hover,
.note-item:hover {
    background: var(--hover-bg);
    transform: translateY(-1px);
}

.folder-item:active,
.note-item:active {
    transform: translateY(0);
}

.note-item.active {
    background: var(--hover-bg);
    box-shadow: inset 0 0 0 1px rgba(255, 40, 0, 0.3);
}

.folder-icon,
.note-icon {
    font-size: 16px;
    opacity: 0.8;
}

.folder-name,
.note-name {
    position: relative;
    z-index: 1;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-dark);
    display: flex;
    justify-content: center;
}

.action-btn {
    background: var(--border-dark);
    border: none;
    border-radius: 8px;
    color: var(--ferrari-red);
    padding: 10px;
    min-width: 36px;
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-smooth);
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
    position: relative;
}

.action-btn:hover {
    background: var(--active-bg);
    padding: 10px 16px;
    box-shadow: 0 2px 8px rgba(255, 40, 0, 0.2);
}

.action-icon {
    font-size: 18px;
    transition: all var(--transition-fast);
    display: block;
    line-height: 1;
    text-align: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.action-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
    transition: all var(--transition-smooth);
    white-space: nowrap;
    display: flex;
    align-items: center;
}

.action-btn:hover .action-icon {
    opacity: 0;
    width: 0;
}

.action-btn:hover .action-text {
    opacity: 1;
    width: auto;
}

/* ===== MAIN AREA ===== */
.main {
    flex: 1;
    background: var(--bg-black);
    display: flex;
    flex-direction: column;
    padding: 80px 5vw 100px 10vw;
    overflow-y: auto;
    position: relative;
}

.toggle-btn {
    position: absolute;
    top: 16px;
    left: 10vw;
    width: 36px;
    height: 36px;
    background: var(--bg-dark);
    border: none;
    border-radius: 8px;
    color: var(--ferrari-red);
    font-size: 20px;
    cursor: pointer;
    opacity: 0.3;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-btn:hover {
    opacity: 1;
    background: var(--hover-bg);
    transform: scale(1.05);
}

.toggle-btn:active {
    transform: scale(0.95);
}

.toggle-btn::after {
    content: '›';
    font-size: 24px;
}

.sidebar:not(.hidden) ~ .main .toggle-btn {
    left: calc(280px + 16px);
}

.sidebar:not(.hidden) ~ .main .toggle-btn::after {
    content: '‹';
}

/* Content Area */
.content {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    flex: 1;
    margin: 0 auto;
    position: relative;
}

.title-input {
    width: 100%;
    background: none;
    border: none;
    font-size: var(--title-size);
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    outline: none;
    margin-bottom: 32px;
    flex-shrink: 0;
    font-family: var(--font-family);
    transition: all var(--transition-fast);
}

.title-input:focus {
    color: var(--ferrari-red);
}

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

/* Editor Wrapper */
.editor-wrapper {
    flex: 1;
    position: relative;
}

.body-editor {
    width: 100%;
    min-height: 100%;
    background: none;
    border: none;
    font-size: var(--body-size);
    line-height: 1.8;
    color: var(--text-secondary);
    outline: none;
    font-family: var(--font-family);
    font-weight: 400;
}

.body-editor:empty:before {
    content: attr(data-placeholder);
    color: var(--text-placeholder);
    pointer-events: none;
}

/* Typography in Editor */
.body-editor h1 {
    font-size: var(--h1-size) !important;
    font-weight: 500 !important;
    margin: 24px 0 16px !important;
    color: var(--text-primary) !important;
    line-height: 1.4 !important;
    display: block !important;
}

.body-editor h2 {
    font-size: var(--h2-size) !important;
    font-weight: 500 !important;
    margin: 20px 0 12px !important;
    color: var(--text-primary) !important;
    line-height: 1.4 !important;
    display: block !important;
}

.body-editor strong,
.body-editor b {
    font-weight: 700;
}

.body-editor em,
.body-editor i {
    font-style: italic;
    font-weight: 400;
}

.body-editor strong em,
.body-editor em strong {
    font-weight: 600;
    font-style: italic;
}

.body-editor ul,
.body-editor ol {
    margin: 16px 0;
    padding-left: 32px;
}

.body-editor li {
    margin: 8px 0;
}

/* Slash Command Menu */
.slash-menu {
    position: absolute;
    background: var(--bg-darker);
    border: 1px solid var(--border-dark);
    border-radius: 8px;
    padding: 6px;
    min-width: 220px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 100;
    backdrop-filter: blur(10px);
    background: rgba(26, 26, 26, 0.95);
}

.slash-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 14px;
}

.slash-menu-item:hover,
.slash-menu-item.selected {
    background: var(--hover-bg);
    transform: translateX(2px);
}

.command-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--border-dark);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--ferrari-red);
}

.command-label {
    color: var(--text-primary);
    font-weight: 500;
}

/* Word Count */
.word-count {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-dark);
    padding: 6px 14px;
    border-radius: 12px;
    font-size: 12px;
    color: var(--ferrari-red);
    font-weight: 500;
    backdrop-filter: blur(10px);
    background: rgba(44, 44, 44, 0.8);
    transition: all var(--transition-smooth);
    z-index: 50;
}

/* Adjust word count position when sidebar is visible */
.sidebar:not(.hidden) ~ .main .word-count {
    left: calc(50% + 140px); /* Shift right by half sidebar width */
}

.word-count:hover {
    background: rgba(44, 44, 44, 0.95);
    transform: translateX(-50%) scale(1.05);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity var(--transition-smooth);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-dark);
    border-top-color: var(--ferrari-red);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

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

/* Password Modal */
.password-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.password-card {
    background: var(--bg-dark);
    padding: 40px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(255, 40, 0, 0.3);
}

.password-card h2 {
    color: var(--ferrari-red);
    margin-bottom: 20px;
    font-size: 28px;
}

.password-card p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.6;
}

.password-card input {
    width: 100%;
    background: var(--bg-black);
    border: 1px solid var(--border-dark);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 14px;
    font-size: 16px;
    font-family: var(--font-family);
    margin-bottom: 20px;
}

.password-card input:focus {
    outline: none;
    border-color: var(--ferrari-red);
}

.password-card button {
    width: 100%;
    background: var(--ferrari-red);
    border: none;
    border-radius: 8px;
    color: white;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.password-card button:hover {
    background: #cc2000;
    transform: translateY(-2px);
}

.password-card .warning {
    margin-top: 20px;
    color: #ff6b6b;
    font-size: 14px;
    font-weight: 500;
}

/* Loading Overlay Styles */
.loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-overlay .spinner {
    animation: spin 0.8s linear infinite;
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-dark);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--hover-bg);
}

/* Selection */
::selection {
    background: rgba(255, 40, 0, 0.3);
    color: var(--text-primary);
}
