/* ═══════════════════════════════════════════
   전역 리셋 & 기본 레이아웃
   모든 태그 여백 초기화, 다크 배경, 기본 폰트
   ═══════════════════════════════════════════ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', sans-serif;
    background: #0f1923;
    color: #e0e0e0;
}

/* ═══════════════════════════════════════════
   헤더
   상단 타이틀 바 (µDCIM 로고, Running 상태 뱃지)
   ═══════════════════════════════════════════ */
.header {
    background: #1a2733;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid #2a3a4a;
}

.header h1 {
    font-size: 20px;
    color: #4fc3f7;
}

.header .status {
    font-size: 12px;
    color: #81c784;
    background: #1b3a2a;
    padding: 3px 10px;
    border-radius: 12px;
}

/* ═══════════════════════════════════════════
   헤더 우측 영역
   사용자명 + 역할 배지 + 로그아웃 버튼 + Grafana 링크
   ═══════════════════════════════════════════ */
.header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-user {
    font-size: 13px;
    color: #90a4ae;
}

.header-user strong {
    color: #e0e0e0;
}

.badge-role {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.badge-admin {
    background: #1976d2;
    color: #fff;
}

.badge-viewer {
    background: #37474f;
    color: #90a4ae;
}

.btn-logout {
    background: none;
    border: 1px solid #546e7a;
    color: #90a4ae;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.btn-logout:hover {
    border-color: #e57373;
    color: #e57373;
}

.btn-grafana {
    background: #e65100;
    color: #fff;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    text-decoration: none;
    font-weight: 600;
}

.btn-grafana:hover {
    background: #bf360c;
}

/* ═══════════════════════════════════════════
   탭 메뉴
   상단 네비게이션 탭 (데이터조회 / 삭제 / 팬제어 / ...)
   active 탭은 하단 파란 밑줄로 표시
   ═══════════════════════════════════════════ */
.tabs {
    display: flex;
    background: #162029;
    border-bottom: 2px solid #2a3a4a;
}

.tab {
    padding: 12px 24px;
    cursor: pointer;
    color: #90a4ae;
    font-size: 14px;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab:hover {
    color: #e0e0e0;
    background: #1a2a36;
}

.tab.active {
    color: #4fc3f7;
    border-bottom-color: #4fc3f7;
}

/* ═══════════════════════════════════════════
   콘텐츠 영역
   탭 아래 메인 컨텐츠, 최대 너비 1200px 중앙 정렬
   ═══════════════════════════════════════════ */
.content {
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

/* ═══════════════════════════════════════════
   카드
   각 기능 섹션을 감싸는 다크 박스
   ═══════════════════════════════════════════ */
.card {
    background: #1a2733;
    border: 1px solid #2a3a4a;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
}

.card h3 {
    color: #4fc3f7;
    margin-bottom: 12px;
    font-size: 16px;
}

/* ═══════════════════════════════════════════
   폼 레이아웃
   form-row: 가로 배치 (입력 필드 나란히)
   form-group: 세로 배치 (라벨 + 인풋 한 쌍)
   ═══════════════════════════════════════════ */
.form-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group label {
    font-size: 12px;
    color: #90a4ae;
}

/* ═══════════════════════════════════════════
   입력 요소 공통 스타일
   input / select / textarea 전체 적용
   ═══════════════════════════════════════════ */
input, select, textarea {
    background: #0f1923;
    border: 1px solid #2a3a4a;
    color: #e0e0e0;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #4fc3f7;
}

/* 슬라이더(range) 예외 처리
   공통 padding이 핸들이 끝까지 안 가는 원인이므로 별도 초기화 */
input[type="range"] {
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 0;
}

textarea {
    resize: vertical;
    min-height: 80px;
    font-family: 'Courier New', monospace;
}

/* ═══════════════════════════════════════════
   버튼
   btn-primary : 파란색 (기본 액션)
   btn-danger  : 빨간색 (삭제 / 경고)
   btn-success : 초록색 (확인 / 활성화)
   btn-sm      : 작은 버튼 (테이블 내 버튼 등)
   ═══════════════════════════════════════════ */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary { background: #1976d2; color: white; }
.btn-primary:hover { background: #1565c0; }

.btn-danger { background: #c62828; color: white; }
.btn-danger:hover { background: #b71c1c; }

.btn-success { background: #2e7d32; color: white; }
.btn-success:hover { background: #1b5e20; }

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* ═══════════════════════════════════════════
   테이블
   알람 규칙 목록 등에 사용
   ═══════════════════════════════════════════ */
table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #2a3a4a;
    font-size: 13px;
}

th {
    color: #90a4ae;
    font-weight: 600;
    background: #162029;
}

tr:hover {
    background: #162029;
}

/* ═══════════════════════════════════════════
   배지
   알람 심각도(warning/critical) 및
   상태(firing/pending/inactive) 표시용 태그
   ═══════════════════════════════════════════ */
.badge {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.badge-warning  { background: #f57f17; color: #fff; }
.badge-critical { background: #c62828; color: #fff; }
.badge-firing   { background: #c62828; color: #fff; }
.badge-pending  { background: #f57f17; color: #fff; }
.badge-inactive { background: #37474f; color: #90a4ae; }

/* ═══════════════════════════════════════════
   결과 출력 박스
   Flux 쿼리 결과, 삭제 결과 등 텍스트 출력 영역
   스크롤 가능, 고정폭 폰트(Courier New)
   ═══════════════════════════════════════════ */
.result-box {
    background: #0a1218;
    border: 1px solid #2a3a4a;
    border-radius: 4px;
    padding: 12px;
    margin-top: 12px;
    max-height: 400px;
    overflow: auto;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    white-space: pre-wrap;
}

/* ═══════════════════════════════════════════
   차트 컨테이너
   Chart.js 캔버스를 감싸는 박스 (데이터 조회 탭)
   ═══════════════════════════════════════════ */
.chart-container {
    position: relative;
    height: 300px;
    margin-top: 12px;
}

/* ═══════════════════════════════════════════
   토스트 알림
   우측 상단에 잠깐 표시되는 성공/에러 메시지
   ═══════════════════════════════════════════ */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 6px;
    font-size: 13px;
    z-index: 1000;
    animation: fadeIn 0.3s;
}

.toast-success { background: #2e7d32; color: white; }
.toast-error   { background: #c62828; color: white; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════
   로딩 인디케이터
   데이터 불러오는 중 표시되는 텍스트
   ═══════════════════════════════════════════ */
.loading {
    text-align: center;
    padding: 40px;
    color: #90a4ae;
}

/* ═══════════════════════════════════════════
   모달
   알람 규칙 편집, 비밀번호 변경 등 팝업 오버레이
   ═══════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    background: #1a2733;
    border: 1px solid #2a3a4a;
    border-radius: 8px;
    padding: 24px;
    width: 500px;
    max-width: 90%;
}

.modal h3 {
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

/* ═══════════════════════════════════════════
   로그인 화면
   앱 진입 시 표시되는 로그인 박스 (중앙 정렬)
   ═══════════════════════════════════════════ */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-box {
    background: #1a2733;
    border: 1px solid #2a3a4a;
    border-radius: 12px;
    padding: 40px;
    width: 380px;
}

.login-box h2 {
    color: #4fc3f7;
    text-align: center;
    margin-bottom: 24px;
    font-size: 22px;
}

.login-box .form-group {
    margin-bottom: 16px;
}

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

.login-box .btn {
    width: 100%;
    padding: 10px;
    font-size: 15px;
}

.login-error {
    color: #e57373;
    font-size: 13px;
    text-align: center;
    margin-bottom: 12px;
}
