/* ==================== RESET & BASE ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colors */
    --primary-color: #1b8bb4;
    --primary-hover: #156d8f;
    --danger-color: #dc3545;
    --danger-hover: #c82333;
    --success-color: #28a745;
    --warning-color: #ffc107;

    /* Note Colors */
    --note-white: #ffffff;
    --note-red: #f28b82;
    --note-orange: #fbbc04;
    --note-yellow: #fff475;
    --note-green: #ccff90;
    --note-teal: #a7ffeb;
    --note-blue: #cbf0f8;
    --note-darkblue: #aecbfa;
    --note-purple: #d7aefb;
    --note-pink: #fdcfe8;

    /* Grays */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Spacing */
    --header-height: 64px;
    --sidebar-width: 280px;
    --sidebar-collapsed: 72px;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 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);

    /* Transitions */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ==================== HEADER ==================== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 24px;
    max-width: 100%;
    gap: 8px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* User Greeting */
.user-greeting {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 600;
}

#header-user-name {
    color: var(--primary-color);
}

.greeting-separator {
    color: var(--gray-400);
    font-size: 14px;
}

.notes-label {
    color: var(--gray-700);
    font-weight: 500;
}

.menu-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-600);
    transition: var(--transition-fast);
}

.menu-btn:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

/* Hide hamburger menu on PC */
@media (min-width: 1025px) {
    .menu-btn {
        display: none;
    }
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--primary-color);
}

.logo i {
    font-size: 24px;
}

.logo h1 {
    font-size: 22px;
    font-weight: 600;
    color: var(--gray-900);
}

.header-center {
    display: none;
}

.search-container {
    position: relative;
    width: 100%;
}

.search-container i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    font-size: 18px;
}

.search-container input {
    width: 100%;
    height: 48px;
    padding: 0 48px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 15px;
    background: var(--gray-50);
    transition: var(--transition-fast);
}

.search-container input:focus {
    outline: none;
    background: white;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(27, 139, 180, 0.1);
}

.clear-search {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
    transition: var(--transition-fast);
}

.clear-search:hover {
    background: var(--gray-200);
    color: var(--gray-600);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 16px;
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-name {
    font-weight: 500;
    color: var(--gray-700);
}

.home-btn {
    height: 32px;
    padding: 0 12px;
    border-radius: 6px;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition-fast);
}

.home-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background: white;
    border-right: 1px solid var(--gray-200);
    padding: 16px 8px;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    z-index: 90;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

/* Mobile sidebar toggle */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }
}

/* Sidebar Search */
.sidebar-search {
    padding: 0;
    margin-bottom: 12px;
}

.sidebar-search .search-container {
    position: relative;
    width: 100%;
}

.sidebar-search .search-container i.fa-search {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    font-size: 14px;
}

.sidebar-search .search-container input {
    width: 100%;
    height: 40px;
    padding: 0 36px 0 36px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    background: var(--gray-50);
    transition: var(--transition-fast);
}

.sidebar-search .search-container input:focus {
    outline: none;
    background: white;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(27, 139, 180, 0.1);
}

.sidebar-search .clear-search {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
    transition: var(--transition-fast);
}

.sidebar-search .clear-search:hover {
    background: var(--gray-200);
    color: var(--gray-600);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    transition: var(--transition-fast);
    margin-bottom: 4px;
}

.nav-item:hover {
    background: var(--gray-100);
}

.nav-item.active {
    background: var(--primary-color);
    color: white;
}

.nav-item i {
    font-size: 20px;
    width: 24px;
}

.sidebar-divider {
    height: 1px;
    background: var(--gray-200);
    margin: 16px 0;
}

.tags-section {
    margin-top: 8px;
}

.tags-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    color: var(--gray-600);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.add-tag-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    transition: var(--transition-fast);
}

.add-tag-btn:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}

.tags-list {
    max-height: 300px;
    overflow-y: auto;
}

