/* ===================================
   MATVIO NOTES - Secure Note Management
   Modern, Clean UI
   =================================== */

:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #eef2ff;
    --success: #10b981;
    --success-light: #ecfdf5;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --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;
    --white: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px 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);
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
    font-family: var(--font);
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; height: auto; }
hr { border: none; border-top: 1px solid var(--gray-200); margin: 1.5rem 0; }

/* ===== NAVBAR ===== */
.navbar {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}
.nav-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    height: 60px;
    gap: 1rem;
}
.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}
.nav-brand:hover { color: var(--primary-hover); }
.nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 1rem;
}
.nav-link {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    color: var(--gray-600);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    white-space: nowrap;
}
.nav-link:hover { background: var(--gray-100); color: var(--gray-800); }
.nav-link.active { background: var(--primary-light); color: var(--primary); }

/* Nav badge (task count) */
.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 10px;
    background: var(--danger);
    color: var(--white);
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1;
    margin-left: 4px;
}
.mobile-nav-badge {
    position: absolute;
    top: 2px;
    right: 50%;
    transform: translateX(16px);
    margin-left: 0;
    min-width: 16px;
    height: 16px;
    font-size: 0.6rem;
    padding: 0 4px;
}
.nav-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.nav-user {
    font-size: 0.8rem;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}
.nav-link-sm {
    padding: 0.4rem 0.5rem;
    border-radius: var(--radius);
    color: var(--gray-500);
    font-size: 0.875rem;
    transition: all 0.15s;
}
.nav-link-sm:hover { background: var(--gray-100); color: var(--gray-700); }
.nav-logout:hover { color: var(--danger); }
.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--gray-600);
    cursor: pointer;
    padding: 0.5rem;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    min-height: calc(100vh - 120px);
    padding: 2rem 0;
}
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.page-header h1 i { color: var(--primary); }
.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 0.875rem; }
.text-success { color: var(--success); }

/* ===== BREADCRUMB ===== */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-bottom: 1rem;
}
.breadcrumb a { color: var(--gray-500); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .fa-chevron-right { font-size: 0.6rem; }

/* ===== CARDS ===== */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    margin-bottom: 1.5rem;
    overflow: hidden;
}
.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h2 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.card-header h2 i { color: var(--primary); font-size: 0.9rem; }
.card-body { padding: 1.5rem; }
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
.card-grid .card { margin-bottom: 0; }

/* ===== STATS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
a.stat-card-link { color: inherit; text-decoration: none; cursor: pointer; }
a.stat-card-link:hover { color: inherit; border-color: var(--primary); }
a.stat-card-link:hover .stat-icon { background: var(--primary); color: var(--white); }
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}
.stat-number { font-size: 1.75rem; font-weight: 700; color: var(--gray-900); line-height: 1.2; }
.stat-label { font-size: 0.8rem; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.05em; }

/* ===== DASHBOARD GRID ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font);
    text-decoration: none;
    line-height: 1.5;
    white-space: nowrap;
}
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-hover); color: var(--white); }
.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: #059669; color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #dc2626; color: var(--white); }
.btn-outline { background: var(--white); color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); color: var(--gray-700); }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-light); }
.btn-link { background: none; color: var(--gray-500); text-align: center; justify-content: center; }
.btn-link:hover { color: var(--primary); }
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 0.25rem 0.625rem; font-size: 0.8rem; }
.btn-lg { padding: 0.625rem 1.5rem; font-size: 1rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.375rem;
}
.form-group label i { color: var(--gray-400); margin-right: 0.25rem; }
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    font-family: var(--font);
    color: var(--gray-800);
    background: var(--white);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-help { display: block; font-size: 0.8rem; color: var(--gray-500); margin-top: 0.25rem; }
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }
.flex-grow { flex: 2 !important; }
.form-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }
.form-stack { display: flex; flex-direction: column; }
.form-inline-action { display: flex; align-items: flex-end; gap: 1rem; margin-top: 1rem; }
.form-inline-action .form-group { flex: 1; margin-bottom: 0; }

.password-wrapper { position: relative; }
.password-wrapper input { padding-right: 2.5rem; }
.toggle-password {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0.25rem;
}
.toggle-password:hover { color: var(--gray-600); }

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    cursor: pointer;
    color: var(--gray-600);
}
.checkbox-label input { width: auto; }

/* ===== ALERTS ===== */
.alert {
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.9rem;
}
.alert i { margin-top: 0.15rem; }
.alert-error { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-link { color: inherit; text-decoration: underline; font-weight: 600; margin-left: 0.5rem; }
.error-list { margin-top: 0.5rem; padding-left: 1.5rem; font-size: 0.85rem; }

/* ===== LOGIN ===== */
.login-body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.login-container {
    width: 100%;
    max-width: 420px;
}
.login-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
}
.login-header { text-align: center; margin-bottom: 2rem; }
.login-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin: 0 auto 1rem;
}
.login-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
}
.login-subtitle {
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}
.login-form { margin-bottom: 1rem; }
.login-form .btn-block { margin-top: 1.5rem; padding: 0.75rem; }
.login-footer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--gray-400);
    margin-top: 1.5rem;
}
.login-alt-actions { margin-top: 1rem; }

