@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

html {
    font-size: 16px;
    overflow-x: hidden;          /* prevent horizontal scroll from 100vw breakouts */
}
body {
    background-color: white;
    margin: 0;
    text-align: center;
    font-size: 1rem;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    font-weight: 400;
    line-height: 1.6;
    color: #222;
    /* Sticky footer: gj&oslash;r body til flex-column slik at #footer alltid n&aring;r bunnen */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
body > #footer {
    margin-top: auto;        /* skyver footer til bunnen n&aring;r innholdet er kort */
}
h1, h2, h3, h4, h5, h6 {
    font-family: 'Inter', Helvetica, Arial, sans-serif;
    font-weight: 600;
}
h2, h3, a {
    text-decoration: none;
    color: #333;
}

fieldset {
    box-sizing: border-box;   /* normalize: width includes padding+border */
    width: 740px;
    border-radius: 5px;
    border: 2px solid #e0e0e0;
    margin: 0 auto 10px;
    text-align: left;
    background-color: rgba(0, 0, 0, 0.007);
}
fieldset > legend {
    font-size: 18px;
    font-weight: bold;
    padding: 0 10px 0 10px;
}
hr {
    border: none;
    height: 2px;
    background-color: #eeeeee;
    margin: 10px 0;
}

select:disabled {
    color: red;
}
input[readonly]:focus {
    outline: none;
    border: 1px solid #ccc;
}

.button {
    display: inline-block;
    background-color: #b02626;
    color: #ffffff;
    border-radius: 5px;
    text-align: center;
    font-size: 17px;
    font-weight: 600;
    min-width: 120px;
    border: 2px solid #b02626;
    padding: 13px 22px;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s, transform 0.2s, box-shadow 0.2s;
    -webkit-border-radius: 5px;
}
.button:hover {
    background-color: #a61c1c;
    border-color: #a61c1c;
    transform: scale(1.04);
    box-shadow: 0 6px 16px rgba(176, 38, 38, 0.25);
}
.button:active {
    transform: scale(1);
}
.button .fa {
    margin-left: 8px;
    font-size: 0.85em;
}
.button_cancel {
    background-color: #fff;
    color: #b02626;
    border-color: #b02626;
}
.button_cancel:hover {
    background-color: #b02626;
    color: #fff;
    border-color: #b02626;
}
/* Outline variant: transparent bg, dark text, red border. Hover fills red with white. */
.button_outline {
    background-color: transparent;
    color: #222;
    border-color: #b02626;
}
.button_outline:hover {
    background-color: #b02626;
    color: #fff;
    border-color: #b02626;
}

/* ============================================================
   Confirmation dialog (showConfirm in script.js) - a styled, on-brand
   replacement for the browser's native confirm() popup.
   ============================================================ */
.confirm-dialog {
    border: none;
    border-radius: 5px;
    padding: 0;
    width: min( 420px, calc( 100vw - 32px ) );
    box-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.35);
    color: #222;
}
.confirm-dialog::backdrop {
    background: rgba(20, 20, 25, 0.45);
}
.confirm-body {
    padding: 24px 24px 20px;
    text-align: left;
}
.confirm-title {
    margin: 0 0 8px;
    color: #b02626;
    font-size: 1.1em;
}
.confirm-message {
    margin: 0 0 22px;
    line-height: 1.55;
    color: #333;
}
.confirm-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.confirm-actions .button {
    min-width: 0;
    padding: 9px 18px;
    font-size: 15px;
    margin-top: 0;
}
/* Destructive confirm (delete) - the primary button goes red to signal danger. */
.confirm-danger {
    background-color: #c33;
    border-color: #c33;
}
.confirm-danger:hover {
    background-color: #b02626;
    border-color: #b02626;
}
/* Demo signing: the code the user re-types, and its input. */
.sign-code {
    font-family: 'Roboto Mono', monospace;
    font-size: 1.8em;
    font-weight: 700;
    letter-spacing: 0.3em;
    text-indent: 0.3em;            /* balance the trailing letter-spacing */
    text-align: center;
    background: #f5f7fb;
    border: 1px dashed #b9c2d0;
    border-radius: 5px;
    padding: 16px;
    margin: 4px 0 14px;
    color: #b02626;
    user-select: none;
}
.sign-code-input {
    width: 100%;
    box-sizing: border-box;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.3em;
    text-indent: 0.3em;
    font-size: 1.3em;
    font-family: 'Roboto Mono', monospace;
    padding: 10px;
    border: 1px solid #cfd6e2;
    border-radius: 5px;
}
.sign-code-input:focus {
    outline: none;
    border-color: #b02626;
    box-shadow: 0 0 0 3px rgba(176, 38, 38, 0.12);
}
.sign-code-error {
    display: none;             /* shown by JS on a wrong code */
    color: #c33;
    margin: 8px 0 0;
    font-size: 0.9em;
}

