
:root {
    --sop-admin-bg: #fee2e2;
    --sop-danger: #f14668;
    --sop-grey-bg: #f5f5f5;
    --sop-border-grey: #dbdbdb;
    --sop-link: #3273dc;
}

body, button, input, select, textarea {
    font-family: 'Nunito', sans-serif;
}

#logo { cursor: pointer; }
.button.is-primary { background-color: #6FB352; }
.button.is-primary:active, .button.is-primary:hover { background-color: #4c7d37; }

.admin { color: red; }

/* Icon alignment utilities */
.svg-icon { vertical-align: -0.125em; flex-shrink: 0; }
.svg-icon--gap { margin-right: 0.5rem; }
.svg-icon--gap-sm { margin-right: 0.25rem; }

/* Width utilities */
.w-25 { width: 25%; }
.w-30 { width: 30%; }
.w-35 { width: 35%; }
.w-40 { width: 40%; }
.w-50 { width: 50%; }
.w-60 { width: 60%; }
.w-70 { width: 70%; }
.w-80 { width: 80%; }
.w-100 { width: 100%; }

/* Header row layout */
.flex-between { display: flex; justify-content: space-between; align-items: center; }

.content-area {
	margin: 0 1.5rem;
}

.chartunits {
    font-weight: normal;
    color: #777;
    display: inline-block;
    margin-left: .4em;
    font-size: 90%;
}

/* Ensure weekend annotations render behind data series in ApexCharts */
.apexcharts-xaxis-annotations {
    pointer-events: none;
}

.apexcharts-series {
    pointer-events: auto;
}

.dashboard-flex {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    flex: 1;
    min-width: 0;
}

.dashboard-item-data {
    display: none;
}

.dashboard-with-nav {
	padding: 0 2rem;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.dashboard-nav {
    width: 180px;
    flex-shrink: 0;
    position: sticky;
    top: 8px;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 3px;
    background: rgba(248, 248, 248, 0.97);
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px;
    transition: width 0.2s ease;
}

.dashboard-nav.collapsed {
    width: 28px;
    min-width: 28px;
    overflow: hidden;
    padding: 6px 4px;
    gap: 0;
}

.dashboard-nav.collapsed .dash-nav-btn {
    display: none;
}

.dash-nav-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    color: #666;
    padding: 2px 0;
    align-self: flex-end;
    line-height: 1;
    flex-shrink: 0;
    margin-bottom: 2px;
}

.dash-nav-toggle:hover {
    color: #333;
}

.dashboard-nav.collapsed .dash-nav-toggle {
    align-self: center;
    margin-bottom: 0;
}

.dash-nav-btn {
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 0.82em;
    color: #333;
    text-align: left;
    white-space: normal;
    word-break: break-word;
    line-height: 1.3;
    transition: background 0.15s, border-color 0.15s;
}

.dash-nav-btn:hover {
    background: #e8e8e8;
    border-color: #888;
}

.dash-nav-btn.dash-nav-section {
    background: #eef2f7;
    font-weight: bold;
    border-color: #b5c4d8;
    margin-top: 4px;
}

Table.dashboardDataTab { width: 100%; }
Table.dashboardDataTab TD,
Table.dashboardDataTab TH {
    padding: 2px 4px;
    text-align: center;
    font-size:130%;
}
.dashboardDataTab TH {
    font-weight: normal;
    color: black;
}
.dashboardDataTab TD{
    font-weight: bold;
}
.dashboardDataTab TD .chartunits {
    margin-left: 0.2em;
}
.dashboardDataTab.units-wrap TD .chartunits {
    display: block;
    margin-left: 0;
}
.perfchart { 
    padding: 10px;
    background: #eee;
    border: solid black 1px;
    margin-right: 2em;
    margin-bottom: 2em;
}
.dashitem {
    flex-grow: 1;
    position: relative;
    display: flex;
    flex-direction: column;
}
.dashitem > div {
    padding: 0.5rem;
    width: 100%;
    flex: 1;
    border: solid #ccc 1px;
    background-color: white;
}
.dashitem .itemtitle { 
    font-weight: bold;
}
.nodata { 
    text-align:center;
    margin-top: 3rem;
    font-style: italic;
}
.dashitem .download {
    display: none;
    color: #888;
	margin-left:8px;
}

.isadmin .dashitem .download {
    display: inline !IMPORTANT;
}

.dashitem .maximize-btn {
	cursor: pointer;
    background: transparent;
    border: none;
    color: #888;
    font-size: 16px;
    padding: 0 4px;
	margin-left: 4px;
    line-height: 1;
    transition: color 0.2s ease;
}

.dashitem .maximize-btn:hover {
    color: #333;
}

.dashitem .reset-zoom-btn {
	display: none;
}

.db-callout { 
    border-top: solid #ccc 1px;
    margin-top: 4px;
}

.db-callouts { overflow: auto; }
.db-callout .date { font-size: 9pt; line-height: 8pt; padding-top:5px; }
.db-callout .asset { font-weight: bold; float: left; margin-right: 1em;}
.db-callout .description { font-weight: normal; }

.db-values { overflow: auto; }
.db-values tr td { padding: 4px 2px; border-top: solid #ddd 1px; }
.db-values table tr td:nth-child(2) { font-weight: bold ; }
.db-values table tr td:nth-child(3) { text-align: right; padding-right: 0.2em;}

.db-scrolling { overflow: auto; }

.db-asset-list { caption-side: bottom; border-collapse: separate; margin-top: 6px; }
.db-asset-list tr td { padding: 4px 0; border-bottom: solid #ddd 1px; }
.db-asset-list tr td:first-child { padding-right: 1rem; }
.db-asset-list tr td:last-child { text-align: right; }

.db-status th { padding: 6px 2px; }
.db-status tr td { padding: 4px 2px; border-top: solid #ddd 1px; }
.db-status tr td:first-child { padding-right: 1rem; }
.db-status tr td:last-child { text-align: right; }

.db-status-late { background: #FFBF00; color: white;}
.db-status-vlate { background: red; color: white;}
.db-scrolling h2 { font-weight:bold; padding-top: 4px; }

.db-status { display:flex; }
.db-status-col { margin-right: 2em; }

.customTooltip {
    text-align: left;
    flex: none;
}
.customTooltip .tt-caption { 
    padding: 4px;
    background: #eceff1;
    font-size: 12px;
    width: 100%;
    margin-left: 0;
    font-family: Helvetica, Arial, sans-serif;
}
.customTooltip .tt-data { 
    padding: 4px;
}
.customTooltip .tt-dataPC { 
    margin: 2px 4px;
    height: 1em;
    border: solid #3e8de0 2px;
}
.customTooltip .tt-dataPC div { 
    height: 100%; 
    background: #3e8de0;
}
.customTooltip .tt-pnote {
    margin: 6px;
    max-width: 300px;
    max-height: 500px;
    overflow: scroll;
    white-space: pre-wrap;
}

.customTooltip .tt-components {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid #e0e0e0;
    font-size: 11px;
}

.customTooltip .tt-comp-title {
    font-weight: 600;
    color: #666;
    margin-bottom: 4px;
}

.customTooltip .tt-comp-item {
    padding: 2px 0;
    color: #555;
}

#note-dialog .customTooltip .tt-pnote {
    max-width: 100%;
    max-height: 500px;
    overflow: auto;
}

.footer {
    padding: 1rem 1.5rem 1rem;
    border-top: 1px solid #c8ccd5;
}

@media screen and (min-width: 1024px) {
    .is-pulled-right-desktop { float: right; }
}
    
#note-tooltip {
    border-radius: 5px;
    box-shadow: 2px 2px 6px -4px #999;
    cursor: default;
    font-size: 14px;
    opacity: 0.95;
    pointer-events: none;
    position: absolute;
    z-index: 999999;
    transition: .15s ease all;
    background: rgb(255, 255, 255, 0.96);
    padding: 0;
    width: 300px;
    max-width: 90vw;
    font: var(--bulma-body-font);
    font-size: 14px;
    max-height: 80vh;
    color: rgb(64, 70, 84);
}

#note-tooltip .tt-pnote {
    overflow: auto !IMPORTANT;
    max-height: 60vh;
    white-space: pre-wrap;
    word-wrap: break-word;
}

#note-dialog .modal-content {
    background: white;
}

#note-dialog .tt-content { 
    padding: 0.5rem;
}

#note-dialog .tt-caption { 
    font-size: 130%;
    font-weight: bold;
    padding: 0.5rem;
}

