/* =====================================================
   RPC 사일로 모니터링 대시보드 - 전역 스타일
   Pretendard 폰트 + CSS 변수 + 반응형 그리드
   ===================================================== */
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css');

/* ==================== CSS Variables ==================== */
:root {
    --sidebar-bg: #1a1c3a;
    --sidebar-active: #3d4bce;
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-width: 240px;

    --content-bg: #f1f3f9;
    --card-bg: #ffffff;
    --card-border: #e8eaf4;

    --primary: #3559cb;
    --primary-light: #e9effc;
    --secondary: #6b7cdb;
    --accent: #35c884;
    --accent-cyan: #309ce4;
    --warning: #f59e0b;
    --danger: #ef4444;

    --text-primary: #1e2240;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;

    --header-height: 64px;
    --radius-card: 16px;
    --radius-btn: 8px;
}

/* ==================== Reset ==================== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size:20px;
    background: var(--content-bg);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    height: 100%;
}

a {
    text-decoration: none;
    color: inherit;
}

ul,
ol {
    list-style: none;
}

button {
    font-family: inherit;
    cursor: pointer;
}

/* ==================== Layout ==================== */
#app {
    display: flex;
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
    transition: transform 0.25s ease;
}

.sidebar-logo {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logo h1 {
    font-size:19px;
    font-weight: 700;
    color: #fff;
    line-height: 1.4;
}

.sidebar-logo span {
    font-size:15px;
    color: rgba(255, 255, 255, 0.45);
    font-weight: 400;
}

.sidebar-nav {
    padding: 12px 0;
    flex: 1;
}

.nav-section-label {
    font-size:14px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 16px 20px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    font-size:18px;
    color: rgba(255, 255, 255, 0.65);
    border-radius: 0;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.nav-item.active {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
}

.nav-item svg {
    flex-shrink: 0;
    opacity: 0.8;
}

.nav-item.active svg {
    opacity: 1;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size:17px;
    color: rgba(255, 255, 255, 0.45);
}

.sidebar-footer a {
    color: rgba(255, 255, 255, 0.45);
    font-size:17px;
}

.sidebar-footer a:hover {
    color: #fff;
}

/* ---- Main wrapper ---- */
.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ---- Header ---- */
.page-header {
    height: var(--header-height);
    background: #fff;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 14px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-header .hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    background: white;
    cursor: pointer;
    flex-shrink: 0;
}

.page-header .page-title {
    font-size:21px;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
}

.header-meta {
    font-size:17px;
    color: var(--text-secondary);
}

/* ---- Main content ---- */
.main-content {
    padding: 20px 24px;
    flex: 1;
}

/* ==================== Card ==================== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-card);
    padding: 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

/* ==================== Scrollbar ==================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ==================== Grid helpers ==================== */
.grid-4col {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.grid-2col {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
}

.grid-3col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

/* ==================== Usage Bar ==================== */
.usage-bar-track {
    height: 8px;
    background: #e9effc;
    border-radius: 99px;
    overflow: hidden;
}

.usage-bar-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 1.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==================== Data Table ==================== */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 480px;
}

.data-table th {
    padding: 10px 14px;
    text-align: left;
    font-size:17px;
    font-weight: 600;
    color: var(--text-secondary);
    background: #f8f9fc;
    border-bottom: 1px solid var(--card-border);
    white-space: nowrap;
}

.data-table td {
    padding: 13px 14px;
    border-bottom: 1px solid #f1f3f9;
    font-size:18px;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr:hover td {
    background: #f8f9ff;
}

/* ==================== Badge ==================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size:16px;
    font-weight: 600;
}

.badge-green {
    background: #dcfce7;
    color: #16a34a;
}

.badge-yellow {
    background: #fef9c3;
    color: #ca8a04;
}

.badge-red {
    background: #fee2e2;
    color: #dc2626;
}

.badge-gray {
    background: #f3f4f6;
    color: #6b7280;
}

/* ==================== Gauge SVG (TotalWeight) ==================== */
.gauge-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.gauge-svg {
    width: 100%;
    max-width: 280px;
}

/* ==================== Bar Chart ==================== */
.bar-chart-wrap {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    min-height: 180px;
    overflow-x: auto;
    overflow-y: visible;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
    padding-bottom: 2px;
}

.bar-chart-wrap::-webkit-scrollbar { height: 4px; }
.bar-chart-wrap::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.bar-col {
    flex: 1;
    min-width: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.bar-col .bar-val {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.bar-col .bar-fill {
    width: 100%;
    border-radius: 5px 5px 0 0;
    transition: height 1.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.bar-col .bar-label {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.3;
    white-space: nowrap;
}

/* ==================== Animations ==================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-in {
    animation: fadeIn 0.3s ease forwards;
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(0);
    }
}

/* ==================== Overlay ==================== */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 49;
}

.sidebar-overlay.show {
    display: block;
}

/* ==================== Summary Card ==================== */
.summary-card {
    display: flex;
    align-items: center;
    gap: 14px;
}

.summary-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.summary-label {
    font-size:16px;
    color: var(--text-secondary);
    margin-bottom: 3px;
}

.summary-value {
    font-size:30px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.summary-unit {
    font-size:18px;
    font-weight: 400;
    margin-left: 3px;
}

/* ==================== Weather Widget ==================== */
.weather-widget {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.weather-icon {
    font-size:44px;
    line-height: 1;
    flex-shrink: 0;
}

.weather-temp {
    font-size:30px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.weather-desc {
    font-size:17px;
    color: var(--text-secondary);
    margin-top: 3px;
}

.weather-date {
    font-size:15px;
    color: var(--text-muted);
    margin-top: 1px;
}

.weather-detail {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-left: auto;
}

.weather-detail-row {
    display: flex;
    gap: 6px;
    align-items: center;
    font-size:16px;
}

.weather-detail-row .lbl {
    color: var(--text-muted);
    width: 22px;
}

.weather-detail-row .val {
    font-weight: 700;
}

/* ==================== Login Page ==================== */
.login-page {
    display: flex;
    height: 100vh;
    min-height: 600px;
}

.login-left {
    width: 50%;
    background: linear-gradient(135deg, #1a1c3a 0%, #2d3580 50%, #3559cb 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 40px;
}

.login-left-inner {
    color: #fff;
    text-align: center;
}

.login-left-title {
    font-size:30px;
    font-weight: 800;
    margin-bottom: 12px;
}

.login-left-sub {
    font-size:17px;
    opacity: 0.7;
}

.login-left-icon {
    font-size:74px;
    margin-bottom: 28px;
}

.login-right {
    width: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    padding: 40px;
}

.login-form-wrap {
    width: 100%;
    max-width: 400px;
}

.login-title {
    font-size:30px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.login-subtitle {
    font-size:17px;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size:15px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    height: 52px;
    padding: 0 16px;
    border: 1.5px solid var(--card-border);
    border-radius: var(--radius-btn);
    font-size:18px;
    font-family: inherit;
    background: #fff;
    color: var(--text-primary);
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(53, 89, 203, 0.12);
}

.btn-login {
    width: 100%;
    height: 52px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-btn);
    font-size:18px;
    font-weight: 700;
    margin-top: 8px;
    transition: background 0.2s;
}

.btn-login:hover {
    background: #2a46b0;
}

.login-remember {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    font-size:16px;
    color: var(--text-secondary);
}

.login-remember input[type=checkbox] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* ==================== Tabs (silo page) ==================== */
.tab-row {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 8px 18px;
    border-radius: var(--radius-btn);
    background: #fff;
    color: var(--text-secondary);
    font-size:18px;
    font-weight: 500;
    border: 1px solid var(--card-border);
    transition: all 0.15s;
}

.tab-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.tab-btn.active {
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(53, 89, 203, 0.3);
}

/* ==================== Responsive ==================== */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 0px;
    }

    .sidebar {
        width: 240px;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        animation: slideIn 0.25s ease forwards;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .page-header .hamburger {
        display: flex;
    }

    .grid-2col {
        grid-template-columns: 1fr;
    }

    /* 모바일: 총 사일로 중량(우측 컬럼)을 사일로 현황(좌측 컬럼)보다 위에 표시 */
    #rightCol {
        order: -1;
    }

    .grid-3col {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-4col {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .main-content {
        padding: 14px 12px;
    }

    .card {
        padding: 14px;
        border-radius: 12px;
    }

    .grid-3col {
        grid-template-columns: 1fr;
    }

    .grid-4col {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .data-table th,
    .data-table td {
        padding: 8px 10px;
        font-size:16px;
    }

    .login-page {
        flex-direction: column;
    }

    .login-left {
        width: 100%;
        flex: 0 0 240px;
        padding: 32px;
    }

    .login-right {
        width: 100%;
        flex: 1;
    }

    .login-left-icon {
        font-size:50px;
        margin-bottom: 16px;
    }

    .login-left-title {
        font-size:24px;
    }
}