.tag-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
    margin-bottom: 2px;
}

.tag-item:hover {
    background: var(--gray-100);
}

.tag-item.active {
    background: var(--gray-200);
}

.tag-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--gray-700);
}

.tag-name i {
    font-size: 16px;
    color: var(--gray-500);
}

.tag-count {
    font-size: 12px;
    color: var(--gray-500);
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 12px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--gray-200);
}

.note-count {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--gray-600);
}

.note-count i {
    color: var(--primary-color);
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
    margin-left: var(--sidebar-width);
    margin-top: var(--header-height);
    padding: 32px;
    min-height: calc(100vh - var(--header-height));
    transition: var(--transition);
}

.sidebar.collapsed~.main-content {
    margin-left: var(--sidebar-collapsed);
}

/* ==================== NEW NOTE INPUT ==================== */
.new-note-container {
    max-width: 600px;
    margin: 0 auto 32px;
}

.new-note-input {
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow);
    transition: var(--transition-fast);
}

.new-note-input:focus-within {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.new-note-input input {
    width: 100%;
    border: none;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--gray-900);
}

.new-note-input input:focus {
    outline: none;
}

.new-note-input textarea {
    width: 100%;
    border: none;
    font-size: 14px;
    resize: none;
    min-height: 60px;
    max-height: 200px;
    color: var(--gray-700);
    font-family: inherit;
}

.new-note-input textarea:focus {
    outline: none;
}

.new-note-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--gray-200);
}

.note-options {
    display: flex;
    align-items: center;
    gap: 8px;
}

.note-actions-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ==================== COLOR PICKER ==================== */
.color-picker {
    display: flex;
    gap: 6px;
}

.color-btn {
    width: 32px;
    height: 32px;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition-fast);
    position: relative;
}

.color-btn:hover {
    transform: scale(1.1);
    border-color: var(--gray-400);
}

.color-btn.active {
    border-color: var(--gray-700);
    transform: scale(1.15);
}

.color-btn.active::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--gray-700);
    font-size: 14px;
}

/* ==================== BUTTONS ==================== */
.icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-600);
    transition: var(--transition-fast);
}

.icon-btn:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.btn-text {
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    transition: var(--transition-fast);
}

.btn-text:hover {
    background: var(--gray-100);
}

.btn-primary {
    padding: 8px 20px;
    border: none;
    background: var(--primary-color);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition-fast);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-danger {
    padding: 8px 20px;
    border: none;
    background: var(--danger-color);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition-fast);
}

.btn-danger:hover {
    background: var(--danger-hover);
}

/* ==================== NOTES GRID ==================== */
.notes-grid {
    column-count: 4;
    column-gap: 16px;
    max-width: 1400px;
    margin: 0 auto;
}

.note-card {
    break-inside: avoid;
    margin-bottom: 16px;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: box-shadow 0.6s cubic-bezier(0.2, 0.8, 0.2, 1), transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.note-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.note-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: currentColor;
}

.note-card[data-color="#ffffff"] {
    color: var(--gray-400);
}

.note-card[data-color="#f28b82"] {
    color: var(--note-red);
}

.note-card[data-color="#fbbc04"] {
    color: var(--note-orange);
}

.note-card[data-color="#fff475"] {
    color: var(--note-yellow);
}

.note-card[data-color="#ccff90"] {
    color: var(--note-green);
}

.note-card[data-color="#a7ffeb"] {
    color: var(--note-teal);
}

.note-card[data-color="#cbf0f8"] {
    color: var(--note-blue);
}

.note-card[data-color="#aecbfa"] {
    color: var(--note-darkblue);
}

.note-card[data-color="#d7aefb"] {
    color: var(--note-purple);
}

.note-card[data-color="#fdcfe8"] {
    color: var(--note-pink);
}

.note-card[data-color="#ffffff"] {
    background: var(--note-white);
}