#note-dialog .modal-card-foot {
    padding: 1rem;;
}

.apexcharts-point-annotation-marker {
    cursor:pointer;
}

/* Ensure ApexCharts tooltips appear above modal headers */
.apexcharts-tooltip {
    z-index: 999999 !important;
}

#chart-maximize-modal .modal-card-body {
    max-height: calc(100vh - 140px);
    overflow: visible;
    padding: 0.75rem;
}

#chart-maximize-modal .modal-chart-content {
    overflow: visible;
}

#chart-maximize-modal .modal-chart-content {
    width: 100%;
    min-height: 400px;
}

#chart-maximize-modal .modal-card {
    display: flex;
    flex-direction: column;
    max-height: 98vh;
}

#chart-maximize-modal .modal-card-head {
    padding: 0.75rem 1rem;
}

#chart-maximize-modal .modal-card-foot {
    padding: 0.75rem 1rem;
}

/* Bulma modals default to z-index 40, which is below the fixed sidebar (200) */
.modal {
    z-index: 300;
}

/* ======================== */
/* Sidebar Layout           */
/* ======================== */

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 200;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.04);
}

.app-content {
    flex: 1;
    margin-left: 240px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-content .container {
    max-width: 100% !important;
}

/* Sidebar header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.sidebar-logo {
    width: 100%;
    height: auto;
    cursor: pointer;
    display: block;
}

.sidebar-header a {
    flex: 1;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #9ca3af;
    padding: 2px 6px;
    line-height: 1;
}

.sidebar-close:hover {
    color: #374151;
}

/* Section labels */
.sidebar-section-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #4b5563;
    background: #e5e7eb;
    padding: 7px 14px;
    margin: 6px 6px 2px;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
}