/* Long Norwegian compound words (e.g. "personvernerklæring") must wrap rather than
   force horizontal scroll on narrow screens. lang="no" enables proper hyphenation;
   overflow-wrap is the reliable fallback where the dictionary doesn't break a word. */
h1, h2, h3, h4, h5, h6 {
    overflow-wrap: break-word;
    hyphens: auto;
}

.container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 0 auto 10px;
    width: 740px;
    box-sizing: border-box;
    text-align: left;
}
.container.narrow-left {
    grid-template-columns: 140px 1fr;
}
.left, .right {
    min-width: 0;
}
.container > .left > fieldset,
.container > .right > fieldset {
    width: 100%;             /* fill grid cell */
    margin-bottom: 0;
}

/* Action row at the bottom of a form section. Right-aligned by default;
   add .center for short forms (login, register). Width is parent-relative so
   it fits any wrapper (e.g. 740 px form on /create, narrower login box). */
.form-actions {
    margin: 10px 0 0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.form-actions.center {
    justify-content: center;
}

/* Helper text shown under a legend, explaining a field in plain language. */
.field-help {
    margin: 4px 0 8px;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

.small_info {
    font-weight: normal;
    font-size: 12px;
    color: #d0d0d0;
}
.small_info:hover {
    color: #b02626;
}

.message-bar {
    display: none;
    position: fixed;
    top: 0px;
    left: 0;
    width: 100%;
    padding: 25px;
    box-sizing: border-box;
    text-align: center;
    z-index: 10000;
    transition: top 0.5s ease;
}
.message-bar.info {
    background-color: #b02626;
    color: #ffffff;
    font-weight: normal;
}
.message-bar.warning {
    background-color: #E38B06;
    font-weight: bold;
    color: #ffffff;
}
.message-bar.alert {
    background-color: #F20000;
    color: #ffffff;
    font-weight: bold;
    animation: blink 1s linear infinite;
}

.fa {
    cursor: pointer;
    font-size: 90%;
}

.fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.3);
    z-index: 999999;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}
.fullscreen-overlay img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 5px;
    border: 1px solid #b02626;
}

/* Native <dialog> (replaces the former jQuery UI dialog) */
dialog {
    border: none;
    border-radius: 5px;
    padding: 0;
    color: #b02626;
    box-shadow: 0 10px 40px rgba( 0, 0, 0, 0.25 );
}
dialog::backdrop {
    background: rgba( 0, 0, 0, 0.45 );
}

.cmd_delete, .cmd_edit, .cmd_tools, .cmd_view, #delete_image {
    color: #b02626;
    --fa-beat-scale: 0.93;
    --fa-animation-duration: 2.5s;
}
#upload_image, #delete_image {
    --fa-beat-scale: 1.05;
    --fa-animation-duration: 2s;
}

#header {
    padding: 10px;
    text-align: left;
    padding-bottom: 10px;
    margin-bottom: 0;
    border-bottom: 1px solid #cbcbcb;
    background-color: rgba(255, 255, 255, 0.7);
}
/* Brand-logo: symbol + ordmerke + undertittel */
.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}
.brand-symbol {
    height: 48px;
    width: auto;
    display: block;
}
.brand-logo {
    height: 51px;
    width: 153px;
    display: block;
}
/* Footer-variant: 6px hvit padding rundt logo + r&oslash;d border */
.brand-footer .brand-logo {
    padding: 6px;
    background: #fff;
    border: 2px solid #b02626;
    border-radius: 5px;
    box-sizing: content-box;
}
.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1;
    text-align: left;
}
.brand-name {
    font-family: 'Inter', Helvetica, Arial, sans-serif;
    font-size: 1.4rem;
    font-weight: 800;
    color: #b02626;
    letter-spacing: -0.02em;
    line-height: 1;
}
.brand-tagline {
    font-size: 0.46rem;
    font-weight: 700;
    color: #b02626;
    letter-spacing: 0.06em;
    margin-top: 3px;
    line-height: 1;
    text-transform: uppercase;
}
#header > h3 {
    margin: 0;
    color: #b02626;
    text-decoration: none;
    display: inline-block;
    margin-left: 20px;
}
#header .header-nav {
    float: right;
    display: flex;
    gap: 16px;
    align-items: center;
}
#header .header-nav a {
    color: #b02626;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.95rem;
}
#header .header-nav a:hover {
    text-decoration: underline;
}
/* Hamburger toggle: hidden on desktop; mobile media-block reveals it. */
.nav-toggle {
    display: none;
    background: none;
    border: 1px solid #b02626;
    color: #b02626;
    border-radius: 5px;
    padding: 6px 12px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.nav-toggle:hover {
    background: #b02626;
    color: #fff;
}
#header > div > a {
    text-decoration: none;
    font-family: "Poppins", Sans-serif;
    padding-right: 10px;
    font-size: 0.94rem;
}

