:root {
    --bg: #f5f5f7;
    --surface: #ffffff;
    --surface-glass: rgba(255, 255, 255, 0.8);
    --text: #1d1d1f;
    --text-secondary: #6e6e73;
    --border: #e5e5e7;
    --primary: #0066cc;
    --primary-hover: #004499;
    --primary-light: rgba(0, 102, 204, 0.08);
    --shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.06);
    --radius: 12px;
    --font: 'Inter', 'Roboto', -apple-system, sans-serif;
    --sidebar-width: 260px;
    --danger: #ff453a;
    --danger-light: #ffd6d4;
}

body.dark {
    --bg: #050508;
    --surface: #0d0d14;
    --surface-glass: rgba(13, 13, 20, 0.8);
    --text: #f5f5f7;
    --text-secondary: #86868b;
    --border: #1a1a24;
    --primary: #2f80ed;
    --primary-hover: #1d4ed8;
    --primary-light: rgba(47, 128, 237, 0.15);
    --shadow: none;
    --shadow-lg: none;
    --danger: #ff453a;
    --danger-light: #450a0a;
}

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

body {
    font-family: var(--font);
    background-color: var(--bg);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
    transition: background-color 0.2s, color 0.2s;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
}

.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(5, 5, 8, 0.4);
    backdrop-filter: blur(8px);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.sidebar-backdrop.active {
    opacity: 1;
    pointer-events: all;
}

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background-color: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 100;
    transition: width 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), border-color 0.2s, background-color 0.2s;
}

.sidebar-header {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
    white-space: nowrap;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary);
}

.logo-icon {
    width: 20px;
    height: 20px;
}

.sidebar-action {
    padding: 0 1.25rem 1.25rem 1.25rem;
    overflow: hidden;
}

.sidebar-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 0.75rem;
}

.list-title {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    font-weight: 600;
    margin-bottom: 0.5rem;
    padding-left: 0.5rem;
    overflow: hidden;
    white-space: nowrap;
}

.note-list {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.note-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
    transition: background-color 0.15s, color 0.15s;
    overflow: hidden;
}

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

.note-item.active {
    background-color: var(--primary);
    color: #ffffff;
}

.note-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.note-item-delete {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: none;
    background-color: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0;
    margin-left: 0.5rem;
    flex-shrink: 0;
}

.note-item-delete svg {
    width: 14px;
    height: 14px;
}

.note-item:hover .note-item-delete {
    opacity: 0.7;
}

.note-item:hover .note-item-delete:hover {
    opacity: 1;
    background-color: #ff3b30 !important;
    color: #ffffff !important;
}

.note-item.active .note-item-delete {
    color: rgba(255, 255, 255, 0.7);
}

.note-item.active .note-item-delete:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.2) !important;
}

@media (max-width: 768px) {
    .note-item-delete {
        opacity: 0.8;
    }
}

.note-item-title {
    font-weight: 500;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.note-item-date {
    font-size: 0.7rem;
    opacity: 0.65;
    margin-top: 0.15rem;
}

.sidebar-footer {
    padding: 1.25rem;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow: hidden;
}

.btn-theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.55rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background-color: transparent;
    color: var(--text);
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    transition: background-color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

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

body.dark .light-icon {
    display: block;
}
body.dark .dark-icon {
    display: none;
}
body:not(.dark) .light-icon {
    display: none;
}
body:not(.dark) .dark-icon {
    display: block;
}

.user-profile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.25rem 0.25rem 0 0.25rem;
    white-space: nowrap;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    max-width: 65%;
}

.user-avatar {
    width: 15px;
    height: 15px;
    color: var(--text-secondary);
}

.username {
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-auth-action {
    background: none;
    border: none;
    color: var(--primary);
    font-family: var(--font);
    font-weight: 600;
    font-size: 0.78rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    transition: background-color 0.15s;
}

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

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg);
}

.topbar {
    height: 65px;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    z-index: 10;
    transition: background-color 0.2s, border-color 0.2s;
}

.left-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    max-width: 70%;
}

.title-meta-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    margin-left: 0.25rem;
}

