/* 기본 스타일 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', sans-serif;
    background: #f5f7fa;
    color: #333;
    font-size: 14px;
    line-height: 1.6;
}

/* 로그인 페이지 */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    /* Subtle neutral background instead of a strong purple gradient */
    background: linear-gradient(180deg, #f3f5f7 0%, #ffffff 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    /* Softer shadow for a cleaner, less 'flashy' appearance */
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.login-box h1 {
    font-size: 24px;
    margin-bottom: 8px;
    color: #333;
    text-align: center;
}

.login-box .subtitle {
    font-size: 14px;
    color: #666;
    text-align: center;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.btn-primary {
    padding: 8px 14px;
    background: #3b82f6; /* subtle blue */
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.12s ease, transform 0.06s ease;
}

.btn-primary:hover {
    background: #2f6fdb;
}

.btn-primary:active {
    transform: translateY(0);
}

/* keep login button full-width specifically */
.login-box .btn-primary {
    width: 100%;
}

/* 알림 메시지 */
.alert {
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-error {
    background: #fee;
    color: #c33;
    border: 1px solid #fcc;
}

.alert-success {
    background: #efe;
    color: #3c3;
    border: 1px solid #cfc;
}

/* 대시보드 */
.dashboard-container {
    min-height: 100vh;
    background: #f5f7fa;
}

.dashboard-header {
    background: white;
    padding: 20px 30px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.dashboard-header h1 {
    font-size: 22px;
    color: #333;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 14px;
}

.btn-link {
    color: #667eea;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    transition: background 0.2s;
}

.btn-link:hover {
    background: #f0f0f0;
}

/* 대시보드 컨텐츠 */
.dashboard-content {
    padding: 30px;
    max-width: 1400px;
    margin: 0 auto;
}

/* 요약 카드 */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
    margin-top: 20px;
}

.card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.card-actions {
    display: flex;
    gap: 8px;
}

.card h3 {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
    font-weight: 500;
}

.card .value {
    font-size: 32px;
    font-weight: 700;
    color: #333;
    margin: 0;
}

/* 차트 */
.chart-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.chart-container {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.chart-container.full-width {
    grid-column: 1 / -1;
}

.chart-container h3 {
    font-size: 16px;
    margin-bottom: 20px;
    color: #333;
}

.chart-container canvas {
    max-height: 300px;
}

/* 테이블 */
.table-responsive {
    overflow-x: auto;
    margin-top: 15px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table thead {
    background: #f8f9fa;
    border-bottom: 2px solid #e0e0e0;
}

.data-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #555;
}

/* first column (checkbox) shouldn't show pointer cursor */
.data-table th:first-child {
    cursor: default;
}

.data-table td {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
}

.data-table tbody tr:hover {
    background: #f8f9fa;
}

/* change cursor when hovering rows to indicate clickable/selectable */
.data-table tbody tr {
    cursor: pointer;
}
.row-checkbox {
    cursor: pointer;
}

/* 필터 */
.filter-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 15px;
    align-items: flex-end;
}

.filter-row select,
.filter-row input,
.date-controls select,
.form-row select,
.modal-content select,
.control-group select,
.form-row input,
.modal-content input {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    flex: 1;
}

/* Date group (year/month/day stacked label + controls) */
.date-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.date-group .date-label {
    font-size: 12px;
    color: #444;
}

.date-controls {
    display: flex;
    gap: 6px;
    align-items: center;
}

.control-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Page size control placed in the top filter area */
.page-size-control {
    display: flex;
    align-items: center;
    gap: 8px;
}
.page-size-control select {
    width: 140px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

/* Distribute available space evenly among top-level filter groups
   (e.g., start-date group, end-date group, control group) so they
   scale to the card width instead of being left-aligned. */
.filter-row > * {
    flex: 1 1 0;
    min-width: 0; /* allow children to shrink below their intrinsic width */
}

/* Let selects inside the date-controls share the group width and shrink
   when the overall card is narrow. */
.date-controls select {
    flex: 1 1 0;
    min-width: 0;
}

/* Control-group: make selects expand, keep the reset button auto-sized. */
.control-group select {
    flex: 1 1 0;
    min-width: 0;
}
.control-group button {
    flex: 0 0 auto;
}

.filter-row button {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.filter-row button:hover {
    background: #5568d3;
}

.btn-secondary {
    padding: 8px 14px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

.btn-secondary:hover {
    background: #5a6268;
}

/* 테이블 정렬 */
.data-table th {
    cursor: pointer;
    user-select: none;
}

.data-table th:hover {
    background: #e9ecef;
}

.sort-arrow {
    display: inline-block;
    margin-left: 5px;
    color: #667eea;
    font-weight: bold;
}

/* 페이지네이션 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    padding: 20px 0;
}

.pagination button {
    padding: 8px 12px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.pagination button:hover:not(:disabled) {
    background: #f0f0f0;
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination .page-info {
    font-size: 14px;
    color: #666;
}

.pagination select {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

/* 파일 업로드 */
input[type="file"] {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-right: 10px;
    font-size: 14px;
}

#uploadMessage {
    margin-top: 15px;
}

/* Modal */
.modal {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    /* overlay covers viewport; modal-content will be centered via absolute positioning
       to avoid issues when ancestors have transforms that affect fixed/flex centering. */
    z-index: 1000;
}
.modal-content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    width: 560px;
    max-width: 95%;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    /* ensure on top of overlay */
    z-index: 1010;
}
.modal-content h3 {
    margin-bottom: 12px;
}
.form-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
}
.form-row label {
    font-size: 13px;
    color: #444;
    margin-bottom: 6px;
}
.form-row input, .form-row textarea {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}
.form-row textarea { min-height: 80px; }
.modal-actions {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 8px;
}

/* Modal buttons less flashy and evenly distributed */
.modal-actions .btn-primary,
.modal-actions .btn-secondary {
    padding: 8px 12px;
    font-size: 14px;
    border-radius: 6px;
    width: 48%;
}

/* 반응형 */
@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .chart-row {
        grid-template-columns: 1fr;
    }

    .summary-cards {
        grid-template-columns: 1fr;
    }

    .filter-row {
        flex-direction: column;
        /* make children stretch to full width of the card */
        align-items: stretch;
    }

    /* Ensure each top-level filter group becomes full-width on mobile */
    .filter-row > * {
        width: 100% !important;
        flex: none !important;
    }

    /* Keep travelAgency + country select and reset button on one row
       within the control group; make the select expand while button stays auto-sized. */
    .control-group {
        display: flex;
        gap: 8px;
        align-items: center;
        width: 100% !important;
    }
    .control-group select {
        flex: 1 1 0 !important;
        width: auto !important;
        min-width: 0 !important;
    }
    .control-group button {
        flex: 0 0 auto !important;
    }

    /* make page-size-control full width on small screens */
    .page-size-control {
        width: 100% !important;
        justify-content: flex-start;
    }
    .page-size-control select {
        width: 100% !important;
    }
}