.note-card[data-color="#f28b82"] {
    background: var(--note-red);
}

.note-card[data-color="#fbbc04"] {
    background: var(--note-orange);
}

.note-card[data-color="#fff475"] {
    background: var(--note-yellow);
}

.note-card[data-color="#ccff90"] {
    background: var(--note-green);
}

.note-card[data-color="#a7ffeb"] {
    background: var(--note-teal);
}

.note-card[data-color="#cbf0f8"] {
    background: var(--note-blue);
}

.note-card[data-color="#aecbfa"] {
    background: var(--note-darkblue);
}

.note-card[data-color="#d7aefb"] {
    background: var(--note-purple);
}

.note-card[data-color="#fdcfe8"] {
    background: var(--note-pink);
}

.note-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 8px;
    word-wrap: break-word;
}

.note-content {
    font-size: 14px;
    color: var(--gray-700);
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin-bottom: 12px;
}

.note-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.note-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 12px;
    font-size: 12px;
    color: var(--gray-700);
}

.note-tag i {
    font-size: 10px;
}

.note-attachments {
    margin-top: 12px;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
    margin-bottom: 6px;
    font-size: 13px;
}

.attachment-item i {
    color: var(--primary-color);
}

.attachment-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-actions {
    display: flex;
    gap: 4px;
}

.attachment-actions button {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-600);
    transition: var(--transition-fast);
}

.attachment-actions button:hover {
    background: rgba(0, 0, 0, 0.1);
}

.note-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.note-date {
    font-size: 12px;
    color: var(--gray-500);
}

.note-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: var(--transition-fast);
}

.note-card:hover .note-actions {
    opacity: 1;
}

.note-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-600);
    transition: var(--transition-fast);
}

.note-action-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--gray-900);
}

/* ==================== MODAL ==================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.small-modal .modal-content {
    max-width: 400px;
}

/* Delete Modal Styling */
.delete-modal .modal-content {
    background: white;
    border: 1px solid var(--gray-200);
}

.delete-modal .modal-header h3 {
    color: var(--danger-color);
    font-size: 18px;
    font-weight: 600;
}

.delete-modal .modal-body p {
    color: var(--gray-700);
    margin-bottom: 8px;
}

.delete-modal .warning-text {
    color: var(--gray-500);
    font-size: 13px;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
}

.edit-title-input {
    flex: 1;
    border: none;
    font-size: 20px;
    font-weight: 600;
    color: var(--gray-900);
    background: transparent;
}

.edit-title-input:focus {
    outline: none;
}

.modal-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.modal-body textarea {
    width: 100%;
    border: none;
    font-size: 15px;
    line-height: 1.6;
    resize: none;
    min-height: 200px;
    color: var(--gray-700);
    font-family: inherit;
    background: transparent;
}

.modal-body textarea:focus {
    outline: none;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-options {
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Tag Input */
.tag-input-container {
    margin-bottom: 16px;
}

.tag-input-container input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
}

.tag-input-container input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(27, 139, 180, 0.1);
}

.existing-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.existing-tag {
    padding: 6px 12px;
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    border-radius: 16px;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.existing-tag:hover {
    background: var(--gray-200);
}

.existing-tag.selected {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.warning-text {
    color: var(--danger-color);
    font-size: 14px;
    margin-top: 8px;
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--gray-400);
}

.empty-state i {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--gray-600);
}

.empty-state p {
    font-size: 16px;
    color: var(--gray-500);
}