.note-title-input {
    border: none;
    background: transparent;
    font-family: var(--font);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    outline: none;
    width: 100%;
}

.note-title-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.4;
}

.note-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.meta-item svg {
    width: 12px;
    height: 12px;
}

.meta-item.info-msg {
    color: var(--primary);
    font-weight: 500;
}

.badge {
    padding: 0.1rem 0.35rem;
    font-size: 0.65rem;
    font-weight: 600;
    border-radius: 4px;
    white-space: nowrap;
}

.badge-readonly {
    background-color: var(--danger-light);
    color: var(--danger);
}

.right-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sync-indicator {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-right: 0.5rem;
}

.sync-indicator .success-icon {
    color: #34c759;
    width: 14px;
    height: 14px;
}

.sync-indicator .spin-icon {
    display: none;
    animation: spin 1s linear infinite;
    width: 14px;
    height: 14px;
}

.sync-indicator.saving .success-icon {
    display: none;
}

.sync-indicator.saving .spin-icon {
    display: inline-block;
}

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

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
    border: none;
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius);
    font-family: var(--font);
    font-weight: 500;
    font-size: 0.82rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    text-decoration: none;
    transition: background-color 0.15s;
}

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

.btn-outline {
    background-color: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius);
    font-family: var(--font);
    font-weight: 500;
    font-size: 0.82rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

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

.btn-icon {
    background: none;
    border: none;
    color: var(--text);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s;
}

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

.editor-area {
    flex: 1;
    background-color: var(--surface);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: background-color 0.2s;
}

#editor {
    flex: 1;
    overflow-y: auto;
}

.ql-toolbar.ql-snow {
    border: none !important;
    border-bottom: 1px solid var(--border) !important;
    background-color: var(--bg);
    padding: 0.5rem 1.25rem !important;
    transition: background-color 0.2s, border-color 0.2s;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.ql-toolbar.ql-snow .ql-formats {
    margin-right: 0 !important;
    border: none !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
}

.ql-toolbar.ql-snow button,
.ql-toolbar.ql-snow .ql-picker-label {
    width: 34px !important;
    height: 34px !important;
    padding: 6px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 6px;
    transition: background-color 0.15s;
}

.ql-toolbar.ql-snow button:hover,
.ql-toolbar.ql-snow .ql-picker-label:hover {
    background-color: var(--border) !important;
}

.ql-toolbar.ql-snow .ql-picker.ql-header {
    width: 80px !important;
}

.ql-toolbar.ql-snow .ql-picker.ql-header .ql-picker-label {
    width: 100% !important;
    padding: 0 8px !important;
    justify-content: space-between !important;
}

.ql-toolbar.ql-snow button svg,
.ql-toolbar.ql-snow .ql-picker-label svg {
    width: 20px !important;
    height: 20px !important;
}

.ql-container.ql-snow {
    border: none !important;
    font-family: var(--font) !important;
    font-size: 1rem !important;
}

.ql-editor {
    padding: 1.5rem !important;
    color: var(--text);
    line-height: 1.6;
}

.ql-editor img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 0.5rem 0;
}

.ql-editor.ql-blank::before {
    color: var(--text-secondary) !important;
    font-style: normal !important;
    left: 1.5rem !important;
}

.ql-snow .ql-stroke {
    stroke: var(--text) !important;
}

.ql-snow .ql-fill {
    fill: var(--text) !important;
}

.ql-snow .ql-picker {
    color: var(--text) !important;
}

