/*
 * ===============================================================================
 * K-TOP 중고차 관리 시스템 - 전용 커스텀 CSS
 * ===============================================================================
 * 이 파일은 프로젝트 전체의 공통 스타일, 컴포넌트 스타일, 페이지별 스타일,
 * 그리고 외부 라이브러리(Flatpickr 등)의 오버라이드 스타일을 포함합니다.
 *
 * 목차:
 * 1. Global Styles & Variables (전역 스타일 및 CSS 변수)
 * 2. Reusable Components (공용 컴포넌트: 테이블, 폼, 버튼 등)
 * 3. Page-Specific Styles (특정 페이지 전용 스타일)
 * 4. External Library Overrides (외부 라이브러리 스타일 수정)
 * ===============================================================================
 */


/* ===============================================================================
 *  1. Global Styles & Variables
 * =============================================================================== */

/* -- (1.1) CSS 변수 정의 -- */
:root {
    --primary-color: #0d6efd; /* Bootstrap Primary Color */
    --danger-color: #dc3545;  /* Bootstrap Danger Color */
    --dark-accent: #2c3e50;  /* 하단 네비게이션 바 배경색 */
    --light-gray: #f8f9fa;   /* 기본 배경색 */
}

/* -- (1.2) Body 및 기본 레이아웃 -- */
body {
    background-color: var(--light-gray);
}

/* base.html의 fixed-top 헤더가 콘텐츠를 가리는 것을 방지. */
/* - 데스크탑: 상단 바(48px) + 하단 바(56px) = 104px */
body {
    padding-top: 104px;
}
/* - 모바일: 상단 바(56px) */
@media (max-width: 991.98px) {
    body {
        padding-top: 56px;
    }
}


/* ===============================================================================
 *  2. Reusable Components
 * =============================================================================== */

/* -- (2.1) 테이블 관련 -- */
/* 목록 페이지의 정렬 링크 */
.sort-link {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}
.sort-link:hover {
    color: var(--primary-color);
}
.sort-indicator {
    color: #888;
}

/* -- (2.2) 폼 관련 -- */
/* 파일 업로드 미리보기 공통 스타일 (car_form.html 등에서 사용) */
.file-preview-container {
    border: 1px dashed #ced4da;
    border-radius: .25rem;
    margin-top: .5rem;
    padding: .5rem;
    min-height: 120px;
    background-color: #fff;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.file-preview-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative; /* 삭제 버튼 위치의 기준점 */
}
.file-preview-item img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border: 1px solid #dee2e6;
    border-radius: .25rem;
}
.file-preview-item .file-name {
    font-size: 0.8em;
    padding: 0.25rem;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.file-preview-item .remove-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    line-height: 18px; /* 텍스트 수직 중앙 정렬 */
    text-align: center;
    padding: 0;
    font-size: 0.8em;
    background-color: var(--danger-color);
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 50%; /* 원형 버튼 */
    font-weight: bold;
}
.file-preview-item .remove-btn::before {
    content: '×'; /* 닫기 아이콘 */
}

/* 수정 페이지: 기존 파일 삭제 체크박스 스타일 */
.existing-file {
    border: 2px solid #ddd;
    padding: 8px;
    border-radius: 8px;
}
.existing-file-delete {
    background-color: rgba(255, 255, 255, 0.8);
    padding: 2px 5px;
    border-radius: 5px;
}


/* ===============================================================================
 *  3. Page-Specific Styles
 * =============================================================================== */

/* -- (3.1) 차량 상세 페이지 갤러리 썸네일 -- */
#lightgallery-container .img-thumbnail {
    cursor: pointer;
    transition: transform 0.2s;
}
#lightgallery-container .img-thumbnail:hover {
    transform: scale(1.05);
}


/* ===============================================================================
 *  4. External Library Overrides
 * =============================================================================== */

/* -- (4.1) Flatpickr (날짜 선택기) 커스텀 -- */
/* =========================
   캘린더 전체
========================= */
.flatpickr-calendar {
    width: 320px;
    padding: 10px;
    border-radius: 14px;
    border: 1px solid #e5e7eb;
    background: #fff;
    box-shadow: 0 12px 28px rgba(0,0,0,.15);
    font-size: 14px;
}

/* =========================
   상단 연 / 월
========================= */
.flatpickr-months {
    display: flex;
    align-items: center; /* 수직 중앙 정렬 (이것은 그대로 유지) */
    height: 44px;
}

.flatpickr-current-month {
    flex-grow: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    
    /* <<<< 핵심 수정 1: transform을 사용하여 미세 위치 조정 >>>> */
    /* 현재 위치에서 Y축(수직)으로 -2px 만큼 위로 이동시킵니다. */
    transform: translateY(-9px); 
}

