@font-face {
    font-family: 'AtkinsonHyperlegible';
    src: url('fonts/AtkinsonHyperlegible-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'AtkinsonHyperlegible';
    src: url('fonts/AtkinsonHyperlegible-Italic.ttf') format('truetype');
    font-weight: 400;
    font-style: italic;
}

@font-face {
    font-family: 'AtkinsonHyperlegible';
    src: url('fonts/AtkinsonHyperlegible-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
}

@font-face {
    font-family: 'AtkinsonHyperlegible';
    src: url('fonts/AtkinsonHyperlegible-BoldItalic.ttf') format('truetype');
    font-weight: 700;
    font-style: italic;
}

:root {
    --ui-zoom: 1;
}

body {
    font-family: 'AtkinsonHyperlegible', system-ui, sans-serif;
    font-size: calc(14px * var(--ui-zoom));
    padding-top: 0;
    padding-bottom: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-bar {
    background-color: #1f252b;
    border-bottom: 1px solid #3f4954;
    padding: 10px 15px;
    z-index: 1030;
}

.tabs-and-search {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.top-tab-list {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 2px;
}

.top-tab-link {
    border: 1px solid #495564;
    color: #d6dde8;
    min-height: calc(36px * var(--ui-zoom));
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    font-size: calc(0.95rem * var(--ui-zoom));
}

.top-tab-link.active {
    background-color: #1e509a !important;
    border-color: #1e509a;
    color: #ffffff !important;
}

.tab-icon {
    font-size: 0.95rem;
    line-height: 1;
}

#categories {
    column-count: 3;      /* Standard: 3 Spalten */
    column-gap: 15px;     /* Abstand zwischen den Spalten */
    padding: 0 15px;      /* Behalte den seitlichen Abstand bei */
}

.category {
    width: 100%;          /* Füllt die Breite der aktuellen Spalte */
    break-inside: avoid-column; /* Verhindert das Umbrechen EINER Karte auf zwei Spalten */

    margin-bottom: 15px;  /* Behält den unteren Abstand bei */
    transition: background-color 0.2s; /* Behalte Übergänge bei */
}

.category.dragging {
    opacity: 0.5;
    border: 2px dashed #fff;
}

.category.dragover {
    background-color: rgba(204, 2, 2, 0.441);
}

.category-card {
    display: flex; /* Card-Struktur */
    flex-direction: column;
    background-color: #343a40;
    color: #fff;
    height: 100%; /* Sorgt dafür, dass der Hintergrund die ganze Kachel füllt */
}
.card-header {
    background-color: #2b2d2f;
    color: #fff;
    padding-top: calc(15px * var(--ui-zoom));
    font-size: calc(1.1rem * var(--ui-zoom));
    text-align: center;
}
.category-card .card-body {
    flex-grow: 1;
    padding: calc(5px * var(--ui-zoom)) calc(5px * var(--ui-zoom)) calc(10px * var(--ui-zoom)) calc(10px * var(--ui-zoom));
}

.bottom-nav {
    background-color: #343a40;
    border-top: 1px solid #454d55;
    position: relative;
    margin-top: auto;
    width: 100%;
    min-height: 96px;
}

#categories.all-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 15px;
    grid-auto-flow: dense;
    grid-auto-rows: 8px;
    align-items: start;
    column-count: unset;
}

#categories.all-grid .category,
#categories.all-grid .note-tile {
    break-inside: unset;
    margin-bottom: 0;
    grid-row-end: span 1;
}

.bottom-nav-list {
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.bottom-nav-btn {
    min-width: 78px;
    text-align: center;
}

.bottom-nav-icon-btn {
    min-width: 42px;
    width: 42px;
    padding-left: 0;
    padding-right: 0;
    font-size: 1.1rem;
    line-height: 1.2;
    color: #f2d7a5 !important;
    border-color: #92764d;
}

.bottom-nav-icon-btn:hover,
.bottom-nav-icon-btn:focus {
    color: #ffe8bf !important;
    border-color: #b38d59;
}

.bottom-zoom-item {
    width: min(420px, 92vw);
}

.bottom-zoom-control {
    border: 1px solid #495564;
    border-radius: 8px;
    padding: 8px 10px;
    background: #2a3138;
}

.bottom-zoom-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.bottom-zoom-label,
.bottom-zoom-value {
    font-size: 0.85rem;
    color: #d6dde8;
    line-height: 1;
}

.bottom-zoom-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

#uiZoomRange {
    margin: 0;
}

.bottom-nav .nav-link.btn:hover {
    background-color: #6c757d;
}

.accordion {
    margin-left: 15px;
    margin-right: 15px;
    margin-top: 10px;
}

#dropZone {
    min-height: 150px;
    transition: background-color 0.3s;
}

