/* Sticky footer: the page is a column at least as tall as the viewport, and
   the footer takes the leftover space above it with margin-top:auto. Short
   pages therefore keep the footer at the bottom of the window, long pages let
   it sit below the content and scroll away.

   It used to be fixed-bottom, which pinned it over the content and cost a
   permanent slice of every screen. */
html {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-top: 60px;   /* clears the fixed navigation bar */
    padding-bottom: 0;
}

/* ── Navigation bar ──────────────────────────────────────────────────────
   Same palette as the footer, so the two frames of the page match. */
.app-navbar {
    background-color: #ECECEC;
    border-bottom: 1px solid #dcdcdc;
    min-height: 48px;
    padding-top: 0;
    padding-bottom: 0;
}

.app-navbar .navbar-brand,
.app-navbar .nav-link,
.app-navbar .navbar-title {
    color: #212529;
}

.app-navbar .nav-link:hover,
.app-navbar .navbar-brand:hover {
    color: #1e7cec;
}

.app-navbar .navbar-title {
    color: #1e7cec;
    font-weight: 700;
}

/* The brand mark is a QR code for this site: scannable at full size, and a
   link home when clicked. */
.qr-logo {
    width: 36px;
    height: 36px;
    display: block;
    background: #fff;
    border-radius: 4px;
    padding: 2px;
}

.qr-logo-link {
    display: inline-flex;
    align-items: center;
    padding: 0;
    margin-right: 0.75rem;
}

span {
    margin: 0 10px
}

#top_navbar {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1030;
}

/* The title sits immediately after the QR logo, on the left. */
#top_navbar .navbar-brand:nth-child(2) {
    margin: 0;
    padding: 0;
}

#top_navbar .navbar-brand {
    margin-right: 0;
}

/* Needs the id to outrank the rule above, which would otherwise collapse the
   gap between the QR mark and the title to nothing. */
#top_navbar .qr-logo-link {
    margin-right: 0.6rem;
}

/* Footer layout — the row spans the full width and uses the same 1rem side
   padding as the navigation bar, so both bars line up with the page edges. */
.app-footer {
    margin-top: auto;   /* pushes the footer to the bottom on short pages */
    flex-shrink: 0;
    background-color: #ECECEC;
    border-top: 1px solid #dcdcdc;
    padding-top: 8px;
    padding-bottom: 8px;
    display: block;
}

.footer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    width: 100%;
}

@media (max-width: 768px) {
    .app-footer {
        flex-direction: column;
        gap: 15px;
    }
}
/* Page label after the brand, e.g. the project name on the project page. */
.navbar-page-title {
    color: #6c757d;
    font-size: 0.95rem;
    margin-left: 0.75rem;
    max-width: 34ch;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* The toggler icon, drawn here rather than left to Bootstrap.
   Bootstrap 5.0 paints it only via .navbar-light/.navbar-dark, so a navbar
   carrying neither rendered an invisible button — and on the home page that
   was the only way to reach the login link on a phone. */
.app-navbar .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%2833,37,41,0.85%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
}

.app-navbar .navbar-toggler {
    border-color: rgba(33, 37, 41, 0.2);
}

.app-navbar .navbar-toggler:focus {
    box-shadow: 0 0 0 0.2rem rgba(30, 124, 236, 0.25);
}


/* ── Confirmation dialog ──────────────────────────────────────────────────
   Replaces the browser's native confirm(), which cannot be styled. Matches
   the cards: light header, rounded corners, restrained borders. */
.confirm-modal .modal-content {
    border: none;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.18);
}

.confirm-modal .modal-header {
    align-items: center;
    gap: 12px;
    background: #f7f9fc;
    border-bottom: 1px solid #e9edf2;
    padding: 1rem 1.25rem;
}

.confirm-modal .modal-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0;
    color: #212529;
}

/* The destructive action is signalled here rather than by colouring the whole
   dialog red. */
.confirm-modal .confirm-modal-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(220, 53, 69, 0.12);
    color: #dc3545;
    font-size: 1rem;
}

.confirm-modal .modal-body {
    padding: 1.25rem;
    color: #6c757d;
    font-size: 0.95rem;
    line-height: 1.55;
}

