/* Custom Global Table & Badge High-Contrast Overrides */

/* Table Typography & Contrast */
.table {
    color: #1e293b !important;
}

.table th {
    font-weight: 600;
    color: #0f172a !important;
    background-color: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    font-size: 0.825rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.table td {
    vertical-align: middle;
    color: #334155;
    font-size: 0.875rem;
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(241, 245, 249, 0.4);
}

.table-hover tbody tr:hover {
    background-color: rgba(226, 232, 240, 0.5);
}

/* Badge High-Contrast Global Definitions */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600 !important;
    font-size: 0.75rem !important;
    padding: 0.35em 0.65em !important;
    border-radius: 4px;
    line-height: 1.2;
    letter-spacing: 0.01em;
}

/* Backward compatibility for Bootstrap 4 / legacy OneUI badge classes */
.badge-primary, .badge.bg-primary {
    background-color: #2563eb !important;
    color: #ffffff !important;
}

.badge-info, .badge.bg-info {
    background-color: #0284c7 !important;
    color: #ffffff !important;
}

.badge-success, .badge.bg-success {
    background-color: #059669 !important;
    color: #ffffff !important;
}

.badge-warning, .badge.bg-warning {
    background-color: #d97706 !important;
    color: #ffffff !important;
}

.badge-danger, .badge.bg-danger {
    background-color: #dc2626 !important;
    color: #ffffff !important;
}

.badge-secondary, .badge.bg-secondary {
    background-color: #64748b !important;
    color: #ffffff !important;
}

.badge-light, .badge.bg-light {
    background-color: #f1f5f9 !important;
    color: #1e293b !important;
    border: 1px solid #cbd5e1 !important;
}

.badge-dark, .badge.bg-dark {
    background-color: #0f172a !important;
    color: #ffffff !important;
}

/* Tab badges */
.nav-pills .nav-link .badge {
    margin-left: 0.35rem;
    font-size: 0.75rem;
}

/* Dark Mode Table & High Contrast Overrides */
.dark-mode .table,
#page-container.dark-mode .table {
    color: #cbd5e1 !important;
}

.dark-mode .table th,
#page-container.dark-mode .table th {
    color: #f8fafc !important;
    background-color: #1e293b !important;
    border-bottom: 2px solid #334155 !important;
}

.dark-mode .table td,
#page-container.dark-mode .table td {
    color: #cbd5e1 !important;
    border-bottom-color: #334155 !important;
}

.dark-mode .table-striped tbody tr:nth-of-type(odd),
#page-container.dark-mode .table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(30, 41, 59, 0.5) !important;
}

.dark-mode .table-hover tbody tr:hover,
#page-container.dark-mode .table-hover tbody tr:hover {
    background-color: rgba(51, 65, 85, 0.4) !important;
}

.dark-mode .table .text-muted,
#page-container.dark-mode .table .text-muted,
.dark-mode .text-muted,
#page-container.dark-mode .text-muted {
    color: #94a3b8 !important;
}

.dark-mode .form-label,
#page-container.dark-mode .form-label {
    color: #f1f5f9 !important;
}

.dark-mode .form-text,
#page-container.dark-mode .form-text {
    color: #94a3b8 !important;
}

.dark-mode .breadcrumb-item,
#page-container.dark-mode .breadcrumb-item {
    color: #94a3b8 !important;
}

.dark-mode .breadcrumb-item.active,
#page-container.dark-mode .breadcrumb-item.active {
    color: #f8fafc !important;
}

/* Subtle muted text in tables should still be legible */
.table .text-muted {
    color: #64748b !important;
}

.table .font-size-xs, .table .fs-xs {
    font-size: 0.75rem !important;
}

/* ==========================================================================
   Bootstrap 4 to Bootstrap 5 Utility Compatibility (Margins, Padding, Align)
   ========================================================================== */
.mr-0 { margin-right: 0 !important; }
.mr-1 { margin-right: 0.25rem !important; }
.mr-2 { margin-right: 0.5rem !important; }
.mr-3 { margin-right: 1rem !important; }
.mr-4 { margin-right: 1.5rem !important; }
.mr-5 { margin-right: 3rem !important; }

