* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    display: flex;
    height: 100vh;
    background-color: #1e1e24;
    color: #fff;
    overflow: hidden;
    position: relative;
}

a { text-decoration: none; }
a:hover { text-decoration: underline; }

.toast-container {
    position: fixed;
    top: 0px;
    left: calc(50% - 150px);
    z-index: 9999;
}

.toast {
    line-height: 1.4;
    width: 300px;               /* Cố định chiều rộng */
    /*height: 60px;*/
    padding: 10px 30px 10px 10px;
    margin-bottom: 10px;
    color: white;
    border-radius: 6px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    font-size: 14px;
    text-align: justify;

    display: flex;
    align-items: center;        /* Căn giữa dọc */
    justify-content: justify;    /* Căn giữa ngang */

    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.4s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.hide {
    opacity: 0;
    transform: translateY(-20px);
}

.toast.info { background: #0ec554;}
.toast.error { background: #f74e59; }
.toast.warning { background: #db9b2d; }

.toast-close {
    position: absolute;
    top: 4px;
    right: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    color: white;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.toast-close:hover {
    opacity: 1;
}

/* --- SIDEBAR ĐIỀU KHIỂN & BIẾN ĐỔI THU NHỎ --- */
#sidebar {
    width: 320px;
    background-color: #2a2b36;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    border-right: 2px solid #3e3f4b;
    overflow-y: auto;
    transition: all 0.3s ease;
    z-index: 10;
}

/* Khi sidebar bị thu nhỏ */
#sidebar.collapsed {
    width: 0;
    padding: 20px 0;
    overflow: hidden;
    border-right: none;
    pointer-events: none;
}

/* Nút Thu nhỏ / Mở rộng */
#toggle-sidebar {
    position: absolute;
    left: 320px;
    top: 5px;
    background-color: #00adb5;
    color: #fff;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    z-index: 100;
    font-weight: bold;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: left 0.3s ease;
    box-shadow: 2px 0 5px rgba(0,0,0,0.3);
}

body.sidebar-collapsed #toggle-sidebar {
    left: 0;
}

/* --- UI SIDEBAR --- */
h3 {
    border-bottom: 1px solid #4e5062;
    padding-bottom: 5px;
    margin-bottom: 10px;
    color: #00adb5;
    font-size: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 10px;
}

input, select, button {
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #4e5062;
    background-color: #3e3f4b;
    color: #fff;
    outline: none;
}

button {
    background-color: #00adb5;
    color: white;
    font-weight: bold;
    cursor: pointer;
    border: none;
    transition: background 0.2s;
}

button:hover {
    background-color: #008c9e;
}

.space {flex-grow: 1}

#loading {
    position: absolute;  
    padding: 10px 30px;
    background: white;
    color: black;
    border-radius: 5px; 
    left: calc(50% - 50px);
    top: 300px;
    display: none;
}

/* Danh sách thiết bị tạo sẵn */
.device-item {
    position: relative;
    background-color: #3a3b4c;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 6px;
    border-left: 4px solid #00adb5;
    overflow: hidden;
}

.collapse {
    height: 70px;
}

.btn-collapse {
    position: absolute;
    right: 10px;
    top: 7px;
    cursor: pointer;
}

.drag-source {
    background-color: #4e5062;
    padding: 6px;
    margin: 5px 0;
    border-radius: 4px;
    cursor: grab;
    user-select: none;
    font-size: 13px;
    display: flex;
    justify-content: space-between;
}

.drag-source:active {
    cursor: grabbing;
}

/* --- KHU VỰC DASHBOARD --- */
#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

#dashboard-header {
    display: flex;
    align-items: center;
    background-color: #2a2b36;
    padding: 5px 20px 5px 50px;
    border-bottom: 2px solid #3e3f4b;
}

#dash-title {font-size: 1.1rem;}
#btn-update-dash {margin-right: 20px}

#lUsername {margin-right: 20px}

#dashboard-view {
    flex: 1;
    position: relative;
    background-color: #121214;
    background-size: cover;
    background-position: center;
    overflow: auto;
}

/* --- WIDGETS TRÊN DASHBOARD --- */
.dashboard-widget {
    position: absolute;
    background-color: rgba(42, 43, 54, 0.9);
    border: 2px solid #00adb5;
    border-radius: 6px;
    padding: 6px;
    min-width: 60px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    cursor: move;
    backdrop-filter: blur(5px);
}

.widget-header {
    font-weight: bold;
    font-size: 12px;
    color: #00adb5;
    border-bottom: 1px solid #4e5062;
    padding-bottom: 4px;
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.widget-remove {
    color: #ff2e63;
    cursor: pointer;
    font-weight: bold;
    font-size: 16px;
    padding-left: 10px;
}

.widget-body {
    font-size: 15px;
    font-weight: bold;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(calc(50% - 10px), 1fr));
}

/* Giao diện danh sách point bên trong khối thiết bị tổng */
.widget-sub-item {
    background: rgba(255,255,255,0.05);
    padding: 3px 8px;
    margin-top: 1px;
    font-size: 13px;
    font-weight: normal;
    display: flex;
}

/*********************************************/
/* Toggle switch */
/*********************************************/

/* Ẩn checkbox mặc định của trình duyệt */
.toggle-switch input {
    display: none;
}

/* Tạo kiểu dáng cho nút gạt (thanh trượt) */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 16px;
}

/* Màu nền của thanh trượt khi ở trạng thái OFF */
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 34px;
}

/* Nút tròn nhỏ bên trong thanh trượt */
.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 0px;
    bottom: 0px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

/* Đổi màu nền thanh trượt thành màu xanh khi bật ON */
input:checked + .slider {
    background-color: #2196F3;
}

/* Di chuyển nút tròn sang phải khi bật ON */
input:checked + .slider:before {
    transform: translateX(16px);
}
/*******************************************/