/* =========================================================
   GLOBAL VARIABLES
   ========================================================= */

:root {
    --nav: #E0E0E0;
    --white: #FFFFFF;
    --text: #111111;
    --border: #DDDDDD;
    --light-bg: #F8F9FA;
}


/* =========================================================
   GLOBAL
   ========================================================= */

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    margin: 0;
    padding: 0;
}

body {
    background: var(--white);
    color: var(--text);

    font-family: Arial, Helvetica, sans-serif;
}


/* =========================================================
   NAVIGATION BAR - DESKTOP
   ========================================================= */

.navbar {
    position: fixed;

    top: 0;
    left: 0;
    right: 0;

    width: 100%;

    z-index: 1000;

    background: var(--nav);
}


/* Desktop navigation wrapper */

.desktop-navbar {
    display: flex;

    justify-content: space-between;
    align-items: center;

    width: 100%;

    padding: 12px 16px;
}


/* Mobile navigation hidden on desktop */

.mobile-navbar {
    display: none;
}


/* =========================================================
   LOGO + TITLE
   ========================================================= */

.nav-left {
    display: flex;
    align-items: center;
}

.title-with-image {
    display: flex;

    align-items: center;

    gap: 10px;
}

.title-icon {
    display: block;

    height: 56px;
    width: auto;
}

.nav-left span {
    color: #000000;

    font-family: Arial, Helvetica, sans-serif;

    font-size: 1.4rem;
    font-weight: bold;

    line-height: 1.2;
}


/* =========================================================
   DESKTOP NAVIGATION LINKS
   ========================================================= */

.nav-right {
    display: flex;

    align-items: center;

    flex-wrap: wrap;
}

.nav-right a {
    color: #000000;

    text-decoration: none;

    margin-left: 16px;
}

.nav-right a:hover {
    text-decoration: underline;
}


/* =========================================================
   MAIN CONTENT CONTAINER
   ========================================================= */

.container {
    max-width: 1000px;

    margin: 90px auto 0 auto;

    padding: 0 16px;
}


/* Headings that are jump targets */

h3[id] {
    scroll-margin-top: 100px;
}


/* =========================================================
   GENERAL FORMS
   ========================================================= */

.form,
.grid2 {
    display: grid;

    gap: 10px;
}

.grid2 {
    grid-template-columns: 1fr 1fr;

    align-items: start;
}

.grid2 fieldset {
    border: 1px solid #DDDDDD;

    border-radius: 8px;

    padding: 12px;
}

.grid2 .fullrow {
    grid-column: 1 / -1;
}


/* =========================================================
   NORMAL FORM ROW
   ========================================================= */

.form-row {
    display: grid;

    grid-template-columns: 180px 1fr;

    align-items: center;

    gap: 8px;

    margin-bottom: 8px;
}


/* =========================================================
   INPUTS
   ========================================================= */

label,
input,
select,
textarea {
    font-family: Arial, Helvetica, sans-serif;

    font-size: 1em;
}

input[type="text"],
input[type="number"],
input[type="file"],
input[type="email"],
input[type="password"],
select,
textarea {
    width: 100%;

    padding: 6px 8px;

    border: 1px solid #CCCCCC;

    border-radius: 6px;

    background: #FFFFFF;
}


/* =========================================================
   BUTTONS
   ========================================================= */

button,
.btn {
    padding: 8px 12px;

    border: 0;

    border-radius: 6px;

    background: var(--nav);

    color: #000000;

    cursor: pointer;

    font-family: Arial, Helvetica, sans-serif;
}

button:hover,
.btn:hover {
    filter: brightness(0.9);
}

.btn-primary {
    background: #D9D9D9;
}


/* =========================================================
   FLASH MESSAGE
   ========================================================= */

.flash {
    padding: 10px;

    margin-bottom: 10px;

    border-radius: 6px;
}

.flash.error {
    background: #FFE8E6;
}

.flash.success {
    background: #E6FFED;
}

.flash.warning {
    background: #FFF7E6;
}


/* =========================================================
   HINT TEXT
   ========================================================= */

.hint {
    margin-top: 10px;

    color: #000000;

    font-size: 1em;

    font-style: normal;
}