.confirm-modal .modal-footer {
    border-top: 1px solid #e9edf2;
    padding: 0.85rem 1.25rem;
    gap: 8px;
}

.confirm-modal .modal-footer .btn {
    min-width: 110px;
}

@media (max-width: 575.98px) {
    .confirm-modal .modal-footer {
        flex-direction: column-reverse;
    }

    .confirm-modal .modal-footer .btn {
        width: 100%;
        margin: 0;
    }
}


/* ── Install button ───────────────────────────────────────────────────────
   Sits in the bar itself rather than inside the collapsed menu, so it does
   not need the menu opened to be found. Revealed by static/js/install.js. */
/* The install entry sits in the collapsed menu, so it is styled as a menu row
   rather than a button squeezed into the bar. It used to live in the bar
   itself, where on a narrow phone it pushed the toggler onto a second line. */
.app-navbar .install-button {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
    background: none;
    border: 0;
    text-align: left;
    padding: 0.5rem 0;
    color: #1e7cec;
    font-weight: 600;
}

.app-navbar .install-button:hover,
.app-navbar .install-button:focus {
    color: #1560d4;
}

.confirm-modal .install-modal-icon {
    background: rgba(30, 124, 236, 0.12);
    color: #1e7cec;
}

.install-steps {
    padding-left: 1.1rem;
    color: #495057;
    font-size: 0.95rem;
    line-height: 1.7;
}






/* ── Elements dressed as buttons ──────────────────────────────────────────
   Only a real <button> centres its own content. An <a>, <label> or <span>
   carrying .btn just grows the box and leaves the text where it was, so it
   rides high — by 1px on desktop, and by 5px once the 44px minimum tap target
   stretches the box on a phone. That is what put "Cancel" out of line with
   "Save changes", and the centre-of-the-code labels out of line with their
   own buttons.

   Applies at every width, since the desktop offset is visible too. */
a.btn,
label.btn,
span.btn,
div.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ── Messages ─────────────────────────────────────────────────────────────
   Dismissible pop-ups in the top right, clear of the fixed navigation bar.
   Errors stay until dismissed; everything else fades after a few seconds. */
.app-toasts {
    position: fixed;
    top: calc(48px + 12px);      /* below the bar */
    right: 12px;
    z-index: 1080;               /* over a modal backdrop (1050) */
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* Bootstrap's .toast-container is width:max-content, so it shrinks to the
       shortest message and every pop-up comes out a different width. Set the
       width explicitly instead. */
    width: min(380px, calc(100vw - 24px));
}

.app-toast {
    width: 100%;
    border: 1px solid #e3e6ea;
    border-left: 4px solid #6c757d;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.app-toast .toast-body {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 0.75rem 0.85rem;
    font-size: 0.9rem;
    line-height: 1.45;
    color: #212529;
}

.app-toast-icon {
    flex: 0 0 auto;
    line-height: 1.45;
}

.app-toast-text {
    flex: 1 1 auto;
    overflow-wrap: anywhere;
}

.app-toast-close {
    flex: 0 0 auto;
    margin-top: 1px;
}

/* One colour per level, on the left edge and the icon only, so the text
   stays readable. */
.app-toast-success { border-left-color: #198754; }
.app-toast-success .app-toast-icon { color: #198754; }

.app-toast-error,
.app-toast-danger { border-left-color: #dc3545; }
.app-toast-error .app-toast-icon,
.app-toast-danger .app-toast-icon { color: #dc3545; }

.app-toast-warning { border-left-color: #ffc107; }
.app-toast-warning .app-toast-icon { color: #b98900; }

.app-toast-info,
.app-toast-debug { border-left-color: #1e7cec; }
.app-toast-info .app-toast-icon,
.app-toast-debug .app-toast-icon { color: #1e7cec; }

@media (max-width: 575.98px) {
    .app-toasts {
        top: calc(44px + 8px);
        right: 8px;
        left: 8px;
        /* auto, so the left and right offsets decide the width */
        width: auto;
        max-width: none;
    }

    .app-toast .toast-body {
        font-size: 0.85rem;
    }
}
