/* Server Notes application styles */

:root {
    --notes-topbar-height: 58px;
    --notes-sidebar-width: 260px;
    --notes-list-width: 350px;
    --notes-border: var(--bs-border-color);
    --notes-soft-bg: #f6f7f9;
    --notes-hover-bg: #eef2f6;
    --notes-active-bg: #e8f0fe;
    --notes-active-color: #0d4fbd;
    --notes-pane-bg: #ffffff;
    --notes-code-bg: #f6f8fa;
    --notes-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

[data-bs-theme="dark"] {
    --notes-soft-bg: #15191f;
    --notes-hover-bg: #1d232b;
    --notes-active-bg: #172f52;
    --notes-active-color: #9ec5fe;
    --notes-pane-bg: #111418;
    --notes-code-bg: #0d1117;
    --notes-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
}

button,
input,
select,
textarea {
    font: inherit;
}

.icon-button,
.mini-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    background: transparent;
    color: var(--bs-body-color);
    border-radius: 0.6rem;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.icon-button {
    width: 2.4rem;
    height: 2.4rem;
    font-size: 1.05rem;
}

.mini-icon-button {
    width: 1.85rem;
    height: 1.85rem;
    font-size: 0.9rem;
}

.icon-button:hover,
.mini-icon-button:hover {
    background: var(--notes-hover-bg);
}

.danger-hover:hover {
    color: var(--bs-danger);
    background: rgba(var(--bs-danger-rgb), 0.1);
}

.mobile-only {
    display: none;
}

/* Login */

.login-page {
    min-height: 100%;
    background:
        radial-gradient(circle at top left, rgba(13, 110, 253, 0.12), transparent 34rem),
        linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.login-card {
    width: min(100%, 430px);
    background: #fff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 1.2rem;
    padding: 2rem;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.login-brand h1 {
    margin: 0;
    font-size: 1.65rem;
    font-weight: 700;
}

.login-brand p {
    margin: 0.25rem 0 0;
    color: #64748b;
}

.brand-mark {
    width: 3.25rem;
    height: 3.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 1rem;
    background: linear-gradient(145deg, #0d6efd, #4f46e5);
    color: #fff;
    font-size: 1.45rem;
    box-shadow: 0 8px 20px rgba(13, 110, 253, 0.25);
    flex: 0 0 auto;
}

.brand-mark.small {
    width: 2rem;
    height: 2rem;
    border-radius: 0.6rem;
    font-size: 1rem;
    box-shadow: none;
}

.login-security-note {
    margin: 1.5rem 0 0;
    font-size: 0.84rem;
    line-height: 1.45;
    color: #64748b;
    text-align: center;
}

/* Main app */

.app-page {
    height: 100vh;
    overflow: hidden;
    background: var(--notes-pane-bg);
}

.notes-app {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.app-topbar {
    height: var(--notes-topbar-height);
    flex: 0 0 var(--notes-topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.85rem;
    border-bottom: 1px solid var(--notes-border);
    background: var(--notes-pane-bg);
    z-index: 30;
}

.topbar-left,
.topbar-actions,
.toolbar-leading,
.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--bs-body-color);
    text-decoration: none;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.app-workspace {
    min-height: 0;
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: var(--notes-sidebar-width) var(--notes-list-width) minmax(0, 1fr);
    overflow: hidden;
}

.sidebar-pane,
.notes-list-pane,
.note-pane {
    min-width: 0;
    min-height: 0;
}

.sidebar-pane {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--notes-border);
    background: var(--notes-soft-bg);
}

.sidebar-header {
    height: 48px;
    flex: 0 0 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.85rem;
    border-bottom: 1px solid var(--notes-border);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--bs-secondary-color);
}

.sidebar-content {
    min-height: 0;
    overflow-y: auto;
    padding: 0.65rem;
}

.nav-row,
.folder-row,
.tag-row {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--bs-body-color);
    border-radius: 0.55rem;
    text-align: left;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.56rem 0.65rem;
    font-size: 0.92rem;
}

.nav-row span:first-child {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
}

.nav-row:hover,
.folder-row:hover,
.tag-row:hover {
    background: var(--notes-hover-bg);
}

.nav-row.active,
.folder-row.active,
.tag-row.active {
    background: var(--notes-active-bg);
    color: var(--notes-active-color);
    font-weight: 600;
}

.count-badge {
    min-width: 1.5rem;
    padding: 0.1rem 0.42rem;
    border-radius: 99px;
    background: rgba(100, 116, 139, 0.13);
    color: var(--bs-secondary-color);
    font-size: 0.72rem;
    text-align: center;
}

.sidebar-section {
    margin-top: 1rem;
}

.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0.4rem 0.35rem;
    color: var(--bs-secondary-color);
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.folder-tree,
.tag-list {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.folder-node {
    min-width: 0;
}

.folder-line {
    display: flex;
    align-items: center;
    min-width: 0;
}

.folder-row {
    min-width: 0;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    padding: 0.43rem 0.48rem;
    font-size: 0.88rem;
}

.folder-row-main {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.folder-row-name,
.tag-row-name {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.folder-actions {
    display: flex;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.folder-line:hover .folder-actions,
.folder-actions:focus-within {
    opacity: 1;
}

.folder-children {
    margin-left: 0.85rem;
    padding-left: 0.45rem;
    border-left: 1px solid var(--notes-border);
}

.tag-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.42rem 0.55rem;
    font-size: 0.86rem;
}

.tag-row-main {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.notes-list-pane {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--notes-border);
    background: var(--notes-pane-bg);
}

.notes-list-header {
    flex: 0 0 auto;
    border-bottom: 1px solid var(--notes-border);
    background: var(--notes-pane-bg);
}

.search-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.45rem;
    padding: 0.65rem;
}

.search-box {
    height: 2.4rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 0.7rem;
    border: 1px solid var(--notes-border);
    border-radius: 0.65rem;
    background: var(--bs-body-bg);
    color: var(--bs-secondary-color);
}

.search-box:focus-within {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.15);
}

.search-box input {
    min-width: 0;
    width: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--bs-body-color);
}

.new-note-button {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.filter-panel {
    display: grid;
    gap: 0.5rem;
    padding: 0 0.65rem 0.65rem;
}

.compact-switch {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2rem;
}

.list-context {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.75rem 0.65rem;
}

.list-context > div {
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
    min-width: 0;
}

.list-context strong {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.list-context span {
    color: var(--bs-secondary-color);
    font-size: 0.78rem;
    white-space: nowrap;
}

.notes-list {
    min-height: 0;
    overflow-y: auto;
    padding: 0.45rem;
}

.note-list-item {
    width: 100%;
    display: block;
    border: 1px solid transparent;
    border-radius: 0.72rem;
    background: transparent;
    color: var(--bs-body-color);
    text-align: left;
    padding: 0.75rem;
    margin-bottom: 0.2rem;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.note-list-item:hover {
    background: var(--notes-hover-bg);
}

.note-list-item.active {
    background: var(--notes-active-bg);
    border-color: rgba(var(--bs-primary-rgb), 0.25);
}

.note-list-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 0.3rem;
}

.note-list-title {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-weight: 650;
}

.note-list-favorite {
    color: #d99b00;
    flex: 0 0 auto;
}

.note-list-snippet {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    min-height: 2.5em;
    color: var(--bs-secondary-color);
    font-size: 0.82rem;
    line-height: 1.35;
}

.note-list-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.55rem;
    color: var(--bs-secondary-color);
    font-size: 0.72rem;
}

.note-list-badges {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    min-width: 0;
    overflow: hidden;
}

.format-badge,
.tag-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 99px;
    white-space: nowrap;
}

.format-badge {
    padding: 0.14rem 0.42rem;
    background: rgba(var(--bs-primary-rgb), 0.1);
    color: var(--bs-primary);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
}

.tag-chip {
    padding: 0.2rem 0.5rem;
    background: rgba(100, 116, 139, 0.12);
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
}

.load-more-wrap {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    padding: 0.35rem 0.6rem 0.65rem;
    border-top: 1px solid transparent;
}

.load-more-wrap {
    border-top-color: var(--notes-border);
}

.load-more-wrap[hidden] {
    display: none !important;
}

.list-empty {
    flex: 1 1 auto;
    display: grid;
    place-content: center;
    text-align: center;
    color: var(--bs-secondary-color);
}

.list-empty i {
    font-size: 2rem;
    margin-bottom: 0.35rem;
}

.note-pane {
    position: relative;
    overflow: hidden;
    background: var(--notes-pane-bg);
}

.note-empty-state {
    height: 100%;
    display: grid;
    place-content: center;
    padding: 2rem;
    text-align: center;
    color: var(--bs-secondary-color);
}

.note-empty-state h2 {
    color: var(--bs-body-color);
    margin-top: 0.8rem;
    font-size: 1.35rem;
}

.empty-icon {
    font-size: 3rem;
    opacity: 0.55;
}

.note-view,
.note-editor {
    height: 100%;
    min-height: 0;
}

.note-view {
    overflow-y: auto;
    padding-bottom: 3rem;
}

.note-toolbar {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--notes-border);
    background: var(--notes-pane-bg);
    position: sticky;
    top: 0;
    z-index: 10;
}

.note-heading-wrap {
    min-width: 0;
}

.note-heading-wrap h1 {
    margin: 0;
    font-size: 1.25rem;
    line-height: 1.2;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.note-meta {
    margin-top: 0.2rem;
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
}

.note-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    max-width: 980px;
    margin: 1rem auto 0;
    padding: 0 1.5rem;
}

.rendered-note {
    max-width: 980px;
    margin: 0 auto;
    padding: 1.5rem;
    font-size: 0.96rem;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

.rendered-note > :first-child {
    margin-top: 0;
}

.rendered-note > :last-child {
    margin-bottom: 0;
}

.rendered-note h1,
.rendered-note h2,
.rendered-note h3,
.rendered-note h4 {
    margin-top: 1.55em;
    margin-bottom: 0.55em;
    line-height: 1.25;
}

.rendered-note h1 {
    font-size: 1.8rem;
}

.rendered-note h2 {
    font-size: 1.45rem;
}

.rendered-note h3 {
    font-size: 1.2rem;
}

.rendered-note pre {
    position: relative;
    border: 1px solid var(--notes-border);
    border-radius: 0.7rem;
    background: var(--notes-code-bg);
    overflow: auto;
    padding: 1rem;
    line-height: 1.5;
}

.rendered-note pre code {
    white-space: pre;
}

.rendered-note code:not(pre code) {
    padding: 0.12rem 0.32rem;
    border-radius: 0.35rem;
    background: rgba(100, 116, 139, 0.12);
    color: var(--bs-body-color);
}

.rendered-note blockquote {
    margin: 1rem 0;
    padding: 0.2rem 0 0.2rem 1rem;
    border-left: 4px solid var(--bs-primary);
    color: var(--bs-secondary-color);
}

.rendered-note table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.rendered-note th,
.rendered-note td {
    border: 1px solid var(--notes-border);
    padding: 0.5rem 0.65rem;
    text-align: left;
}

.rendered-note img {
    max-width: 100%;
}

.plain-text-view {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--bs-font-monospace);
    line-height: 1.55;
}

.trash-actions {
    display: flex;
    gap: 0.65rem;
    max-width: 980px;
    margin: 1rem auto;
    padding: 0 1.5rem;
}

.note-editor {
    display: flex;
    flex-direction: column;
}

.editor-label {
    font-weight: 650;
}

.editor-meta-grid {
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: minmax(220px, 2fr) minmax(130px, 0.8fr) minmax(150px, 1fr) auto;
    gap: 0.55rem;
    padding: 0.7rem;
    border-bottom: 1px solid var(--notes-border);
}

.note-title-input {
    font-weight: 650;
}

.tags-input {
    grid-column: 1 / -1;
}

.favorite-edit-button.active,
#view-favorite.active {
    color: #d99b00;
    background: rgba(217, 155, 0, 0.12);
}