.input-group {
    width: 100%;
    margin: 15px 15px;
    max-width: calc(100% - 30px);
}

#urlInput {
    font-size: 1rem;
}

.card-title {
    font-size: 1rem;
    margin: 0;
    font-weight: 500;
}

.favorite {
    margin-top: calc(10px * var(--ui-zoom));
    display: flex;
    align-items: flex-start;
}

.favorite img {
    width: calc(24px * var(--ui-zoom));
    height: calc(24px * var(--ui-zoom));
    margin-right: calc(10px * var(--ui-zoom));
    object-fit: contain;
}

.favorite a {
    font-size: calc(1rem * var(--ui-zoom));
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.35;
}

.nav-tabs {
    margin-left: 15px;
    margin-right: 15px;
}

#searchForm {
    min-width: 180px;
    max-width: 300px;
}
.cat-edit {
    column-count: 1 !important;
}
footer {
    position: fixed;
    bottom: 20px;
    color: white;
    text-align: center;
    padding: 20px 0;
    width: 100%;
}
footer a {
    color: inherit;
}

footer a:hover, 
footer a:visited, 
footer a:active {
    color: inherit;
}

/* --- Media Queries für column-count --- */
@media (min-width: 1400px) {
    #categories {
        column-count: 5; /* 5 Spalten */
    }
}

@media (min-width: 1200px) and (max-width: 1399px) {
     #categories {
        column-count: 4; /* 4 Spalten */
    }
}

@media (min-width: 992px) and (max-width: 1199px) {
     #categories {
        column-count: 3; /* 3 Spalten */
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    #categories {
        column-count: 2; /* 2 Spalten */
    }
}

@media (max-width: 767px) {
    body {
        padding-bottom: 0;
    }

    .top-bar {
        padding-top: 0;
    }

    .tabs-and-search {
        align-items: stretch;
        flex-direction: column;
    }

    .top-tab-list {
        width: 100%;
    }

    .top-tab-link {
        min-width: 42px;
        justify-content: center;
    }

    #categories {
        column-count: 1; /* 1 Spalte */
    }

    #categories.all-grid {
        grid-template-columns: 1fr;
    }
    .card-title {
        font-size: 1rem;
    }
    .favorite a {
        font-size: 1.0rem;
    }
    .btn-sm {
        font-size: 0.9rem;
        padding: 6px 12px;
    }
    .accordion-button {
        font-size: 1.0rem;
    }
    #searchForm {
        min-width: 100%;
        max-width: 100%;
    }

    .bottom-nav-list {
        width: 100%;
        justify-content: center;
        gap: 4px;
    }

    .bottom-nav-btn {
        min-width: 58px;
        padding-left: 8px;
        padding-right: 8px;
    }

    .bottom-zoom-item {
        width: 100%;
        padding: 0 6px;
    }

    .bottom-zoom-control {
        padding: 6px 8px;
    }
}

@media (max-width: 576px) {
    .favorite img {
        width: 24px;
        height: 24px;
    }
    #urlInput {
        font-size: 1.1rem;
    }
    #pasteButton {
        font-size: 1rem;
        padding: 8px 16px;
    }
    #searchForm {
        min-width: 80px;
    }
    #search {
        font-size: 0.9rem;
    }
}

/* ================================================================
    FREE CANVAS – desktop edit mode (>=992px, not "Alle" tab)
    ================================================================ */

#categories.free-canvas {
    position: relative;
    column-count: unset !important;
    min-height: 600px;
    padding: 0 15px 80px;
}