.sidebar-section-label:hover {
    background: #d1d5db;
    color: #1f2937;
}

.sidebar-chevron {
    margin-left: auto;
    flex-shrink: 0;
    transition: transform 0.18s ease;
}

.sidebar-section-label.is-collapsed .sidebar-chevron {
    transform: rotate(-90deg);
}

.sidebar-section-label--admin {
    color: #b91c1c;
    background: #fee2e2;
}

.sidebar-section-label--admin:hover {
    background: #fecaca;
    color: #991b1b;
}

/* Plant card */
.sidebar-plant {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 12px;
    padding: 6px 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    flex-shrink: 0;
    text-decoration: none;
    transition: background 0.12s, border-color 0.12s;
}

.sidebar-plant:hover {
    background: #f0fdf4;
    border-color: #bbf7d0;
    text-decoration: none;
}

.sidebar-plant-icon {
    width: 34px;
    height: 34px;
    background: #dcfce7;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #16a34a;
    flex-shrink: 0;
}

.sidebar-plant-details {
    flex: 1;
    min-width: 0;
}

.sidebar-plant-name {
    font-weight: 600;
    font-size: 0.82rem;
    line-height: 1.3;
    color: #111827;
    word-break: break-word;
}

.sidebar-plant-logo {
    display: block;
    max-height: 40px;
    max-width: 100%;
    object-fit: contain;
    object-position: left center;
}

.sidebar-plant-swap {
    color: #9ca3af;
    flex-shrink: 0;
    text-decoration: none;
    display: flex;
    align-items: center;
}

.sidebar-plant-swap:hover {
    color: #374151;
}

/* Nav links */
.sidebar-nav {
    flex: 1;
    padding: 4px 0 8px;
    overflow-y: auto;
}

.sidebar-link {
    display: block;
    padding: 6px 12px;
    font-size: 0.95rem;
    color: #374151;
    text-decoration: none;
    border-radius: 6px;
    margin: 1px 6px;
    transition: background 0.12s, color 0.12s;
    line-height: 1.4;
}

.sidebar-link:hover {
    background: #f3f4f6;
    color: #111827;
    text-decoration: none;
}

.sidebar-link.is-active {
    background: #f0fdf4;
    color: #16a34a;
    font-weight: 600;
}

.sidebar-link--admin {
    color: #dc2626;
}

.sidebar-link--admin.is-active {
    background: #fee2e2;
    color: #991b1b;
    font-weight: 600;
}