.editor-split {
    min-height: 0;
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.editor-column,
.preview-column {
    min-width: 0;
    min-height: 0;
}

.editor-column {
    border-right: 1px solid var(--notes-border);
    overflow: hidden;
}

.preview-column {
    position: relative;
    overflow-y: auto;
    background: var(--notes-pane-bg);
}

.preview-heading {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 0.42rem 0.75rem;
    border-bottom: 1px solid var(--notes-border);
    background: var(--notes-soft-bg);
    color: var(--bs-secondary-color);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.editor-preview {
    padding: 1rem 1.2rem 2rem;
}

.CodeMirror {
    height: 100%;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 14px;
    line-height: 1.55;
    background: var(--notes-pane-bg);
    color: var(--bs-body-color);
}

.CodeMirror-gutters {
    border-right-color: var(--notes-border);
    background: var(--notes-soft-bg);
}

.CodeMirror-linenumber {
    color: var(--bs-secondary-color);
}

.CodeMirror-cursor {
    border-left-color: var(--bs-body-color);
}

.save-indicator {
    min-width: 4.5rem;
    color: var(--bs-secondary-color);
    font-size: 0.78rem;
    text-align: right;
}

.save-indicator.saving {
    color: var(--bs-warning);
}

.save-indicator.saved {
    color: var(--bs-success);
}

.save-indicator.failed {
    color: var(--bs-danger);
}

.mobile-overlay {
    display: none;
}


/* Native dialog and application toast */

.folder-dialog {
    width: min(92vw, 520px);
    max-width: none;
    padding: 0;
    border: 0;
    border-radius: 0.9rem;
    background: transparent;
    color: var(--bs-body-color);
    box-shadow: var(--notes-shadow);
}

.folder-dialog::backdrop {
    background: rgba(2, 6, 23, 0.52);
    backdrop-filter: blur(2px);
}

.folder-dialog-card {
    overflow: hidden;
    border: 1px solid var(--notes-border);
    border-radius: 0.9rem;
    background: var(--notes-pane-bg);
}

.folder-dialog-header,
.folder-dialog-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
}

.folder-dialog-header {
    border-bottom: 1px solid var(--notes-border);
}

.folder-dialog-body {
    padding: 1rem;
}

.folder-dialog-footer {
    justify-content: flex-end;
    border-top: 1px solid var(--notes-border);
    background: var(--notes-soft-bg);
}

.app-toast {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 100;
    width: min(calc(100vw - 2rem), 360px);
    overflow: hidden;
    border: 1px solid var(--notes-border);
    border-radius: 0.75rem;
    background: var(--notes-pane-bg);
    color: var(--bs-body-color);
    box-shadow: var(--notes-shadow);
    opacity: 0;
    transform: translateY(0.75rem);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.app-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.app-toast.error {
    border-color: rgba(var(--bs-danger-rgb), 0.55);
}

.app-toast-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 0.8rem;
    border-bottom: 1px solid var(--notes-border);
    background: var(--notes-soft-bg);
}

.app-toast.error .app-toast-header {
    color: var(--bs-danger);
}

.app-toast-body {
    padding: 0.8rem;
    font-size: 0.9rem;
}

/* Dark theme adjustments */

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #171b21;
    border-color: #343b45;
}