/* ==================== LOADING ==================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==================== TOAST ==================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: var(--gray-900);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: toastSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--danger-color);
}

.toast.warning {
    background: var(--warning-color);
    color: var(--gray-900);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1400px) {
    .notes-grid {
        column-count: 3;
    }
}

@media (max-width: 1024px) {
    .notes-grid {
        column-count: 2;
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    .header-container {
        padding: 0 16px;
    }

    .header-center {
        margin: 0 16px;
    }

    .logo h1 {
        display: none;
    }

    .user-name {
        display: none;
    }

    .main-content {
        padding: 16px;
    }

    .notes-grid {
        column-count: 1;
    }

    .new-note-container {
        margin-bottom: 24px;
    }
}

@media (max-width: 480px) {
    .search-container {
        display: none;
    }

    .color-picker {
        flex-wrap: wrap;
    }

    .color-btn {
        width: 28px;
        height: 28px;
    }

    .new-note-actions {
        flex-wrap: wrap;
        gap: 12px;
    }

    .note-options {
        width: 100%;
        justify-content: center;
    }

    .note-actions-right {
        width: 100%;
        justify-content: flex-end;
    }

    .modal-footer {
        flex-wrap: wrap;
        gap: 12px;
    }

    .modal-options {
        width: 100%;
        justify-content: center;
    }

    .modal-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* ==================== DARK MODE ==================== */
body.dark-mode {
    --bg-primary: #0f0c29;
    --bg-secondary: #1a1625;
    --bg-tertiary: #24243e;

    background: linear-gradient(135deg, #4a5568 0%, #2d3748 50%, #1a202c 100%);
    transition: background 0.5s ease;
}

body.dark-mode .header {
    background: rgba(15, 12, 41, 0.95);
    border-bottom-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
}

body.dark-mode .sidebar {
    background: rgba(26, 22, 37, 0.95);
    border-right-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .nav-item {
    color: rgba(255, 255, 255, 0.7);
}

body.dark-mode .nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

body.dark-mode .nav-item.active {
    background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
    color: #fff;
}

body.dark-mode .main-content {
    background: transparent;
}

body.dark-mode .new-note-input {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
}

body.dark-mode .new-note-input input,
body.dark-mode .new-note-input textarea {
    color: #fff;
    background: transparent;
}

body.dark-mode .new-note-input input::placeholder,
body.dark-mode .new-note-input textarea::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

body.dark-mode .note-card {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
}

body.dark-mode .note-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

body.dark-mode .note-title {
    color: #fff;
}

body.dark-mode .note-content {
    color: rgba(255, 255, 255, 0.8);
}

body.dark-mode .note-date {
    color: rgba(255, 255, 255, 0.5);
}

body.dark-mode .modal {
    background: rgba(0, 0, 0, 0.8);
}

body.dark-mode .modal-content {
    background: rgba(26, 22, 37, 0.98);
    border-color: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(30px);
}

body.dark-mode .modal-header {
    border-bottom-color: rgba(0, 0, 0, 0.3);
}

body.dark-mode .modal-footer {
    border-top-color: rgba(0, 0, 0, 0.3);
}

/* Dark mode - Modal icon buttons with circular backgrounds */
body.dark-mode .modal .icon-btn {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

body.dark-mode .modal .icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* Dark mode - Delete Modal */
body.dark-mode .delete-modal .modal-content,
body.dark-mode #delete-modal .modal-content {
    background: rgba(26, 22, 37, 0.98);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .delete-modal .modal-header h3,
body.dark-mode #delete-modal .modal-header h3 {
    color: #ff6b6b;
}

body.dark-mode .delete-modal .modal-body p,
body.dark-mode #delete-modal .modal-body p {
    color: rgba(255, 255, 255, 0.8);
}

body.dark-mode .delete-modal .warning-text,
body.dark-mode #delete-modal .warning-text {
    color: rgba(255, 255, 255, 0.5);
}

body.dark-mode .edit-title-input,
body.dark-mode #edit-note-content {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

body.dark-mode .edit-title-input::placeholder,
body.dark-mode #edit-note-content::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

body.dark-mode .btn-primary {
    background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
    box-shadow: 0 4px 15px rgba(229, 62, 62, 0.4);
}

body.dark-mode .btn-primary:hover {
    box-shadow: 0 8px 25px rgba(229, 62, 62, 0.6);
}

