/* Base Reset and Typography */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif;
}

body {
    background-color: #f4f4f4;
    color: #333;
    overflow: hidden;
    /* Prevent body scrolling, handle in main */
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    /* 모바일 크롬 주소창 높이에 따른 하단바 잘림 해결 */
    width: 100vw;
    background-color: #f8f9fb;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    /* 노치 및 상단바 겹침 방지 */
    background-color: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    z-index: 10;
}

.header-title {
    font-size: 1.2rem;
    font-weight: bold;
    color: #000;
}

.btn-qr-execute {
    background-color: #0b4a99;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 0.9rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: background-color 0.2s ease;
}

.btn-qr-execute.active {
    background-color: #6fb263;
    /* Green State */
}

/* Main Content Area */
.main-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.qr-result-banner {
    background-color: #e8f5e9;
    color: #2e7d32;
    padding: 12px 16px;
    font-size: 1rem;
    border-bottom: 1px solid #c8e6c9;
    display: flex;
    align-items: center;
}

.qr-result-banner.hidden {
    display: none;
}

/* Attachment Section */
.attachment-section {
    padding: 20px 16px;
}

.section-title {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.section-title h2 {
    font-size: 1.1rem;
    font-weight: bold;
}

.attachment-box {
    background-color: #ffffff;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.attachment-header {
    background-color: #124d9c;
    color: #ffffff;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.attachment-instruction {
    font-size: 0.95rem;
    font-weight: 500;
}

.attachment-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-icon {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.add-btn {
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    width: 28px;
    height: 28px;
    font-size: 1rem;
}

.attachment-body {
    min-height: 80px;
    padding: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* Image Thumbnails */
.thumbnail-wrapper {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #ccc;
}

.thumbnail-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.btn-remove-photo {
    position: absolute;
    top: -5px;
    right: -5px;
    background: red;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Camera Bottom Sheet (Half Screen) */
.camera-sheet {
    position: fixed;
    bottom: -100%;
    left: 0;
    width: 100%;
    height: 55vh;
    background-color: #f4f4f4;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: bottom 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.2);
}

.camera-sheet.active {
    bottom: 105px;
    /* 공간을 띄워서 하단 메뉴와 저장 버튼이 보이게 설정 */
}

.sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background-color: #ffffff;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    border-bottom: 1px solid #e0e0e0;
}

.sheet-header span {
    font-weight: bold;
    font-size: 1.1rem;
    color: #333;
}

.sheet-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: #000;
    min-height: 0;
    /* Fix flex child stretching issue */
}

.video-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 0;
    /* Important for containing the video */
    display: flex;
    justify-content: center;
    align-items: center;
}

#sheet-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.qr-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 250px;
    height: 250px;
    border: 3px solid #6fb263;
    border-radius: 12px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
    /* Dim the surrounding area */
    pointer-events: none;
    transition: border-color 0.3s ease;
}

.qr-guide.recognized {
    border-color: #28a745;
}

.sheet-controls {
    padding: 12px 16px;
    display: flex;
    justify-content: center;
    gap: 16px;
    background-color: #ffffff;
    padding-bottom: env(safe-area-inset-bottom, 16px);
}

#btn-sheet-capture {
    background-color: #0b4a99;
    color: white;
    flex: 2;
    padding: 12px;
    font-size: 1.1rem;
    border: none;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: bold;
}

#btn-sheet-switch {
    background-color: #6c757d;
    color: white;
    flex: 1;
    padding: 12px;
    font-size: 1.1rem;
    border: none;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.hidden {
    display: none !important;
}

/* Bottom Action Bar */
.bottom-action-bar {
    display: flex;
    height: 50px;
}

.btn-action {
    flex: 1;
    border: none;
    font-size: 1.1rem;
    font-weight: bold;
    color: #fff;
    cursor: pointer;
}

.btn-reset {
    background-color: #929292;
}

.btn-save {
    background-color: #0341a4;
}

/* Bottom Navigation */
.bottom-nav {
    display: flex;
    justify-content: space-around;
    background-color: #fff;
    border-top: 1px solid #e0e0e0;
    padding: 8px 0;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    /* 홈 제스처 영역 겹침 방지 */
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: #666;
    text-decoration: none;
    font-size: 0.8rem;
    flex: 1;
}

.nav-item.active {
    color: #3b82f6;
}

.nav-item i {
    font-size: 1.2rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 150px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.95rem;
    z-index: 1000;
    transition: opacity 0.3s ease;
}