.ml-0 { margin-left: 0 !important; }
.ml-1 { margin-left: 0.25rem !important; }
.ml-2 { margin-left: 0.5rem !important; }
.ml-3 { margin-left: 1rem !important; }
.ml-4 { margin-left: 1.5rem !important; }
.ml-5 { margin-left: 3rem !important; }

.pr-0 { padding-right: 0 !important; }
.pr-1 { padding-right: 0.25rem !important; }
.pr-2 { padding-right: 0.5rem !important; }
.pr-3 { padding-right: 1rem !important; }
.pr-4 { padding-right: 1.5rem !important; }
.pr-5 { padding-right: 3rem !important; }

.pl-0 { padding-left: 0 !important; }
.pl-1 { padding-left: 0.25rem !important; }
.pl-2 { padding-left: 0.5rem !important; }
.pl-3 { padding-left: 1rem !important; }
.pl-4 { padding-left: 1.5rem !important; }
.pl-5 { padding-left: 3rem !important; }

.text-right { text-align: right !important; }
.text-left { text-align: left !important; }

@media (min-width: 576px) {
    .text-sm-right { text-align: right !important; }
    .text-sm-left { text-align: left !important; }
}

@media (min-width: 768px) {
    .text-md-right { text-align: right !important; }
    .text-md-left { text-align: left !important; }
}

@media (min-width: 992px) {
    .text-lg-right { text-align: right !important; }
    .text-lg-left { text-align: left !important; }
}

/* Icon spacing inside buttons, badges, links, and titles */
.badge i.fa, .badge i.si,
.btn i.fa, .btn i.si,
.block-title i.fa, .block-title i.si {
    vertical-align: -0.05em;
}

/* Header action toolbars (stay together side-by-side) */
.header-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    flex-wrap: nowrap;
}

/* Fix fixed page-header transparency & bleed-through when page is scrolled */
#page-header {
    background-color: #ffffff !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07) !important;
}

.dark-mode #page-header {
    background-color: #1e293b !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35) !important;
}

/* Header bell: unread count tucked onto the button corner (was centred on it and clipped by the header) */
#page-header-notifications-dropdown {
    position: relative;
    overflow: visible;
}

#page-header-notifications-dropdown .notif-badge {
    /* beats Bootstrap's `.btn .badge { position: relative }` */
    position: absolute;
    top: -7px;
    right: -9px;
    box-sizing: border-box;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    font-size: .625rem;
    font-weight: 700;
    line-height: 14px;
    text-align: center;
    border: 2px solid #fff;
    pointer-events: none;
}

.dark-mode #page-header-notifications-dropdown .notif-badge {
    border-color: #1e293b;
}

/* Modal Close Cross Button Clean Styling */
.modal-header .btn-close,
.modal-header .btn-close-white {
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    opacity: 0.8 !important;
}

.modal-header .btn-close:hover,
.modal-header .btn-close-white:hover {
    opacity: 1 !important;
}

.modal .btn-block-option {
    opacity: 0.8;
    transition: opacity 0.15s ease;
}

.modal .btn-block-option:hover {
    opacity: 1;
}

/* ==========================================================================
   Global Card/Block Breathing Room & Form Action Footer Button Spacing
   ========================================================================== */

/* Fix OneUI 1px bottom padding on block-content to ensure consistent breathing room across all pages */
.block-content:not(.block-content-sm):not(.modal-footer) {
    padding-bottom: 1.5rem !important;
}

/* Ensure tab content containers inside blocks have proper bottom padding */
.block-content.tab-content {
    padding-bottom: 1.5rem !important;
}

/* Form actions / submit button row at bottom of forms, blocks, and tabs */
.block-content form > .text-end:last-child,
.tab-pane form > .text-end:last-child,
.block-content > form > .text-end:last-child,
.block-content > .text-end:last-child,
.tab-pane > .text-end:last-child,
.form-actions-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem !important;
    margin-bottom: 0.5rem !important;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.dark-mode .block-content form > .text-end:last-child,