[data-bs-theme="dark"] .CodeMirror {
    background: #111418;
}

[data-bs-theme="dark"] .CodeMirror-gutters {
    background: #15191f;
}

[data-bs-theme="dark"] .login-page {
    background:
        radial-gradient(circle at top left, rgba(13, 110, 253, 0.14), transparent 34rem),
        linear-gradient(180deg, #111418 0%, #0b0d10 100%);
}

[data-bs-theme="dark"] .login-card {
    background: #15191f;
    border-color: #2d333b;
}

/* Tablet and mobile */

@media (max-width: 1199.98px) {
    :root {
        --notes-list-width: 320px;
    }

    .app-workspace {
        grid-template-columns: var(--notes-list-width) minmax(0, 1fr);
    }

    .sidebar-pane {
        position: fixed;
        inset: var(--notes-topbar-height) auto 0 0;
        width: min(86vw, var(--notes-sidebar-width));
        z-index: 50;
        transform: translateX(-105%);
        box-shadow: var(--notes-shadow);
        transition: transform 0.2s ease;
    }

    .sidebar-open .sidebar-pane {
        transform: translateX(0);
    }

    .mobile-overlay {
        position: fixed;
        inset: var(--notes-topbar-height) 0 0;
        z-index: 45;
        background: rgba(2, 6, 23, 0.46);
    }

    .sidebar-open .mobile-overlay {
        display: block;
    }

    .mobile-only {
        display: inline-flex;
    }
}

@media (max-width: 767.98px) {
    :root {
        --notes-topbar-height: 54px;
    }

    .app-topbar {
        padding: 0 0.55rem;
    }

    .app-workspace {
        display: block;
        position: relative;
    }

    .notes-list-pane,
    .note-pane {
        position: absolute;
        inset: 0;
        width: 100%;
    }

    .notes-list-pane {
        z-index: 2;
        border-right: 0;
    }

    .note-pane {
        z-index: 3;
        transform: translateX(100%);
        transition: transform 0.2s ease;
    }

    .mobile-note-open .note-pane {
        transform: translateX(0);
    }

    .search-row {
        grid-template-columns: minmax(0, 1fr) auto auto;
    }

    .new-note-button span {
        display: none;
    }

    .note-toolbar {
        padding: 0.55rem 0.65rem;
    }

    .note-heading-wrap h1 {
        font-size: 1.05rem;
    }

    .toolbar-actions {
        gap: 0.3rem;
    }

    .editor-meta-grid {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 0.45rem;
        padding: 0.55rem;
    }

    .note-title-input {
        grid-column: 1 / -1;
    }

    #edit-format,
    #edit-folder {
        grid-column: 1 / 2;
    }

    .favorite-edit-button {
        grid-column: 2 / 3;
        grid-row: 2 / 4;
        align-self: stretch;
        height: auto;
    }

    .tags-input {
        grid-column: 1 / -1;
    }

    .editor-split {
        display: block;
    }

    .editor-column {
        height: 100%;
        border-right: 0;
    }

    .preview-column {
        display: none;
    }

    .rendered-note {
        padding: 1rem;
        font-size: 0.92rem;
    }

    .note-tags,
    .trash-actions {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .trash-actions {
        flex-direction: column;
    }

    .folder-actions {
        opacity: 1;
    }

    .save-indicator#global-save-status {
        display: none;
    }
}

