/* ==========================================
   CSS VARIABLES FOR THEME
   These variables make it easy to change colors later
========================================== */
:root {
    /* Colors */
    --primary-color: #4f46e5;
    /* Indigo */
    --primary-hover: #4338ca;

    --success-color: #10b981;
    /* Emerald */
    --success-hover: #059669;

    --danger-color: #ef4444;
    /* Red */
    --danger-hover: #dc2626;

    --warning-color: #f59e0b;
    /* Amber */
    --warning-hover: #d97706;

    /* Neutrals */
    --bg-color: #f8fafc;
    /* Light gray background */
    --surface-color: #ffffff;
    /* White cards */
    --text-primary: #1e293b;
    /* Dark slate */
    --text-secondary: #64748b;
    /* Light slate */
    --border-color: #e2e8f0;
    /* Divider lines */

    /* Typography */
    --font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;

    /* Layout styling */
    --border-radius: 12px;
    --border-radius-sm: 8px;

    /* Shadows for depth */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    /* Transitions for smooth animations */
    --transition-fast: 150ms ease-in-out;
    --transition-normal: 250ms ease-in-out;
}

/* ==========================================
   DARK THEME VARIABLES
========================================== */
.dark-theme {
    /* Neutrals - inverted for dark mode */
    --bg-color: #0f172a;
    /* Very dark slate */
    --surface-color: #1e293b;
    /* Dark slate */
    --text-primary: #f8fafc;
    /* Off-white */
    --text-secondary: #94a3b8;
    /* Muted slate */
    --border-color: #334155;
    /* Dark border */

    /* Slightly adjusted shadows for dark mode */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4);
}

