/* Main Stylesheet for GW Data Center — Modern theme */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Thai:wght@300;400;500;600;700&family=Prompt:wght@500;600;700&display=swap');

:root {
    --sidebar-width: 268px;
    --primary-color: #4f46e5;
    --primary-soft: #eef2ff;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --success-soft: #ecfdf5;
    --info-color: #06b6d4;
    --info-soft: #ecfeff;
    --warning-color: #f59e0b;
    --warning-soft: #fffbeb;
    --danger-color: #ef4444;
    --danger-soft: #fef2f2;
    --dark-color: #1e293b;
    --muted-color: #64748b;
    --light-color: #f1f5f9;
    --border-color: #e2e8f0;
    --sidebar-bg: #0f172a;
    --radius: 18px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 2px 8px rgba(15, 23, 42, .04);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, .06), 0 12px 32px rgba(15, 23, 42, .06);
    --gradient-brand: linear-gradient(135deg, #22d3ee 0%, #3b82f6 55%, #6366f1 100%);

    /* Bootstrap overrides */
    --bs-primary: #4f46e5;
    --bs-primary-rgb: 79, 70, 229;
    --bs-success: #10b981;
    --bs-success-rgb: 16, 185, 129;
    --bs-info-rgb: 6, 182, 212;
    --bs-body-color: #1e293b;
    --bs-link-color: #4f46e5;
    --bs-link-color-rgb: 79, 70, 229;
}

body {
    font-family: 'IBM Plex Sans Thai', 'Sarabun', sans-serif;
    background:
        radial-gradient(1200px 500px at 100% -10%, rgba(99, 102, 241, .08), transparent 60%),
        radial-gradient(900px 400px at 20% -10%, rgba(34, 211, 238, .08), transparent 60%),
        var(--light-color);
    background-attachment: fixed;
    color: var(--dark-color);
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, .page-title, .stat-value {
    font-family: 'Prompt', 'IBM Plex Sans Thai', sans-serif;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; background-clip: padding-box; }

/* ================= Sidebar ================= */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background:
        radial-gradient(400px 300px at 0% 0%, rgba(59, 130, 246, .25), transparent 70%),
        radial-gradient(300px 300px at 100% 100%, rgba(99, 102, 241, .18), transparent 70%),
        var(--sidebar-bg);
    color: white;
    transition: all 0.3s;
    z-index: 1050;
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.15);
    overflow-y: auto;
}

.sidebar-overlay { display: none; }

@media (max-width: 991.98px) {
    .sidebar { margin-left: calc(-1 * var(--sidebar-width)); }
    .sidebar.toggled { margin-left: 0; }
    .main-content { margin-left: 0 !important; padding: 18px !important; }
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.5);
        backdrop-filter: blur(2px);
        z-index: 1040;
    }
    .sidebar-overlay.show { display: block; }
}

.sidebar-brand {
    text-decoration: none;
    padding: 1.4rem 1.25rem;
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.sidebar-brand img {
    width: 44px;
    height: 44px;
    filter: drop-shadow(0 6px 14px rgba(59, 130, 246, .45));
    transition: transform .4s;
}

.sidebar-brand:hover img { transform: rotate(-8deg) scale(1.05); }

.sidebar-brand .brand-title {
    font-family: 'Prompt', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: .2px;
}

.sidebar-brand .brand-title span {
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.sidebar-brand .brand-sub {
    font-size: .72rem;
    color: rgba(255, 255, 255, .5);
    letter-spacing: .08em;
    text-transform: uppercase;
}

.sidebar .nav { padding: 0 .75rem; }

.sidebar .nav-link {
    color: rgba(255, 255, 255, 0.68);
    padding: 11px 14px;
    margin: 3px 0;
    font-weight: 500;
    font-size: .93rem;
    border-radius: 12px;
    border: 0;
    transition: all 0.25s;
    display: flex;
    align-items: center;
}

.sidebar .nav-link i {
    margin-right: 12px;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(255, 255, 255, .06);
    font-size: .9rem;
    flex-shrink: 0;
    transition: all .25s;
}

.sidebar .nav-link:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.06);
    transform: translateX(3px);
}