#panel-menu {
    font-size: 25px;
    text-align: left;
    margin-bottom: 20px;
}

/* ============================================================
   Footer – tre kolonner: logo+info, tagline+CTA, lenker
   ============================================================ */
#footer {
    color: #444;
    background-color: #f3f4f6;
    font-size: 0.95rem;
    width: 100%;
    margin-top: 80px;
    padding: 60px 20px 30px;
    box-sizing: border-box;
    border-top: 1px solid #e5e7eb;
    text-align: left;
}
.footer-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 48px;
    align-items: start;
}
.footer-col {
    line-height: 1.6;
}
.footer-col p {
    margin: 0;
}
/* Footer-brand: liten ramme rundt symbolet */
.brand-footer .brand-symbol {
    height: 37px;
    padding: 5px;
    background: #fff;
    border: 2px solid #b02626;
    border-radius: 5px;
    box-sizing: content-box;
}
.brand-footer .brand-name {
    font-size: 1.4rem;
}
.brand-footer .brand-tagline {
    font-size: 0.46rem;
    margin-top: 2px;
}
.footer-divider {
    width: 40px;
    border-top: 2px solid #b02626;
    margin: 24px 0 20px;
}
.footer-tagline {
    margin: 0 0 24px;
    font-weight: 500;
    color: #222;
}
.footer-col .button {
    font-size: 0.95rem;
    padding: 10px 18px;
    min-width: 0;
    margin-top: 10px;
}
.footer-col-links ul {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: right;
}
.footer-col-links li {
    margin-bottom: 6px;
    line-height: 1.8;
}
.footer-col-links a {
    color: #444;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s ease;
}
.footer-col-links a:hover {
    color: #b02626;
}
.footer-bottom {
    max-width: 1100px;
    margin: 40px auto 0;
    padding-top: 24px;
    border-top: 1px solid #e5e7eb;
    text-align: center;
    color: #777;
    font-size: 0.85rem;
}

/* Responsiv: stack til 1 kolonne p&aring; smale skjermer */
@media (max-width: 760px) {
    .footer-inner {
        grid-template-columns: 1fr;
        gap: 32px;
    }
    .footer-col-links ul {
        text-align: left;
    }
}

/* Responsive */
@media (max-width: 780px) {
    fieldset {
        width: 640px;
    }
    .small_info {
        font-size: 10px;
    }
}
@media (max-width: 680px) {
    fieldset {
        width: 380px;
    }
    .left, .right {
        flex-basis: 100%;
    }
}
@media (max-width: 338px) {
    .container {
        display: block;
    }
}

/* ============================================================
   Consolidated mobile layout. Additive overrides that only apply
   on small screens (desktop layout above is unchanged). Placed last
   so they win over the fixed-width steps for overlapping ranges.
   ============================================================ */
@media (max-width: 768px) {
    /* Fluid forms instead of the fixed 640/380px widths */
    fieldset,
    .container {
        width: 100%;
        max-width: 100%;
    }
    /* Stack the two-column rows into one */
    .container,
    .container.narrow-left {
        grid-template-columns: 1fr;
    }
    /* Mobile header: brand on the left, hamburger on the right; the nav turns
       into a dropdown panel anchored to the header. Pre-JS fallback still wraps
       gracefully (the .is-open toggle just stays in its default closed state). */
    #header {
        text-align: left;
        position: relative;
        display: flex;
        align-items: center;
        gap: 10px;
    }
    #header > h3 {
        display: none;            /* page-name (eg "ADMIN") doesn't fit on mobile */
    }
    .nav-toggle {
        display: inline-flex;
        margin-left: auto;        /* pin to the right */
    }
    #header .header-nav {
        float: none;
        position: absolute;
        top: 100%;
        right: 0;
        left: 0;
        background: #fff;
        border-bottom: 1px solid #cbcbcb;
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        margin-top: 0;
        padding: 6px 0;
        z-index: 1000;
        display: none;            /* hidden until #header gets .is-open */
    }
    #header.is-open .header-nav {
        display: flex;
    }
    #header .header-nav a {
        padding: 12px 18px;
        border-bottom: 1px solid #f0f0f0;
        font-size: 1rem;
    }
    #header .header-nav a:last-child {
        border-bottom: none;
    }
    #header .header-nav a:hover {
        background: #faf2f2;
        text-decoration: none;
    }
    /* Action rows wrap; buttons no longer need a fixed min-width */
    .form-actions {
        flex-wrap: wrap;
    }
    .button {
        min-width: 0;
    }
    /* Wide admin/data tables scroll horizontally instead of overflowing */
    .pure-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 480px) {
    /* On phones, stack action buttons full width for easy tapping */
    .form-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .form-actions .button {
        width: 100%;
        box-sizing: border-box;
    }
    fieldset {
        padding: 10px 12px;
    }
    #panel-menu {
        font-size: 20px;
    }
}
