:root {
    --primary-color: #1a5276;
    --secondary-color: #2874a6;
    --accent-color: #f39c12;
    --light-color: #f8f9fa;
    --dark-color: #2c3e50;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --sidebar-width: 260px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Kanit', sans-serif;
}

body {
    background-color: #f5f8fa;
    color: #333;
    line-height: 1.6;
}

.btn-table-action {
    padding: 2px 8px;
    font-size: 12px;
    line-height: 1.5;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    background-color: var(--primary-color);
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-block;
    margin: 0 2px;
}

.btn-table-action:hover {
    background-color: #e9ecef;
    color: #212529;
    text-decoration: none;
}

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 15px;
}

/* Header Styles */
header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.top-header {
    background-color: rgba(0, 0, 0, 0.1);
    padding: 8px 0;
    font-size: 14px;
}

/* Animation for Header Scroll */
.top-header,
.main-header {
    transition: all 0.3s ease-in-out;
    max-height: 200px;
    /* กำหนดความสูงเผื่อไว้ให้พอดีกับเนื้อหา */
    opacity: 1;
    overflow: hidden;
}

header.scrolled-hide .top-header,
header.scrolled-hide .main-header {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

.top-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.social-links a {
    color: white;
    margin-left: 15px;
    text-decoration: none;
    transition: opacity 0.3s;
}

.social-links a:hover {
    opacity: 0.8;
}

.main-header {
    padding: 15px 0;
}

.logo-section {
    display: flex;
    align-items: center;
}

.logo {
    width: 75px;
    height: 75px;
    background-color: white;
    background-image: url("/assets/images/h_monitor100x100.png");
    background-size: cover;
    /* ให้รูปพอดี */
    background-position: center;
    /* จัดกึ่งกลาง */
    background-repeat: no-repeat;

    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;

    margin-right: 15px;
    font-weight: bold;
    color: var(--primary-color);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}


.site-title h1 {
    font-size: 24px;
    margin-bottom: 5px;
}

.site-title p {
    font-size: 14px;
    opacity: 0.9;
}

/* Navigation */
nav {
    background-color: var(--secondary-color);
}

.nav-container {
    display: flex;
    justify-content: space-between;
}

.main-nav {
    display: flex;
    list-style: none;
}

.main-nav li {
    position: relative;
}

.main-nav a {
    color: white;
    text-decoration: none;
    padding: 15px 20px;
    display: block;
    transition: background-color 0.3s;
}

.main-nav a:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.dropdown-menu {
    position: absolute;
    background-color: white;
    min-width: 200px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: none;
    z-index: 100;
    border-radius: 0 0 5px 5px;
    overflow: hidden;
}

.dropdown-menu a {
    color: var(--dark-color);
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    transition: background-color 0.3s;
}

.dropdown-menu a:hover {
    background-color: #f5f5f5;
}

.dropdown:hover .dropdown-menu {
    display: block;
}

.search-box {
    display: flex;
    align-items: center;
    padding: 8px 0;
}

.search-box input {
    padding: 8px 12px;
    border: none;
    border-radius: 4px 0 0 4px;
    width: 200px;
    transition: width 0.3s;
}

.search-box input:focus {
    width: 250px;
    outline: none;
}

.search-box button {
    background-color: var(--accent-color);
    border: none;
    color: white;
    padding: 8px 15px;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    transition: background-color 0.3s;
}

.search-box button:hover {
    background-color: #e67e22;
}

/* Grid System (Bootstrap-like) */
.row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -15px;
    /* Gutter compensation */
    margin-left: -15px;
    /* Gutter compensation */
}

.col-md-6 {
    position: relative;
    width: 100%;
    padding-right: 15px;
    /* Gutter */
    padding-left: 15px;
    /* Gutter */
    margin-bottom: 20px;
    /* Vertical spacing */
}

/* On medium screens (>= 768px), make columns 50% wide */
@media (min-width: 768px) {
    .col-md-6 {
        flex: 0 0 50%;
        max-width: 50%;
    }
}

/* Main Content with Sidebar */
.main-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px 15px;
    gap: 30px;
}

.sidebar {
    /* width: var(--sidebar-width); */
}

.content-area {
    min-width: 0;
}

.sidebar-card {
    background-color: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
    transition: transform 0.3s, box-shadow 0.3s;
}

