﻿/* Dark Mode Toggle Switch */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.375rem 0.75rem;
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
    margin-bottom: 0;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #007bff;
}

input:checked + .slider:before {
    transform: translateX(20px);
}

input:checked + .slider {
    background-color: #28a745;
}

/* Dark mode enhancements */
.dark-mode .theme-switch-wrapper {
    color: #fff;
}

.dark-mode .slider {
    background-color: #6c757d;
}

/* Dark mode: form-control disabled/readonly */
.dark-mode .form-control:disabled,
.dark-mode .form-control[readonly] {
    background-color: #40464d !important; /* Slightly lighter than #343a40 to stand out from page background */
    border-color: #58616a !important; /* Neutral border to define input edges without too much contrast */
    color: #adb5bd !important; /* Muted gray text for disabled state, still readable */
    opacity: 1; /* Prevent Safari from reducing opacity excessively */
    -webkit-text-fill-color: #adb5bd !important; /* Ensure consistent text color in Safari */
    cursor: not-allowed !important; /* Show not-allowed cursor to indicate disabled */
}

/* Placeholder text in disabled input (dark mode) */
.dark-mode .form-control::placeholder {
    color: #95a1ab !important; /* Softer gray for placeholder, distinguishable from normal text */
    opacity: 1; /* Ensure consistent visibility across browsers */
}

/* =========================
   Select2 – Dark Mode Theme
   Base page bg: #343a40; text: #fff
   ========================= */

/* Container + selection (single & multiple) */
.dark-mode .select2-container .select2-selection--single,
.dark-mode .select2-container .select2-selection--multiple {
    background-color: #3d434a; /* Dark input background (enabled) */
    border: 1px solid #58616a; /* Neutral border */
    color: #e9ecef; /* Light text */
}

/* Height & alignment for single */
.dark-mode .select2-container .select2-selection__rendered {
    color: #e9ecef; /* Selected text color */
}

.dark-mode .select2-container .select2-selection__placeholder {
    color: #adb5bd; /* Placeholder in selection */
}

/* Arrow & clear icon */
.dark-mode .select2-container .select2-selection__arrow b {
    border-color: #adb5bd transparent transparent transparent; /* Caret color */
}

.dark-mode .select2-container .select2-selection__clear {
    color: #cfd6dc; /* Clear “x” icon */
}

    .dark-mode .select2-container .select2-selection__clear:hover {
        color: #ffffff; /* Hover state */
    }

/* Multiple selection: tag pills */
.dark-mode .select2-container .select2-selection--multiple .select2-selection__choice {
    background-color: #40464d; /* Tag background */
    border: 1px solid #58616a; /* Tag border */
    color: #dfe3e7; /* Tag text */
}

.dark-mode .select2-container .select2-selection--multiple .select2-selection__choice__remove {
    color: #b9c1c8; /* Remove icon on tag */
}

    .dark-mode .select2-container .select2-selection--multiple .select2-selection__choice__remove:hover {
        color: #ffffff;
    }

/* Focus ring */
.dark-mode .select2-container--focus .select2-selection--single,
.dark-mode .select2-container--focus .select2-selection--multiple {
    border-color: #6aa3ff; /* Accent border on focus */
    box-shadow: 0 0 0 .25rem rgba(13,110,253,.25); /* Accessible focus outline */
}

/* Disabled state (match your disabled palette) */
.dark-mode .select2-container.select2-container--disabled .select2-selection--single,
.dark-mode .select2-container.select2-container--disabled .select2-selection--multiple {
    background-color: #40464d; /* Disabled bg */
    border-color: #3a3f46; /* Softer border */
    color: #adb5bd; /* Muted text */
    cursor: not-allowed;
}

.dark-mode .select2-container.select2-container--disabled .select2-selection__rendered {
    color: #adb5bd; /* Ensure text color applies in Safari */
    -webkit-text-fill-color: #adb5bd;
}

/* Dropdown panel */
.dark-mode .select2-dropdown {
    background-color: #2b2f36; /* Menu bg (darker than control for depth) */
    border: 1px solid #58616a; /* Panel border */
    color: #e9ecef; /* Default text */
    border-radius: .375rem;
}

/* Search field inside dropdown */
.dark-mode .select2-search--dropdown .select2-search__field {
    background-color: #3d434a; /* Search input bg */
    border: 1px solid #58616a; /* Search input border */
    color: #e9ecef; /* Search text */
    border-radius: .375rem;
}

    .dark-mode .select2-search--dropdown .select2-search__field::placeholder {
        color: #95a1ab; /* Search placeholder */
    }

/* Options: default, hover (highlighted), selected */
.dark-mode .select2-results__option {
    color: #e9ecef; /* Option text */
    background-color: transparent; /* Inherit panel bg */
}

.dark-mode .select2-results__option--highlighted[aria-selected] {
    background-color: #495057; /* Hover/highlight */
    color: #ffffff;
}