@media (max-width: 420px) {
    .app-brand > span:last-child {
        display: none;
    }

    .note-toolbar .btn-sm {
        padding-inline: 0.55rem;
    }

    .editor-toolbar .toolbar-leading .editor-label {
        display: none;
    }
}

/* Login security audit */

.security-alert-button {
    position: relative;
    text-decoration: none;
}

.security-alert-button.has-alerts {
    color: var(--bs-danger);
    background: rgba(var(--bs-danger-rgb), 0.08);
}

.security-alert-button.has-alerts:hover {
    color: var(--bs-danger);
    background: rgba(var(--bs-danger-rgb), 0.14);
}

.security-alert-badge {
    position: absolute;
    top: -0.18rem;
    right: -0.24rem;
    min-width: 1.15rem;
    height: 1.15rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.27rem;
    border: 2px solid var(--notes-pane-bg);
    border-radius: 999px;
    background: var(--bs-danger);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 1;
}

.security-page {
    min-height: 100%;
    background: var(--notes-soft-bg);
}

.security-app {
    min-height: 100vh;
}

.security-topbar {
    position: sticky;
    top: 0;
}

.topbar-divider {
    width: 1px;
    height: 1.45rem;
    background: var(--notes-border);
}

.security-page-title {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--bs-secondary-color);
    font-size: 0.88rem;
    font-weight: 650;
}

