/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #007AFF;
    --primary-hover: #0056CC;
    --success-color: #34C759;
    --error-color: #FF3B30;
    --warning-color: #FF9500;
    --background-color: #F2F2F7;
    --surface-color: #FFFFFF;
    --border-color: #E5E5EA;
    --text-primary: #1C1C1E;
    --text-secondary: #8E8E93;
    --text-tertiary: #C7C7CC;
    --shadow-light: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-heavy: 0 8px 24px rgba(0, 0, 0, 0.2);
    --radius-small: 8px;
    --radius-medium: 12px;
    --radius-large: 16px;
    --radius-xl: 20px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-xxl: 48px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', sans-serif;
    background: var(--background-color);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 16px;
}

/* Login styles */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: var(--spacing-md);
}

.login-card {
    background: var(--surface-color);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xxl);
    text-align: center;
    box-shadow: var(--shadow-heavy);
    max-width: 400px;
    width: 100%;
    backdrop-filter: blur(20px);
}

.login-card h1 {
    font-size: 32px;
    font-weight: 700;
    margin: var(--spacing-lg) 0 var(--spacing-sm);
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.login-card p {
    color: var(--text-secondary);
    margin-bottom: var(--spacing-xl);
    font-size: 18px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.input-field {
    padding: var(--spacing-md) var(--spacing-lg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-medium);
    font-size: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--surface-color);
    color: var(--text-primary);
}

.input-field:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
    transform: translateY(-1px);
}

/* App container */
.app-container {
    display: flex;
    min-height: 100vh;
    background: var(--background-color);
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--surface-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    box-shadow: var(--shadow-light);
}

.sidebar-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface-color);
    position: sticky;
    top: 0;
    z-index: 10;
}

.app-icon {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    color: var(--primary-color);
    font-weight: 600;
    font-size: 20px;
    letter-spacing: -0.3px;
}

.app-icon.large {
    font-size: 28px;
    justify-content: center;
    margin-bottom: var(--spacing-sm);
}

.menu-toggle {
    display: none; /* Hidden by default, shown in media query */
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--radius-small);
    transition: all 0.2s ease;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
}

.menu-toggle:hover {
    background: var(--background-color);
    color: var(--text-primary);
}

.sidebar-nav {
    flex: 1;
    padding: var(--spacing-lg);
    overflow-y: auto;
}

.nav-section {
    margin-bottom: var(--spacing-xl);
}

.nav-section h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--spacing-md);
}

.nav-list {
    list-style: none;
    margin-bottom: var(--spacing-md);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-medium);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
    user-select: none;
    font-weight: 500;
}

.nav-item:hover {
    background: var(--background-color);
    transform: translateX(2px);
}

.nav-item.active {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-light);
}

.nav-item svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.sidebar-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
    background: var(--surface-color);
    position: sticky;
    bottom: 0;
}

/* Main content */
.main-content {
    flex: 1;
    margin-left: 280px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.content-header {
    background: rgba(255, 255, 255, 0.85); /* Slightly transparent for backdrop effect */
    border-bottom: 1px solid var(--border-color);
    padding: var(--spacing-lg) var(--spacing-xl);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-lg);
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.header-left h1 {
    font-size: 32px;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.header-left p {
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 500;
    margin: 0;
    padding-top: 6px; /* Align baseline with title */
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-container svg {
    position: absolute;
    left: var(--spacing-md);
    color: var(--text-secondary);
    width: 18px;
    height: 18px;
    pointer-events: none; /* Make icon unclickable */
}

#searchInput {
    padding: var(--spacing-sm) var(--spacing-md) var(--spacing-sm) 44px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-large);
    font-size: 16px;
    width: 320px;
    background: var(--background-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-primary);
}

#searchInput:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--surface-color);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
    transform: translateY(-1px);
}

.content-body {
    flex: 1;
    padding: var(--spacing-xl);
    overflow-y: auto;
}

/* Buttons */
.btn-primary, .btn-secondary {
    border: none;
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-medium);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    letter-spacing: -0.2px;
    white-space: nowrap; /* Prevent text wrapping on buttons */
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: var(--shadow-light);
}

.btn-secondary {
    background: var(--background-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    font-weight: 500;
}

.btn-secondary:hover {
    background: var(--border-color);
    border-color: var(--text-tertiary);
    transform: translateY(-1px);
}

.btn-secondary:active {
    background: var(--text-tertiary);
    transform: translateY(0);
}

.btn-secondary.small {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 13px;
}

/* ... (All other styles like bookmarks-grid, modal, etc. remain the same) ... */

/* [PREVIOUS STYLES FROM .bookmarks-grid to the end remain here] */

/* Bookmarks grid */
.bookmarks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.bookmark-card {
    background: var(--surface-color);
    border-radius: var(--radius-large);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.bookmark-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-heavy);
    border-color: var(--primary-color);
}