/* PIN */
.pin-step-info {
    background: var(--success-light);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #065f46;
}
.pin-input {
    text-align: center;
    font-size: 2rem;
    letter-spacing: 0.75rem;
    padding: 0.75rem !important;
    font-weight: 600;
}
.pin-input-field {
    text-align: center;
    font-size: 1.5rem;
    letter-spacing: 0.5rem;
    font-weight: 600;
}
.pin-dots-container {
    position: relative;
    cursor: pointer;
    padding: 1.5rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 2px solid var(--gray-200);
    transition: border-color 0.15s;
}
.pin-dots-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.pin-dots {
    display: flex;
    justify-content: center;
    gap: 1rem;
}
.pin-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--gray-300);
    transition: all 0.2s;
}
.pin-dot.filled {
    background: var(--primary);
    transform: scale(1.2);
}
.pin-input-hidden {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    cursor: pointer;
}
.device-info {
    background: var(--primary-light);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    text-align: center;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--primary);
    font-weight: 500;
}

/* ===== STATUS BADGES ===== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.875rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 1rem;
}
.status-active { background: var(--success-light); color: #065f46; }
.status-inactive { background: var(--gray-100); color: var(--gray-600); }

/* ===== NOTEBOOKS ===== */
.notebooks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}
.notebook-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    transition: transform 0.15s, box-shadow 0.15s;
    overflow: hidden;
}
.notebook-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.notebook-card-link {
    display: block;
    padding: 1.5rem;
    color: inherit;
}
.notebook-card-link:hover { color: inherit; }
.notebook-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}
.notebook-card-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.25rem; }
.notebook-card-desc { font-size: 0.85rem; color: var(--gray-500); margin-bottom: 0.75rem; }
.notebook-card-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: var(--gray-500);
}
.notebook-card-meta i { margin-right: 0.2rem; }
.notebook-card-actions {
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--gray-100);
    display: flex;
    gap: 0.25rem;
    justify-content: flex-end;
}

/* Small notebook cards (dashboard) */
.notebook-grid-sm {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}
.notebook-card-sm {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    transition: all 0.15s;
    color: inherit;
}
.notebook-card-sm:hover { background: var(--primary-light); border-color: var(--primary); color: inherit; }
.notebook-card-sm .notebook-icon { font-size: 1.5rem; color: var(--primary); margin-bottom: 0.5rem; }
.notebook-card-sm .notebook-name { font-size: 0.875rem; font-weight: 600; }
.notebook-card-sm .notebook-count { font-size: 0.75rem; color: var(--gray-500); }

