/* --- Global Styles & Variables --- */
@import url('https://fonts.googleapis.com/css2?family=Pretendard:wght@400;600;700&display=swap');

:root {
    /* New Color Palette */
    --color-orange: #F58220;
    --color-blue: #0055A5;
    --color-gold: #FDB913;
    --color-orange-hover: #d9701a;
    --color-blue-hover: #004182;

    --primary-color: var(--color-blue);
    --primary-hover: var(--color-blue-hover);
    --secondary-color: #6c757d;
    --secondary-hover: #5a6268;
    --success-color: var(--color-orange);
    --error-color: #FF3B30;   /* Apple Red */
    --bg-color: #F2F2F7;      /* Apple System Gray 6 */
    --card-bg: #FFFFFF;
    --text-color: #1D1D1F;    /* Apple Almost Black */
    --text-muted: #8A8A8E;   /* Apple System Gray */
    --border-color: #D1D1D6;  /* Apple System Gray 4 */
    --shadow-color: rgba(0, 0, 0, 0.1);
    --font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    box-sizing: border-box;
}

.container {
    width: 100%;
    max-width: 900px; /* Increased for better desktop button layout */
    background: var(--card-bg);
    padding: 30px 40px;
    border-radius: 16px;
    box-shadow: 0 4px 20px var(--shadow-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

.header-icon {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

header h1 {
    margin: 0;
    font-size: 2em;
    font-weight: 700;
}

header p {
    margin: 8px 0 0;
    color: var(--text-muted);
    font-size: 1.1em;
}

/* --- Index Page Specific Styles --- */

.nav-container {
    display: flex;
    justify-content: space-between; /* 버튼 그룹은 왼쪽, 링크는 오른쪽으로 정렬 */
    align-items: center;
    flex-wrap: wrap; /* 필요시 줄바꿈 허용 */
    gap: 30px; /* 요소 간 간격 유지 */
    margin-bottom: 30px;
}


.report-selector {
    display: flex; /* Flexbox 사용 */
    flex-wrap: wrap; /* 버튼이 많아지면 줄바꿈 허용 */
    gap: 15px; /* Increased gap for more spacing */
    justify-content: center; /* Center the buttons when they don't fill the width */
}

.report-selector button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid #ced4da; /* 테두리 색상을 더 잘보이게 수정 */
    background-color: #fff;
    color: var(--text-muted);
    border-radius: 10px;
    transition: all 0.2s ease-in-out;
    flex-basis: auto; /* 내용에 따라 너비 자동 조절 */
    width: auto; /* 내용에 따라 너비 자동 조절 */
}

.results-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    /* margin-left: auto; 제거 */
    flex-grow: 0; /* 불필요한 공간 차지 방지 */
    flex-shrink: 0; /* 불필요한 축소 방지 */
}

.results-link:hover {
    background-color: #e9ecef;
    color: var(--primary-hover);
    text-decoration: none;
}

.results-link i {
    margin-right: 8px;
}

/* --- Form Styles --- */
.report-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: fadeIn 0.5s ease-in-out;
    min-height: 640px; /* 폼 높이를 고정하여 화면 전환 시 움직임 방지 */
}

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

.report-form h2 {
    text-align: center;
    margin: 0 0 10px;
    color: var(--primary-color);
    border-bottom: 2px solid var(--color-gold);
    padding-bottom: 10px;
    font-weight: 700;
}

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

.form-group label {
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.95em;
}

.form-group input[type="text"],
.form-group input[type="datetime-local"],
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1em;
    font-family: var(--font-family);
    box-sizing: border-box;
    background-color: var(--bg-color);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-gold);
    box-shadow: 0 0 0 3px rgba(253, 185, 19, 0.25);
}

/* --- Responsive Styles --- */
@media (max-width: 768px) {
    body {
        padding: 0;
        background-color: var(--card-bg); /* 모바일에서는 카드 배경색을 전체 배경으로 사용 */
    }

    .container {
        width: 100%;
        max-width: 100%;
        min-height: 100vh;
        border-radius: 0;
        padding: 20px;
        box-shadow: none;
        box-sizing: border-box;
    }

    header {
        margin-bottom: 25px;
    }

    header h1 {
        font-size: 1.8em;
    }
    
    header p {
        font-size: 1em;
    }

    .nav-container {
        flex-direction: column;
        align-items: stretch; /* 버튼과 링크가 전체 너비를 차지하도록 */
        gap: 20px;
    }

    .report-buttons-group {
        flex-direction: column; /* 모바일에서 버튼 그룹 세로 정렬 */
        width: 100%;
    }

    .report-selector {
        flex-direction: column; /* Stack buttons vertically */
        width: 100%;
    }

    .report-selector button {
        width: 100%; /* Make buttons full width on mobile */
        min-width: auto; /* 모바일에서는 최소 너비 초기화 */
    }

    .results-link {
        margin-left: 0; /* Remove auto margin for mobile */
        text-align: center;
        padding: 12px;
        background-color: #f8f9fa; /* 배경색을 추가하여 터치 영역을 명확히 함 */
        border: 1px solid #dee2e6;
    }

    .report-form {
        min-height: auto; /* 모바일에서는 자동 높이로 변경하여 유연하게 대응 */
    }
}