/* =========================================================
   GENERAL TABLE
   ========================================================= */

.table {
    width: 100%;

    margin: 12px 0;

    border-collapse: collapse;
}

.table th,
.table td {
    padding: 8px;

    border: 1px solid #DDDDDD;

    text-align: left;

    vertical-align: top;
}


/* =========================================================
   SMALL TABLE
   ========================================================= */

.small-table th {
    width: 220px;

    padding: 6px 8px;

    background: #F5F5F5;

    text-align: left;
}

.small-table td {
    padding: 6px 8px;
}


/* =========================================================
   FUNCTION PAGE
   TEMPLATE DOWNLOAD BUTTONS
   ========================================================= */

.template-buttons {
    display: flex;

    flex-direction: column;

    align-items: flex-start;

    gap: 10px;

    margin-top: 10px;

    margin-bottom: 15px;
}


/* =========================================================
   FUNCTION PAGE
   FILE UPLOAD
   ========================================================= */

.upload-form .upload-row {
    display: flex;

    gap: 20px;

    align-items: center;

    margin: 10px 0;
}

.upload-form .upload-col {
    display: flex;

    flex-direction: column;

    gap: 6px;

    min-width: 320px;
}

.upload-label {
    font-family: Arial, Helvetica, sans-serif;

    font-size: 1.2em;

    font-weight: bold;
}


/* =========================================================
   RADIO BUTTONS
   ========================================================= */

.radio-row {
    display: flex;

    align-items: center;

    gap: 6px;

    margin: 2px 0;
}


/* =========================================================
   RESULT SUMMARY
   ========================================================= */

.grid3 {
    display: grid;

    grid-template-columns: 1fr 1fr 1fr;

    gap: 12px;

    align-items: start;
}

.result-summary > div {
    padding: 10px 12px;

    border: 1px solid #DDDDDD;

    border-radius: 8px;
}

.result-summary .label {
    margin-bottom: 6px;

    font-weight: bold;
}

.result-summary .value {
    font-size: 1.05rem;
}


/* =========================================================
   ACTION ROW
   ========================================================= */

.action-row {
    display: flex;

    gap: 12px;

    align-items: center;

    margin-top: 14px;
}


/* =========================================================
   LIBRARY SIDEBAR - DESKTOP
   ========================================================= */

.sidebar-nav {
    position: fixed;

    left: 10px;

    top: 120px;

    width: clamp(140px, 15%, 220px);

    padding: 12px;

    background: #F8F9FA;

    border: 1px solid #CCCCCC;

    border-radius: 8px;
}

.sidebar-nav ul {
    margin: 8px 0 0 18px;

    padding: 0;
}

.sidebar-nav li {
    margin-bottom: 6px;
}

.sidebar-nav a {
    display: inline-block;

    padding: 4px 8px;

    color: #000000;

    text-decoration: none;

    border-radius: 6px;
}

.sidebar-nav a:hover {
    background: #E9ECEF;
}

.sidebar-nav a.active {
    background: #0D6EFD;

    color: #FFFFFF;

    font-weight: bold;
}


/* =========================================================
   GRID 4
   ========================================================= */

.grid4 {
    display: grid;

    grid-template-columns: repeat(2, 1fr);

    gap: 15px;
}


/* =========================================================
   FOOTER
   ========================================================= */

.site-footer {
    margin-top: 30px;

    padding: 16px 0 20px 0;

    border-top: 1px solid #E5E5E5;

    background: #FFFFFF;

    color: #888888;

    text-align: center;

    font-size: 13px;

    line-height: 1.4;
}


/* Optional old fixed footer */

.footer-fixed {
    position: fixed;

    right: 20px;

    bottom: 15px;

    z-index: 1000;

    background: transparent;

    color: #888888;

    text-align: right;

    font-size: 12px;

    line-height: 1.4;
}


/* =========================================================
   MOBILE PHONE
   ========================================================= */