.sidebar-link--admin:hover {
    background: #fef2f2;
    color: #b91c1c;
}

/* User footer */
.sidebar-user {
    border-top: 1px solid #e5e7eb;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.sidebar-user-avatar {
    width: 34px;
    height: 34px;
    background: #6FB352;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.78rem;
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 0.82rem;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 0.72rem;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-logout {
    color: #9ca3af;
    text-decoration: none;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.sidebar-user-logout:hover {
    color: #374151;
}

/* Mobile overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 199;
}

.sidebar-overlay.is-active {
    display: block;
}

/* Mobile top bar */
.mobile-topbar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 150;
}

.mobile-menu-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.mobile-menu-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: #374151;
    border-radius: 2px;
}

/* Mobile responsive */
@media screen and (max-width: 1023px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .sidebar-close {
        display: block;
    }

    .app-content {
        margin-left: 0;
    }

    .mobile-topbar {
        display: flex;
    }

    .sidebar-link {
        font-size: 1.15rem;
        padding: 10px 14px;
    }

    .sidebar-section-label {
        font-size: 0.88rem;
        padding: 9px 16px;
    }
}

@media screen and (max-width: 768px) {
    /* Increase base font size on mobile */
    html {
        font-size: 18px;
    }

    body {
        font-size: 1rem;
    }

    /* User info smaller on mobile */
    .navbar > .ml-3 {
        font-size: 0.85rem;
        padding-right: 0.5rem;
    }

    /* Larger buttons */
    .button {
        font-size: 1.1rem;
        padding: 0.75em 1em;
    }

    /* Larger form inputs and selects */
    .input,
    .select select,
    .textarea {
        font-size: 1.1rem;
    }

    /* Larger table text */
    table {
        font-size: 1rem;
    }

    /* Ensure dashboard tables remain readable */
    Table.dashboardDataTab TD,
    Table.dashboardDataTab TH {
        font-size: 140%;
    }

    /* Larger footer text */
    .footer {
        font-size: 1rem;
    }

    /* Larger content headings */
    h1, .title {
        font-size: 1.75rem;
    }

    h2, .subtitle {
        font-size: 1.5rem;
    }

    /* Increase link size for better tap targets */
    a {
        font-size: 1.05rem;
    }
}

@media print {
    .sidebar,
    .sidebar-overlay,
    .mobile-topbar,
    .footer {
        display: none !important;
    }

    .app-content {
        margin-left: 0 !important;
    }

    .section.py-3 {
        padding-top: 0 !important;
    }

    /* Pages set their page background via an inline style on .section; never print it */
    .section {
        background-color: transparent !important;
    }
}

/* Shared asset tree / badge styles (asset index, asset profile, maintenance assets) */
.tree-toggle { cursor: pointer; user-select: none; display: inline-block; width: 1em; text-align: center; margin-right: 3px; }
.tree-toggle:empty::before { content: ''; }
.asset-row.is-collapsed { display: none; }
.asset-type-badge { font-size: 0.75em; padding: 1px 6px; border-radius: 3px; background: #e8f0fe; color: #3367d6; }
.location-badge { font-size: 0.75em; padding: 1px 6px; border-radius: 3px; background: #f3e8fd; color: #7b2d8b; }
.consumable-badge { font-size: 0.75em; padding: 1px 6px; border-radius: 3px; background: #e6f4ea; color: #1e8e3e; }
.stock-low-badge { font-size: 0.75em; padding: 1px 6px; border-radius: 3px; background: #fce8e6; color: #c5221f; }
.tree-cell { display: flex; align-items: center; }
.tree-indent { width: 12px; flex-shrink: 0; }
.tree-connector {
    width: 16px; flex-shrink: 0;
    align-self: stretch; position: relative;
}
.tree-connector::before {
    content: ''; position: absolute;
    left: 6px; top: 0; bottom: 0; width: 1px; background: #ccc;
}
.tree-connector.is-last::before { bottom: 50%; }
.tree-connector::after {
    content: ''; position: absolute;
    left: 6px; top: 50%; width: 10px; height: 1px; background: #ccc;
}

/* Shared spinner animation */
@keyframes spin { to { transform: rotate(360deg); } }
.animate-spin { animation: spin 1s linear infinite; }