/* Ensure smooth transition when toggling themes */
body {
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* ==========================================
   GLOBAL RESET
   Removes default browser margins and padding
========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Utility Classes */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ==========================================
   HEADER STYLES
========================================== */
.app-header {
    background-color: var(--surface-color);
    padding: 30px 0;
    box-shadow: var(--shadow-sm);
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 40px;
}

.app-header h1 {
    font-size: 2.25rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-titles {
    flex: 1;
}

/* Theme Toggle Button */
.btn-icon {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-icon:hover {
    background-color: var(--bg-color);
    transform: scale(1.05);
}

.btn-icon:active {
    transform: scale(0.95);
}

/* ==========================================
   MAIN CONTENT & SECTIONS
========================================== */
main {
    flex: 1;
    /* Pushes footer to the bottom */
}

/* Common Card Styling */
.card {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    padding: 30px;
    box-shadow: var(--shadow-md);
    margin-bottom: 30px;
    border: 1px solid var(--border-color);
}

.section-title {
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.helper-text {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 0.95rem;
}

/* ==========================================
   FORM STYLES (Add Bookmark Section)
========================================== */
.bookmark-form {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    /* 3 columns for desktop */
    gap: 16px;
    align-items: end;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

input[type="text"],
input[type="url"],
select {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    font-family: inherit;
    transition: all var(--transition-fast);
    background-color: var(--bg-color);
    width: 100%;
    color: var(--text-primary);
}

/* Category Badge Styling */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 8px;
    width: fit-content;
}

.badge-general {
    background-color: #f1f5f9;
    color: #475569;
}

.badge-work {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge-personal {
    background-color: #fce7f3;
    color: #be185d;
}

.badge-learning {
    background-color: #fef3c7;
    color: #b45309;
}

/* Dark mode overrides for badges */
.dark-theme .badge-general {
    background-color: #334155;
    color: #cbd5e1;
}

.dark-theme .badge-work {
    background-color: #1e3a8a;
    color: #bfdbfe;
}

.dark-theme .badge-personal {
    background-color: #831843;
    color: #fbcfe8;
}

.dark-theme .badge-learning {
    background-color: #78350f;
    color: #fde68a;
}

/* Input Focus Micro-animation */
input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
    background-color: var(--surface-color);
}

/* ==========================================
   SEARCH SECTION
========================================== */
.search-section {
    margin-bottom: 40px;
}

.search-container {
    position: relative;
    max-width: 500px;
    margin: 0 auto;
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-input {
    padding-left: 44px !important;
    border-radius: 40px !important;
    /* Pill shape for search */
    box-shadow: var(--shadow-sm);
    background-color: var(--surface-color) !important;
}

/* ==========================================
   BUTTON STYLES
========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    font-family: inherit;
}

/* Button Micro-animations */
.btn:active {
    transform: scale(0.97);
    /* Click effect */
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    height: 48px;
    /* Match input height */
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-visit {
    background-color: var(--success-color);
    color: white;
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-visit:hover {
    background-color: var(--success-hover);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-edit {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 8px 16px;
    font-size: 0.9rem;
}

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

.btn-delete {
    background-color: #fee2e2;
    color: var(--danger-color);
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-delete:hover {
    background-color: var(--danger-color);
    color: white;
}

/* ==========================================
   BOOKMARK CARDS (Grid Layout)
========================================== */
.bookmarks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.bookmark-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 20px;
    transition: all var(--transition-normal);
}

/* Card Hover Lift Micro-animation */
.bookmark-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.bookmark-title {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 4px;

    /* Truncate long titles with an ellipsis (...) */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bookmark-url {
    color: var(--text-secondary);
    font-size: 0.9rem;

    /* Truncate long URLs with an ellipsis (...) */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    /* Allows buttons to wrap on very small screens */
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

/* ==========================================
   FOOTER STYLES
========================================== */
.app-footer {
    text-align: center;
    padding: 30px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 60px;
    border-top: 1px solid var(--border-color);
}

/* ==========================================
   RESPONSIVE DESIGN
   Adjusts layout for smaller screen sizes (mobile)
========================================== */
@media (max-width: 768px) {
    .bookmark-form {
        grid-template-columns: 1fr;
        /* Stack inputs vertically on mobile */
    }

    .btn-primary {
        margin-top: 8px;
        /* Add spacing when stacked */
    }

    .card-actions {
        flex-direction: column;
        /* Stack buttons vertically on small cards */
    }

    .card-actions .btn {
        width: 100%;
        /* Full width buttons on mobile */
    }
}
/* ==========================================
   ADDED: auth, filters, pin, toast, toolbar
========================================== */
[hidden] { display: none !important; }

.header-actions { display: flex; align-items: center; gap: 12px; }

.user-chip { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--border-color); }
.user-name { font-size: 0.9rem; font-weight: 600; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.auth-card { text-align: center; max-width: 480px; margin: 40px auto; }
.auth-card .btn { margin: 0 auto; }
.auth-icon { font-size: 2.2rem; color: var(--primary-color); margin-bottom: 12px; }
.form-error { margin-top: 16px; padding: 10px 12px; border-radius: var(--border-radius-sm); background: #fee2e2; color: #b91c1c; font-size: 0.9rem; }

.form-actions { display: flex; gap: 8px; align-items: flex-end; }
.btn-success { background-color: var(--success-color); color: white; height: 48px; }
.btn-success:hover { background-color: var(--success-hover); }
.btn-secondary { background: transparent; border: 1px solid var(--border-color); color: var(--text-primary); height: 48px; }
.btn-secondary:hover { background-color: var(--bg-color); border-color: var(--text-secondary); }
.btn-sm { height: auto; padding: 8px 14px; font-size: 0.9rem; }

.filter-bar { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; }
.chip {
    padding: 6px 14px; border: 1px solid var(--border-color); border-radius: 40px;
    background: var(--surface-color); color: var(--text-secondary);
    font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer;
    transition: all var(--transition-fast);
}
.chip:hover { border-color: var(--primary-color); color: var(--text-primary); }
.chip.active { background: var(--primary-color); border-color: var(--primary-color); color: #fff; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.count-badge { font-size: 0.9rem; font-weight: 600; padding: 2px 10px; border-radius: 20px; background: var(--border-color); color: var(--text-secondary); vertical-align: middle; }

.btn-pin { background: transparent; border: 1px solid var(--border-color); color: var(--text-secondary); padding: 8px 12px; font-size: 0.9rem; }
.btn-pin:hover { color: var(--warning-color); border-color: var(--warning-color); }
.btn-pin.active { color: var(--warning-color); border-color: var(--warning-color); background: rgba(245, 158, 11, 0.12); }
.bookmark-card.pinned { border-color: var(--warning-color); }
.btn-visit.disabled { background: var(--border-color); color: var(--text-secondary); cursor: not-allowed; }

.empty-state { grid-column: 1 / -1; text-align: center; margin-top: 40px; }

.toast {
    position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
    padding: 12px 20px; border-radius: var(--border-radius-sm);
    background: var(--text-primary); color: var(--bg-color);
    box-shadow: var(--shadow-lg); font-size: 0.95rem;
    opacity: 0; pointer-events: none; transition: opacity var(--transition-normal), transform var(--transition-normal); z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 768px) {
    .header-content { flex-direction: column; gap: 16px; }
    .user-name { display: none; }
    .form-actions .btn { flex: 1; }
    .toolbar { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; }
}
