:root {
    --bg-color: #0d0d0d;
    --card-bg: #1a1a1a;
    --text-primary: #e0e0e0;
    --text-secondary: #999;
    --danger: #ff4d4d;
    --warning: #ffcc00;
    --success: #00e676;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

header {
    padding: 15px 20px;
    text-align: center;
    border-bottom: 1px solid #222;
    position: sticky;
    top: 0;
    background: rgba(13, 13, 13, 0.9);
    backdrop-filter: blur(10px);
    z-index: 100;
}

h1 { margin: 0; font-size: 1rem; letter-spacing: 3px; color: var(--text-secondary); font-weight: 900; }

.installer-copy-box {
    background: #111;
    border: 1px solid #333;
    padding: 8px 12px;
    border-radius: 6px;
    margin-top: 12px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 0.65rem;
    color: var(--text-secondary);
    cursor: pointer;
    max-width: 90%;
    margin-left: auto;
    margin-right: auto;
    transition: all 0.2s;
}
.installer-copy-box:active { background: #222; transform: scale(0.98); }
.installer-copy-box i { color: var(--success); }
.installer-copy-box span { 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    font-family: monospace; 
}

#summary-bar { margin-top: 8px; }
.badge { background: #222; padding: 4px 12px; border-radius: 4px; font-weight: bold; font-size: 0.8rem; color: var(--text-secondary); }
.badge.critical { background: var(--danger); color: white; animation: blink 1.5s infinite; }

@keyframes blink { 0% { opacity: 1; } 50% { opacity: 0.6; } 100% { opacity: 1; } }

#server-list { 
    padding: 12px; 
    display: grid; 
    grid-template-columns: 1fr 1fr; /* 2열 그리드 강제 */
    gap: 10px; 
}

/* 서버 카드 스타일 - 컴팩트하게 변경 */
.server-card {
    position: relative;
    z-index: 1;
    background: var(--card-bg);
    border-radius: 8px;
    padding: 12px;
    border-left: 3px solid #333;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: transform 0.1s ease, background 0.3s ease;
}
.server-card:active { transform: scale(0.95); background: #252525; }

.server-card.online { border-left-color: var(--success); }
.server-card.warning { border-left-color: var(--warning); }
.server-card.critical { border-left-color: var(--danger); }

.server-name { 
    font-size: 0.85rem; 
    font-weight: bold; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between; /* 양 끝 정렬 */
    align-items: center;
    width: 100%;
}
.name-right { display: flex; align-items: center; gap: 8px; }

.remote-access-section { margin-top: 15px; text-align: center; }
.remote-btn-large {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #222;
    color: var(--success);
    border: 1px solid var(--success);
    padding: 12px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.9rem;
    transition: all 0.2s;
}
.remote-btn-large:hover { background: var(--success); color: black; }
.remote-btn-large:active { transform: scale(0.98); }

.ip-small { font-size: 0.65rem; opacity: 0.6; font-weight: normal; margin-left: 4px; }
.memo-small { font-size: 0.65rem; color: var(--success); opacity: 0.8; font-weight: normal; margin-left: 6px; }
.time-ago { font-size: 0.6rem; color: var(--warning); font-weight: normal; }

.metrics { 
    display: flex; 
    flex-direction: row; /* 한 줄로 표시 */
    gap: 4px; 
    margin-top: 8px; 
}
.metric-item { 
    flex: 1;
    background: rgba(0,0,0,0.3); 
    padding: 4px 2px; 
    border-radius: 4px; 
    display: flex; 
    flex-direction: column; /* 라벨과 수치를 위아래로 */
    align-items: center; 
    transition: all 0.3s;
}
.metric-item.alert-active {
    background: rgba(255, 77, 77, 0.2);
    box-shadow: inset 0 0 10px rgba(255, 77, 77, 0.3);
    border: 1px solid var(--danger);
    animation: alert-pulse-bg 2s infinite;
}

@keyframes alert-pulse-bg {
    0% { background: rgba(255, 77, 77, 0.1); }
    50% { background: rgba(255, 77, 77, 0.3); }
    100% { background: rgba(255, 77, 77, 0.1); }
}

.label { font-size: 0.5rem; opacity: 0.7; margin-bottom: 1px; }
.value { font-size: 0.75rem; font-weight: 800; transition: color 0.3s ease; }
.value.updated { animation: pulse-green 0.5s ease; }

@keyframes pulse-green {
    0% { color: var(--success); text-shadow: 0 0 5px var(--success); }
    100% { color: inherit; text-shadow: none; }
}

.footer-info { display: none; } /* 메인에선 숨김 */

/* 모달(상세보기) 스타일 */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #1e1e1e;
    width: 90%;
    max-width: 400px;
    border-radius: 12px;
    padding: 20px;
    position: relative;
    border: 1px solid #333;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close-btn { position: absolute; top: 10px; right: 15px; font-size: 1.5rem; cursor: pointer; color: var(--text-secondary); }
.spec-list { margin-top: 15px; font-size: 0.85rem; line-height: 1.6; color: var(--text-secondary); }
.spec-item { margin-bottom: 8px; border-bottom: 1px solid #222; padding-bottom: 4px; }
.spec-label { color: var(--text-primary); font-weight: bold; margin-right: 5px; }

/* 메모 섹션 스타일 */
.memo-section { margin-top: 20px; border-top: 1px solid #333; padding-top: 15px; }
.memo-input {
    width: 100%;
    background: #121212;
    border: 1px solid #444;
    color: white;
    padding: 8px;
    border-radius: 4px;
    margin-top: 5px;
    box-sizing: border-box;
}
.save-btn {
    background: var(--success);
    color: #000;
    border: none;
    padding: 8px 15px;
    border-radius: 4px;
    font-weight: bold;
    margin-top: 10px;
    cursor: pointer;
    width: 100%;
}
.save-btn.secondary { background: #333; color: white; border: 1px solid #555; margin-top: 15px; }

/* Settings Section */
.settings-section { margin-top: 20px; border-top: 1px solid #333; padding-top: 15px; }
.settings-section h3 { font-size: 0.9rem; margin-bottom: 15px; color: var(--text-primary); }
.setting-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.setting-row label { font-size: 0.8rem; color: var(--text-secondary); flex: 1; }
.small-input { width: 60px; background: #121212; border: 1px solid #444; color: white; padding: 4px; border-radius: 4px; margin: 0 10px; text-align: center; }

/* Switch Toggle Style */
.switch { 
    position: relative; 
    display: inline-block; 
    width: 44px; 
    height: 22px; 
    flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider { 
    position: absolute; 
    cursor: pointer; 
    top: 0; left: 0; right: 0; bottom: 0; 
    background-color: #444; 
    transition: .3s; 
    border-radius: 22px; 
}
.slider:before { 
    position: absolute; 
    content: ""; 
    height: 16px; 
    width: 16px; 
    left: 3px; 
    bottom: 3px; 
    background-color: white; 
    transition: .3s; 
    border-radius: 50%; 
}
input:checked + .slider { background-color: var(--success); }
input:checked + .slider:before { transform: translateX(22px); }

/* Danger Zone */
.danger-zone { margin-top: 30px; border-top: 1px dashed #555; padding-top: 15px; text-align: center; }
.delete-btn {
    background: transparent;
    color: #ff4d4d;
    border: 1px solid #ff4d4d;
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}
.delete-btn:hover { background: #ff4d4d; color: white; }

/* Metrics History Styles */
.metrics-history-section { margin-top: 15px; border-top: 1px solid #333; padding-top: 15px; }
.view-metrics-btn {
    background: #222;
    color: var(--success);
    border: 1px solid var(--success);
    padding: 10px;
    width: 100%;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: bold;
}
.view-metrics-btn:hover { background: var(--success); color: black; }
#metrics-history-list {
    margin-top: 10px;
    max-height: 250px;
    overflow-y: auto;
    background: #000;
    border: 1px solid #333;
    border-radius: 4px;
}
.metrics-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.metrics-table th {
    text-align: left;
    padding: 8px 6px;
    border-bottom: 2px solid #333;
    position: sticky;
    top: 0;
    background: #222;
    color: var(--text-primary);
}
.metrics-table td {
    padding: 6px;
    border-bottom: 1px solid #1a1a1a;
}
.metrics-table tr:nth-child(even) { background: #0a0a0a; }

.loading { text-align: center; padding: 50px; color: var(--text-secondary); font-style: italic; }

/* Mobile Optimization (Simplified view to prevent clipping) */
@media (max-width: 480px) {
    #server-list { 
        padding: 8px; 
        gap: 6px; 
    }
    .server-card { 
        padding: 10px 8px; 
    }
    /* Hide IP but show Memo in grid view if space permits */
    .ip-small { 
        display: none !important; 
    }
    .memo-small {
        display: inline !important;
        font-size: 0.6rem;
    }
    .server-name { 
        font-size: 0.75rem; 
        margin-bottom: 8px;
    }
    .time-ago {
        font-size: 0.55rem;
    }
    .remote-link {
        font-size: 1.2rem;
        padding: 10px;
    }
    .metrics { 
        gap: 3px; 
    }
    .metric-item {
        padding: 3px 1px;
    }
    .value { 
        font-size: 0.65rem; 
    }
    .installer-copy-box {
        font-size: 0.55rem;
        padding: 6px 10px;
        gap: 6px;
    }
    h1 {
        font-size: 0.85rem;
        letter-spacing: 2px;
    }
}