/* ===== NOTES LIST ===== */
.note-list { display: flex; flex-direction: column; }
.note-list-item {
    display: block;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--gray-100);
    color: inherit;
    transition: background 0.1s;
}
.note-list-item:last-child { border-bottom: none; }
.note-list-item:hover { background: var(--gray-50); margin: 0 -1.5rem; padding-left: 1.5rem; padding-right: 1.5rem; }
.note-list-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.25rem; }
.note-list-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--gray-500);
}
.note-list-meta i { margin-right: 0.15rem; }

/* Note cards in notebook view */
.notes-list { display: flex; flex-direction: column; gap: 0.5rem; }
.note-card {
    display: flex;
    align-items: stretch;
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    transition: box-shadow 0.15s;
    overflow: hidden;
}
.note-card:hover { box-shadow: var(--shadow-md); }
.note-card-select {
    display: flex;
    align-items: center;
    padding: 0 0.75rem;
    border-right: 1px solid var(--gray-100);
}
.note-card-body {
    flex: 1;
    padding: 1rem 1.25rem;
    color: inherit;
    min-width: 0;
}
.note-card-body:hover { color: inherit; }
.note-card-title { font-weight: 600; font-size: 1rem; margin-bottom: 0.25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-card-preview { font-size: 0.85rem; color: var(--gray-500); margin-bottom: 0.5rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.note-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--gray-500);
}
.note-card-meta i { margin-right: 0.15rem; }
.note-tags-inline { color: var(--primary); }
.note-card-actions {
    display: flex;
    align-items: center;
    padding: 0 0.5rem;
    border-left: 1px solid var(--gray-100);
}

/* List controls */
.list-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.sort-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}
.sort-controls label { color: var(--gray-500); margin-right: 0.25rem; }
.sort-btn {
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius);
    color: var(--gray-600);
    font-size: 0.8rem;
    transition: all 0.1s;
}
.sort-btn:hover { background: var(--gray-100); color: var(--gray-800); }
.sort-btn.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }

/* Bulk actions */
.bulk-actions {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gray-800);
    color: var(--white);
    padding: 0.75rem 1.5rem;
    border-radius: 999px;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-lg);
    z-index: 50;
}
.bulk-count { font-size: 0.875rem; }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding: 1rem 0;
}
.pagination-info { font-size: 0.875rem; color: var(--gray-500); }

/* ===== NOTE VIEW ===== */
.note-view {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    padding: 2rem;
    margin-bottom: 2rem;
}
.note-view-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}
.note-view-header h1 { font-size: 1.75rem; font-weight: 700; line-height: 1.3; }
.note-view-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
.note-view-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--gray-100);
}
.note-view-meta i { margin-right: 0.25rem; }
.note-view-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}
.tag-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.8rem;
    font-weight: 500;
    transition: background 0.1s;
}
.tag-badge:hover { background: #dbeafe; color: var(--primary); }
.tag-badge .tag-count { background: var(--primary); color: var(--white); border-radius: 50%; padding: 0 0.375rem; font-size: 0.7rem; margin-left: 0.25rem; }
.tag-badge-sm {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    font-size: 0.75rem;
    color: var(--primary);
    padding: 0.1rem 0.5rem;
    background: var(--primary-light);
    border-radius: 999px;
}

/* Note content */
.note-view-content {
    font-size: 0.9375rem;
    line-height: 1.7;
    color: var(--gray-700);
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.note-view-content div { margin-bottom: 0.125rem; }
.note-view-content a { color: var(--primary); text-decoration: underline; }
.note-view-content table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
.note-view-content td, .note-view-content th {
    border: 1px solid var(--gray-200);
    padding: 0.5rem 0.75rem;
    text-align: left;
}
.note-view-content th { background: var(--gray-50); font-weight: 600; }
.note-view-content ul, .note-view-content ol { padding-left: 1.5rem; }
.note-view-content blockquote {
    border-left: 4px solid var(--primary);
    padding-left: 1rem;
    color: var(--gray-600);
    margin: 1rem 0;
}
.note-view-content .note-resource {
    background: var(--gray-50);
    padding: 0.75rem;
    border-radius: var(--radius);
    margin: 0.5rem 0;
    font-size: 0.85rem;
    color: var(--gray-500);
}

/* Resources */
.note-resources {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--gray-100);
}
.note-resources h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.resource-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}
.resource-item {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
}
.resource-image {
    display: block;
    width: 100%;
    height: 150px;
    object-fit: cover;
    background: var(--gray-100);
}
.resource-file {
    height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--gray-50);
    color: var(--gray-400);
    font-size: 2rem;
}
.resource-file span { font-size: 0.75rem; color: var(--gray-500); margin-top: 0.25rem; }
.resource-meta {
    padding: 0.5rem 0.75rem;
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--gray-500);
    border-top: 1px solid var(--gray-100);
}
.resource-open-link { color: var(--primary); font-weight: 500; }
.resource-open-link:hover { text-decoration: underline; }
.resource-item a.resource-file { text-decoration: none; color: var(--gray-400); }
.resource-item a.resource-file:hover { color: var(--primary); background: var(--primary-light); }
.resource-item a img.resource-image { cursor: zoom-in; transition: opacity 0.15s; }
.resource-item a img.resource-image:hover { opacity: 0.85; }