.ql-snow .ql-picker-options {
    background-color: var(--surface) !important;
    border-color: var(--border) !important;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.ql-snow .ql-picker-options .ql-picker-item {
    color: var(--text) !important;
}

.ql-snow .ql-picker-options .ql-picker-item:hover {
    color: var(--primary) !important;
}

.ql-snow .ql-picker-label {
    color: var(--text) !important;
}

.editor-footer {
    height: 28px;
    border-top: 1px solid var(--border);
    background-color: var(--surface);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 1.25rem;
    font-size: 0.72rem;
    color: var(--text-secondary);
    transition: background-color 0.2s, border-color 0.2s;
}

.live-stats {
    display: flex;
    align-items: center;
}

.count-divider {
    margin: 0 0.4rem;
    opacity: 0.4;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal.active {
    opacity: 1;
    pointer-events: all;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(5, 5, 8, 0.4);
    backdrop-filter: blur(8px);
}

.modal-content {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    width: 90%;
    max-width: 400px;
    position: relative;
    z-index: 1010;
    box-shadow: var(--shadow-lg);
    transform: translateY(10px);
    transition: transform 0.2s ease;
}

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

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

.modal-header h3 {
    font-weight: 600;
    font-size: 0.95rem;
}

.modal-body {
    padding: 1.25rem;
}

.share-link-group {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.share-url-input {
    flex: 1;
    border: 1px solid var(--border);
    background-color: var(--bg);
    color: var(--text);
    padding: 0.55rem;
    border-radius: var(--radius);
    outline: none;
    font-family: var(--font);
    font-size: 0.82rem;
}

.social-share-group {
    display: flex;
    justify-content: space-between;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
}

.btn-social {
    flex: 1;
    height: 38px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background-color: var(--bg);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

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

.btn-social.zalo span {
    font-size: 0.72rem;
    font-weight: 700;
}

.btn-social svg {
    width: 16px;
    height: 16px;
}

.qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
    border-top: 1px solid var(--border);
    padding-top: 1.25rem;
}

#qrCanvas {
    padding: 0.4rem;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: block;
    width: 160px;
    height: 160px;
}

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2000;
}

.toast {
    background-color: var(--surface-glass);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.55rem 0.9rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 0.82rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transform: translateY(10px);
    opacity: 0;
    animation: toast-in 0.2s forwards;
}

@keyframes toast-in {
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes toast-out {
    to {
        transform: translateY(10px);
        opacity: 0;
    }
}

.auth-page {
    background: radial-gradient(circle at top right, var(--primary-light), transparent 45%), var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100vw;
    overflow-y: auto;
}

.auth-page .toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
}

.auth-wrapper {
    width: 90%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.btn-back {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s;
}

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

.btn-back svg {
    width: 15px;
    height: 15px;
}

.auth-card {
    background-color: var(--surface-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2.25rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.auth-logo-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
}

.auth-logo-group h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-top: 0.5rem;
}

.auth-logo-group p {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.auth-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    gap: 1.25rem;
}

.auth-tab {
    background: none;
    border: none;
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.auth-tab.active {
    color: var(--primary);
    border-color: var(--primary);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
}

.form-group label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon svg {
    position: absolute;
    left: 14px;
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.input-with-icon input {
    width: 100%;
    height: 52px;
    padding: 0.85rem 1rem 0.85rem 2.8rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background-color: var(--surface);
    color: var(--text);
    font-family: var(--font);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-size: 0.92rem;
}

.input-with-icon input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-light);
}

.btn-large {
    height: 50px;
    font-size: 0.92rem;
    font-weight: 600;
    border-radius: var(--radius);
}

.error-message {
    color: var(--danger);
    font-size: 0.78rem;
    margin-bottom: 0.8rem;
    display: none;
}

.w-full {
    width: 100%;
}

@media (min-width: 769px) {
    .sidebar-toggle-btn {
        display: flex !important;
    }
    
    .menu-btn {
        display: none !important;
    }
    
    .close-sidebar-btn {
        display: none !important;
    }
    
    .app-container.collapsed .sidebar {
        width: 0 !important;
        min-width: 0 !important;
        border-right: none !important;
        transform: translateX(-100%);
        overflow: hidden;
        visibility: hidden;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }

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

    .sidebar.active {
        transform: translateX(0) !important;
    }

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

    .sidebar-toggle-btn {
        display: none !important;
    }

    .menu-btn {
        display: flex !important;
    }

    .topbar {
        padding: 0 1rem;
    }

    .left-actions {
        max-width: 65%;
    }

    .right-actions .btn-primary span {
        display: none;
    }

    .right-actions .btn-primary {
        padding: 0.5rem;
        border-radius: 50%;
    }
}

#userProfile {
    display: none !important;
}
