/*
 * MyNotes. Scoped to .notes-page so the stylesheet can be loaded globally and
 * every colour comes from the shared --tb-* theme tokens.
 */

.notes-page {
    max-width: 1240px;
    margin: 0 auto;
    padding: 1.25rem;
    color: var(--tb-text);
}

.notes-hero {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.notes-heading {
    color: var(--tb-heading);
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0 0 .25rem;
}

.notes-subtitle {
    color: var(--tb-text-muted);
    margin: 0;
    max-width: 48rem;
}

.notes-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    flex: 0 0 auto;
}

.notes-hero-title-row {
    display: flex;
    align-items: baseline;
    gap: .75rem;
}

.notes-hero-title-row .notes-heading {
    margin: 0;
    min-width: 0;
}

.notes-help-chip {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    min-height: 32px;
    padding: 0 .25rem;
    border: 0;
    background: none;
    color: var(--tb-text);
    font-size: .875rem;
    font-weight: 600;
}

.notes-help-chip .fa-info-circle {
    color: var(--tb-success);
}

.notes-help-chip:hover,
.notes-help-chip:focus {
    color: var(--tb-text);
    text-decoration: underline;
}

.notes-help-panel {
    margin-bottom: 1rem;
    padding: .65rem .85rem;
    background: var(--tb-success-bg);
    border: 1px solid var(--tb-border);
    border-left: 4px solid var(--tb-success);
    border-radius: var(--tb-radius-sm);
    color: var(--tb-text);
    font-size: .875rem;
}

.notes-help-panel > div + div {
    margin-top: .2rem;
}

.notes-hero > .notes-help-panel {
    flex: 0 0 100%;
    width: 100%;
    margin-bottom: 0;
}

.notes-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: .75rem;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--tb-border);
}

.notes-search {
    display: flex;
    align-items: center;
    flex: 1 1 22rem;
    flex-wrap: wrap;
    gap: .5rem;
    max-width: 40rem;
}

.notes-search .form-control {
    flex: 1 1 12rem;
    min-width: 0;
}

.notes-toolbar-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .75rem;
}

.notes-count {
    color: var(--tb-text-muted);
    font-weight: 600;
}

.notes-page .btn {
    min-height: 44px;
}

.notes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 1rem;
}

.notes-card {
    --notes-accent: var(--tb-primary);
    --notes-ink: var(--tb-heading);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: var(--tb-surface);
    border: 1px solid var(--tb-border);
    border-left: 6px solid var(--notes-accent);
    border-radius: var(--tb-radius);
    box-shadow: var(--tb-shadow-sm);
    transition: box-shadow var(--tb-transition), transform var(--tb-transition);
}

.notes-card:hover {
    box-shadow: var(--tb-shadow);
    transform: translateY(-2px);
}