@media (max-width: 480px) {
    .report-selector button {
        font-size: 0.9em; /* 더 작은 화면에서 폰트 크기 조정 */
        padding: 10px;
    }
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.report-form button[type="submit"] {
    padding: 15px;
    font-size: 1.1em;
    font-weight: bold;
    color: white;
    background-color: var(--success-color);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    margin-top: 10px;
    transition: background-color 0.2s, transform 0.2s;
}

.report-form button[type="submit"]:hover {
    background-color: var(--color-orange-hover);
    transform: translateY(-2px);
}

.report-form button[type="submit"]:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* --- Results Page Specific Styles --- */
.results-container {
    max-width: 1200px;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px; /* 요소 간 간격 추가 */
    margin-bottom: 25px;
}

.search-container {
    position: relative;
    flex-grow: 1; /* 검색창이 가능한 많은 공간을 차지하도록 설정 */
}

.search-container i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

#search-input {
    width: 100%;
    padding: 10px 20px 10px 40px; /* 아이콘을 위한 왼쪽 패딩 추가 */
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1em;
    font-family: var(--font-family);
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#search-input:focus {
    outline: none;
    border-color: var(--color-gold);
    box-shadow: 0 0 0 3px rgba(253, 185, 19, 0.25);
}

.btn-primary, .btn-secondary {
    padding: 10px 20px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1em;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: var(--secondary-hover);
}

.table-container {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

#report-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

#report-table th, #report-table td {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
}

#report-table thead {
    background-color: #F9F9FB; /* Lighter than bg-color */
}

#report-table th {
    font-weight: 700;
    font-size: 0.9em;
    text-transform: uppercase;
    color: var(--text-muted);
}

#report-table tbody tr:last-child td {
    border-bottom: none;
}

#report-table tbody tr:hover {
    background-color: #F2F2F7;
}

/* 시간 잘림 현상 수정을 위한 스타일 (강화) */
#report-table th:nth-child(2),
#report-table td:nth-child(2),
#report-table th:nth-child(7),
#report-table td:nth-child(7) {
    min-width: 170px !important; /* 최소 너비를 늘리고 !important로 우선순위 강화 */
    white-space: nowrap;
}

.details-cell {
    max-width: 300px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.loading-cell, .no-data-cell {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 1.1em;
}

/* --- Utility & Footer --- */
.hidden { display: none !important; }

#status-message {
    text-align: center;
    margin-bottom: 20px;
    padding: 12px;
    border-radius: 8px;
    font-weight: bold;
    display: none;
    animation: fadeIn 0.5s;
}

#status-message.success {
    display: block;
    background-color: #d1e7dd;
    color: #0f5132;
}

#status-message.error {
    display: block;
    background-color: #f8d7da;
    color: #842029;
}

.app-footer {
    margin-top: 2rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.app-footer p {
    margin: 0.25rem 0;
}

/* Search Highlight */
.highlight {
    background-color: #FFFF00; /* Bright yellow for highlight */
    font-weight: bold;
}

/* Filter Dropdown */
.filter-container {
    position: relative;
}

#report-type-filter {
    padding: 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1em;
    font-family: var(--font-family);
    background-color: var(--card-bg);
    appearance: none; /* 기본 드롭다운 화살표 제거 */
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%236c757d%22%20d%3D%22M287%2C197.9L159.3%2C69.2c-3.7-3.7-9.7-3.7-13.4%2C0L5.4%2C197.9c-3.7%2C3.7-3.7%2C9.7%2C0%2C13.4l13.4%2C13.4c3.7%2C3.7%2C9.7%2C3.7%2C13.4%2C0l110.7-110.7c3.7-3.7%2C9.7-3.7%2C13.4%2C0l110.7%2C110.7c3.7%2C3.7%2C9.7%2C3.7%2C13.4%2C0l13.4-13.4C290.7%2C207.6%2C290.7%2C201.6%2C287%2C197.9z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 10px top 50%;
    background-size: 12px auto;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#report-type-filter:focus {
    outline: none;
    border-color: var(--color-gold);
    box-shadow: 0 0 0 3px rgba(253, 185, 19, 0.25);
}