.sidebar .nav-link.active {
    color: white;
    background: linear-gradient(135deg, rgba(59, 130, 246, .35), rgba(99, 102, 241, .25));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08), 0 8px 20px rgba(59, 130, 246, .2);
}

.sidebar .nav-link.active i {
    background: var(--gradient-brand);
    color: #fff;
    box-shadow: 0 4px 12px rgba(59, 130, 246, .5);
}

.sidebar-heading {
    text-transform: uppercase;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 1.4rem .9rem 0.4rem;
    color: rgba(255, 255, 255, 0.35);
    letter-spacing: 0.12em;
}

.sidebar-footer {
    margin: 1rem;
    padding: .9rem 1rem;
    border-radius: 14px;
    background: rgba(255, 255, 255, .04);
    border: 1px solid rgba(255, 255, 255, .06);
    font-size: .78rem;
    color: rgba(255, 255, 255, .5);
}

.sidebar-footer .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--success-color);
    display: inline-block;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, .6);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .6); }
    70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ================= Main Content ================= */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 28px 32px;
    transition: all 0.3s;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Page header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.page-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0;
    color: var(--dark-color);
    letter-spacing: -.3px;
}

.page-subtitle {
    color: var(--muted-color);
    font-size: .9rem;
    margin: 2px 0 0;
}

.page-icon {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-brand);
    color: #fff;
    font-size: 1.3rem;
    box-shadow: 0 10px 24px rgba(59, 130, 246, .35);
    flex-shrink: 0;
}

.btn-toggle-sidebar {
    width: 44px; height: 44px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.breadcrumb {
    background: #fff;
    padding: .5rem 1rem;
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
    font-size: .85rem;
}

.breadcrumb a { text-decoration: none; font-weight: 500; }

.live-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border-radius: 999px;
    padding: .45rem .9rem;
    font-size: .82rem;
    color: var(--muted-color);
    box-shadow: var(--shadow-sm);
}

.live-chip .dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--success-color);
    animation: pulse-dot 2s infinite;
}

/* ================= Cards ================= */
.card {
    border: 1px solid rgba(226, 232, 240, .7);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    background: #fff;
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1.1rem 1.5rem;
    font-weight: 600;
    color: var(--dark-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: var(--radius) var(--radius) 0 0 !important;
}

.card-body { padding: 1.4rem 1.5rem; }

.card-title-icon {
    width: 34px; height: 34px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    font-size: .9rem;
}

.card-title-icon.primary { background: var(--primary-soft); color: var(--primary-color); }
.card-title-icon.success { background: var(--success-soft); color: var(--success-color); }
.card-title-icon.info { background: var(--info-soft); color: var(--info-color); }
.card-title-icon.warning { background: var(--warning-soft); color: var(--warning-color); }

.card-title { font-family: 'Prompt', sans-serif; font-weight: 600; }

/* ================= Filter Bar ================= */
.filter-card { overflow: visible; }

.filter-card .form-label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--muted-color);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: .4rem;
}

.form-select, .form-control {
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: .6rem 1rem;
    background-color: #f8fafc;
    font-size: .93rem;
    transition: all .2s;
}

.form-select:focus, .form-control:focus {
    border-color: #818cf8;
    background-color: #fff;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, .12);
}

.form-select:disabled { background-color: #f1f5f9; color: #94a3b8; }

/* Segmented control (hospital type) */
.segmented {
    display: flex;
    background: #f1f5f9;
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
    border: 1px solid var(--border-color);
}

.segmented input { display: none; }

.segmented label {
    flex: 1;
    text-align: center;
    padding: .45rem .5rem;
    border-radius: 9px;
    cursor: pointer;
    font-size: .86rem;
    font-weight: 500;
    color: var(--muted-color);
    transition: all .2s;
    white-space: nowrap;
    margin: 0;
}

.segmented label:hover { color: var(--dark-color); }

.segmented input:checked + label {
    background: #fff;
    color: var(--primary-color);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .08);
}