.dark-mode .tab-pane form > .text-end:last-child,
.dark-mode .block-content > form > .text-end:last-child,
.dark-mode .block-content > .text-end:last-child,
.dark-mode .tab-pane > .text-end:last-child,
.dark-mode .form-actions-footer {
    border-top-color: rgba(255, 255, 255, 0.1);
}

/* ==========================================================================
   Mobile / small screens (phones, ≤ 767px)
   ========================================================================== */
@media (max-width: 767.98px) {
    /* Block headers: the action area (filters, buttons, search) wraps under the title instead
       of crushing it or running off the screen. */
    .block-header {
        flex-wrap: wrap;
        row-gap: .5rem;
    }
    .block-header > .block-title {
        flex: 1 1 auto;
        min-width: 0;
    }
    .block-header > .block-options {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: .5rem;
        max-width: 100%;
        margin-left: auto;
        padding-left: 0;
    }
    .block-header > .block-options > * {
        min-width: 0;
        max-width: 100%;
        margin-left: 0 !important;
    }
    .block-header > .block-options .form-select,
    .block-header > .block-options .form-control,
    .block-header > .block-options .input-group {
        flex: 1 1 150px;
        width: auto;
        min-width: 0;
    }

    /* Long identifiers (UUIDs, DRS IDs, references) wrap instead of pushing the page wide. */
    .font-monospace,
    code {
        overflow-wrap: anywhere;
    }

    /* Wide tables scroll inside their card; keep a little breathing room and smaller type. */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
    .table-responsive > .table {
        font-size: .8125rem;
    }
    .table-responsive > .table > :not(caption) > * > * {
        padding: .5rem .5rem;
    }

    /* Page content gutters a touch tighter on phones. */
    #main-container .content {
        padding-left: .75rem;
        padding-right: .75rem;
    }

    /* Modals use the full width on phones. */
    .modal-dialog:not(.modal-sm) {
        margin: .5rem;
        max-width: none;
    }

    /* Household record header: smaller avatar and chips so several fit per row. */
    .meta-chip {
        padding: .25rem .5rem;
        font-size: .78rem;
    }
    .block-content .item.item-circle {
        width: 40px !important;
        height: 40px !important;
    }

    /* Tab bars scroll sideways rather than wrapping into tall stacks. */
    .nav-tabs-block,
    .nav-tabs-alt,
    #level1-subtabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: thin;
    }
    .nav-tabs-block > .nav-item,
    .nav-tabs-alt > .nav-item,
    #level1-subtabs > .nav-item {
        flex: 0 0 auto;
    }
    .nav-tabs-block .nav-link,
    .nav-tabs-alt .nav-link,
    #level1-subtabs .nav-link {
        white-space: nowrap;
    }
}

/* Avatar aspect ratio and anti-stretching */
#page-header-user-dropdown img {
    width: 21px;
    height: 21px;
    object-fit: cover;
    flex-shrink: 0;
}

.img-avatar {
    object-fit: cover;
}

/* ==========================================================================
   SweetAlert2 Enhanced Icons & Modern Dialog Styling
   ========================================================================== */

/* Modernized Success Icon */
.swal2-icon.swal2-success {
    border-color: #10b981 !important;
    color: #10b981 !important;
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0.12), 0 8px 16px -4px rgba(16, 185, 129, 0.18) !important;
    border-width: 3px !important;
}

.swal2-icon.swal2-success .swal2-success-ring {
    border: 3px solid rgba(16, 185, 129, 0.25) !important;
}

.swal2-icon.swal2-success [class^='swal2-success-line'] {
    background-color: #10b981 !important;
    height: 0.35em !important;
    border-radius: 4px !important;
}

/* Ensure background masks match popup background seamlessly */
.swal2-popup .swal2-success-circular-line-left,
.swal2-popup .swal2-success-circular-line-right,
.swal2-popup .swal2-success-fix {
    background-color: #ffffff !important;
}

/* Dark mode support for SweetAlert2 */
body.dark-mode .swal2-popup,
.dark-mode .swal2-popup {
    background: #1e293b !important;
    color: #f1f5f9 !important;
}