.notes-card-main {
    appearance: none;
    -webkit-appearance: none;
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: .45rem;
    width: 100%;
    padding: .9rem .95rem .75rem;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.notes-card-main:focus {
    outline: 3px solid var(--tb-focus);
    outline-offset: -3px;
}

.notes-card-title {
    display: block;
    overflow: hidden;
    color: var(--notes-ink);
    font-size: 1.08rem;
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -0.01em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notes-card-preview {
    display: -webkit-box;
    overflow: hidden;
    min-height: 2.8em;
    color: var(--tb-text);
    line-height: 1.4;
    word-break: break-word;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
}

.notes-card-footer {
    padding: .5rem .95rem;
    border-top: 1px solid var(--tb-border);
    color: var(--tb-text-muted);
    font-size: .8rem;
}

.notes-swatches {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}

.notes-swatch-option {
    display: inline-flex;
    margin: 0;
}

.notes-swatch {
    -webkit-appearance: none;
    appearance: none;
    width: 1.5rem;
    height: 1.5rem;
    margin: 0;
    border: 1px solid var(--tb-border-strong);
    border-radius: 50%;
    background: var(--notes-accent);
    cursor: pointer;
}

.notes-swatch:checked {
    box-shadow: 0 0 0 3px var(--tb-surface), 0 0 0 5px var(--notes-accent);
}

.notes-swatch:focus-visible {
    outline: 2px solid var(--tb-link);
    outline-offset: 2px;
}

.notes-color-primary {
    --notes-accent: var(--tb-primary);
    --notes-ink: #375a7f;
}

.notes-color-success {
    --notes-accent: var(--tb-success);
    --notes-ink: #087f5b;
}

.notes-color-warning {
    --notes-accent: var(--tb-warning);
    --notes-ink: #8a5a00;
}

.notes-color-danger {
    --notes-accent: var(--tb-danger);
    --notes-ink: #bd2a2a;
}

.notes-color-info {
    --notes-accent: var(--tb-info);
    --notes-ink: #1f6fb2;
}

.notes-color-dark {
    --notes-accent: var(--tb-heading);
    --notes-ink: var(--tb-heading);
}

.notes-color-light {
    --notes-accent: var(--tb-border-strong);
    --notes-ink: var(--tb-heading);
    background: var(--tb-surface-alt);
}

html[data-theme="dark"] .notes-color-primary {
    --notes-accent: var(--tb-primary);
    --notes-ink: var(--tb-info-text);
}

html[data-theme="dark"] .notes-color-success {
    --notes-accent: var(--tb-success);
    --notes-ink: var(--tb-success-text);
}

html[data-theme="dark"] .notes-color-warning {
    --notes-accent: var(--tb-warning);
    --notes-ink: var(--tb-warning-text);
}

html[data-theme="dark"] .notes-color-danger {
    --notes-accent: var(--tb-danger);
    --notes-ink: var(--tb-danger-text);
}

html[data-theme="dark"] .notes-color-info {
    --notes-accent: var(--tb-info);
    --notes-ink: var(--tb-info-text);
}

html[data-theme="dark"] .notes-color-dark {
    --notes-accent: var(--tb-heading);
    --notes-ink: var(--tb-heading);
}

html[data-theme="dark"] .notes-color-light {
    --notes-accent: var(--tb-border-strong);
    --notes-ink: var(--tb-heading);
}

.notes-view-toggle {
    flex: 0 0 auto;
}

.notes-view-list .notes-grid {
    grid-template-columns: 1fr;
    gap: .55rem;
}

.notes-view-list .notes-card {
    flex-direction: row;
    align-items: stretch;
}

.notes-view-list .notes-card:hover {
    transform: none;
}

.notes-view-list .notes-card-main {
    display: grid;
    grid-template-columns: minmax(10rem, 16rem) minmax(0, 1fr);
    align-items: center;
    gap: 1rem;
}

.notes-view-list .notes-card-title {
    white-space: normal;
    font-size: 1rem;
}

.notes-view-list .notes-card-preview {
    min-height: 0;
    -webkit-line-clamp: 2;
}

.notes-view-list .notes-card-footer {
    display: flex;
    align-items: center;
    padding: .75rem 1rem;
    border-top: 0;
    border-left: 1px solid var(--tb-border);
    white-space: nowrap;
}

.notes-empty {
    padding: 2rem 1rem;
    color: var(--tb-text-muted);
}

.notes-empty p {
    margin-bottom: .75rem;
}

.notes-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: .75rem;
    margin-top: 1.5rem;
    color: var(--tb-text-muted);
}

.notes-page-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: .4rem .85rem;
    border: 1px solid var(--tb-border);
    border-radius: var(--tb-radius-sm);
    background: var(--tb-surface);
    color: var(--tb-link);
    text-decoration: none;
}

.notes-page-link:hover,
.notes-page-link:focus {
    background: var(--tb-surface-alt);
    color: var(--tb-text);
    text-decoration: none;
}

.notes-page-link.is-disabled {
    opacity: .65;
    pointer-events: none;
}

@media (max-width: 767.98px) {
    .notes-view-toggle {
        display: none;
    }

    .notes-view-list .notes-grid {
        grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
        gap: 1rem;
    }

    .notes-view-list .notes-card {
        flex-direction: column;
        align-items: stretch;
    }

    .notes-view-list .notes-card-main {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: .45rem;
        padding: .9rem .95rem .75rem;
    }

    .notes-view-list .notes-card-title {
        font-size: 1.08rem;
        white-space: nowrap;
    }

    .notes-view-list .notes-card-preview {
        min-height: 2.8em;
        -webkit-line-clamp: 4;
    }

    .notes-view-list .notes-card-footer {
        display: block;
        padding: .5rem .95rem;
        border-top: 1px solid var(--tb-border);
        border-left: 0;
        white-space: normal;
    }
}

@media (max-width: 479.98px) {
    .notes-hero {
        flex-direction: column;
    }

    .notes-hero-title-row {
        order: 1;
    }

    .notes-hero > .notes-help-panel {
        flex-basis: auto;
        order: 2;
    }

    .notes-hero-actions {
        order: 3;
        width: 100%;
    }

    .notes-hero-actions .btn {
        flex: 1 1 100%;
    }

    .notes-search {
        flex-basis: 100%;
    }

    .notes-grid {
        grid-template-columns: 1fr;
    }
}