/* ===== EDITOR ===== */
.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.5rem;
    background: var(--gray-50);
    border: 1px solid var(--gray-300);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
}
.editor-toolbar button {
    padding: 0.375rem 0.625rem;
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.1s;
    font-size: 0.85rem;
}
.editor-toolbar button:hover { background: var(--gray-200); }
.editor-toolbar button.active { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.toolbar-divider { width: 1px; background: var(--gray-300); margin: 0 0.25rem; }
.note-editor {
    min-height: 400px;
    padding: 1rem;
    border: 1px solid var(--gray-300);
    border-radius: 0 0 var(--radius) var(--radius);
    font-family: var(--font);
    font-size: 0.9375rem;
    line-height: 1.6;
    outline: none;
    background: var(--white);
    overflow-y: auto;
}
.note-editor:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.15); }
.note-source-editor {
    width: 100%;
    min-height: 400px;
    padding: 1rem;
    border: 1px solid var(--gray-300);
    border-radius: 0 0 var(--radius) var(--radius);
    font-family: monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    resize: vertical;
}

/* ===== SEARCH ===== */
.search-card .card-body { padding: 1.5rem; }
.search-main { display: flex; gap: 0.75rem; margin-bottom: 1rem; }
.search-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}
.search-input-wrapper > i {
    position: absolute;
    left: 1rem;
    color: var(--gray-400);
    pointer-events: none;
}
.search-input-lg {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-family: var(--font);
    transition: border-color 0.15s;
}
.search-input-lg:focus { outline: none; border-color: var(--primary); }
.search-clear {
    position: absolute;
    right: 0.75rem;
    color: var(--gray-400);
    padding: 0.25rem;
}
.search-clear:hover { color: var(--gray-600); }
.search-filters { display: flex; gap: 1rem; flex-wrap: wrap; }
.filter-group { display: flex; align-items: center; gap: 0.5rem; }
.filter-group label { font-size: 0.85rem; color: var(--gray-500); white-space: nowrap; }
.filter-group select {
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-family: var(--font);
    background: var(--white);
}

/* Quick search */
.quick-search { display: flex; gap: 0.75rem; }
.quick-search .search-input-wrapper { flex: 1; }