.security-content {
    width: min(100%, 1500px);
    margin: 0 auto;
    padding: 1.35rem;
}

.security-heading-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.25rem;
    margin-bottom: 1rem;
}

.security-heading-row h1 {
    margin: 0;
    font-size: clamp(1.45rem, 2.5vw, 2rem);
    font-weight: 750;
    letter-spacing: -0.025em;
}

.security-heading-row p {
    max-width: 760px;
    margin: 0.35rem 0 0;
    color: var(--bs-secondary-color);
}

.security-reviewed-time {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--notes-border);
    border-radius: 0.65rem;
    background: var(--notes-pane-bg);
    color: var(--bs-secondary-color);
    font-size: 0.8rem;
    white-space: nowrap;
}

.security-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
}

.security-alert > i {
    margin-top: 0.12rem;
    font-size: 1.1rem;
}

.security-stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.security-stat-card {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem;
    border: 1px solid var(--notes-border);
    border-radius: 0.85rem;
    background: var(--notes-pane-bg);
    box-shadow: 0 4px 15px rgba(15, 23, 42, 0.035);
}

.security-stat-icon {
    width: 2.8rem;
    height: 2.8rem;
    flex: 0 0 2.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.8rem;
    font-size: 1.25rem;
}

.security-stat-icon.danger {
    background: rgba(var(--bs-danger-rgb), 0.11);
    color: var(--bs-danger);
}