body.dark-mode .icon-btn {
    color: rgba(255, 255, 255, 0.7);
}

body.dark-mode .icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

body.dark-mode .search-container {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .search-container input {
    color: #fff;
}

body.dark-mode .search-container input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

body.dark-mode .empty-state {
    color: rgba(255, 255, 255, 0.6);
}

body.dark-mode .note-count {
    color: rgba(255, 255, 255, 0.7);
}

body.dark-mode .toast {
    background: rgba(26, 22, 37, 0.95);
    border-color: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(20px);
}

/* Dark Mode Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
    margin-right: 8px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e0;
    transition: .4s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #4a5568;
}

input:checked+.slider:before {
    transform: translateX(30px);
    background-color: #fff;
}

.toggle-icon {
    font-size: 14px;
    z-index: 1;
}

.toggle-icon.sun {
    color: #f6ad55;
}

.toggle-icon.moon {
    color: #f6e05e;
}

/* Hover effect */
.switch:hover .slider:before {
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.05);
}

body,
.header,
.sidebar,
.main-content,
.note-card,
.new-note-input,
.modal-content,
.search-container {
    transition: background 0.5s ease, border-color 0.5s ease, color 0.5s ease;
}


/* Dark Mode Fixes */
body.dark-mode .logo-text {
    color: #fff;
}

body.dark-mode .user-name {
    color: #fff;
}

body.dark-mode .search-container .icon-btn {
    color: rgba(255, 255, 255, 0.7);
}

body.dark-mode .search-container .icon-btn:hover {
    color: #fff;
}

body.dark-mode .attachment-item {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.dark-mode .attachment-item span {
    color: rgba(255, 255, 255, 0.9);
}

body.dark-mode .attachment-item .icon-btn {
    color: rgba(255, 255, 255, 0.7);
    background: transparent;
}

body.dark-mode .attachment-item .icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}


/* Dark Mode - Additional Fixes */

/* Logo text */
body.dark-mode .header .logo-text,
body.dark-mode .logo-text {
    color: #ffffff !important;
}

/* User name */
body.dark-mode .header .user-name,
body.dark-mode .user-name {
    color: #ffffff !important;
}

/* Search button */
body.dark-mode .search-container .icon-btn,
body.dark-mode #clear-search {
    color: rgba(255, 255, 255, 0.7) !important;
    background: transparent !important;
}

body.dark-mode .search-container .icon-btn:hover,
body.dark-mode #clear-search:hover {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.1) !important;
}

/* Modal inputs - background color */
body.dark-mode .modal-content input,
body.dark-mode .modal-content textarea,
body.dark-mode #edit-note-title,
body.dark-mode #edit-note-content {
    background: #191624 !important;
    border: none !important;
    color: #ffffff !important;
}

body.dark-mode .modal-content input::placeholder,
body.dark-mode .modal-content textarea::placeholder,
body.dark-mode #edit-note-title::placeholder,
body.dark-mode #edit-note-content::placeholder {
    color: rgba(255, 255, 255, 0.5) !important;
}

/* Attachment items in modal */
body.dark-mode #edit-note-attachments .attachment-item,
body.dark-mode .attachment-item {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

body.dark-mode #edit-note-attachments .attachment-item span,
body.dark-mode .attachment-item span {
    color: rgba(255, 255, 255, 0.9) !important;
}

body.dark-mode #edit-note-attachments .icon-btn,
body.dark-mode .attachment-item .icon-btn {
    color: rgba(255, 255, 255, 0.7) !important;
    background: transparent !important;
}

body.dark-mode #edit-note-attachments .icon-btn:hover,
body.dark-mode .attachment-item .icon-btn:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
}


/* Dark Mode - Search Input Fix */
body.dark-mode .search-container input,
body.dark-mode #search-input {
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
}

body.dark-mode .search-container input::placeholder,
body.dark-mode #search-input::placeholder {
    color: rgba(255, 255, 255, 0.5) !important;
}