/* Search results */
.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--gray-600);
}
.results-time { color: var(--gray-400); font-size: 0.8rem; }
.search-results { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 2rem; }
.search-result-item {
    background: var(--white);
    padding: 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    transition: box-shadow 0.15s;
    color: inherit;
    display: block;
}
.search-result-item:hover { box-shadow: var(--shadow-md); color: inherit; }
.result-title { font-size: 1.05rem; font-weight: 600; margin-bottom: 0.375rem; }
.result-title mark { background: #fef08a; color: inherit; padding: 0.05rem 0.15rem; border-radius: 2px; }
.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--gray-500);
    margin-bottom: 0.5rem;
}
.result-meta i { margin-right: 0.15rem; }
.result-notebook { font-weight: 500; }
.result-preview { font-size: 0.875rem; color: var(--gray-600); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.result-preview mark { background: #fef08a; color: inherit; padding: 0.05rem 0.15rem; border-radius: 2px; }
.result-tags { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-top: 0.5rem; }

/* Tags cloud */
.tags-cloud { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ===== FILE UPLOAD ===== */
.file-upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    background: var(--gray-50);
}
.file-upload-area:hover,
.file-upload-area.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}
.file-input-hidden {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    cursor: pointer;
}
.file-upload-content i { color: var(--primary); margin-bottom: 1rem; }
.file-upload-text { font-size: 1rem; font-weight: 500; color: var(--gray-700); margin-bottom: 0.5rem; }
.file-upload-subtext { font-size: 0.875rem; color: var(--gray-500); }
.file-upload-info { font-size: 0.8rem; color: var(--gray-400); margin-top: 0.75rem; }
.file-upload-info.file-selected { color: var(--primary); font-weight: 500; }

/* Import guide */
.import-guide { padding-left: 1.25rem; }
.import-guide li { margin-bottom: 0.5rem; font-size: 0.9rem; color: var(--gray-600); }

/* ===== EMPTY STATES ===== */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--gray-400);
}
.empty-state i { font-size: 2.5rem; margin-bottom: 0.75rem; }
.empty-state p { font-size: 0.9rem; }
.empty-state-lg {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
}
.empty-state-lg i { font-size: 3rem; color: var(--gray-300); margin-bottom: 1rem; }
.empty-state-lg h2 { font-size: 1.25rem; color: var(--gray-700); margin-bottom: 0.5rem; }
.empty-state-lg p { color: var(--gray-500); margin-bottom: 1.5rem; }
.empty-actions { display: flex; justify-content: center; gap: 0.75rem; }

/* ===== DEVICE LIST ===== */
.device-list { display: flex; flex-direction: column; gap: 0.75rem; }
.device-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}
.device-item .device-icon { color: var(--gray-400); font-size: 1.25rem; padding-top: 0.15rem; }
.device-info-detail { min-width: 0; flex: 1; }
.device-name { font-size: 0.8rem; color: var(--gray-700); word-break: break-all; line-height: 1.4; }
.device-meta { display: flex; flex-wrap: wrap; gap: 0.75rem; font-size: 0.75rem; color: var(--gray-500); margin-top: 0.25rem; }

/* ===== MODAL ===== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal.active { display: flex; }
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
}
.modal-content {
    position: relative;
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
}
.modal-header h2 { font-size: 1.1rem; display: flex; align-items: center; gap: 0.5rem; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-400);
    cursor: pointer;
    line-height: 1;
}
.modal-close:hover { color: var(--gray-700); }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--gray-100); display: flex; justify-content: flex-end; gap: 0.75rem; }

/* ===== IMPROVED SEARCH RESULTS ===== */
.result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.375rem;
}
.result-header .result-title {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
}
.result-notebook-badge {
    flex-shrink: 0;
    background: var(--primary-light);
    color: var(--primary);
    padding: 0.2rem 0.625rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}
.search-result-item .result-preview {
    -webkit-line-clamp: 4;
    line-clamp: 4;
    max-height: 6em;
}

/* Browse section */
.browse-section { display: flex; flex-direction: column; gap: 1.5rem; }
.browse-notebooks {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.browse-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    color: var(--gray-700);
    font-size: 0.9rem;
    transition: all 0.15s;
}
.browse-item:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.browse-item i { color: var(--primary); }
.browse-count {
    background: var(--gray-100);
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    color: var(--gray-500);
    font-weight: 600;
}
.browse-item:hover .browse-count { background: rgba(99,102,241,0.15); color: var(--primary); }

