/* 모바일 전용 스타일 (max-width: 768px) - style.css에서 분리 */

/* 모바일에서 버튼 크기 조정 */
@media (max-width: 768px) {
    .memo-action-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
        min-width: 45px;
    }
    
    .memo-actions {
        gap: 0.3rem;
    }
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .header {
        padding: 0.25rem 0.5rem;
        flex-wrap: nowrap;
        min-height: 50px;
        gap: 0.25rem;
    }
    
    /* 모바일 세로보기에서 헤더 최적화 */
    @media (max-width: 768px) and (orientation: portrait) {
        .header {
            min-height: 45px;
            padding: 0.2rem 0.4rem;
        }
        
        .main-container {
            margin-top: 45px !important;
            padding-top: 0 !important;
        }
    }
    
    .header-left {
        display: flex;
        align-items: center;
        flex: 0 0 auto;
    }
    
    .header-left .logo {
        font-size: 1.2rem;
        margin: 0;
    }
    
    .header-nav {
        display: flex;
        gap: 0.5rem;
        flex: 1;
        justify-content: center;
    }
    
    .nav-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.7rem;
        border-radius: 6px;
        white-space: nowrap;
        min-width: 32px;
        text-align: center;
    }
    
    /* 모바일에서 네비게이션 버튼 텍스트 변경 */
    #timeline-btn::before {
        content: "T";
    }
    
    #calendar-btn::before {
        content: "C";
    }
    
    /* 모바일에서 원래 텍스트 숨기기 */
    #timeline-btn span,
    #calendar-btn span {
        display: none;
    }
    
    .header-right {
        display: flex;
        align-items: center;
        gap: 0.25rem;
        flex: 0 0 auto;
        justify-content: flex-end;
        flex: 1;
    }
    
    .user-info {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
        display: none; /* 모바일에서 사용자 정보 숨김 */
    }
    
    .user-name {
        font-size: 0.75rem;
    }
    
    /* 데스크톱과 동일한 단순 버튼 스타일 적용 */
    .logout-btn {
        padding: 0.5rem 1rem;
        border: 2px solid var(--border-gray);
        background-color: var(--white);
        color: var(--text-gray);
        font-family: 'Noto Sans KR', sans-serif;
        font-weight: 500;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s ease;
        font-size: 0.9rem;
        white-space: nowrap;
        min-width: 80px;
    }
    
    .people-list-btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.8rem;
        border-radius: 6px;
        white-space: nowrap;
        min-width: 28px;
        background-color: var(--naver-green);
        color: white;
        border: none;
        margin-right: 0.25rem;
        font-weight: 600;
        text-align: center;
    }
    
    .llm-chat-btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
        border-radius: 8px;
        white-space: nowrap;
        min-width: 80px;
    }

    /* 로그아웃 버튼을 LLM 버튼과 동일한 크기/폰트로 정렬 */
    .logout-btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
        border-radius: 8px;
        min-width: 80px;
    }
    
    .main-container {
        height: calc(100vh - 50px);
        flex-direction: column;
        overflow: hidden;
        display: flex;
        gap: 0;
        padding: 0;
        margin: 0;
        align-items: stretch;
        justify-content: flex-start;
        margin-top: 0 !important;
        padding-top: 0 !important;
        min-height: 0;
    }
    
    /* 모바일에서 main-container 레이아웃 최적화 */
    @media (max-width: 768px) {
        .main-container {
            justify-content: flex-start !important;
            align-items: stretch !important;
            gap: 0 !important;
            padding: 0 !important;
            margin: 0 !important;
        }
    }
    
    /* 모바일에서 더 정확한 높이 계산 */
    @supports (height: 100dvh) {
        .main-container {
            height: calc(100dvh - 50px);
        }
    }
    
    /* 모바일에서 추가 높이 조정 */
    @media (max-width: 768px) and (orientation: portrait) {
        .main-container {
            height: calc(100vh - 45px);
            min-height: calc(100vh - 45px);
        }
        
        .main-content {
            min-height: calc(100vh - 200px) !important;
        }
        
        .memo-list-section {
            min-height: calc(100vh - 350px) !important;
        }
    }
    
    /* 모바일에서 사이드바를 오버레이로 변경 */
    .sidebar {
        position: fixed;
        left: -100%;
        top: 50px;
        width: 85%;
        height: calc(100vh - 50px);
        padding: 0.5rem;
        border-right: 2px solid var(--border-gray);
        background-color: white;
        overflow-y: auto;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.15);
        box-sizing: border-box;
    }
    
    /* 모바일 세로보기에서 사이드바 높이 최적화 */
    @media (max-width: 768px) and (orientation: portrait) {
        .sidebar {
            top: 45px;
            height: calc(100vh - 45px);
        }
    }
    
    .sidebar.active {
        left: 0;
    }
    
    /* 모바일에서 사이드바 오버레이 배경 */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    .sidebar-overlay.active {
        display: block;
        opacity: 1;
    }
    
    /* 모바일에서 사람 목록 섹션 헤더 최적화 */
    .person-section {
        margin: 0;
        padding: 0;
    }
    
    .person-header {
        margin: 0 0 0.25rem 0;
        padding: 0.25rem;
    }
    
    .section-title {
        margin: 0;
        font-size: 0.9rem;
    }
    
    /* 모바일에서 사람 정보 헤더 최적화 */
    .person-info-header {
        margin-bottom: 0.5rem;
        gap: 0.5rem;
    }
    
    .person-avatar-large {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }
    
    .selected-person-info .person-name {
        font-size: 1.2rem;
        margin-bottom: 0.25rem;
    }
    
    .person-details {
        gap: 0.5rem;
        font-size: 0.8rem;
    }
    
    /* 메인 콘텐츠 - 모바일에서 전체 화면 사용 */
    .main-content {
        flex: 1;
        padding: 0.25rem;
        overflow-y: auto;
        min-height: 0;
        order: 2;
        display: flex !important;
        flex-direction: column;
        margin: 0;
        box-sizing: border-box;
        width: 100%;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        min-height: 300px !important;
        max-height: none !important;
        flex-shrink: 0;
        flex-grow: 1;
    }
    
    /* 모바일에서 main-content를 헤더 바로 아래로 강제 배치 */
    @media (max-width: 768px) {
        .main-content {
            margin-top: 0 !important;
            padding-top: 0 !important;
            order: 1 !important;
            flex-shrink: 0 !important;
            min-height: calc(100vh - 100px) !important;
        }
        
        .sidebar {
            order: 2 !important;
        }
    }
    
    .memo-input-container {
        flex-direction: column;
    }
    
    .memo-submit-btn {
        align-self: flex-end;
    }
    
    /* 모바일에서 메모 입력 섹션 최적화 */
    .memo-input-section {
        padding: 0.5rem;
        margin-bottom: 0.5rem;
        border-radius: 8px;
    }
    
    /* 모바일에서 선택된 사람 정보 최적화 */
    .selected-person-info {
        padding: 0.5rem;
        margin-bottom: 0.5rem;
        border-radius: 8px;
    }
    
    /* 모바일에서 메모 목록 섹션 최적화 */
    .memo-list-section {
        padding: 0.25rem;
        margin: 0;
    }

    /* 메모 검색 입력 모바일 최적화 */
    .memo-search {
        margin: 0.25rem 0 0.5rem 0;
    }
    .memo-search-input {
        width: 100%;
        padding: 0.4rem 0.6rem;
        font-size: 0.9rem;
        border: 1px solid var(--border-gray);
        border-radius: 6px;
        box-sizing: border-box;
    }
    
    /* 모바일에서 메모 아이템 최적화 */
    .memo-item {
        padding: 0.5rem;
        margin-bottom: 0.5rem;
        border-radius: 8px;
    }
    
    .memo-content {
        padding: 0.25rem;
        font-size: 0.9rem;
        line-height: 1.4;
    }
    
    .memo-date-display {
        font-size: 0.75rem;
        margin-top: 0.25rem;
    }
    
    /* 모바일에서 날짜 입력 최적화 */
    .date-input {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
        border-radius: 6px;
    }
    
    /* person-toggle-btn 관련 스타일 제거됨 (폴더 아이콘 삭제로 인해) */
    
    /* LLM 패널 모바일 대응 */
    .llm-chat-panel.active {
        width: 100%;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1001;
        border-left: none;
    }
    
    .main-container.llm-active .main-content,
    .main-container.llm-active .sidebar {
        display: none;
    }
    
    /* 모바일에서 메모 아이템 스타일 */
    .memo-item {
        padding: 0.5rem;
        margin-bottom: 0.25rem;
        border-radius: 6px;
        background-color: var(--white);
        border: 1px solid var(--border-gray);
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    }
    
    .memo-content {
        font-size: 0.85rem;
        line-height: 1.4;
        margin: 0.125rem 0;
    }
    
    .memo-date-display {
        font-size: 0.75rem;
        color: var(--text-gray);
        margin-bottom: 0.125rem;
    }
    
    /* 모바일에서 사람 아이템 스타일 */
    .person-item {
        padding: 0.25rem;
        margin-bottom: 0.125rem;
        border-radius: 4px;
        background-color: var(--white);
        border: 1px solid var(--border-gray);
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
        display: flex;
        align-items: center;
        gap: 0.25rem;
    }
    
    .person-name {
        font-size: 0.85rem;
        font-weight: 500;
    }
    
    /* 모바일에서 체크박스 스타일 */
    .person-checkbox {
        width: 16px;
        height: 16px;
        margin: 0;
    }
    
    /* 모바일에서 검색 입력창 스타일 */
    .search-input {
        width: 100%;
        padding: 0.25rem;
        border: 1px solid var(--border-gray);
        border-radius: 6px;
        font-size: 0.85rem;
        margin-bottom: 0.25rem;
        box-sizing: border-box;
    }
    
    /* 모바일에서 메모 입력 섹션 스타일 */
    .memo-input-section {
        margin-bottom: 0.25rem;
        padding: 0.25rem;
        background-color: var(--light-gray);
        border-radius: 6px;
        border: 1px solid var(--border-gray);
        flex-shrink: 0;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        min-height: 120px !important;
        max-height: none !important;
        overflow: visible !important;
    }
    
    /* 모바일에서 메모 입력 섹션을 상단으로 이동 */
    @media (max-width: 768px) {
        .memo-input-section {
            margin-top: 0 !important;
            margin-bottom: 0.5rem !important;
            order: 1 !important;
            flex-shrink: 0 !important;
        }
        
        .memo-list-section {
            order: 2 !important;
            flex: 1 !important;
            min-height: 0 !important;
        }
        
        .selected-person-info {
            order: 3 !important;
            flex-shrink: 0 !important;
        }
    }
    
    .memo-input {
        width: 100%;
        min-height: 60px;
        padding: 0.25rem;
        border: 1px solid var(--border-gray);
        border-radius: 6px;
        font-size: 0.85rem;
        margin-bottom: 0.25rem;
        resize: vertical;
        box-sizing: border-box;
    }

    /* contenteditable 대체 입력이 존재할 때 textarea는 숨김 (JS와 일치) */
    .memo-input-editable + textarea.memo-input {
        display: none !important;
    }
    
    .memo-submit-btn {
        padding: 0.25rem 0.5rem;
        background-color: var(--naver-green);
        color: white;
        border: none;
        border-radius: 6px;
        font-size: 0.75rem;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.3s ease;
        display: inline-block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .memo-submit-btn:hover {
        background-color: #02b34a;
    }
    
    /* 모바일에서 날짜 입력 스타일 */
    .date-input {
        width: 100%;
        padding: 0.25rem;
        border: 1px solid var(--border-gray);
        border-radius: 6px;
        font-size: 0.85rem;
        margin-bottom: 0.25rem;
        box-sizing: border-box;
    }
    
    /* 모바일에서 메모 목록 섹션 스타일 */
    .memo-list-section {
        flex: 1;
        overflow-y: auto;
        min-height: 0;
        padding-top: 0.25rem;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        min-height: 200px !important;
        max-height: none !important;
        flex-shrink: 0;
        flex-grow: 1;
    }
    
    /* 모바일에서 메모 목록 섹션 높이 최적화 */
    @media (max-width: 768px) {
        .memo-list-section {
            flex: 1 !important;
            min-height: 0 !important;
            max-height: none !important;
            overflow-y: auto !important;
            padding: 0.5rem !important;
            background-color: var(--white);
            border-radius: 6px;
            border: 1px solid var(--border-gray);
        }
    }
    
    /* 모바일에서 선택된 사람 정보 스타일 */
    .selected-person-info {
        margin-bottom: 0.25rem;
        padding: 0.25rem;
        background-color: var(--white);
        border-radius: 6px;
        border: 1px solid var(--border-gray);
        /* 표시/숨김은 JS에서 제어. 강제 표시 제거 */
        visibility: visible !important;
        opacity: 1 !important;
        height: auto !important;
        min-height: 80px !important;
        max-height: none !important;
        overflow: visible !important;
        flex-shrink: 0;
    }
    
    /* 모바일에서 선택된 사람 정보를 하단에 배치 */
    @media (max-width: 768px) {
        .selected-person-info {
            margin-top: auto !important;
            margin-bottom: 0 !important;
            padding: 0.5rem !important;
            border-top: 1px solid var(--border-gray);
            background-color: var(--light-gray);
        }
    }
    
    .person-info-header {
        margin-bottom: 0.125rem;
    }
    
    .person-info-stats {
        display: flex;
        gap: 0.5rem;
        font-size: 0.7rem;
    }
}