.security-stat-icon.warning {
    background: rgba(var(--bs-warning-rgb), 0.16);
    color: #9a6700;
}

[data-bs-theme="dark"] .security-stat-icon.warning {
    color: #ffcf66;
}

.security-stat-card > div {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.security-stat-label {
    color: var(--bs-secondary-color);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.045em;
    text-transform: uppercase;
}

.security-stat-card strong {
    margin: 0.08rem 0;
    font-size: 1.7rem;
    line-height: 1.1;
}

.security-stat-card small {
    overflow: hidden;
    color: var(--bs-secondary-color);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.security-panel {
    margin-top: 1rem;
    overflow: hidden;
    border: 1px solid var(--notes-border);
    border-radius: 0.85rem;
    background: var(--notes-pane-bg);
}

.security-panel-header {
    min-height: 66px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--notes-border);
}

.security-panel-header h2,
.security-unlock-help h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 730;
}

.security-panel-header p,
.security-unlock-help p {
    margin: 0.18rem 0 0;
    color: var(--bs-secondary-color);
    font-size: 0.82rem;
}

.security-table {
    --bs-table-bg: transparent;
    font-size: 0.85rem;
}

.security-table thead th {
    padding: 0.65rem 0.85rem;
    border-bottom-width: 1px;
    background: var(--notes-soft-bg);
    color: var(--bs-secondary-color);
    font-size: 0.72rem;
    font-weight: 750;
    letter-spacing: 0.045em;
    text-transform: uppercase;
    white-space: nowrap;
}

.security-table tbody td {
    padding: 0.7rem 0.85rem;
}

.security-table code {
    padding: 0.16rem 0.35rem;
    border-radius: 0.35rem;
    background: var(--notes-code-bg);
    color: var(--bs-body-color);
    font-size: 0.8rem;
}

.security-empty-state {
    min-height: 125px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 0.45rem;
    padding: 1.25rem;
    color: var(--bs-secondary-color);
    text-align: center;
}

.security-empty-state i {
    font-size: 1.7rem;
}

.security-empty-state p {
    margin: 0;
}

