/* SpellBookMarks Custom Styles */

/* ====================== Auth Pages (Dark Theme) ====================== */

.sb-auth-page {
    min-height: 100vh;
    background: #0f0f1a;
    color: #e0e0e0;
}

.sb-auth-page .text-muted {
    color: #8a8aaa !important;
}

.sb-auth-page .card {
    background: #1a1a2e;
    border: 1px solid #2d2d4e;
    color: #e0e0e0;
}

.sb-auth-page .card-title {
    color: #e0e0e0;
}

.sb-auth-page .form-label {
    color: #c0d0e0;
}

.sb-auth-page .form-check-label {
    color: #c0d0e0;
}

.sb-auth-page .btn-primary {
    background-color: #5e32a8;
    border-color: #5e32a8;
}

.sb-auth-page .btn-primary:hover {
    background-color: #7040c0;
    border-color: #7040c0;
}

.sb-auth-page .btn-outline-secondary {
    color: #b088e0;
    border-color: #b088e0;
}

.sb-auth-page .btn-outline-secondary:hover {
    background-color: #5e32a8;
    border-color: #5e32a8;
    color: #fff;
}

.sb-brand {
    font-size: 1.8rem;
    font-weight: 700;
    color: #b088e0;
}

/* ====================== Body ====================== */

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    background: #0f0f1a;
}

html {
    scrollbar-gutter: stable;
}

/* ====================== Navbar ====================== */

.sb-navbar {
    background: #1a1a2e !important;
    border-bottom: 1px solid #2d2d4e;
    padding: 0.65rem 1rem 0.5rem;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.sb-brand-nav {
    font-size: 1.1rem;
    font-weight: 700;
    color: #b088e0 !important;
    white-space: nowrap;
    text-decoration: none;
}

.sb-search-input {
    background: #2d2d4e !important;
    border: 1px solid #3d3d6e !important;
    color: #e0e0e0 !important;
    resize: none;
    min-height: 38px;
    max-height: 120px;
    overflow-y: auto;
    font-size: 0.95rem;
    padding: 0.375rem 0.75rem;
}

.sb-search-input::placeholder {
    color: #7a7a9a !important;
}

.sb-search-input:focus {
    background: #353558 !important;
    border-color: #5e32a8 !important;
    box-shadow: 0 0 0 0.2rem rgba(94, 50, 168, 0.25) !important;
    outline: none;
}

.sb-service-tag {
    font-size: 0.8rem;
    padding: 0.35em 0.65em;
    white-space: nowrap;
}

.sb-service-tag.matched {
    background-color: #198754 !important;
}

.sb-service-tag.unmatched {
    background-color: #dc3545 !important;
}

#tags .badge {
    font-size: 0.75rem;
}

/* ====================== Local Results ====================== */

.sb-local-results {
    background: #2d2d4e;
    border: 1px solid #3d3d6e;
    border-radius: 6px;
    padding: 0.6rem 1rem;
    color: #e0e0e0;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* ====================== Main Content ====================== */

.sb-main {
    padding: 1rem;
    min-height: calc(100vh - 60px);
    background: #0f0f1a;
}

/* ====================== Masonry Columns ====================== */

.sb-masonry {
    column-count: 1;
    column-gap: 1rem;
}

@media (min-width: 480px) {
    .sb-masonry { column-count: 2; }
}

@media (min-width: 768px) {
    .sb-masonry { column-count: 3; }
}

@media (min-width: 1200px) {
    .sb-masonry { column-count: 4; }
}

@media (min-width: 1600px) {
    .sb-masonry { column-count: 5; }
}

/* ====================== Section Cards ====================== */

.sb-section {
    break-inside: avoid;
    margin-bottom: 1rem;
    background: #1a1a2e;
    border: 1px solid #2d2d4e;
    border-radius: 8px;
}

.sb-section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.8rem;
    background: #1a1528;
    border-bottom: 1px solid #2d2d4e;
    cursor: default;
}

.sb-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #a0b4d4;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    flex-grow: 1;
    margin: 0;
}

.sb-section-icon {
    color: #8a6ab0;
    font-size: 0.9rem;
}

.sb-section-links {
    list-style: none;
    margin: 0;
    padding: 0.3rem 0;
}

/* ====================== Links ====================== */