body.dark-mode .swal2-popup .swal2-title,
.dark-mode .swal2-popup .swal2-title {
    color: #f8fafc !important;
}

body.dark-mode .swal2-popup .swal2-html-container,
.dark-mode .swal2-popup .swal2-html-container {
    color: #94a3b8 !important;
}

body.dark-mode .swal2-popup .swal2-success-circular-line-left,
body.dark-mode .swal2-popup .swal2-success-circular-line-right,
body.dark-mode .swal2-popup .swal2-success-fix,
.dark-mode .swal2-popup .swal2-success-circular-line-left,
.dark-mode .swal2-popup .swal2-success-circular-line-right,
.dark-mode .swal2-popup .swal2-success-fix {
    background-color: #1e293b !important;
}

/* Enhanced Warning / Error / Info icons for consistency */
.swal2-icon.swal2-error {
    border-color: #ef4444 !important;
    color: #ef4444 !important;
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.12) !important;
    border-width: 3px !important;
}

.swal2-icon.swal2-error [class^='swal2-x-mark-line'] {
    background-color: #ef4444 !important;
    border-radius: 4px !important;
}

.swal2-icon.swal2-warning {
    border-color: #f59e0b !important;
    color: #f59e0b !important;
    box-shadow: 0 0 0 6px rgba(245, 158, 11, 0.12) !important;
    border-width: 3px !important;
}

.swal2-icon.swal2-info {
    border-color: #3b82f6 !important;
    color: #3b82f6 !important;
    box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.12) !important;
    border-width: 3px !important;
}

.swal2-icon.swal2-question {
    border-color: #6366f1 !important;
    color: #6366f1 !important;
    box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.12) !important;
    border-width: 3px !important;
}

/* SweetAlert2 Popup button & dialog enhancement */
.swal2-styled.swal2-confirm {
    background-color: #2563eb !important;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35) !important;
    border-radius: 0.375rem !important;
    font-weight: 500 !important;
    padding: 0.55rem 1.5rem !important;
}

.swal2-styled.swal2-cancel {
    border-radius: 0.375rem !important;
    font-weight: 500 !important;
    padding: 0.55rem 1.5rem !important;
}

.swal2-popup {
    border-radius: 0.75rem !important;
    padding: 1.75em 1.5em !important;
}


/* Sidebar submenu icons: one fixed width so the labels line up, a little smaller and softer than the text.
   They follow the link colour (light / dark sidebar alike) and take the active colour on the current page. */
.nav-main-submenu .nav-main-link > .nav-main-link-icon {
    width: 1.125rem;
    min-width: 1.125rem;
    margin-right: 0.5rem;
    font-size: 0.8rem;
    text-align: center;
    color: inherit;
    opacity: 0.6;
}
.nav-main-submenu .nav-main-link:hover > .nav-main-link-icon,
.nav-main-submenu .nav-main-link.active > .nav-main-link-icon,
.nav-main-submenu .nav-main-item.open > .nav-main-link-submenu > .nav-main-link-icon {
    color: inherit;
    opacity: 1;
}

/* Auth / Login Page Screen Background (Matching remote IDCOL Wizard) */
.auth-page-bg {
    background-color: #f3f7fb;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.5)),
        url('/images/background.jpeg');
    background-size: auto, cover;
    background-position: center, center;
    background-repeat: no-repeat, no-repeat;
    background-attachment: fixed, fixed;
    min-height: 100vh;
    width: 100%;
}

@media (max-width: 1024px) {
    .auth-page-bg {
        background-attachment: scroll, scroll;
        background-position: center, center top;
    }
}

/* Auth / Login Page Video Background */
.auth-video-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    overflow: hidden;
    background-color: #0b111e;
}

.auth-bg-video {
    position: absolute;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    transform: translate(-50%, -50%);
    object-fit: cover;
    z-index: 1;
    pointer-events: none;
}

.auth-video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    background: radial-gradient(circle at 75% 50%, rgba(11, 17, 30, 0.25) 0%, rgba(11, 17, 30, 0.65) 100%);
    pointer-events: none;
}

.auth-page-content {
    position: relative;
    z-index: 3;
    min-height: 100vh;
    width: 100%;
}