/* Dark Mode - Note Action Buttons (Edit/Delete on card hover) */
body.dark-mode .note-action-btn {
    color: rgba(255, 255, 255, 0.8);
    background: rgba(0, 0, 0, 0.3);
}

body.dark-mode .note-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* Dark Mode - User Greeting */
body.dark-mode #header-user-name {
    color: #4EADF9;
}

body.dark-mode .notes-label {
    color: rgba(255, 255, 255, 0.9);
}

body.dark-mode .greeting-separator {
    color: rgba(255, 255, 255, 0.4);
}

/* Dark Mode - Sidebar Search */
body.dark-mode .sidebar-search .search-container input {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

body.dark-mode .sidebar-search .search-container input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

body.dark-mode .sidebar-search .search-container input:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: #4EADF9;
    box-shadow: 0 0 0 3px rgba(78, 173, 249, 0.2);
}

body.dark-mode .sidebar-search .search-container i.fa-search {
    color: rgba(255, 255, 255, 0.5);
}

body.dark-mode .sidebar-search .clear-search {
    color: rgba(255, 255, 255, 0.5);
}

body.dark-mode .sidebar-search .clear-search:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
}

/* ==================== MOBILE RESPONSIVE ==================== */
.mobile-only {
    display: none;
}

@media (max-width: 1024px) {
    .desktop-only {
        display: none !important;
    }

    .mobile-only {
        display: block;
    }

    /* Adjust header for mobile to prevent overflow */
    .header-container {
        padding: 0 16px;
        gap: 12px;
    }

    .header-left {
        width: 100%;
        gap: 12px;
    }

    .menu-btn {
        display: flex;
        /* Ensure it's visible on mobile */
        margin-right: 4px;
        min-width: 40px;
        /* Prevent squishing */
    }

    /* Make user greeting smaller */
    .user-greeting {
        font-size: 16px;
        flex: 1;
        min-width: 0;
        display: flex;
        align-items: center;
    }

    #header-user-name {
        display: inline-block;
    }

    .notes-label {
        margin-left: auto;
    }

    /* Mobile Menu Items in Sidebar */
    .mobile-menu-items {
        padding: 0 0 16px 0;
        border-bottom: 1px solid var(--gray-200);
        margin-bottom: 16px;
    }

    /* Dark mode toggle layout in mobile sidebar */
    .mobile-menu-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 16px;
        color: var(--gray-700);
        font-weight: 500;
        font-size: 14px;
        border-radius: 8px;
    }

    .mobile-menu-link {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 16px;
        color: var(--gray-700);
        font-weight: 500;
        font-size: 14px;
        text-decoration: none;
        border-radius: 8px;
        transition: var(--transition-fast);
        margin-bottom: 4px;
    }

    .mobile-menu-link:hover {
        background: var(--gray-100);
        color: var(--gray-900);
    }

    .mobile-menu-link i {
        font-size: 20px;
        width: 24px;
        color: var(--primary-color);
        display: flex;
        justify-content: center;
    }

    /* Adjust sidebar footer */
    .sidebar-footer {
        padding-top: 16px;
    }
}

@media (max-width: 480px) {
    /* Removed max-width restriction on username */

    .notes-label {
        font-size: 14px;
    }

    /* Ensure no horizontal scroll */
    .header-container {
        padding-right: 8px;
    }

    .header-right {
        gap: 8px;
    }

    /* Ensure sidebar overlays correctly on small screens */
    .sidebar.active {
        box-shadow: 100vw 0 0 rgba(0, 0, 0, 0.5);
        /* Hacky overlay effect */
    }
}

/* Dark Mode support for new mobile items */
body.dark-mode .mobile-menu-item,
body.dark-mode .mobile-menu-link {
    color: rgba(255, 255, 255, 0.9);
}

body.dark-mode .mobile-menu-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

body.dark-mode .mobile-menu-items {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}