.security-panel-note {
    padding: 0.65rem 0.85rem;
    border-top: 1px solid var(--notes-border);
    color: var(--bs-secondary-color);
    font-size: 0.78rem;
}

.security-history-header {
    align-items: flex-start;
}

.security-filter-form {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.security-search-field {
    position: relative;
}

.security-search-field > i {
    position: absolute;
    top: 50%;
    left: 0.62rem;
    z-index: 2;
    color: var(--bs-secondary-color);
    font-size: 0.78rem;
    transform: translateY(-50%);
    pointer-events: none;
}

.security-search-field .form-control {
    width: 190px;
    padding-left: 1.85rem;
}

.security-filter-form .form-select {
    width: 175px;
}

.security-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    padding: 0.8rem;
    border-top: 1px solid var(--notes-border);
    color: var(--bs-secondary-color);
    font-size: 0.82rem;
}

.security-pagination .btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.security-unlock-help {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid var(--notes-border);
    border-radius: 0.85rem;
    background: var(--notes-pane-bg);
}

.security-unlock-help h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.security-code-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
    margin-top: 0.85rem;
}

.security-code-grid strong {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.82rem;
}

.security-code-grid pre {
    height: 100%;
    margin: 0;
    overflow: auto;
    padding: 0.8rem;
    border-radius: 0.65rem;
    background: var(--notes-code-bg);
    color: var(--bs-body-color);
    font-size: 0.78rem;
}

@media (max-width: 1099.98px) {
    .security-stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .security-history-header {
        flex-direction: column;
    }

    .security-filter-form {
        width: 100%;
    }

    .security-search-field {
        flex: 1 1 auto;
    }

    .security-search-field .form-control {
        width: 100%;
    }
}

@media (max-width: 767.98px) {
    .security-content {
        padding: 0.85rem;
    }

    .topbar-divider,
    .security-page-title {
        display: none;
    }

    .security-heading-row {
        flex-direction: column;
    }

    .security-reviewed-time {
        width: 100%;
        justify-content: center;
    }

    .security-stat-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .security-panel-header {
        align-items: flex-start;
    }

    .security-filter-form {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .security-search-field,
    .security-filter-form .form-select {
        width: 100%;
    }

    .security-code-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 480px) {
    .security-filter-form {
        grid-template-columns: minmax(0, 1fr);
    }

    .security-filter-form .btn {
        width: 100%;
    }

    .security-pagination {
        justify-content: space-between;
        gap: 0.4rem;
    }

    .security-pagination span {
        font-size: 0.72rem;
    }
}

/* Personal portal */

.portal-page {
    min-height: 100%;
    background: #ffffff;
}

[data-bs-theme="dark"] .portal-page,
[data-bs-theme="dark"] body.portal-page {
    background: #0f1217;
}

.portal-app {
    min-height: 100vh;
    background:
        radial-gradient(circle at 8% 0%, rgba(13, 110, 253, 0.09), transparent 30rem),
        var(--bs-body-bg);
}

.portal-topbar {
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem clamp(1rem, 3vw, 2.5rem);
    border-bottom: 1px solid var(--bs-border-color);
    background: color-mix(in srgb, var(--bs-body-bg) 94%, transparent);
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(14px);
}

.portal-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--bs-body-color);
    text-decoration: none;
    font-size: 1.08rem;
    font-weight: 750;
    letter-spacing: -0.015em;
}

.portal-brand:hover {
    color: var(--bs-body-color);
}

.portal-brand-mark {
    width: 2.45rem;
    height: 2.45rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.78rem;
    color: #fff;
    background: linear-gradient(145deg, #0d6efd, #4f46e5);
    box-shadow: 0 8px 18px rgba(13, 110, 253, 0.2);
}

.portal-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.portal-topbar-actions form,
.portal-card-form {
    margin: 0;
}

.portal-username {
    color: var(--bs-secondary-color);
    font-size: 0.9rem;
    margin-right: 0.25rem;
}

.portal-signout-button {
    min-height: 2.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.7rem;
    padding: 0.42rem 0.75rem;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
}

.portal-signout-button:hover {
    background: var(--notes-hover-bg);
}

.portal-content {
    width: min(100%, 1500px);
    margin: 0 auto;
    padding: clamp(2rem, 5vw, 4.5rem) clamp(1rem, 4vw, 3rem) 4rem;
}

.portal-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.65rem;
}