.sidebar-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.sidebar-title {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 15px;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-links {
    list-style: none;
}

.sidebar-links li {
    border-bottom: 1px solid #eee;
}

.sidebar-links li:last-child {
    border-bottom: none;
}

.sidebar-links a {
    display: block;
    padding: 12px 15px;
    color: var(--dark-color);
    text-decoration: none;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-links a:hover {
    background-color: #f8f9fa;
    color: var(--primary-color);
    padding-left: 20px;
}

.sidebar-links a.active {
    background-color: var(--light-color);
    color: var(--primary-color);
    font-weight: 500;
    border-left: 4px solid var(--accent-color);
}

.section-title {
    font-size: 24px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Dashboard Cards */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.dashboard-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s, box-shadow 0.3s;
}

.dashboard-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.card-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
}

.card-icon.primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.card-icon.success {
    background: linear-gradient(135deg, var(--success-color), #2ecc71);
}

.card-icon.warning {
    background: linear-gradient(135deg, var(--warning-color), #f1c40f);
}

.card-icon.danger {
    background: linear-gradient(135deg, var(--danger-color), #e74c3c);
}

.card-value {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 5px;
}

.card-title {
    font-size: 14px;
    color: #666;
}

.card-trend {
    display: flex;
    align-items: center;
    margin-top: 10px;
    font-size: 14px;
}

.trend-up {
    color: var(--success-color);
}

.trend-down {
    color: var(--danger-color);
}

/* Filter Section */
.filter-section {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

.filter-title {
    font-size: 18px;
    margin-bottom: 15px;
    color: var(--primary-color);
}

.filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 15px;
}

.filter-item {
    flex: 1;
    min-width: 200px;
}

.filter-item label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.filter-item select,
.filter-item input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #f8f9fa;
    transition: border-color 0.3s;
}

.filter-item select:focus,
.filter-item input:focus {
    border-color: var(--primary-color);
    outline: none;
}

.filter-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.btn {
    display: inline-block;
    background-color: var(--accent-color);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    background-color: #e67e22;
}

.btn-primary {
    background-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #154360;
}

.btn-primary.active {
    background-color: var(--accent-color);
    border-color: #e67e22;
}

.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.btn-success {
    background-color: var(--success-color);
}

.btn-success:hover {
    background-color: #219653;
}

/* Chart Section */
.chart-section {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

.chart-container {
    height: 400px;
    position: relative;
}

/* Table Section */
.table-section {
    background-color: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.data-table th,
.data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.data-table th {
    background-color: #f8f9fa;
    color: var(--primary-color);
    font-weight: 500;
}

.data-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.data-table tr:hover {
    background-color: #f1f1f1;
}

.status-badge {
    display: inline-block;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-success {
    background-color: rgba(39, 174, 96, 0.1);
    color: var(--success-color);
}

.status-warning {
    background-color: rgba(243, 156, 18, 0.1);
    color: var(--warning-color);
}

.status-danger {
    background-color: rgba(231, 76, 60, 0.1);
    color: var(--danger-color);
}

/* Footer */
footer {
    background: linear-gradient(135deg, var(--dark-color), #34495e);
    color: white;
    padding: 50px 0 20px;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
    margin-bottom: 30px;
}

.footer-column h3 {
    font-size: 18px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-links {
    list-style: none;
}

.footer-links li {
    margin-bottom: 10px;
}

.footer-links a {
    color: #ddd;
    text-decoration: none;
    transition: color 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-links a:hover {
    color: white;
}

.contact-info {
    margin-bottom: 15px;
}

.contact-info i {
    margin-right: 10px;
    color: var(--accent-color);
}

.copyright {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 14px;
    color: #fff;
}

.copyright a {
    color: #fff;
}

/* Responsive */
@media (max-width: 992px) {

    .sidebar {
        width: 100%;
    }

    .sidebar-card {
        margin-bottom: 15px;
    }
}

@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
    }

    .main-nav {
        flex-wrap: wrap;
    }

    .search-box {
        margin-top: 10px;
        width: 100%;
    }

    .search-box input {
        width: 100%;
    }

    .filter-group {
        flex-direction: column;
    }

    .filter-item {
        min-width: 100%;
    }
}

.table-wrapper {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    max-height: 70vh;
    border: 1px solid #eee;
    border-radius: 8px;
}

.report-table {
    border-collapse: collapse;
    width: 100%;
    min-width: max-content;
}

.report-table th,
.report-table td {
    padding: 12px 15px;
    /*text-align: center;*/
    white-space: nowrap;
    border: 1px solid #eee;
    font-size: 14px;
}

/* ===== HEADER ===== */
.report-table thead th {
    background-color: #f8f9fa;
    color: var(--primary-color);
    font-weight: 500;
    position: sticky;
    top: 0;
    z-index: 3;
    border-bottom: 2px solid #ddd;
}

/* ===== STICKY FIRST COLUMN ===== */
.sticky-col {
    position: sticky;
    left: 0;
    z-index: 2;
    text-align: left;
    min-width: 250px;
    background-color: #fff;
    border-right: 2px solid #eee;
}

/* sticky header + sticky col ซ้อนกัน */
thead .sticky-col {
    z-index: 4;
    background-color: #f8f9fa;
}

/* ===== BODY ===== */
.report-table tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

.report-table tbody tr:nth-child(even) .sticky-col {
    background-color: #f9f9f9;
}

.report-table tbody tr:hover {
    background-color: #f1f1f1;
}

.report-table tbody tr:hover .sticky-col {
    background-color: #f1f1f1;
}

/* ===== FOOTER ===== */
.report-table tfoot td {
    background-color: var(--primary-color);
    color: #fff;
    font-weight: bold;
}

.report-table tfoot .sticky-col {
    background-color: var(--primary-color);
    color: #fff;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.85);
    /* พื้นหลังขาวจางๆ */
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    backdrop-filter: blur(4px);
    /* เบลอฉากหลัง */
}

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid #e0e0e0;
    border-top: 6px solid var(--primary-color);
    /* สีหมุนตามธีมหลัก */
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.loading-text {
    font-size: 1.2rem;
    color: var(--primary-color);
    font-weight: 600;
    letter-spacing: 1px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.custom-modal {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 400px;
    overflow: hidden;
    animation: slideDown 0.3s ease-out;
}

.custom-modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.custom-modal-title {
    margin: 0;
    font-size: 1.25rem;
    color: #333;
}

.custom-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #888;
}

.custom-modal-body {
    padding: 30px 20px;
    text-align: center;
}

.custom-modal-icon {
    font-size: 3rem;
    color: #28a745;
    margin-bottom: 15px;
}

.custom-modal-message {
    font-size: 1.1rem;
    color: #555;
    margin: 0;
}

.custom-modal-footer {
    padding: 15px 20px;
    background-color: #f8f9fa;
    text-align: center;
}

@keyframes slideDown {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.team-grid{
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 20px;
}