.segmented label .count {
    display: inline-block;
    min-width: 22px;
    font-size: .72rem;
    padding: 1px 6px;
    border-radius: 999px;
    background: #e2e8f0;
    color: var(--muted-color);
    margin-left: 4px;
}

.segmented input:checked + label .count { background: var(--primary-soft); color: var(--primary-color); }

/* Buttons */
.btn { border-radius: 12px; font-weight: 600; padding: .6rem 1.1rem; }

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #4f46e5);
    border: 0;
    box-shadow: 0 6px 16px rgba(79, 70, 229, .3);
    transition: all .2s;
}

.btn-primary:hover, .btn-primary:focus {
    background: linear-gradient(135deg, #2563eb, #4338ca);
    transform: translateY(-1px);
    box-shadow: 0 10px 20px rgba(79, 70, 229, .35);
}

.btn-light-soft {
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    color: var(--muted-color);
}

.btn-light-soft:hover { background: #e2e8f0; color: var(--dark-color); }

/* ================= Stat Cards ================= */
.stat-card {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius);
    padding: 1.25rem 1.35rem;
    background: #fff;
    border: 1px solid rgba(226, 232, 240, .7);
    box-shadow: var(--shadow-sm);
    height: 100%;
    transition: transform .25s, box-shadow .25s;
}

.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.stat-card::after {
    content: '';
    position: absolute;
    width: 140px; height: 140px;
    right: -50px; top: -50px;
    border-radius: 50%;
    background: var(--accent-soft, #eef2ff);
    opacity: .7;
}

.stat-card .stat-icon {
    position: relative;
    z-index: 1;
    width: 48px; height: 48px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    color: #fff;
    background: var(--accent, #4f46e5);
    box-shadow: 0 8px 18px var(--accent-shadow, rgba(79, 70, 229, .3));
}

.stat-card .stat-body { position: relative; z-index: 1; }

.stat-card.accent-dark    { --accent: linear-gradient(135deg, #334155, #0f172a); --accent-soft: #f1f5f9; --accent-shadow: rgba(15, 23, 42, .25); }
.stat-card.accent-primary { --accent: linear-gradient(135deg, #3b82f6, #4f46e5); --accent-soft: #eef2ff; --accent-shadow: rgba(79, 70, 229, .3); }
.stat-card.accent-info    { --accent: linear-gradient(135deg, #22d3ee, #0891b2); --accent-soft: #ecfeff; --accent-shadow: rgba(6, 182, 212, .3); }
.stat-card.accent-success { --accent: linear-gradient(135deg, #34d399, #059669); --accent-soft: #ecfdf5; --accent-shadow: rgba(16, 185, 129, .3); }
.stat-card.accent-warning { --accent: linear-gradient(135deg, #fbbf24, #d97706); --accent-soft: #fffbeb; --accent-shadow: rgba(245, 158, 11, .3); }

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.15;
    color: var(--dark-color);
    margin: .65rem 0 0;
    letter-spacing: -.5px;
}

.stat-value small { font-size: 1rem; color: var(--muted-color); font-weight: 500; }

.stat-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--muted-color);
    margin: 0;
}

.stat-progress {
    height: 6px;
    border-radius: 999px;
    background: #f1f5f9;
    margin-top: .75rem;
    overflow: hidden;
}

.stat-progress .bar {
    height: 100%;
    border-radius: 999px;
    background: var(--accent);
    transition: width .8s cubic-bezier(.22, 1, .36, 1);
}

/* Legacy counters (kept for other modules) */
.card-counter { border-radius: 14px; transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1); }
.card-counter:hover { transform: translateY(-3px); box-shadow: var(--shadow-md) !important; }

/* Menu Card Styles (from HPV module) */
.menu-card {
    border: 1px solid rgba(226, 232, 240, .7);
    border-radius: var(--radius);
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    overflow: hidden;
}

.menu-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-md); }

.icon-circle {
    width: 60px; height: 60px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.bg-gradient-primary { background: var(--gradient-brand); }

/* ================= Charts ================= */
.chart-scroll-wrapper { width: 100%; overflow-x: auto; padding-bottom: 6px; }
.chart-inner { height: 400px; position: relative; }
.chart-inner-small { height: 300px; position: relative; }
.chart-container { position: relative; height: 400px; width: 100%; }

/* ================= DataTables ================= */
.dt-buttons .btn, .dt-buttons .dt-button {
    background: var(--success-soft) !important;
    color: #047857 !important;
    border: 1px solid #a7f3d0 !important;
    border-radius: 10px !important;
    padding: 6px 14px !important;
    font-size: 0.86rem;
    font-weight: 600;
    margin-right: 6px;
    transition: all 0.2s;
}

.dt-buttons .btn:hover, .dt-buttons .dt-button:hover { background: #d1fae5 !important; }

div.dataTables_wrapper .row { margin-right: 0; margin-left: 0; }

div.dataTables_wrapper div.dataTables_filter {
    text-align: right;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

div.dataTables_wrapper div.dataTables_filter label {
    font-weight: normal;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    color: var(--muted-color);
}

div.dataTables_wrapper div.dataTables_filter input {
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: #f8fafc;
    padding: 6px 12px;
    margin-left: 0.5rem;
    width: auto;
    max-width: 200px;
}

div.dataTables_wrapper div.dataTables_info { color: var(--muted-color); font-size: .86rem; }

.page-link { border: 0; border-radius: 8px !important; margin: 0 2px; color: var(--muted-color); }
.page-item.active .page-link { background: var(--gradient-brand); color: #fff; }

@media (max-width: 768px) {
    div.dataTables_wrapper div.dataTables_filter { justify-content: flex-start; margin-top: 10px; }
    div.dataTables_wrapper div.dataTables_filter input { width: 100%; max-width: 200px; }
    .dt-buttons { margin-bottom: 10px; }
    .stat-value { font-size: 1.6rem; }
}

table.dataTable { border-collapse: separate !important; border-spacing: 0; }

table.dataTable thead th,
table.dataTable thead td {
    background: #f8fafc !important;
    color: var(--muted-color) !important;
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border-color) !important;
    vertical-align: middle;
    white-space: nowrap;
}

table.dataTable tbody td {
    white-space: nowrap;
    vertical-align: middle;
    border-color: #f1f5f9 !important;
    font-size: .92rem;
}

table.dataTable tbody tr:hover > * { background-color: #f8fafc !important; box-shadow: none !important; }

.table-bordered > :not(caption) > * > * { border-width: 0 0 1px 0; }
.table-bordered > :not(caption) > * { border-width: 0; }

/* Table badges */
.badge-status {
    padding: 6px 12px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.78rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.badge-status::before {
    content: '';
    width: 7px; height: 7px;
    border-radius: 50%;
    background: currentColor;
}

.bg-connected { background-color: var(--success-soft); color: #047857; }
.bg-disconnected { background-color: var(--danger-soft); color: #b91c1c; }
.bg-never { background-color: #f1f5f9; color: #64748b; }

.badge-type {
    padding: 4px 10px;
    border-radius: 8px;
    font-size: .75rem;
    font-weight: 600;
}

.badge-type.hosp { background: var(--primary-soft); color: var(--primary-color); }
.badge-type.pcu { background: var(--info-soft); color: #0e7490; }

/* Borders / text helpers (legacy) */
.border-left-primary { border-left: 0.3rem solid var(--primary-color) !important; }
.border-left-success { border-left: 0.3rem solid var(--success-color) !important; }
.border-left-info { border-left: 0.3rem solid var(--info-color) !important; }
.border-left-warning { border-left: 0.3rem solid var(--warning-color) !important; }
.border-left-secondary { border-left: 0.3rem solid var(--secondary-color) !important; }
.border-left-dark { border-left: 0.3rem solid var(--dark-color) !important; }
.border-left-black { border-left: 0.3rem solid #0f172a !important; }
.text-gray-300 { color: #cbd5e1 !important; }
.text-gray-800 { color: #1e293b !important; }

/* Fade-in animation */
.fade-up { animation: fadeUp .5s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