/* ... [Rest of your original CSS from here] ... */
.bookmark-card:active {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.bookmark-preview {
    width: 100%;
    height: 160px;
    border-radius: var(--radius-medium);
    background: var(--background-color);
    margin-bottom: var(--spacing-md);
    overflow: hidden;
    position: relative;
}

.bookmark-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.bookmark-card:hover .bookmark-preview img {
    transform: scale(1.05);
}

.bookmark-preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, var(--primary-color), var(--warning-color));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.bookmark-header {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.bookmark-favicon {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-small);
    background: var(--background-color);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.bookmark-favicon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bookmark-title {
    font-weight: 600;
    font-size: 18px;
    color: var(--text-primary);
    line-height: 1.4;
    margin-bottom: var(--spacing-sm);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    letter-spacing: -0.2px;
}

.bookmark-description {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: var(--spacing-md);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bookmark-url {
    color: var(--primary-color);
    font-size: 13px;
    text-decoration: none;
    display: block;
    margin-bottom: var(--spacing-md);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.bookmark-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-sm);
}

.bookmark-folder {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--primary-color);
    color: white;
    border-radius: var(--radius-small);
    font-size: 11px;
    font-weight: 600;
}

.bookmark-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-sm);
}

.bookmark-tag {
    background: var(--background-color);
    color: var(--text-primary);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: var(--radius-small);
    font-size: 11px;
    font-weight: 500;
    border: 1px solid var(--border-color);
}

.bookmark-actions {
    position: absolute;
    top: var(--spacing-sm);
    right: var(--spacing-sm);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.bookmark-card:hover .bookmark-actions {
    opacity: 1;
}

.bookmark-actions button {
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: var(--radius-small);
    padding: var(--spacing-xs);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bookmark-actions button:hover {
    background: white;
    color: var(--error-color);
    transform: scale(1.1);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: var(--spacing-xxl) var(--spacing-lg);
    color: var(--text-secondary);
}

.empty-icon {
    margin-bottom: var(--spacing-lg);
    color: var(--text-tertiary);
}

.empty-state h3 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.empty-state p {
    margin-bottom: var(--spacing-xl);
    font-size: 16px;
    color: var(--text-secondary);
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--spacing-md);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.modal-content {
    background: var(--surface-color);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-heavy);
    animation: modalSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--border-color);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-lg);
}

.modal-header h3 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--radius-small);
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* Form styles */
.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    color: var(--text-primary);
    font-size: 14px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-medium);
    font-size: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--surface-color);
    color: var(--text-primary);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
    transform: translateY(-1px);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.modal-actions {
    display: flex;
    gap: var(--spacing-sm);
    justify-content: flex-end;
    margin-top: var(--spacing-xl);
}

/* Color picker */
.color-picker {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

.color-picker input[type="radio"] {
    display: none;
}

.color-picker label {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.color-picker input[type="radio"]:checked + label {
    border-color: var(--text-primary);
    transform: scale(1.1);
    box-shadow: var(--shadow-light);
}

.color-picker label::after {
    content: '✓';
    color: white;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.2s ease;
    font-size: 14px;
}

.color-picker input[type="radio"]:checked + label::after {
    opacity: 1;
}

/* Notifications */
.notification {
    position: fixed;
    top: var(--spacing-lg);
    right: var(--spacing-lg);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-medium);
    color: white;
    font-weight: 600;
    z-index: 1001;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 300px;
    word-wrap: break-word;
    box-shadow: var(--shadow-medium);
}

.notification.success {
    background: var(--success-color);
}

.notification.error {
    background: var(--error-color);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}


/******************************************/
/** RESPONSIVE STYLES - START **/
/******************************************/

/* Tablet and Mobile styles */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.2);
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .menu-toggle {
        display: inline-flex; /* Show menu button */
    }

    .header-left {
        /* The menu toggle will be here, so title needs less space */
        flex-grow: 1;
    }

    .header-left h1 {
        font-size: 24px;
    }
    .header-left p {
        display: none; /* Hide count on smaller tablets to save space */
    }

    .content-header {
        padding: var(--spacing-md);
        flex-wrap: nowrap; /* Keep header on one line for tablets */
    }

    #searchInput {
        width: 200px; /* Make search smaller on tablets */
    }
}


/* Mobile-specific styles */
@media (max-width: 768px) {
    .content-header {
        flex-wrap: wrap; /* Allow header items to wrap to a new line */
        padding: var(--spacing-md);
    }

    .header-left {
        width: 100%; /* Title section takes full width */
        justify-content: space-between; /* Pushes title and menu button apart */
        order: 1; /* First row */
        margin-bottom: var(--spacing-md); /* Space between rows */
        gap: var(--spacing-sm);
    }

    .header-left h1 {
        font-size: 28px;
    }

    .header-left p {
        display: block; /* Show count again on mobile */
        padding-top: 4px;
    }

    /* Move menu toggle inside header-left for better alignment */
    .header-left .menu-toggle {
        order: -1; /* Place at the start of header-left */
    }

    .header-right {
        width: 100%; /* Search and add button take full width */
        order: 2; /* Second row */
    }
    
    #searchInput {
        width: 100%; /* Make search fill the container */
    }

    .search-container {
        flex-grow: 1; /* Allow search container to grow */
    }

    .btn-primary .button-text {
        display: none; /* Hide text on add button */
    }

    .btn-primary {
        padding: var(--spacing-sm);
        width: 44px;
        height: 44px;
        flex-shrink: 0;
    }
    .btn-primary svg {
        margin: 0;
    }

    .content-body {
        padding: var(--spacing-md);
    }
    
    .bookmarks-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }

    .modal-actions {
        flex-direction: column;
    }
    
    .modal-actions .btn-primary, .modal-actions .btn-secondary {
        width: 100%;
        justify-content: center;
    }
}