.numInputWrapper .numInput,
.flatpickr-monthDropdown-months {
    font-weight: 700 !important;
}

.flatpickr-prev-month,
.flatpickr-next-month {
    padding: 6px;
    flex-shrink: 0; /* 화살표 크기가 줄어들지 않도록 함 */
}

/* =========================
   요일
========================= */
/* <<<< 핵심 수정 3: 요일 위아래 여백 추가 >>>> */
.flatpickr-weekdaycontainer {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    padding: 8px 0; /* 위아래 여백(padding)을 주어 간격을 만듦 */
    border-top: 1px solid #f1f3f5;
    border-bottom: 1px solid #f1f3f5;
}

.flatpickr-weekdays {
    display: contents;
}

.flatpickr-weekday {
    text-align: center;
    font-size: .75rem;
    font-weight: 600;
    color: #6b7280;
    height: auto; /* 고정 높이 제거 */
    line-height: normal; /* 고정 라인 높이 제거 */
}
.flatpickr-weekday:first-child { color: #ef4444; }
.flatpickr-weekday:last-child  { color: #3b82f6; }

/* =========================
   날짜
========================= */
.dayContainer {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    padding: 6px 0;
}

.flatpickr-day {
    margin: auto;
    width: 38px;
    height: 38px;
    line-height: 38px;
    border-radius: 50%;
    font-weight: 500;
    transition: .2s;
}

.flatpickr-day:hover {
    background: #f3f4f6;
}

.flatpickr-day.today {
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    font-weight: 700;
}

.flatpickr-day.selected {
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
}

.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
    color: #d1d5db;
}

/* =========================
   하단 버튼 (Bootstrap 통합)
========================= */
.flatpickr-footer {
    display: flex;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid #f1f3f5;
}

.flatpickr-footer .btn {
    flex: 1;
    height: 36px;
    font-weight: 600;
}

/* =========================
   모바일 전용 UI
========================= */
@media (max-width: 480px) {
    .flatpickr-calendar {
        width: 100%;
        max-width: 360px;
        border-radius: 16px;
    }

    .flatpickr-day {
        width: 44px;
        height: 44px;
        line-height: 44px;
        font-size: 1rem;
    }

    .flatpickr-footer .btn {
        height: 42px;
        font-size: .95rem;
    }
}


/* --- LightGallery z-index 수정 --- */
/* Bootstrap 모달(z-index: 1050) 위로 LightGallery가 표시되도록 z-index 값을 더 높게 설정합니다. */
.lg-backdrop {
  z-index: 1060 !important;
}

.lg-outer {
  z-index: 1070 !important;
}

/* --- 이미지 삭제/선택용 커스텀 컨트롤 스타일 (최종 가독성 개선 버전) --- */

/* 1. 대표 사진 선택 (왼쪽 위 노란색 별 아이콘) */
.thumb-radio-label {
    position: absolute;
    top: 0.3rem;
    left: 0.3rem;
    cursor: pointer;
    line-height: 1; /* 아이콘 버튼의 라인 높이 초기화 */
}
.thumb-radio-input { display: none; }
.thumb-radio-icon {
    font-size: 0.9rem; /* 아이콘 크기 미세 조정 */
    color: #fff;
    background-color: rgba(0, 0, 0, 0.4);
    padding: 0.3rem;
    border-radius: 50%;
    transition: all 0.2s;
}
.thumb-radio-label:hover .thumb-radio-icon { transform: scale(1.15); }
/* 선택 시: 노란색 배경에 흰색 별 */
.thumb-radio-input:checked ~ .thumb-radio-icon {
    background-color: #ffc107; /* Bootstrap warning color */
    color: #fff;
}


/* 2. 사진 삭제 (오른쪽 아래 회색/빨간색 휴지통 아이콘) */
.delete-check-label {
    position: absolute;
    bottom: 0.3rem;
    right: 0.3rem;
    cursor: pointer;
    line-height: 1;
}
.delete-check-input { display: none; }
.delete-check-icon {
    font-size: 0.9rem; /* 아이콘 크기 미세 조정 */
    color: #fff;
    /* 평상시: 회색 배경 */
    background-color: #6c757d; /* Bootstrap secondary color */
    padding: 0.3rem;
    border-radius: 50%;
    transition: all 0.2s;
}
.delete-check-label:hover .delete-check-icon { transform: scale(1.15); }
/* ★★★★★ 선택 시: 빨간색 배경에 흰색 휴지통 ★★★★★ */
.delete-check-input:checked ~ .delete-check-icon {
    background-color: #dc3545; /* Bootstrap danger color */
    color: #fff;
}