/* Copyright line under the sign-in card (panel and web app guest layouts) */
.auth-footer {
    color: rgba(255, 255, 255, .72);
    font-size: .75rem;
    letter-spacing: .02em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .45);
}

.auth-footer .auth-footer-sep {
    display: inline-block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(124, 194, 66, .85);
    vertical-align: middle;
    margin: 0 .55rem;
}

/* ==========================================================================
   SolisCloud PlantStation Background Overlay System
   Applied to Logged-in Admin Panel (#page-container / #main-container)
   ========================================================================== */

:root {
    --solis-bg-image: url('../media/bg/solis-bg-light.webp');
    --solis-grid: url('../media/bg/solis-grid-light.svg');
    --solis-bg-overlay: radial-gradient(circle at 75% 20%, rgba(0, 160, 228, 0.06) 0%, rgba(3, 78, 162, 0.04) 40%, transparent 70%);
    --solis-header-bg: url('../media/bg/solis-header-light.png');
    --solis-card-bg: rgba(255, 255, 255, 0.94);
    --solis-card-border: rgba(0, 0, 0, 0.06);
    --solis-card-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 6px 18px rgba(0, 0, 0, 0.04);
}

#page-container.dark-mode,
body.dark-mode {
    --solis-bg-image: url('../media/bg/solis-bg-dark.webp');
    --solis-grid: url('../media/bg/solis-grid.svg');
    --solis-bg-overlay: radial-gradient(circle at 80% 20%, rgba(0, 160, 228, 0.16) 0%, rgba(3, 78, 162, 0.18) 40%, rgba(114, 191, 68, 0.08) 70%, transparent 90%);
    --solis-header-bg: url('../media/bg/solis-header-dark.png');
    --solis-card-bg: rgba(14, 22, 36, 0.88);
    --solis-card-border: rgba(255, 255, 255, 0.08);
    --solis-card-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.22);
}

/* Logged-in Main Container */
#page-container #main-container,
#page-container.dark-mode #main-container {
    background-color: transparent !important;
    background-image: var(--solis-bg-overlay), var(--solis-grid), var(--solis-bg-image) !important;
    background-size: 100% 100%, 40px 40px, cover !important;
    background-position: center top, top left, center top !important;
    background-attachment: fixed, fixed, fixed !important;
    background-repeat: no-repeat, repeat, no-repeat !important;
    position: relative;
    min-height: 100vh;
}

#page-container #main-container .content,
#page-container.dark-mode #main-container .content {
    background-color: transparent !important;
}

/* Ensure Bootstrap modals always stack above backdrops and layout overlays */
.modal {
    z-index: 1055 !important;
}
.modal-backdrop {
    z-index: 1050 !important;
}

/* Logged-in Header Ambient Scroll Bar */
#page-container #page-header {
    background-color: rgba(255, 255, 255, 0.88) !important;
    background-image: var(--solis-header-bg) !important;
    background-size: 100% 100% !important;
    background-repeat: no-repeat !important;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

#page-container.dark-mode #page-header {
    background-color: rgba(20, 22, 27, 0.90) !important;
    background-image: var(--solis-header-bg) !important;
    background-size: 100% 100% !important;
    background-repeat: no-repeat !important;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

/* Glassmorphism Blocks / Cards in Logged-in Panel */
#page-container .block {
    background-color: var(--solis-card-bg) !important;
    border: 1px solid var(--solis-card-border) !important;
    box-shadow: var(--solis-card-shadow) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 0.875rem;
}

#page-container .block-header {
    background-color: transparent !important;
    border-bottom: 1px solid var(--solis-card-border);
}

#page-container .block-content {
    background-color: transparent !important;
}

/* Dark mode tweaks for tables & cards inside main-container */
#page-container.dark-mode .table {
    --bs-table-bg: transparent;
    color: #e2e8f0;
}

#page-container.dark-mode .table th {
    border-bottom-color: rgba(255, 255, 255, 0.1);
    color: #94a3b8;
}

#page-container.dark-mode .table td {
    border-bottom-color: rgba(255, 255, 255, 0.06);
}