@media (max-width: 768px) {


    /* =====================================================
       MOBILE GLOBAL
       ===================================================== */

    html,
    body {
        width: 100% !important;

        max-width: 100% !important;

        margin: 0 !important;

        padding: 0 !important;

        overflow-x: hidden !important;

        font-size: 16px;
    }

    .page-wrapper {
        width: 100% !important;

        max-width: 100% !important;

        overflow-x: hidden !important;
    }


    /* =====================================================
       MOBILE HEADER
       ===================================================== */

    .navbar {
        position: static !important;

        display: block !important;

        width: 100% !important;

        margin: 0 !important;

        padding: 0 !important;

        background: #E0E0E0;
    }


    /* =====================================================
       MOBILE LOGO + NAAS TITLE
       ===================================================== */

    .desktop-navbar {
        display: flex !important;

        width: 100% !important;

        padding: 10px 12px !important;

        align-items: center !important;

        justify-content: flex-start !important;
    }


    /*
       Hide desktop navigation links on mobile.
       Keep Logo + NAAS title.
    */

    .desktop-navbar .nav-right {
        display: none !important;
    }


    .desktop-navbar .nav-left {
        display: flex !important;

        width: 100% !important;

        align-items: center !important;

        gap: 12px !important;
    }


    .desktop-navbar .title-with-image {
        display: flex !important;

        width: 100% !important;

        align-items: center !important;

        gap: 12px !important;
    }


    .desktop-navbar .title-icon {
        width: 58px !important;

        height: 58px !important;

        flex-shrink: 0 !important;

        object-fit: contain !important;
    }


    .desktop-navbar .nav-left span {
        display: block !important;

        color: #111111 !important;

        font-size: 19px !important;

        font-weight: 700 !important;

        line-height: 1.2 !important;

        white-space: normal !important;
    }


    /* =====================================================
       MOBILE NAVIGATION
       ===================================================== */

    .mobile-navbar {
        display: block !important;

        width: 100% !important;

        background: #E0E0E0;
    }


    /*
       Current page row:
       ☰ Library
    */

    .mobile-menu-button {
        display: flex !important;

        align-items: center !important;

        width: 100% !important;

        height: 52px !important;

        margin: 0 !important;

        padding: 0 14px !important;

        border: 0 !important;

        border-top: 1px solid #CFCFCF !important;

        border-radius: 0 !important;

        background: #E0E0E0 !important;

        color: #111111 !important;

        box-shadow: none !important;

        cursor: pointer;
    }


    .mobile-menu-icon {
        flex: 0 0 auto;

        margin-right: 14px;

        font-size: 24px;

        line-height: 1;
    }


    .mobile-current-page {
        flex: 1;

        color: #111111;

        text-align: left;

        font-size: 18px;

        font-weight: 700;
    }


    /* Dropdown hidden by default */

    .mobile-nav-menu {
        display: none;

        width: 100%;

        margin: 0;

        padding: 0;

        background: #FFFFFF;

        border-top: 1px solid #CCCCCC;

        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
    }


    /* JavaScript adds .open */

    .mobile-nav-menu.open {
        display: block;
    }


    /* Each menu option = one row */

    .mobile-nav-menu a {
        display: block !important;

        width: 100% !important;

        margin: 0 !important;

        padding: 14px 20px !important;

        border-bottom: 1px solid #E3E3E3;

        color: #111111;

        background: #FFFFFF;

        text-align: left !important;

        text-decoration: none;

        font-size: 16px !important;

        line-height: 1.2;
    }


    .mobile-nav-menu a:last-child {
        border-bottom: 0;
    }


    .mobile-nav-menu a:hover,
    .mobile-nav-menu a:active {
        background: #EEEEEE;
    }


    /* =====================================================
       MOBILE MAIN CONTENT
       ===================================================== */

    main.container {
        width: 100% !important;

        max-width: 100% !important;

        margin: 0 !important;

        padding: 16px 10px !important;

        box-sizing: border-box !important;
    }


    .main-content {
        width: 100% !important;

        max-width: 100% !important;

        min-width: 0 !important;

        margin: 0 !important;

        padding: 0 !important;

        box-sizing: border-box !important;
    }


    h1,
    h2,
    h3,
    h4 {
        max-width: 100%;
    }


    h2 {
        margin-top: 4px;

        font-size: 23px !important;
    }


    h3 {
        font-size: 19px !important;
    }


    /* =====================================================
       GENERAL MOBILE FORMS
       ===================================================== */

    .form {
        width: 100% !important;

        max-width: 100% !important;
    }


    .form-row {
        display: grid !important;

        grid-template-columns: 1fr !important;

        width: 100% !important;

        gap: 6px !important;
    }


    input[type="text"],
    input[type="number"],
    input[type="password"],
    input[type="email"],
    select,
    textarea {
        display: block;

        width: 100% !important;

        max-width: 100% !important;

        min-height: 44px !important;

        padding: 8px 10px;

        box-sizing: border-box !important;

        font-size: 16px !important;
    }


    button,
    .btn {
        min-height: 42px;

        font-size: 15px;
    }


    /* =====================================================
       LIBRARY MOBILE
       ===================================================== */

    .sidebar-nav {
        position: static !important;

        width: 100% !important;

        max-width: 100% !important;

        margin: 0 0 18px 0 !important;

        padding: 10px !important;
    }


    .sidebar-nav ul {
        display: flex !important;

        flex-wrap: wrap !important;

        gap: 8px !important;

        margin: 8px 0 0 0 !important;

        padding: 0 !important;

        list-style: none !important;
    }


    .sidebar-nav li {
        margin: 0 !important;
    }


    .sidebar-nav a {
        display: inline-block !important;

        padding: 7px 10px !important;
    }


    /* =====================================================
       FUNCTION MOBILE
       TEMPLATE DOWNLOAD BUTTONS
       ===================================================== */

    .template-buttons {
        display: flex !important;

        flex-direction: column !important;

        align-items: stretch !important;

        width: 100% !important;

        gap: 10px !important;
    }


    .template-buttons button {
        display: block !important;

        width: 100% !important;

        margin: 0 !important;
    }


    /* =====================================================
       FUNCTION MOBILE
       FILE UPLOAD
       ===================================================== */

    .upload-form .upload-row,
    .upload-row {
        display: flex !important;

        flex-direction: column !important;

        align-items: stretch !important;

        width: 100% !important;

        gap: 18px !important;
    }


    .upload-form .upload-col,
    .upload-col {
        display: flex !important;

        flex-direction: column !important;

        width: 100% !important;

        max-width: 100% !important;

        min-width: 0 !important;

        gap: 6px !important;
    }


    .upload-col label {
        display: block;

        margin-bottom: 4px;
    }


    input[type="file"] {
        display: block !important;

        width: 100% !important;

        max-width: 100% !important;

        min-width: 0 !important;

        padding: 8px !important;

        font-size: 15px !important;
    }


    .upload-form > button {
        width: 100% !important;

        margin-top: 16px !important;
    }


    /* =====================================================
       INLINE RADIO BUTTON GROUPS
       ===================================================== */

    .inline-radios {
        display: flex !important;

        flex-direction: column !important;

        align-items: flex-start !important;

        width: 100% !important;

        gap: 10px !important;
    }


    .inline-radios label {
        width: 100% !important;
    }


    .inline-radios input[type="radio"] {
        width: auto !important;

        min-height: auto !important;
    }


    /* =====================================================
       S VALUES MOBILE
       ===================================================== */

    .svalues-form {
        display: block !important;

        width: 100% !important;

        max-width: 100% !important;

        margin: 0 !important;

        padding: 0 !important;
    }


    .svalues-grid {
        display: grid !important;

        grid-template-columns: 1fr !important;

        width: 100% !important;

        max-width: 100% !important;

        gap: 18px !important;
    }


    .svalues-field {
        width: 100% !important;

        max-width: 100% !important;

        min-width: 0 !important;
    }


    .svalues-wide-field {
        width: 100% !important;

        max-width: 100% !important;
    }


    .svalues-field input,
    .svalues-wide-field input {
        display: block !important;

        width: 100% !important;

        max-width: 100% !important;

        box-sizing: border-box !important;
    }


    /* Sb-122 / Sb-124 remain in one row */

    .radio-row {
        display: flex !important;

        flex-direction: row !important;

        align-items: center !important;

        flex-wrap: wrap !important;

        width: 100% !important;

        gap: 20px !important;
    }


    .radio-row label {
        display: inline-flex !important;

        align-items: center !important;

        width: auto !important;

        margin: 0 !important;
    }


    .radio-row input[type="radio"] {
        width: auto !important;

        min-height: auto !important;

        margin-right: 5px !important;
    }


    .svalues-result-lines {
        width: 100% !important;

        max-width: 100% !important;
    }


    .svalues-result-row {
        grid-template-columns: 1fr !important;

        row-gap: 4px !important;
    }


    .svalues-result-label {
        white-space: normal !important;
    }


    /* =====================================================
       SETTINGS MOBILE
       ===================================================== */

    .form-inline {
        display: flex !important;

        flex-direction: column !important;

        align-items: stretch !important;

        width: 100% !important;

        gap: 10px !important;
    }


    .form-inline input,
    .form-inline select {
        display: block !important;

        width: 100% !important;

        max-width: 100% !important;

        margin: 0 !important;

        box-sizing: border-box !important;
    }


    .form-inline button {
        align-self: flex-start;

        width: auto !important;

        margin-top: 2px !important;
    }


    /* =====================================================
       GENERAL TABLES ON MOBILE
       ===================================================== */

    table.table {
        display: block !important;

        width: 100% !important;

        max-width: 100% !important;

        overflow-x: auto !important;

        overflow-y: hidden !important;

        white-space: nowrap !important;

        -webkit-overflow-scrolling: touch;
    }


    .table th,
    .table td {
        padding: 8px !important;

        font-size: 13px !important;
    }


    /* =====================================================
       SETTINGS TABLE ACTIONS
       ===================================================== */

    .table form.inline {
        display: flex !important;

        align-items: center !important;

        gap: 6px !important;

        width: max-content !important;
    }


    .table form.inline input {
        width: 130px !important;

        min-height: 36px !important;
    }


    /* =====================================================
       REQUESTS PAGE MOBILE
       ===================================================== */

    .requests-page {
        width: 100% !important;

        max-width: 100% !important;

        min-width: 0 !important;
    }


    .table-wrapper {
        display: block !important;

        width: 100% !important;

        max-width: 100% !important;

        overflow-x: auto !important;

        overflow-y: hidden !important;

        -webkit-overflow-scrolling: touch;
    }


    .request-table {
        width: max-content !important;

        min-width: 100% !important;

        border-collapse: collapse !important;
    }


    .request-table th,
    .request-table td {
        padding: 8px !important;

        white-space: nowrap !important;

        font-size: 13px !important;
    }


    /* =====================================================
       TIME INPUT MOBILE
       ===================================================== */

    .time-grid {
        display: grid !important;

        grid-template-columns: 1fr !important;

        width: 100% !important;

        gap: 18px !important;
    }


    .time-row {
        display: grid !important;

        grid-template-columns: 1fr !important;

        gap: 6px !important;
    }


    fieldset {
        width: 100% !important;

        min-width: 0 !important;
    }


    /* =====================================================
       RESULTS PAGE MOBILE
       ===================================================== */

    .results-layout {
        display: block !important;

        width: 100% !important;

        max-width: 100% !important;
    }


    .nuclide-sidebar {
        position: static !important;

        width: 100% !important;

        max-width: 100% !important;

        max-height: none !important;

        margin-bottom: 16px !important;

        box-sizing: border-box !important;
    }


    .nuclide-list {
        display: flex !important;

        flex-direction: row !important;

        width: 100% !important;

        gap: 8px !important;

        overflow-x: auto !important;

        -webkit-overflow-scrolling: touch;
    }


    .nuclide-nav {
        flex-shrink: 0;
    }


    .grid3 {
        grid-template-columns: 1fr !important;
    }


    .info-grid {
        grid-template-columns: 1fr !important;
    }


    /* =====================================================
       OTHER GRIDS MOBILE
       ===================================================== */

    .grid2,
    .grid4 {
        grid-template-columns: 1fr !important;
    }


    /* =====================================================
       FOOTER MOBILE
       ===================================================== */

    .site-footer {
        width: 100% !important;

        margin-top: 24px !important;

        padding: 18px 10px !important;

        color: #888888;

        text-align: center !important;

        font-size: 12px !important;

        line-height: 1.4 !important;
    }


    .footer-fixed {
        position: static !important;
    }

}