.sb-link-item {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0.5rem;
    padding: 0.3rem 0.8rem;
    transition: background 0.1s;
}

.sb-link-item:hover {
    background: #252542;
}

.sb-link-item a {
    color: #c8d8e8;
    text-decoration: none;
    font-size: 0.875rem;
    flex-grow: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sb-link-item a:hover {
    color: #b088e0;
}

.sb-link-item a:focus-visible {
    outline: 2px solid #b088e0;
    outline-offset: 2px;
    border-radius: 3px;
    color: #b088e0;
}

.sb-link-favicon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    object-fit: contain;
}

.sb-link-icon {
    font-size: 14px;
    color: #7a8ca0;
    flex-shrink: 0;
    width: 16px;
    text-align: center;
}

/* Horizontal rule */
.sb-link-hr {
    flex-grow: 1;
    border: 0;
    border-top: 1px solid #4d4d7e;
    margin: 0;
    opacity: 1;
}

/* Sublist */
.sb-sublist-toggle {
    color: #c8d8e8;
    font-size: 0.875rem;
    flex-grow: 1;
    background: none;
    border: none;
    padding: 0;
    text-align: left;
    cursor: pointer;
}

.sb-sublist-toggle:hover {
    color: #b088e0;
}

.sb-sublist-items {
    padding: 0.2rem 0 0.2rem 2rem;
}

.sb-sublist-items a {
    display: block;
    color: #a0b8c8;
    font-size: 0.8rem;
    padding: 0.15rem 0;
    text-decoration: none;
}

.sb-sublist-items a:hover {
    color: #b088e0;
}

/* ====================== Edit Mode ====================== */

body.edit-mode .sb-section {
    border-color: #5e32a8;
}

body.edit-mode .sb-section-header {
    cursor: grab;
}

.sb-drag-handle {
    color: #5a6a8a;
    cursor: grab;
    font-size: 0.85rem;
    display: none;
}

body.edit-mode .sb-drag-handle {
    display: inline;
}

.sb-drag-handle:active {
    cursor: grabbing;
}

.sb-edit-btns {
    display: none;
    gap: 0.25rem;
    flex-shrink: 0;
}

body.edit-mode .sb-edit-btns {
    display: flex;
}

.sb-edit-btn {
    background: none;
    border: none;
    padding: 0.1rem 0.25rem;
    font-size: 0.8rem;
    cursor: pointer;
    border-radius: 3px;
    line-height: 1;
}

