/* ===========================
   QuickNote — Design System
   =========================== */

:root {
    /* Colors */
    --bg-primary: #0a0a14;
    --bg-secondary: #0f0f1a;
    --bg-tertiary: #161625;
    --bg-card: #1a1a2e;
    --bg-card-hover: #1f1f35;
    --bg-card-active: #252540;
    
    --text-primary: #f0f0f5;
    --text-secondary: #8888a0;
    --text-tertiary: #55556a;
    --text-placeholder: #44445a;
    
    --accent: #6C63FF;
    --accent-light: #8B83FF;
    --accent-dark: #5550CC;
    --accent-glow: rgba(108, 99, 255, 0.15);
    
    --teal: #4ECDC4;
    --teal-glow: rgba(78, 205, 196, 0.1);
    
    --danger: #FF6B6B;
    --danger-dark: #CC5555;
    
    --border: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.1);
    
    /* Spacing */
    --sidebar-width: 320px;
    --toolbar-height: 56px;
    
    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    
    /* Transitions */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===========================
   Reset & Base
   =========================== */

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::selection {
    background: var(--accent);
    color: white;
}

::-webkit-scrollbar {
    width: 4px;
}

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

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

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

/* ===========================
   Splash Screen
   =========================== */

.splash-screen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: splashFade 0.5s ease 1.5s forwards;
}

.splash-content {
    text-align: center;
    animation: splashPulse 1.5s ease;
}

.splash-icon {
    margin-bottom: 16px;
    animation: splashIconFloat 1.5s ease;
}

.splash-title {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, #6C63FF, #4ECDC4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
}

.splash-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 300;
    letter-spacing: 0.5px;
}

@keyframes splashPulse {
    0% { opacity: 0; transform: scale(0.9); }
    30% { opacity: 1; transform: scale(1); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes splashIconFloat {
    0% { transform: translateY(10px); opacity: 0; }
    40% { transform: translateY(0); opacity: 1; }
}

@keyframes splashFade {
    to { opacity: 0; pointer-events: none; }
}

/* ===========================
   App Layout
   =========================== */

.app {
    display: flex;
    height: 100vh;
    opacity: 0;
    animation: appFadeIn 0.4s ease 1.8s forwards;
}

@keyframes appFadeIn {
    to { opacity: 1; }
}

/* ===========================
   Sidebar
   =========================== */

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 100;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    background: linear-gradient(135deg, #6C63FF, #4ECDC4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.btn-close-sidebar {
    display: none;
}

/* Search */
.search-wrapper {
    position: relative;
    padding: 0 16px 12px;
}

.search-icon {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(calc(-50% - 6px));
    color: var(--text-tertiary);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 10px 12px 10px 38px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: all 0.2s var(--ease);
}

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

.search-input:focus {
    border-color: var(--accent);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Notes Meta */
.notes-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 20px 8px;
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.btn-sort {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s var(--ease);
}

.btn-sort:hover {
    color: var(--text-secondary);
    background: var(--bg-card);
}

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

.note-item {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s var(--ease);
    margin-bottom: 4px;
    border: 1px solid transparent;
    position: relative;
    animation: noteSlideIn 0.25s var(--ease-bounce);
}

@keyframes noteSlideIn {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: translateX(0); }
}

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

.note-item.active {
    background: var(--bg-card-active);
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent-glow), inset 0 0 20px var(--accent-glow);
}

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

.note-item-preview {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 6px;
}

.note-item-date {
    font-size: 11px;
    color: var(--text-tertiary);
    font-weight: 400;
}

/* New Note Button */
.btn-new-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 12px 16px 20px;
    padding: 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.25s var(--ease);
    box-shadow: 0 4px 16px rgba(108, 99, 255, 0.3);
}

.btn-new-note:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(108, 99, 255, 0.4);
}

.btn-new-note:active {
    transform: translateY(0);
}

/* ===========================
   Editor Area
   =========================== */

.editor-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    min-width: 0;
    position: relative;
}

/* Editor Toolbar */
.editor-toolbar {
    display: none;
    align-items: center;
    padding: 0 24px;
    height: var(--toolbar-height);
    border-bottom: 1px solid var(--border);
    gap: 12px;
}

.editor-toolbar.visible {
    display: flex;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s var(--ease);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

.btn-delete-note:hover {
    color: var(--danger);
    background: rgba(255, 107, 107, 0.1);
}

.btn-menu {
    display: none;
}

.editor-toolbar-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 16px;
}

.editor-date, .editor-chars {
    font-size: 12px;
    color: var(--text-tertiary);
}

.editor-toolbar-actions {
    display: flex;
    gap: 4px;
}

/* Title Input */
.note-title {
    display: none;
    width: 100%;
    padding: 24px 32px 8px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 28px;
    font-weight: 700;
    font-family: inherit;
    outline: none;
    letter-spacing: -0.5px;
}

.note-title.visible {
    display: block;
}

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

/* Content Textarea */
.note-content {
    display: none;
    flex: 1;
    width: 100%;
    padding: 12px 32px 32px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    line-height: 1.7;
    outline: none;
    resize: none;
}

.note-content.visible {
    display: block;
}

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

/* Empty State */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    animation: emptyFade 0.5s ease;
}

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

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

.empty-state-icon {
    margin-bottom: 8px;
    opacity: 0.7;
}

.empty-state h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 14px;
    color: var(--text-tertiary);
    margin-bottom: 8px;
}

.btn-primary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.25s var(--ease);
    box-shadow: 0 4px 16px rgba(108, 99, 255, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(108, 99, 255, 0.4);
}

/* ===========================
   Modal
   =========================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s var(--ease);
}

.modal-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: 32px;
    max-width: 360px;
    width: 90%;
    text-align: center;
    transform: scale(0.9);
    transition: transform 0.25s var(--ease-bounce);
    box-shadow: var(--shadow-lg);
}

.modal-overlay.visible .modal {
    transform: scale(1);
}

.modal-icon {
    margin-bottom: 16px;
}

.modal h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 6px;
}

.modal p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.btn-secondary {
    flex: 1;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s var(--ease);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
}

.btn-danger {
    flex: 1;
    padding: 10px 16px;
    background: var(--danger);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s var(--ease);
}

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

/* ===========================
   Toast
   =========================== */

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 12px 24px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    z-index: 600;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s var(--ease-bounce);
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===========================
   Sidebar Overlay (mobile)
   =========================== */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.3s var(--ease);
}

.sidebar-overlay.visible {
    opacity: 1;
}

/* ===========================
   Responsive — Tablet & Mobile
   =========================== */

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform 0.3s var(--ease);
        box-shadow: var(--shadow-lg);
        z-index: 200;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
    }

    .sidebar-overlay.visible {
        pointer-events: auto;
    }

    .btn-close-sidebar {
        display: flex;
    }

    .btn-menu {
        display: flex;
    }

    .note-title {
        padding: 20px 20px 8px;
        font-size: 22px;
    }

    .note-content {
        padding: 8px 20px 24px;
        font-size: 14px;
    }

    .editor-toolbar {
        padding: 0 16px;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 100%;
        min-width: 100%;
    }
}

/* ===========================
   Utility Animations
   =========================== */

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Focus visible for keyboard nav */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