.free-canvas .category,
.free-canvas .note-tile {
    position: absolute;
    margin-bottom: 0;
}

body.edit-mode .free-canvas .category,
body.edit-mode .free-canvas .note-tile {
    cursor: grab;
}

body.edit-mode .free-canvas .category:active,
body.edit-mode .free-canvas .note-tile:active {
    cursor: grabbing;
}

.free-canvas .category.dragging,
.free-canvas .note-tile.dragging {
    opacity: 0.82;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    z-index: 1000;
}

/* ================================================================
   NOTE TILES – allgemein (Grid + Free Canvas)
   ================================================================ */

.note-tile {
    width: 100%;
    break-inside: avoid-column;
    margin-bottom: calc(15px * var(--ui-zoom));
    transition: background-color 0.2s;
    box-sizing: border-box;
}

/* Resize handle only in free canvas / edit mode */
.free-canvas .note-tile {
    overflow: hidden;
    min-width: 150px;
    min-height: 80px;
}

/* Kategorie-Kachel: Standardbreite im Free Canvas */
.free-canvas .category {
    width: calc(240px * var(--ui-zoom));
}

/* ---- Eigener Resize-Handle (JS fügt ihn an) ---- */
.note-resize-handle {
    display: none;
}

body.edit-mode .free-canvas .note-resize-handle {
    display: block;
    position: absolute;
    bottom: 0;
    right: 0;
    width: 18px;
    height: 18px;
    cursor: se-resize;
    z-index: 20;
    /* Visueller Indikator: diagonale Linien */ 
    background:
        linear-gradient(135deg,
            transparent 33%, rgba(95, 126, 161, 0.8) 33%, rgba(95, 126, 161, 0.8) 40%,
            transparent 40%, transparent 57%, rgba(95, 126, 161, 0.8) 57%, rgba(95, 126, 161, 0.8) 64%,
            transparent 64%);
    border-radius: 0 0 4px 0;
}

.note-card {
    background-color: #343a40;
    color: #f0f2f5;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.note-card .card-header {
    background-color: #2b2d2f;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: calc(8px * var(--ui-zoom)) calc(12px * var(--ui-zoom));
    flex-shrink: 0;
    cursor: grab;
    user-select: none;
}

