/* ========================================
   WJS 차량운행일지 v2.0 모바일 우선 CSS
   Galaxy S25 최적화 (420x800px)
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 모바일 우선 설계 */
body {
    font-family: 'Malgun Gothic', sans-serif;
    font-size: 20px;
    line-height: 1.3;
    color: #333;
    background-color: #f5f5f5;
    /* Galaxy S25 기본 뷰포트 */
    min-width: 420px;
    max-width: 100vw;
    overflow-x: hidden;
}

/* Galaxy S25 최적화 미디어 쿼리 */
@media screen and (max-width: 420px) {
    body {
        font-size: 13px;
        line-height: 1.2;
    }
}

/* ========================================
   화면 전환
   ======================================== */
.screen {
    display: none;
    padding: 20px;
    min-height: 100vh;
    background: #f5f6fa;
    width: 100%;
    box-sizing: border-box;
}

.screen.active {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* ========================================
   로그인 화면
   ======================================== */
.login-container {
    max-width: 400px;
    margin: 50px auto;
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.login-container h1 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 24px;
}

.login-label {
    font-size: 22px;
    color: #2c3e50;
}


.version-info {
    color: #7f8c8d;
    font-size: 16px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.firebase-status {
    font-size: 16px;
    font-weight: bold;
    transition: color 0.3s ease;
    color: #e74c3c;
    /* 기본값: 빨간색 (연결 안됨) */
}

.firebase-status.connected {
    color: #27ae60;
    /* 녹색 (연결됨) */
}

.firebase-status.disconnected {
    color: #e74c3c;
    /* 빨간색 (연결 안됨) */
}

.db-status-text {
    font-size: 16px;
    color: #7f8c8d;
    margin-left: 3px;
}

.login-tabs {
    display: flex;
    margin-bottom: 20px;
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid #bdc3c7;
}

.tab-button {
    flex: 1;
    padding: 12px;
    border: none;
    background: #ecf0f1;
    color: #7f8c8d;
    cursor: pointer;
    transition: all 0.3s;
}

.tab-button.active {
    background: #3498db;
    color: white;
}

.login-type {
    display: none;
}

.login-type.active {
    display: block;
}

.login-type label {
    display: block;
    margin-bottom: 8px;
    color: #2c3e50;
    font-weight: bold;
}

.login-type input {
    width: 100%;
    padding: 12px;
    border: 1px solid #bdc3c7;
    border-radius: 5px;
    margin-bottom: 15px;
    font-size: 16px;
}

.login-type button {
    width: 100%;
    padding: 12px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.login-type button:hover {
    background: #229954;
}

/* ========================================
   메인 화면 - 모바일 우선
   ======================================== */
.user-container,
.ev-container {
    max-width: 100%;
    margin: 0;
    padding: 5px;
}

.user-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-direction: row;
    gap: 10px;
    flex-wrap: nowrap;
}

/* 데스크톱에서만 중앙 정렬 */
@media screen and (min-width: 768px) {

    .user-container,
    .ev-container {
        max-width: 600px;
        margin: 0 auto;
        padding: 10px;
    }

    .header {
        padding: 15px;
        margin-bottom: 15px;
    }
}

.mode-switch {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.mode-switch span {
    font-weight: bold;
    color: #2c3e50;
}

.mode-switch button {
    padding: 8px 15px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
}

.logout-btn {
    padding: 8px 15px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.read-data-btn {
    background: #17a2b8;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 8px 15px;
    font-size: 12px;
    cursor: pointer;
    margin-top: 16px;
    width: 100%;
}


/* ========================================
   폼 컨테이너
   ======================================== */
.form-container {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: block !important;
    visibility: visible !important;
    min-height: 50px;
}

.form-container h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 18px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 8px;
}

/* ========================================
   폼 요소 - 모바일 우선
   ======================================== */

/* 숫자 입력창 스피너(화살표) 제거 */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

.form-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.form-group {
    flex: 1;
    min-width: 0;
    /* flex 아이템 축소 허용 */
}

.form-group.full-width {
    flex: 2;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    color: #2c3e50;
    font-weight: bold;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font-size: 13px;
    min-height: 36px;
    /* 터치 친화적 높이 */
}

/* Galaxy S25 특별 최적화 */
@media screen and (max-width: 420px) {
    .form-row {
        gap: 6px;
        margin-bottom: 10px;
    }

    .form-group label {
        font-size: 13px;
        margin-bottom: 3px;
    }

    .form-group input,
    .form-group select {
        padding: 6px;
        font-size: 14px;
        min-height: 34px;
    }
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
}

/* ========================================
   버튼
   ======================================== */
.save-btn {
    width: 100%;
    padding: 15px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
}

.search-btn,
.clear-btn {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}

.search-btn {
    background: #3498db;
    color: white;
}

.clear-btn {
    background: #95a5a6;
    color: white;
}

.delete-btn {
    padding: 5px 10px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}

/* ========================================
   검색 결과
   ======================================== */
.search-results {
    margin-top: 20px;
}

.search-results h3 {
    color: #2c3e50;
    margin-bottom: 15px;
}

.result-item {
    border: 1px solid #bdc3c7;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 5px;
    background: #ffffff;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
}

.result-buttons {
    display: flex;
    gap: 5px;
}

.edit-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.edit-btn:hover {
    background: #45a049;
}

.delete-btn {
    background: #ff4444;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.delete-btn:hover {
    background: #cc0000;
}

.result-item div {
    margin-bottom: 5px;
    font-size: 13px;
}

/* ========================================
   모바일 최적화 (Galaxy S25 포함)
   ======================================== */
@media (max-width: 480px) {
    .screen {
        padding: 3px;
    }

    .login-container {
        margin: 15px auto;
        padding: 15px;
        max-width: calc(100vw - 20px);
    }

    .form-container {
        padding: 12px;
        margin-bottom: 10px;
    }

    .form-container h2 {
        font-size: 15px;
        margin-bottom: 15px;
    }

    .header {
        padding: 8px;
        flex-direction: row;
        gap: 6px;
        justify-content: space-between;
        align-items: center;
    }

    .user-header {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 6px;
    }

    .mode-switch {
        justify-content: flex-start;
        flex-wrap: nowrap;
        gap: 4px;
    }

    .mode-switch span {
        font-size: 10px;
    }

    .mode-switch button {
        padding: 6px 8px;
        font-size: 10px;
        white-space: nowrap;
    }

    .logout-btn {
        padding: 6px 8px;
        font-size: 10px;
    }

    .result-header {
        flex-direction: column;
        gap: 6px;
        align-items: flex-start;
    }

    .save-btn {
        padding: 10px;
        font-size: 13px;
        margin-top: 8px;
    }

    .search-btn,
    .clear-btn {
        padding: 10px;
        font-size: 12px;
    }
}

/* Galaxy S25 특별 최적화 (360px-390px) */
@media screen and (max-width: 420px) {
    .login-container {
        margin: 10px auto;
        padding: 12px;
    }

    .login-container h1 {
        font-size: 20px;
    }

    .form-container {
        padding: 10px;
    }

    .form-container h2 {
        font-size: 14px;
        margin-bottom: 12px;
    }

    .header {
        padding: 6px;
    }

    .logout-btn {
        padding: 6px 10px;
        font-size: 11px;
    }
}

/* ========================================
   관리자 화면
   ======================================== */
.admin-container {
    max-width: 800px;
    margin: 0 auto;
}

/* 관리자 헤더 레이아웃 */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-direction: row;
    gap: 10px;
    flex-wrap: nowrap;
}

.admin-back-btn {
    padding: 8px 15px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.admin-back-btn:hover {
    background: #2980b9;
}

.admin-page-title {
    flex: 1;
    text-align: center;


    /* 한글 입력 필드 설정 */
    input[lang="ko"] {
        ime-mode: active;
        -webkit-ime-mode: active;
        -moz-ime-mode: active;
        -ms-ime-mode: active;
    }

    input[lang="ko"]:focus {
        ime-mode: active;
        -webkit-ime-mode: active;
        -moz-ime-mode: active;
        -ms-ime-mode: active;
    }

    font-weight: bold;
    color: #2c3e50;
    font-size: 16px;
}

/* 데이터 사용량 섹션 */
.data-usage-container {
    background: #27ae60;
    color: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
}

.data-usage-container h3 {
    margin-bottom: 15px;
    font-size: 16px;
}

.usage-info {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 10px;
}

.usage-bar {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    height: 20px;
    margin-bottom: 10px;
    overflow: hidden;
}

.usage-progress {
    background: rgba(255, 255, 255, 0.8);
    height: 100%;
    border-radius: 10px;
    transition: width 0.3s ease;
}

.usage-percent {
    font-size: 12px;
    opacity: 0.9;
}

.admin-menu {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.admin-menu-btn {
    padding: 12px 20px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.3s;
}

.admin-menu-btn:hover {
    background: #2980b9;
}

.admin-menu-btn.active {
    background: #27ae60;
}

.admin-section {
    display: none;
}

.admin-section.active {
    display: block;
}

.user-list {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #dee2e6;
}

.user-item {
    background: #f8f9fa;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 5px;
    border: 1px solid #dee2e6;
}

.user-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    margin-bottom: 5px;
}

.user-item-info {
    font-size: 13px;
    color: #666;
}

.settlement-results {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #dee2e6;
}

.settlement-item {
    background: #f8f9fa;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 5px;
    border: 1px solid #dee2e6;
}

.settlement-summary {
    background: #e8f5e8;
    padding: 15px;
    border-radius: 5px;
    border: 1px solid #27ae60;
    margin-bottom: 15px;
    font-weight: bold;
}

.log-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.log-display {
    background: #ffffff;
    color: #333333;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    max-height: 500px;
    overflow-y: auto;
    white-space: pre-wrap;
}

.log-entry {
    margin-bottom: 5px;
    padding: 3px 0;
    border-bottom: 1px solid #e9ecef;
}

.log-timestamp {
    color: #6c757d;
    font-size: 11px;
}

.log-type-system {
    color: #007bff;
    font-weight: bold;
}

.log-type-data {
    color: #28a745;
    font-weight: bold;
}

.log-type-admin {
    color: #dc3545;
    font-weight: bold;
}

.log-type-user {
    color: #17a2b8;
    font-weight: bold;
}

.log-type-error {
    color: #dc3545;
    font-weight: bold;
}

.log-type-delete {
    color: #fd7e14;
    font-weight: bold;
}

/* 관리자 데이터 조회 결과 스타일 */
.result-meta {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px dashed #ddd;
}

.result-item {
    margin-bottom: 15px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #f9f9f9;
}

.result-item:hover {
    background-color: #f0f0f0;
}

.result-header {
    margin-bottom: 10px;
    font-size: 16px;
    font-weight: bold;
    color: #333;
}

.result-header strong {
    color: #007bff;
}

/* ========================================
   처리중 팝업
   ======================================== */
.processing-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10001;
}

.processing-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
}

.processing-box {
    background: white;
    border-radius: 8px;
    padding: 30px;
    max-width: 300px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    text-align: center;
    animation: processingFadeIn 0.3s ease-out;
}

@keyframes processingFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.processing-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: processingSpinner 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes processingSpinner {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.processing-message {
    font-size: 16px;
    color: #2c3e50;
    font-weight: bold;
    line-height: 1.4;
}

/* ========================================
   커스텀 확인창
   ======================================== */
.custom-confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
}

.custom-confirm-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

.custom-confirm-box {
    background: white;
    border-radius: 8px;
    padding: 20px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.custom-confirm-message {
    font-size: 16px;
    color: #2c3e50;
    margin-bottom: 20px;
    text-align: center;
    line-height: 1.4;
}

.custom-confirm-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.custom-confirm-cancel,
.custom-confirm-ok {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    min-width: 80px;
}

.custom-confirm-cancel {
    background: #95a5a6;
    color: white;
}

.custom-confirm-cancel:hover {
    background: #7f8c8d;
}

.custom-confirm-ok {
    background: #e74c3c;
    color: white;
}

.custom-confirm-ok:hover {
    background: #c0392b;
}

/* ========================================
   form-row 내 버튼 통일 스타일
   ======================================== */
.form-row button {
    flex: 1;
    min-height: 44px;
    font-size: 14px;
    font-weight: bold;
    padding: 12px 8px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

/* 모바일에서 form-row 버튼 최적화 */
@media (max-width: 480px) {
    .form-row button {
        min-height: 40px;
        font-size: 12px;
        padding: 10px 6px;
    }
}

/* Galaxy S25 특별 최적화 */
@media screen and (max-width: 420px) {
    .form-row button {
        min-height: 36px;
        font-size: 11px;
        padding: 8px 4px;
    }
}

/* ========================================
   LOG 조회 화면 전용 스타일 (form-row 통일 스타일 적용)
   ======================================== */
.log-button-row {
    display: flex;
    gap: 8px;
}

.log-btn {
    /* form-row button 스타일 상속 */
}

/* 모바일에서 버튼 크기 최적화 */
@media (max-width: 480px) {
    .log-button-row {
        gap: 6px;
    }
}

/* ========================================
   정산처리 버튼 스타일 (form-row 통일 스타일 적용)
   ======================================== */
.settlement-btn {
    /* form-row button 스타일 상속 */
}

/* ========================================
   주행 통계 결과 스타일 (카드 형태로 통일)
   ======================================== */
#statisticsResults {
    /* 기존 result-item 스타일을 재사용 */
}

/* ========================================
   추가 스타일
   ======================================== */
input[readonly] {
    background-color: #f8f9fa !important;
    color: #6c757d;
}

.search-form {
    border-top: 1px solid #dee2e6;
    padding-top: 20px;
    margin-top: 20px;
}

.results-list {
    max-height: 400px;
    overflow-y: auto;
}

/* ========================================
   모바일 관리자 화면 최적화
   ======================================== */
@media (max-width: 480px) {
    .admin-menu {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .admin-menu-btn {
        padding: 12px 15px;
        font-size: 14px;
        margin-bottom: 0;
    }

    .admin-container {
        padding: 5px;
    }

    .data-usage-container {
        padding: 15px;
        margin-bottom: 15px;
    }

    .data-usage-container h3 {
        font-size: 14px;
    }

    .usage-info {
        font-size: 12px;
    }

    .user-item-header {
        flex-direction: column;
        gap: 5px;
        align-items: flex-start;
    }

    .log-display {
        font-size: 11px;
        max-height: 300px;
    }

    /* 모바일에서 관리자 헤더 최적화 */
    .admin-header {
        padding: 8px;
        gap: 8px;
        flex-direction: row;
        flex-wrap: nowrap;
    }

    .admin-back-btn {
        padding: 6px 10px;
        font-size: 11px;
    }

    .admin-page-title {
        font-size: 14px;
    }

    .logout-btn {
        padding: 6px 10px;
        font-size: 11px;
    }
}

/* Galaxy S25 특별 최적화 */
@media screen and (max-width: 420px) {
    .admin-header {
        padding: 6px;
        gap: 6px;
        flex-direction: row;
        flex-wrap: nowrap;
    }

    .admin-back-btn {
        padding: 5px 8px;
        font-size: 10px;
    }

    .admin-page-title {
        font-size: 13px;
    }

    .logout-btn {
        padding: 5px 8px;
        font-size: 10px;
    }
}

/* 전기가 정보 표시 스타일 */
.electric-price-info {
    margin-top: 10px;
    padding: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background-color: #f8f9fa;
}

.electric-price-info h2 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #333;
    font-size: 16px;
    text-align: left;
}

.price-info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.price-info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 15px;
    background-color: white;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    font-size: 16px;
    /* 기본 글자 크기 설정 */
}

.season-label {
    font-weight: 500;
    color: #495057;
    flex: 1;
}

.price-value {
    font-weight: bold;
    color: #007bff;
    font-size: 18px;
    margin: 0 10px;
}

.unit {
    color: #6c757d;
    font-size: 14px;
}

/* 모바일 최적화 */
@media (max-width: 768px) {
    .price-info-item {
        padding: 10px 12px;
    }

    .price-value {
        font-size: 16px;
    }
}

/* 검색 결과 스타일 */
.search-results {
    margin-top: 20px;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #f9f9f9;
}

#searchResults {
    /* display none 제거 - JavaScript로 제어 */
}

#queryResults {
    display: none;
}

#statisticsResults {
    display: none;
}

/* 로그 표시 스타일 */
.log-entry {
    margin: 5px 0;
    padding: 8px;
    background: #f8f9fa;
    border-left: 3px solid #007bff;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.log-timestamp {
    color: #666;
    font-weight: bold;
}

.log-user {
    color: #6c757d;
    font-weight: normal;
    font-size: 12px;
}

.log-type-system {
    color: #007bff;
    font-weight: bold;
}

.log-type-user {
    color: #28a745;
    font-weight: bold;
}

.log-type-admin {
    color: #ffc107;
    font-weight: bold;
}

.log-type-data {
    color: #17a2b8;
    font-weight: bold;
}

.log-type-delete {
    color: #dc3545;
    font-weight: bold;
}

.log-type-default {
    color: #6c757d;
    font-weight: bold;
}