.portal-heading h1 {
    margin: 0;
    font-size: clamp(1.8rem, 3vw, 2.6rem);
    font-weight: 750;
    letter-spacing: -0.035em;
}

.portal-eyebrow {
    margin: 0 0 0.35rem;
    color: var(--bs-primary);
    font-size: 0.78rem;
    font-weight: 750;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.portal-card-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1.15rem;
}

.portal-card-form {
    min-width: 0;
}

.portal-module-card {
    width: 100%;
    min-width: 0;
    min-height: 176px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1.4rem;
    padding: 1.35rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 1.15rem;
    background: var(--notes-pane-bg);
    color: var(--bs-body-color);
    text-align: left;
    text-decoration: none;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.045);
    overflow: hidden;
    transition:
        transform 0.18s ease,
        border-color 0.18s ease,
        box-shadow 0.18s ease;
}

button.portal-module-card {
    cursor: pointer;
}

.portal-module-card:not(.is-disabled):hover {
    color: var(--bs-body-color);
    transform: translateY(-3px);
    border-color: rgba(var(--bs-primary-rgb), 0.48);
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.1);
}

[data-bs-theme="dark"] .portal-module-card {
    box-shadow: 0 9px 26px rgba(0, 0, 0, 0.22);
}

.portal-card-icon {
    width: 3rem;
    height: 3rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.92rem;
    background: rgba(var(--bs-primary-rgb), 0.11);
    color: var(--bs-primary);
    font-size: 1.35rem;
}

.portal-card-title {
    margin-top: auto;
    font-size: 1.12rem;
    font-weight: 720;
    letter-spacing: -0.015em;
}

.portal-card-arrow {
    position: absolute;
    top: 1.1rem;
    right: 1.15rem;
    color: var(--bs-secondary-color);
    font-size: 1rem;
}

.portal-module-card.is-disabled {
    opacity: 0.62;
    background: var(--notes-soft-bg);
}

.portal-coming-soon {
    position: absolute;
    top: 1.05rem;
    right: 1rem;
    padding: 0.2rem 0.48rem;
    border-radius: 999px;
    background: rgba(100, 116, 139, 0.12);
    color: var(--bs-secondary-color);
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.portal-security-badge {
    position: absolute;
    top: 0.9rem;
    right: 0.9rem;
    min-width: 1.65rem;
    height: 1.65rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.42rem;
    border-radius: 999px;
    background: var(--bs-danger);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    box-shadow: 0 0 0 4px rgba(var(--bs-danger-rgb), 0.12);
}

.security-card .portal-card-icon {
    background: rgba(var(--bs-danger-rgb), 0.1);
    color: var(--bs-danger);
}

.portal-login-card .brand-mark {
    background: linear-gradient(145deg, #0d6efd, #4f46e5);
}

@media (max-width: 991.98px) {
    .portal-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px) {
    .portal-topbar {
        min-height: 60px;
        padding: 0.6rem 0.8rem;
    }

    .portal-brand {
        font-size: 1rem;
    }

    .portal-brand-mark {
        width: 2.15rem;
        height: 2.15rem;
        border-radius: 0.68rem;
    }

    .portal-content {
        padding: 1.65rem 0.85rem 2.5rem;
    }

    .portal-card-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 0.85rem;
    }

    .portal-module-card {
        min-height: 126px;
        padding: 1.1rem;
        border-radius: 1rem;
    }

    .portal-card-icon {
        width: 2.65rem;
        height: 2.65rem;
    }
}