/* Pagination improvements */
.pagination-current {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    background: var(--primary);
    color: var(--white);
    font-size: 0.85rem;
    font-weight: 600;
}
.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--gray-600);
    transition: all 0.1s;
}
.pagination-link:hover { background: var(--gray-100); color: var(--gray-800); }

/* ===== FOOTER ===== */
.footer {
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    padding: 1rem 0;
    text-align: center;
}
.footer-content {
    max-width: 1280px;
    margin: 0 auto;
    font-size: 0.8rem;
    color: var(--gray-400);
}

/* ===== TOAST NOTIFICATIONS ===== */
#everlog-toasts {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 400px;
    width: calc(100% - 2rem);
    pointer-events: none;
}
.el-toast {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    opacity: 0;
    transform: translateX(100%);
    transition: none;
    background: var(--white);
    border: 1px solid var(--gray-200);
    color: var(--gray-700);
}
.el-toast-show {
    animation: toastSlideIn 0.3s ease forwards;
}
.el-toast-hide {
    animation: toastSlideOut 0.25s ease forwards;
}
@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastSlideOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100%); }
}
.el-toast-body {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}
.el-toast-body span { line-height: 1.4; }
.el-toast-body span a { color: inherit; }
.el-toast-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
    flex-shrink: 0;
}
.el-toast-close:hover { color: var(--gray-700); }
.el-toast-success { background: var(--success-light); border-color: #a7f3d0; color: #065f46; }
.el-toast-success .el-toast-body i { color: var(--success); }
.el-toast-error { background: var(--danger-light); border-color: #fecaca; color: #991b1b; }
.el-toast-error .el-toast-body i { color: var(--danger); }
.el-toast-warning { background: var(--warning-light); border-color: #fde68a; color: #92400e; }
.el-toast-warning .el-toast-body i { color: var(--warning); }
.el-toast-info { background: var(--primary-light); border-color: #c7d2fe; color: #3730a3; }
.el-toast-info .el-toast-body i { color: var(--primary); }

/* ===== CUSTOM MODAL OVERLAY ===== */
.el-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0);
    backdrop-filter: blur(0px);
    transition: background 0.2s, backdrop-filter 0.2s;
    padding: 1rem;
}
.el-modal-overlay.el-modal-active {
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(4px);
}
.el-modal-dialog {
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 440px;
    transform: scale(0.95) translateY(10px);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.el-modal-active .el-modal-dialog {
    transform: scale(1) translateY(0);
    opacity: 1;
}
.el-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
}
.el-modal-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
}
.el-modal-x {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-400);
    cursor: pointer;
    line-height: 1;
    padding: 0;
}
.el-modal-x:hover { color: var(--gray-700); }
.el-modal-body { padding: 1.25rem 1.5rem; }
.el-modal-body p { line-height: 1.5; }
.el-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--gray-100);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Delete confirm input */
.del-confirm-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    font-family: var(--font);
    color: var(--gray-800);
    background: var(--white);
    transition: border-color 0.15s, box-shadow 0.15s;
    margin-top: 0.375rem;
}
.del-confirm-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.del-confirm-error {
    color: var(--danger);
    font-size: 0.8rem;
    margin-top: 0.375rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* ===== MOBILE BOTTOM NAV BAR ===== */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 90;
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
    padding: 0.25rem 0;
    padding-bottom: env(safe-area-inset-bottom, 0.25rem);
}
.mobile-bottom-nav-inner {
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 500px;
    margin: 0 auto;
}
.mobile-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0.75rem;
    color: var(--gray-500);
    font-size: 0.65rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--radius);
    transition: color 0.15s, background 0.15s;
    -webkit-tap-highlight-color: transparent;
    min-width: 60px;
    gap: 0.15rem;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font);
}
.mobile-nav-btn i {
    font-size: 1.15rem;
    margin-bottom: 0.1rem;
}
.mobile-nav-btn:hover,
.mobile-nav-btn:active {
    color: var(--primary);
    background: var(--primary-light);
}
.mobile-nav-btn.active {
    color: var(--primary);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    /* Base font bump for mobile readability */
    html { font-size: 17px; }

    .nav-links { display: none; flex-direction: column; position: absolute; top: 60px; left: 0; right: 0; background: var(--white); border-bottom: 1px solid var(--gray-200); padding: 0.5rem; box-shadow: var(--shadow-md); }
    .nav-links.show { display: flex; }
    .nav-link { font-size: 1rem; padding: 0.75rem 1rem; }
    .nav-toggle { display: block; }
    .nav-user { display: none; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .card-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .page-header { flex-direction: column; align-items: flex-start; }
    .page-header h1 { font-size: 1.35rem; }
    .header-actions { width: 100%; }
    .note-view { padding: 1.25rem; }
    .note-view-header { flex-direction: column; }
    .note-view-header h1 { font-size: 1.4rem; }
    .note-view-content { font-size: 1rem; line-height: 1.75; }
    .note-view-meta { font-size: 0.9rem; }
    .form-row { flex-direction: column; }
    .form-inline-action { flex-direction: column; }
    .search-main { flex-direction: column; }
    .search-filters { flex-direction: column; }
    .notebooks-grid { grid-template-columns: 1fr; }
    .container { padding: 0 1rem; }

    /* Cards & stats */
    .stat-number { font-size: 1.5rem; }
    .stat-label { font-size: 0.85rem; }
    .card-header h2 { font-size: 1.05rem; }
    .card-body { padding: 1.25rem; }

    /* Notebook cards */
    .notebook-card-title { font-size: 1.1rem; }
    .notebook-card-desc { font-size: 0.9rem; }
    .notebook-card-meta { font-size: 0.85rem; }

    /* Note cards & lists */
    .note-card-title { font-size: 1.05rem; }
    .note-card-preview { font-size: 0.9rem; }
    .note-card-meta { font-size: 0.8rem; }
    .note-list-title { font-size: 1rem; }
    .note-list-meta { font-size: 0.8rem; }

    /* Search */
    .search-input-lg { font-size: 1rem; padding: 0.875rem 1rem 0.875rem 2.75rem; }
    .result-title { font-size: 1.1rem; }
    .result-preview { font-size: 0.95rem; }
    .result-meta { font-size: 0.85rem; }

    /* Buttons */
    .btn { font-size: 0.9rem; padding: 0.55rem 1rem; }
    .btn-lg { font-size: 1.05rem; }

    /* Alerts */
    .alert { font-size: 0.95rem; }

    /* Breadcrumb */
    .breadcrumb { font-size: 0.9rem; }

    /* Tags */
    .tag-badge { font-size: 0.85rem; padding: 0.3rem 0.85rem; }

    /* Sort controls */
    .sort-controls { font-size: 0.9rem; }
    .sort-btn { font-size: 0.85rem; }

    /* Pagination */
    .pagination-info { font-size: 0.9rem; }

    /* Show mobile bottom nav */
    .mobile-bottom-nav { display: block; }

    /* Bottom nav text slightly bigger */
    .mobile-nav-btn { font-size: 0.7rem; }
    .mobile-nav-btn i { font-size: 1.25rem; }

    /* Add padding to main content so it doesn't hide behind bottom nav */
    .main-content { padding-bottom: 70px; }

    /* Adjust footer to not be hidden behind bottom nav */
    .footer { padding-bottom: 70px; }
    .footer-content { font-size: 0.85rem; }

    /* Bulk actions bar above bottom nav */
    .bulk-actions { bottom: 80px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .notebook-grid-sm { grid-template-columns: repeat(2, 1fr); }
    .login-card { padding: 1.5rem; }
    .login-header h1 { font-size: 1.5rem; }
    .login-subtitle { font-size: 0.95rem; }

    /* Toast adjustments */
    #everlog-toasts { right: 0.5rem; max-width: calc(100% - 1rem); }
    .el-toast { font-size: 0.9rem; }
}