.dark-mode .select2-results__option[aria-selected="true"] {
    background-color: #0d6efd; /* Selected (primary) */
    color: #ffffff;
}

/* Disabled options */
.dark-mode .select2-results__option[aria-disabled="true"] {
    color: #9aa3ad; /* Muted disabled option */
}

/* =========================
   End Select2 Dark Mode Theme
   ========================= */

.select2-container {
    width: auto !important;
}

#editPopup input {
    padding-right: 1px;
}

#editPopup input.mark-red {
    height: 30px;
    border-color: rgb(220, 53, 69);
    color: rgb(220, 53, 69);
}

.select2-results__option {
    min-height: 30px;
}

#table th {
    vertical-align: middle;
}

#table .selected .text-primary {
    color: #fff !important;
}

.text-primary.exported {
    color: green !important;
}

.info-icon .dropdown-item .red {
    color: red !important;
}

#loading {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10000;
    width: 100%;
    height: 100vh;
    background-color: rgba(192, 192, 192, 0.5);
    text-align: center;
    display: none;
}

#loading img {
    display:block;
    position:absolute;
    left:0;
    right:0;
    bottom:0;
    top: 0;
    margin:auto;
}

.cake-debug, .cake-error {
    margin-left: 250px;
}


/* Nút chat */
.chat-button {
    position: fixed;
    bottom: 0px;
    right: 20px;
    width: 60px;
    height: 60px;
    /*background-color: #007bff;*/
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    /*box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);*/
    cursor: pointer;
    transition: all 0.3s ease-in-out;
}

    .chat-button:hover {
        /*background-color: #0056b3;*/
    }

    .chat-button img {
        width: 60px;
        height: 60px;
    }
/* Khung chat */
.chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 10px;
    box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    background: #007bff;
    color: white;
    padding: 10px;
    text-align: center;
    font-size: 16px;
    position: relative;
}

.close-chat {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 22px;
    font-weight: bold;
    padding: 5px 10px;
    transition: color 0.3s;
}

    .close-chat:hover {
        color: #ffcccb;
    }

.chat-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Setting A4 preview modal */
#excelPreviewModal .modal-dialog, #excelPreviewModal .modal-content {
    width: 210mm;
    max-width: 95vw;
    margin: auto;
    height: 100vh;
    max-height: 100vh !important;
}

#excelPreviewModal iframe {
    width: 100%;
    height: 100vh;
    display: block;
    zoom: 0.7;
}

#excelPreviewModal .modal-footer .btn {
    padding: .25rem .5rem;
    font-size: .85rem;
    margin: 0 .25rem;
}

#excelPreviewModal .modal-footer, #excelPreviewModal .modal-header {
    padding: 0 1rem;
}


.result {
    /* common styles for all icons with tooltips */
    position: relative;
}

    .result::after {
        /* hide default tooltip and style custom tooltip box */
        content: '';
        position: absolute;
        bottom: 125%;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.8);
        color: #fff;
        padding: 4px 8px;
        border-radius: 4px;
        white-space: nowrap;
        font-size: 12px;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.2s ease;
        z-index: 10;
    }

    .result:hover::after,
    .result:hover::before {
        /* show tooltip on hover */
        opacity: 1;
    }

    /* map each icon’s classes to its specific tooltip text */
    .result.fas.fa-times-circle.text-danger:hover::after {
        content: "Hoàn thành – không đạt";
    }

    .result.fas.fa-check-circle.text-info:hover::after {
        content: "Hoàn thành – đạt";
    }

    .result.fas.fa-check-circle.text-success:hover::after {
        content: "Hoàn thành – đạt";
    }

    .result.fas.fa-exclamation-circle.text-warning:hover::after {
        content: "Đạt - chưa hoàn thành";
    }

    .result.fas.fa-times-circle.text-warning:hover::after {
        content: "Không đạt - chưa hoàn thành";
    }

    .result.fas.fa-exclamation-triangle.text-primary:hover::after {
        content: "Chưa kiểm tra xong";
    }

    .result.fas.fa-times-circle.text-dark:hover::after {
        content: "Chưa kiểm tra";
    }

    .result.tf.fas.fa-check-circle.text-success:hover::after {
        content: "Đã hoàn thành";
    }

    .result.tf.fas.fa-exclamation-triangle.text-primary:hover::after {
        content: "Đang kiểm tra";
    }

    .result.tf.fas.fa-times-circle.text-dark:hover::after {
        content: "Chưa kiểm tra";
    }

    /* Icon for experiments that don't require conclusion */
    .result.fas.fa-minus-circle.text-muted:hover::after {
        content: "Thí nghiệm không yêu cầu kết luận";
    }
    .result.fa-minus-circle.text-success:hover::after {
        content: "Thí nghiệm không yêu cầu kết luận - Hoàn thành";
    }
