/* 기본 리셋 */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', sans-serif; background-color: #f0f2f5; display: flex; min-height: 100vh; }

/* 사이드바 스타일 */
.sidebar { width: 240px; background-color: #1a1c23; color: white; padding: 20px 0; flex-shrink: 0; overflow-y: auto; }
.sidebar h2 { text-align: center; margin-bottom: 30px; color: #4ade80; font-size: 1.5rem; }
.sidebar h2 a { text-decoration: none; color: #4ade80; }
.logo { font-size: 1.5rem; font-weight: bold; }
aside.sidebar nav a.dash.active { color: #4ade80; }
/* 공통 링크 스타일 */
.sidebar nav a { display: block; color: #9ca3af; padding: 15px 25px; text-decoration: none; transition: 0.3s; cursor: pointer; font-weight: 600;}
.sidebar nav a:hover { background-color: #2d2f39; color: white; }
.sidebar nav a.active { color: white; border-left: 4px solid #4ade80; font-weight: bold; }

/* 사이드바 하단 유저 프로필 영역 */
.user-profile {
    padding: 20px;
    border-top: 1px solid #444; /* 사이드바 배경색에 맞춰 테두리 색상 조절 */
    margin-top: auto;
    text-align: center;
}

.user-profile .user-name {
    color: #fff;
    font-size: 0.95rem;
    font-weight: 500;
}

/* 메뉴 그룹 타이틀 */
.menu-title { padding: 15px 25px; color: #9ca3af; cursor: pointer; font-weight: 600; display: flex; justify-content: space-between; align-items: center; transition: 0.3s; }
.menu-title:hover { color: white; background-color: #252730; }
.menu-group.open .menu-title { color: #4ade80; border-left: 4px solid #4ade80; }
.menu-title .arrow { font-size: 0.8rem; transition: transform 0.3s ease; }
.menu-group.open .menu-title .arrow { transform: rotate(180deg); }

/* 하위 메뉴 영역 */
.submenu { max-height: 0; overflow: hidden; background-color: #111217; transition: max-height 0.1s ease-out; }
.menu-group.open .submenu { max-height: 500px; }
.submenu a { padding-left: 55px; font-size: 0.85rem; padding-top: 12px; padding-bottom: 12px; display: block; color: #9ca3af; text-decoration: none; transition: 0.3s; border-left: none !important; }
.submenu a:hover { background-color: #252730; color: white; }
.submenu a.active { color: #4ade80; background-color: #2d2f39; font-weight: 600; }
/*.menu-group.open .submenu a.active { border-left: 4px solid #4ade80 }*/

/* 메인 콘텐츠 영역 */
.main-content { flex-grow: 1; padding: 30px; overflow-y: auto; }
header { margin-bottom: 30px; }

/* 대시보드 카드 레이아웃 */
.dashboard-grid { display: flex; gap: 20px; margin-bottom: 30px; flex-wrap: wrap; }
.card { background: white; padding: 20px; border-radius: 12px; flex: 1; min-width: 200px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
.card h3 { font-size: 0.9rem; color: #6b7280; margin-bottom: 10px; }
.card .value { font-size: 1.8rem; font-weight: bold; color: #111827; }

/* 테이블 스타일 */
.table-container { background: white; border-radius: 12px; padding: 20px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
.table-container2 { background: white; border-radius: 12px; margin-bottom:30px; padding: 20px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
table { width: 100%; border-collapse: collapse; margin-top: 15px; }
th { text-align: center; padding: 12px; border-bottom: 2px solid #f3f4f6; color: #374151; }
td { padding: 12px; border-bottom: 1px solid #f3f4f6; color: #4b5563; text-align: center; }
tr:hover { background-color: #f9fafb; }
.action-td {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
}


/* 상태 표시 배지 */
.status { padding: 4px 8px; border-radius: 20px; font-size: 0.8rem; font-weight: 500; }
.status.normal { background: #dcfce7; color: #166534; }
.status.warning { background: #fef9c3; color: #854d0e; }


/* --- [수정됨] 입력 요소 공통 스타일 (Select, Input) --- */
/* 모달창과 검색창 모두에서 사용하기 위해 범용적으로 수정했습니다. */

.form-select,
.form-input {
    width: 100%; /* 기본은 꽉 차게 */
    padding: 8px 12px;
    height: 38px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    font-size: 14px;
    box-sizing: border-box; /* 패딩 포함 너비 계산 */
    outline: none;
    transition: border-color 0.2s;
}

/* 셀렉트 박스 화살표 겹침 방지 (오른쪽 여백 확보) */
.form-select {
    padding-right: 35px; /* 화살표 공간 넉넉히 */
    cursor: pointer;
    min-width: 130px; /* 너무 작아지지 않게 */

    /* 긴 글자 말줄임표 처리 */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.form-input:focus,
.form-select:focus {
    border-color: #007bff;
}


/* --- [신규 추가] 폼 레이아웃 (모달 내부용) --- */
/* style="..." 을 대체하기 위한 클래스들입니다. */

.form-group {
    margin-bottom: 15px; /* 입력칸 사이 간격 */
}

/* 한 줄에 두 개 배치 (Flex) */
.form-row-split {
    display: flex;
    gap: 10px;
}

.form-col {
    flex: 1; /* 공간을 1:1로 나눔 */
}

/* 필수 항목 빨간 별표 */
.required-star {
    color: #dc3545;
    margin-left: 2px;
    font-weight: bold;
}


/* --- 장비 목록 테이블 헤더 및 검색창 --- */
.table-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.table-header h2 { margin: 0; font-size: 1.5rem; color: #333; }

.search-form { display: flex; gap: 10px; align-items: center; }

/* 검색창 영역 (.search-box 안에서는 input 너비를 고정) */
.search-box { display: flex; }

.search-box .form-input {
    width: 200px; /* 검색창일 때만 200px */
    border-radius: 4px 0 0 4px;
    border-right: none;
}

.btn-search {
    height: 38px;
    padding: 0 16px;
    border: 1px solid #6c757d;
    background-color: #6c757d;
    color: white;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    white-space: nowrap;
}
.btn-search:hover { background-color: #5a6268; }

.btn-register { display: flex; align-items: center; justify-content: center; height: 38px; padding: 0 20px; background-color: #007bff; color: white; text-decoration: none; border-radius: 4px; font-weight: bold; font-size: 14px; margin-left: 10px; box-sizing: border-box; border: none; }
.btn-register:hover { background-color: #0056b3; }

/* 버튼 스타일 */
.btn-delete { padding: 6px 12px; background-color: #dc3545; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 0.9rem; transition: background-color 0.2s; }
.btn-delete:hover { background-color: #c82333; }

.btn-edit { padding: 6px 12px; background-color: #ffc107; color: #333; text-decoration: none; border-radius: 4px; font-size: 0.9rem; display: inline-block; border: none; }
.btn-edit:hover { background-color: #e0a800; color: #333; }

/* 모달 스타일 */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); z-index: 9999; justify-content: center; align-items: center; }
.modal-window { background: white; width: 500px; padding: 20px; border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.3); }
.modal-header { display: flex; justify-content: space-between; margin-bottom: 20px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-close { cursor: pointer; font-size: 1.5rem; }

/* 모달 버튼 */
.modal-footer button { padding: 10px 20px; border-radius: 6px; font-size: 0.95rem; font-weight: 600; cursor: pointer; border: none; transition: all 0.2s ease; display: flex; align-items: center; justify-content: center; }
.btn-cancel { background-color: #f3f4f6; color: #6b7280; border: 1px solid #e5e7eb; border-radius: 0 4px 4px 0;}
.btn-cancel:hover { background-color: #e5e7eb; color: #374151; }
.btn-save { background-color: #2563eb; color: white; box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.2); }
.btn-save:hover { background-color: #1d4ed8; transform: translateY(-2px); box-shadow: 0 6px 10px -1px rgba(37, 99, 235, 0.3); }
.btn-save:active, .btn-cancel:active { transform: translateY(0); }

/* =========================================================================================
   [DASHBOARD] 대시보드 통계 카드 영역
   ========================================================================================= */

/* 1. 그리드 레이아웃 (반응형) */
.dashboard-grid {
    display: grid;
    /* 화면 크기에 따라 자동으로 열 개수 조절 (최소 200px 너비 보장) */
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;          /* 카드 사이 간격 */
    margin-bottom: 30px; /* 아래쪽 여백 */
}

/* 2. 통계 카드 디자인 */
.dashboard-grid .card {
    background: white;
    padding: 24px;
    border-radius: 12px;       /* 둥근 모서리 */
    border: 1px solid #e5e7eb; /* 연한 테두리 */
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05); /* 은은한 그림자 */
    text-align: left;        /* 가운데 정렬 */
    transition: transform 0.2s; /* 호버 효과용 */
}

/* 마우스 올렸을 때 살짝 떠오르는 효과 (선택사항) */
.dashboard-grid .card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* 카드 제목 (h3) */
.dashboard-grid .card h3 {
    margin: 0 0 10px 0;
    font-size: 0.95rem;
    color: #6b7280;    /* 회색 텍스트 */
    font-weight: 600;
}

/* 카드 숫자 (.value) */
.dashboard-grid .card .value {
    font-size: 2rem;   /* 큰 글씨 */
    font-weight: 700;  /* 두꺼운 글씨 */
    line-height: 1;
    color: #111827;    /* 기본 검은색 */
}

/* =========================================================================================
   [TEXT COLOR] 텍스트 색상 유틸리티 (공통 사용)
   ========================================================================================= */
.text-success { color: #10b981 !important; } /* 초록색 (렌탈중) */
.text-warning { color: #f59e0b !important; } /* 주황색 (대기/고장) */
.text-primary { color: #3b82f6 !important; } /* 파란색 (강조) */
.text-danger  { color: #ef4444 !important; } /* 빨간색 (폐기 등) */

/* =========================================
   페이지네이션 (Pagination) 스타일
   ========================================= */

/* 페이징 영역 전체 컨테이너 */
.pagination-area {
    display: flex;
    justify-content: center; /* 중앙 정렬 */
    margin-top: 20px;
}

/* 페이징 리스트 (ul) */
.pagination {
    display: flex;
    list-style: none; /* 점 없애기 */
    gap: 5px;         /* 버튼 사이 간격 */
    padding: 0;
    margin: 0;
}

/* 페이지 버튼 공통 스타일 (a 태그) */
.page-link {
    display: block;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: #333;
    background-color: white;
    transition: all 0.2s; /* 부드러운 색상 변경 효과 */
    font-size: 0.9rem;
}

/* 마우스 올렸을 때 (Hover) */
.page-link:hover {
    background-color: #f1f3f5;
    color: #0056b3;
    border-color: #dee2e6;
}

/* [중요] 현재 활성화된 페이지 (Active) */
.page-link.active {
    background-color: #007bff; /* 파란 배경 */
    border-color: #007bff;
    color: white;              /* 흰 글씨 */
    font-weight: bold;
    pointer-events: none;      /* 현재 페이지는 클릭 안 되게 막음 (선택사항) */
}

/* =========================================
   [NEW] 점검 이력(Visit History) 전용 테이블 스타일
   기존 테이블보다 정보를 촘촘하게 보여주기 위함
   ========================================= */

/* 1. 폰트 크기 축소 (기존 1rem -> 0.85rem) */
.history-table {
    font-size: 0.85rem;
    width: 100%;
    border-collapse: collapse;
}

/* 2. 여백 축소 (기존 12px -> 6px/4px) */
.history-table th,
.history-table td {
    padding: 8px 4px; /* 위아래 8px, 좌우 4px */
    text-align: center;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}

/* 3. 헤더 스타일 (기존 디자인과 통일감 유지하되 구분을 위해 배경색 추가) */
.history-table thead th {
    background-color: #f9fafb; /* 기존 hover 색상 활용 */
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap; /* 헤더 줄바꿈 방지 */
}

/* 4. 월별(1월~12월) 컬럼 너비 고정 */
/* 숫자가 1~31만 들어가므로 좁게 설정하여 공간 확보 */
.history-table .month-col {
    width: 38px;      /* 너비 고정 */
    min-width: 38px;
    max-width: 38px;
    color: #9ca3af;   /* 기본 글씨는 연한 회색 */
    font-size: 0.8rem;
}

/* 5. 방문한 날짜 강조 (데이터가 있는 경우) */
.visited-date {
    color: #2563eb;   /* 기존 저장 버튼색(파랑) 활용 */
    font-weight: 700;
    font-size: 0.9rem;
}

/* 6. 긴 텍스트 줄바꿈 방지 (거래처명, 장비명) */
.text-nowrap {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px; /* 너무 길면 ... 처리 */
}

/* 7. 최근 점검일 컬럼 */
.date-col {
    width: 90px;
    color: #4b5563;

/* 탭 스타일 보정 */
    .nav-tabs { display: flex; list-style: none; padding: 0; margin-bottom: 20px; }
    .nav-link {
        display: block; padding: 12px 20px; text-decoration: none; color: #6b7280;
        border-bottom: 2px solid transparent; cursor: pointer; font-weight: 500;
    }
    .nav-link:hover { color: #2563eb; background-color: #f9fafb; }
    .nav-link.active { color: #2563eb; border-bottom: 2px solid #2563eb; font-weight: bold; }
}

/* =========================================================================================
   [AUTH] 로그인 페이지 전용 스타일
   ========================================================================================= */

/* 로그인 화면 전체 배경 (세련된 블루-그레이 그라데이션) */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #f0f4f8 0%, #d9e2ec 100%);
    margin: 0;
}

/* 로그인 카드 UI */
.login-card {
    background: #ffffff;
    width: 360px; /* 기존 400px보다 약간 줄여서 콤팩트한 느낌 부여 */
    padding: 40px 32px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08); /* 부드럽고 깊은 그림자 */
    text-align: center;
}

/* 타이틀 디자인 */
.login-logo {
    font-size: 24px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}

/* 서브 타이틀 */
.login-subtitle {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 30px;
}

/* 폼 그룹 간격 정렬 */
.login-form-group {
    text-align: left;
    margin-bottom: 16px;
}

/* 라벨 디자인 (작고 뚜렷하게) */
.login-form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 6px;
}

/* 입력칸 디자인 (기존보다 작고 부드럽게) */
.login-input {
    width: 100%;
    height: 36px; /* 기존 38px -> 36px로 축소 */
    padding: 8px 12px;
    font-size: 13px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    box-sizing: border-box;
    transition: all 0.2s ease;
    outline: none;
    background-color: #f8fafc; /* 연한 회색 배경으로 세련미 추가 */
}

/* 입력칸 포커스 시 효과 (애플/SaaS 스타일 링) */
.login-input:focus {
    border-color: #3b82f6;
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* 로그인 버튼 (다크 네이비로 무게감 있게) */
.btn-login {
    width: 100%;
    height: 42px;
    margin-top: 10px;
    background-color: #0f172a;
    color: white;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.btn-login:hover {
    background-color: #334155;
}

.btn-login:active {
    transform: scale(0.98); /* 클릭 시 살짝 눌리는 애니메이션 */
}