.note-card .card-body {
    flex-grow: 1;
    padding: calc(8px * var(--ui-zoom)) calc(10px * var(--ui-zoom));
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Im Free Canvas: Card-Body + Textarea füllen die gesamte Kachelhöhe */
.free-canvas .note-tile .note-card .card-body {
    overflow: hidden;
    min-height: 0;
    padding-bottom: 20px; /* Platz für Resize-Handle */
}

.free-canvas .note-tile .note-edit-area {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    width: 100%;
    box-sizing: border-box;
}

.free-canvas .note-tile .note-view {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

/* ---- Note-Titel ---- */
/* ---- Note title (always visible) ---- */
.note-header-title {
    font-size: 1rem;
    margin: 0;
    font-weight: 500;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- Textarea (edit mode) ---- */
.note-edit-area {
    width: 100%;
    flex-grow: 1;
    background-color: #2e3338;
    color: #dce3ec;
    border: 1px solid #495564;
    border-radius: 4px;
    padding: 8px;
    font-size: calc(1rem * var(--ui-zoom));
    line-height: 1.55;
    resize: none;            /* resize wird über das tile-element gesteuert */
    outline: none;
    font-family: inherit;
    min-height: 130px;
    box-sizing: border-box;
}

.note-edit-area:focus {
    border-color: #5f7ea1;
    background-color: #33393f;
}

/* ---- Markdown view (view mode) ---- */
.note-view {
    font-size: calc(1rem * var(--ui-zoom));
    line-height: 1.6;
    color: #dce3ec;
    word-wrap: break-word;
    overflow-y: auto;
    flex-grow: 1;
}

.note-view h1,
.note-view h2,
.note-view h3 {
    font-size: calc(1.1rem * var(--ui-zoom));
    font-weight: 700;
    margin: 0.5em 0 0.2em;
    color: #e8ecf2;
}
.note-view h2 { font-size: calc(1rem * var(--ui-zoom)); }
.note-view h3 { font-size: calc(0.95rem * var(--ui-zoom)); }

.note-view p  { margin: 0.25em 0; }

.note-view code {
    background-color: #1c2025;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.85em;
    font-family: inherit;
}

.note-view pre {
    background-color: #1c2025;
    padding: 8px 10px;
    border-radius: 4px;
    overflow-x: auto;
    margin: 0.4em 0;
    font-family: inherit;
}

.note-view pre code {
    background: none;
    padding: 0;
    font-family: inherit;
}

.note-view ul,
.note-view ol {
    padding-left: 1.4em;
    margin: 0.25em 0;
}

.note-view a       { color: #7db3e0; }
.note-view strong  { color: #e8ecf2; }
.note-view hr      { border-color: #495564; margin: 0.5em 0; }

/* ---- View vs. Edit-Sichtbarkeit ---- */
/* ---- View vs. Edit visibility ---- */
/* Default: view mode – hide textarea and delete button */
.note-edit-area,
.delete-note {
    display: none;
}

/* Edit mode: body gets class edit-mode */
body.edit-mode .note-edit-area {
    display: block;
}

body.edit-mode .delete-note {
    display: inline-block;
}

body.edit-mode .note-view {
    display: none;
}

/* ================================================================
   DELETE-Button in Note-Header
   ================================================================ */
.delete-note {
    flex-shrink: 0;
    padding: 2px 8px;
    font-size: 0.78rem;
    line-height: 1.4;
}

/* ================================================================
   Note-Abschnitt in categories.php
   ================================================================ */
.notes-management-section {
    margin-top: 2.5rem;
}

/* ================================================================
   INLINE EDIT – Note tiles
   ================================================================ */
.note-inline-edit-btn,
.note-inline-save-btn {
    flex-shrink: 0;
    padding: 1px 5px;
    font-size: 0.78rem;
    line-height: 1.4;
    opacity: 0.25;
    border: none;
    background: none;
    color: #d6dde8;
    transition: opacity 0.15s;
    cursor: pointer;
}

.note-inline-edit-btn:hover {
    opacity: 0.9;
    color: #fff;
}

.note-inline-save-btn {
    display: none;
    color: #6abf6a;
    opacity: 0.85;
}

.note-tile.inline-editing .note-inline-edit-btn { display: none; }
.note-tile.inline-editing .note-inline-save-btn { display: inline-flex; align-items: center; }
.note-tile.inline-editing .note-edit-area       { display: block; }
.note-tile.inline-editing .note-view            { display: none; }

/* In full edit-mode the inline controls are redundant */
body.edit-mode .note-inline-edit-btn,
body.edit-mode .note-inline-save-btn { display: none; }

/* ================================================================
   INLINE EDIT – Category card header
   ================================================================ */
.category-card .card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    text-align: left;
    padding: calc(8px * var(--ui-zoom)) calc(12px * var(--ui-zoom));
}

.category-card .card-header .card-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cat-inline-edit-btn {
    flex-shrink: 0;
    padding: 1px 5px;
    font-size: 0.78rem;
    line-height: 1.4;
    opacity: 0.25;
    border: none;
    background: none;
    color: #d6dde8;
    transition: opacity 0.15s;
    cursor: pointer;
}

.cat-inline-edit-btn:hover,
.category.inline-editing .cat-inline-edit-btn {
    opacity: 1;
    color: #7db3e0;
}

/* ================================================================
   INLINE EDIT – Favorite action buttons
   ================================================================ */
.inline-fav-btns {
    display: none;
    align-items: center;
    gap: 3px;
    flex-shrink: 0;
    align-self: center;
}

.category.inline-editing .inline-fav-btns,
body.edit-mode .inline-fav-btns {
    display: flex;
}

.inline-fav-btns .btn {
    padding: 1px 5px;
    font-size: 0.72rem;
    line-height: 1.4;
    opacity: 0.65;
}

.inline-fav-btns .btn:hover { opacity: 1; }

.inline-fav-btns .edit-favorite {
    color: #7db3e0;
    border-color: #4a7aaa;
}

.inline-fav-btns .delete-favorite {
    color: #e07d7d;
    border-color: #aa4a4a;
}