.sb-edit-btn.edit { color: #b088e0; }
.sb-edit-btn.delete { color: #dc3545; }
.sb-edit-btn.edit:hover { background: rgba(176, 136, 224, 0.15); }
.sb-edit-btn.delete:hover { background: rgba(220, 53, 69, 0.15); }

/* Add link dropdown in edit mode */
.sb-add-link-dropdown {
    display: none;
}

body.edit-mode .sb-add-link-dropdown {
    display: block;
}

.sb-add-link-btn {
    width: 100%;
    padding: 0.25rem 0.8rem;
    background: none;
    border: none;
    color: #5e32a8;
    font-size: 0.8rem;
    text-align: left;
    cursor: pointer;
}

.sb-add-link-btn:hover, .sb-add-link-btn:focus {
    background: rgba(94, 50, 168, 0.1);
    color: #8055c0;
}

.sb-add-link-btn::after {
    float: right;
    margin-top: 0.3em;
}

/* ====================== FAB ====================== */

.sb-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    z-index: 1500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

/* ====================== Scrollbar ====================== */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #1a1a2e; }
::-webkit-scrollbar-thumb { background: #3d3d6e; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #5555a0; }

/* ====================== Modals (dark) ====================== */

.modal-content {
    background: #1a1a2e;
    border: 1px solid #3d3d6e;
    color: #e0e0e0;
}

.modal-header {
    border-bottom-color: #2d2d4e;
}

.modal-footer {
    border-top-color: #2d2d4e;
}

.form-control, .form-select {
    background: #252542 !important;
    border-color: #3d3d6e !important;
    color: #e0e0e0 !important;
}

.form-control:focus, .form-select:focus {
    border-color: #5e32a8 !important;
    box-shadow: 0 0 0 0.2rem rgba(94, 50, 168, 0.25) !important;
}

.form-control::placeholder {
    color: #6a7a9a !important;
}

.form-label {
    color: #c0d0e0;
}

.btn-close {
    filter: invert(1);
    border-radius: 4px;
    transition: background-color 0.15s ease;
}

.btn-close:hover {
    background-color: rgba(109, 109, 109, 0.2);
}

.btn-close:focus {
    box-shadow: 0 0 0 0.25rem rgba(109, 109, 109, 0.4);
}

.modal-footer .btn-secondary {
    background-color: transparent;
    border-color: #5e32a8;
    color: #b088e0;
}

.modal-footer .btn-secondary:hover {
    background-color: #5e32a8;
    border-color: #5e32a8;
    color: #fff;
}

.btn-primary {
    background-color: #5e32a8;
    border-color: #5e32a8;
}

.btn-primary:hover, .btn-primary:focus {
    background-color: #7040c0;
    border-color: #7040c0;
}

.btn-primary:active {
    background-color: #4e2890;
    border-color: #4e2890;
}

.btn-outline-primary {
    color: #b088e0;
    border-color: #5e32a8;
}

.btn-outline-primary:hover {
    background-color: #5e32a8;
    border-color: #5e32a8;
    color: #fff;
}

/* ====================== Search shortcuts table ====================== */

.sb-searches-table {
    width: 100%;
    font-size: 0.875rem;
}

.sb-searches-table td {
    padding: 0.4rem 0.5rem;
    vertical-align: middle;
    border-bottom: 1px solid #2d2d4e;
    color: #c0d0e0;
}

.sb-searches-table tbody tr:hover td {
    background-color: rgba(94, 50, 168, 0.15);
}

.sb-searches-table td:last-child {
    text-align: right;
}

.sb-searches-table .alias-badge {
    background: #352560;
    color: #b090e0;
    border-radius: 4px;
    padding: 0.1em 0.4em;
    font-size: 0.8em;
    margin-right: 2px;
}

/* ====================== Sortable ghost/chosen ====================== */

.sortable-ghost {
    opacity: 0.4;
}

.sortable-chosen {
    background: #252542 !important;
}

/* ====================== Filtered/hidden sections ====================== */

.sb-section.sb-hidden {
    display: none;
}

/* ====================== Collapsed sections ====================== */

.sb-section.sb-collapsed .sb-section-links {
    display: none;
}

body.edit-mode .sb-section.sb-collapsed .sb-add-link-dropdown {
    display: none;
}

.sb-section-collapse-btn {
    background: none;
    border: none;
    color: #5a6a8a;
    font-size: 0.8rem;
    padding: 0.1rem 0.3rem;
    cursor: pointer;
    border-radius: 3px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s;
}

.sb-section-collapse-btn:hover {
    color: #b088e0;
    background: rgba(176, 136, 224, 0.1);
}

.sb-section-collapse-btn .bi {
    display: inline-block;
    transition: transform 0.2s;
}

.sb-section.sb-collapsed .sb-section-collapse-btn .bi {
    transform: rotate(-90deg);
}

/* Dark-theme checkbox */
.form-check-input {
    background-color: #252542;
    border-color: #3d3d6e;
}

.form-check-input:checked {
    background-color: #5e32a8;
    border-color: #5e32a8;
}

.form-check-label {
    color: #c0d0e0;
}

/* ====================== Icon Picker ====================== */

.sb-icon-picker {
    max-height: 260px;
    overflow-y: auto;
    padding: 8px;
    background: #252542;
    border: 1px solid #3d3d6e;
    border-radius: 6px;
    margin-top: 0.5rem;
}

.sb-icon-picker-category {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #7a8aaa;
    padding: 6px 2px 3px;
    margin-top: 4px;
}

.sb-icon-picker-category:first-child {
    margin-top: 0;
    padding-top: 2px;
}

.sb-icon-picker-row {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-bottom: 2px;
}

.sb-icon-picker-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a2e;
    border: 1px solid #3d3d6e;
    border-radius: 4px;
    color: #c0d0e0;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.1s, border-color 0.1s;
}

.sb-icon-picker-btn:hover {
    background: #5e32a8;
    border-color: #5e32a8;
    color: #fff;
}

.sb-icon-picker-btn.selected {
    background: #5e32a8;
    border-color: #7040c0;
    color: #fff;
}

.sb-icon-picker-search {
    width: 100%;
    margin-bottom: 0.5rem;
}

/* ====================== Responsive Navbar ====================== */

.sb-btn-nav {
    color: #b088e0;
    border-color: #5e32a8;
    background: none;
}

.sb-btn-nav:hover, .sb-btn-nav:focus {
    background-color: #5e32a8;
    border-color: #5e32a8;
    color: #fff;
}

.sb-btn-nav.btn-warning {
    color: #fff;
}

.sb-nav-hamburger {
    display: none;
    background: none;
    border: 1px solid #5e32a8;
    color: #b088e0;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 1.2rem;
    cursor: pointer;
}

.sb-nav-hamburger:hover {
    border-color: #7040c0;
    color: #c8a8f0;
}

/* Dropdown dividers: no hover highlight */
.sb-divider-li,
.sb-divider-li:hover {
    background: transparent !important;
    cursor: default;
    pointer-events: none;
}

/* Bookmark list hr dividers: no hover highlight outside edit mode */
.sb-link-hr-item:hover {
    background: transparent !important;
    cursor: default;
}
body.edit-mode .sb-link-hr-item:hover {
    background: #252542 !important;
    cursor: inherit;
}

/* Search meta: gap from search box on desktop, gap before nav buttons */
.sb-search-meta {
    margin-left: 0.5rem;
    margin-right: 0.5rem;
    flex-shrink: 0;
}

.sb-signout-item,
.sb-signout-item:hover {
    color: #dc3545 !important;
}

/* Override for mobile menu (more specific) */
.sb-mobile-menu .sb-signout-item,
.sb-mobile-menu .sb-signout-item:hover {
    color: #dc3545 !important;
}

@media (max-width: 767.98px) {
    .sb-nav-desktop {
        display: none !important;
    }
    .sb-nav-hamburger {
        display: block;
    }

    /* Prevent iOS Safari from zooming into the search field on focus */
    .sb-search-input {
        font-size: 16px;
    }

    /* Search meta wraps to a second full-width row below brand+search+hamburger */
    .sb-search-meta {
        order: 10;
        flex-basis: 100%;
        margin-left: 0;
        margin-right: 0;
        padding-top: 0.5rem;
        padding-bottom: 0.2rem;
        flex-wrap: wrap;
    }

    /* A bit more breathing room between favicon and link text on mobile */
    .sb-link-item {
        gap: 0.65rem;
    }
}

.sb-mobile-menu {
    background: #1a1a2e;
    border: 1px solid #2d2d4e;
    border-radius: 6px;
}

.sb-mobile-menu .dropdown-item {
    color: #c0d0e0;
}

.sb-mobile-menu .dropdown-item:hover {
    background: #252542;
    color: #b088e0;
}

.sb-mobile-menu .dropdown-divider {
    border-color: #2d2d4e;
}

/* ====================== Dropdown dark theme ====================== */

.dropdown-menu {
    background: #1a1a2e;
    border-color: #2d2d4e;
}

.dropdown-menu .dropdown-item {
    color: #c0d0e0;
}

.dropdown-menu .dropdown-item:hover {
    background: #252542;
    color: #b088e0;
}

.dropdown-menu .dropdown-divider {
    border-color: #2d2d4e;
}

/* ====================== Import Bookmarks ====================== */

.sb-import-drop-zone {
    border: 2px dashed #3d3d6e;
    border-radius: 8px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    color: #8a8aaa;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
    background: #141424;
    user-select: none;
}

.sb-import-drop-zone:hover,
.sb-import-drop-zone.sb-drag-active {
    border-color: #7040c0;
    background: #1e1a36;
    color: #b088e0;
}

.sb-import-folder-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 50vh;
    overflow-y: auto;
    border: 1px solid #2d2d4e;
    border-radius: 6px;
}

.sb-import-folder-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #252542;
    background: #1a1a2e;
    color: #c0d0e0;
}

.sb-import-folder-item:last-child {
    border-bottom: none;
}

.sb-import-folder-item label {
    flex: 1;
    margin-bottom: 0;
    cursor: pointer;
}

.sb-import-count {
    font-size: 0.8em;
    color: #6a7a9a;
    white-space: nowrap;
}
