/* --- (A) 왼쪽 사이드바 공통 스타일 --- */
.left-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 14rem;
    height: 100vh;
    background-color: #f9f9f9;
    border-right: none;  /* 오른쪽 보더 제거 */
    border: none;        /* 모든 보더 제거 */
    overflow-y: auto;
    z-index: 1000;
    transition: width 0.3s ease-in-out;
    padding-left: 0px;
}

/* (추가) 사이드바 상단 고정 영역 */
.left-sidebar .sidebar-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: inherit; /* 사이드바 배경 유지 */
    border-right: none;  /* 오른쪽 보더 제거 */
    border: none;        /* 모든 보더 제거 */
    
}
/* (추가) 사이드바 스크롤 영역 */
.left-sidebar .sidebar-content {
    overflow-y: auto;
    max-height: calc(100vh - 50px); /* 상단 header 높이(약 50px)만큼 제외 */
    border-right: none;  /* 오른쪽 보더 제거 */
    border: none;        /* 모든 보더 제거 */

}

/* 스크롤바 스타일링도 보더 없이 깔끔하게 수정 */
.left-sidebar .sidebar-content::-webkit-scrollbar {
    width: 5px;
}

.left-sidebar .sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}

.left-sidebar .sidebar-content::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 5px;
    border: none;
}

/* 사이드바가 접혔을 때 (collapsed) */
.left-sidebar.collapsed {
    width: 0 !important;   /* 완전히 숨김 */
    padding: 0 !important; /* 내부 패딩 제거(스크롤바 등) */
    overflow: hidden;      /* 내용이 보이지 않도록 */
}

/* 본문(content) 쪽 */
#content-wrapper {
    margin-left: 14rem;                /* 사이드바가 펼쳐졌을 때 왼쪽 여백 */
    transition: margin-left 0.3s ease-in-out;  /* 부드러운 전환 */
}

/* 사이드바가 접혔을 때 본문 확장용 */
#content-wrapper.expanded {
    margin-left: 0 !important;  
}

.left-sidebar .sidebar-heading {
    font-size: 0.7rem;  /* 글자 크기 줄임 */
    font-weight: 700;   /* 더 굵게 */
    text-transform: uppercase;
    padding: 0.4rem 0.75rem;  /* 패딩 조정 */
    color: #666;  /* 색상 조정 */
    letter-spacing: 0.05em;  /* 자간 살짝 늘림 */
}

.left-sidebar .sidebar-divider {
    height: 1px;
    background-color: #e3e6f0;
    margin: 0.75rem 0;
}

.left-sidebar .nav-item {
    margin: 0.1rem 0;  /* 상하 간격 줄임 */
}

.left-sidebar .nav-link {
    display: block;
    padding: 0.35rem 0.75rem;  /* 좌우 패딩 줄임 */
    color: #707070;  /* 짙은 회색으로 변경 */
    text-decoration: none;
    white-space: nowrap;  /* 줄바꿈 방지 */
    font-size: 0.85rem;  /* 글자 크기 약간 줄임 */
}

.left-sidebar .nav-link:hover {
    background-color: #eaecf4;
    color: #3a3b45;
    text-decoration: none;
}

.left-sidebar .nav-link i {
    margin-right: 4px;
    width: 14px;  /* 아이콘 너비 확보 */
    text-align: center;
}

/* (B) 브라우저 너비가 좁을 때 사이드바를 숨기거나 토글하는 경우,
아래와 같은 미디어 쿼리를 추가로 사용 가능(선택사항) */
@media (max-width: 768px) {
.left-sidebar {
    width: 10rem;
}
}


.file-toggle.active, .b64-toggle.active {
    background-color: #4e73df;
    color: white;
    border-color: #4e73df;
}

.file-toggle:hover:not(.active), .b64-toggle:hover:not(.active) {
    background-color: #eaecf4;
    color: #3a3b45;
}

.file-toggle.active:hover, .b64-toggle.active:hover {
    background-color: #2e59d9;
    border-color: #2653d4;
}
.file-toggle:focus, .b64-toggle:focus {
    outline: none;
    box-shadow: none;
}
.item-group {
    border: 1px solid #e3e6f0;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 10px;  /* 아이템 간 간격 추가 */
}

.item-buttons {
    display: flex;
    flex-direction: column;
    margin-right: 10px;
}
.item-buttons button {
    padding: 2px 5px;
    margin: 2px;
}
.item-content {
    flex-grow: 1;
}
.item-content input {
    width: 100%;
    margin-bottom: 5px;
}
.item-content textarea {
    width: 100%;
    margin-bottom: 10px; /* 기존 마진 */
    margin-top: 10px; /* 추가된 마진 */
}
.add-item-button {
    font-size: 1.2em;
    padding: 0 10px;
}   
@media (max-width: 768px) {
    .card-header {
        flex-direction: column;
        align-items: stretch !important;
    }
    .card-header > div {
        margin-bottom: 10px;
    }
    #functionType {
        width: 100% !important;
    }
}
.flow-item {
    border: 1px solid #e3e6f0;
    padding: 10px;
    border-radius: 5px;
}
.flow-item-group {
    display: block;
}

.flow-item-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px; /* 추가된 마진
}

.flow-item-header .btn-group {
    flex-shrink: 0;
}

.flow-item-header .form-control,
.flow-item-header .flow-function-select {
    flex-grow: 1;
    margin-right: 10px;
}

.flow-item-header .btn-outline-custom {
    flex-shrink: 0;
}

.flow-item-content {
    width: 100%;
}

.flow-item-content textarea {
    width: 100%;
    margin-bottom: 10px;
}

/* 공통 버튼 스타일 */
.btn-outline-custom {
    background-color: #fff;
    border-color: #d1d3e2;
}

.btn-outline-custom:focus, .btn-outline-custom.focus {
    box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.25);
}

.btn-group > .btn-outline-custom:not(:last-child) {
    border-right: none;
}

.btn-group > .btn-outline-custom:not(:first-child) {
    border-left: none;
}

/* 실행 버튼 */
.btn-outline-custom.btn-play {
    color: #4e73df;
}
.btn-outline-custom.btn-play:hover {
    color: #fff;
    background-color: #4e73df;
    border-color: #4e73df;
}

/* flow-function-select 스타일 조정 */
.flow-function-select {
    flex-grow: 1;
}

/* 아이콘 간격 조정 (이미 있다면 중복 제거) */
.btn-outline-custom i {
    width: 14px;
    text-align: center;
}

/* 위/아래 이동 버튼 */
.btn-outline-custom.btn-move {
    color: #858796;
}
.btn-outline-custom.btn-move:hover {
    color: #fff;
    background-color: #858796;
    border-color: #858796;
}

/* 추가 버튼 */
.btn-outline-custom.btn-add {
    color: #1cc88a;
}
.btn-outline-custom.btn-add:hover {
    color: #fff;
    background-color: #1cc88a;
    border-color: #1cc88a;
}

/* 삭제 버튼 */
.btn-outline-custom.btn-remove {
    color: #e74a3b;
}
.btn-outline-custom.btn-remove:hover {
    color: #fff;
    background-color: #e74a3b;
    border-color: #e74a3b;
}

/* 링크 버튼 */
.btn-outline-custom.btn-link {
    color: #4e73df;
}
.btn-outline-custom.btn-link:hover {
    color: #fff;
    background-color: #4e73df;
    border-color: #4e73df;
}

.btn-outline-custom.btn-file {
    color: #36b9cc;
}
.btn-outline-custom.btn-file:hover,
.btn-outline-custom.btn-file.active {
    color: #fff;
    background-color: #36b9cc;
    border-color: #36b9cc;
}

/* B64 토글 버튼 */
.btn-outline-custom.btn-b64 {
    color: #f6c23e;
}
.btn-outline-custom.btn-b64:hover,
.btn-outline-custom.btn-b64.active {
    color: #fff;
    background-color: #f6c23e;
    border-color: #f6c23e;
}

/* 아이콘 간격 조정 */
.btn-outline-custom i {
    width: 14px;
    text-align: center;
}

.item-group {
    border: 1px solid #e3e6f0;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 10px;
}

.item-content {
    margin-top: 10px;
}

.item-content textarea {
    width: 100%;
}

.function-connection {
    background-color: #f8f9fc;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 10px;
}

.function-connections {
    margin-top: 10px;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-dialog {
    max-width: 600px;
    width: 90%;
    margin: 1.75rem auto;
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 30%;
    max-width: 400px;
    max-width: 100%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content input[type="text"],
.modal-content input[type="number"],
.modal-content select {
    width: 100%;
    padding: 5px;
    margin-bottom: 10px;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close:hover,
.close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

@media (max-width: 576px) {
    .modal-dialog {
        max-width: 90%;
        margin: 1rem auto;
    }
}

.modal-content {
    padding: 20px;
}

.modal-header,
.modal-footer {
    padding: 15px 20px;
}

.modal-body {
    padding: 20px;
}

.form-group {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.form-group label {
    width: 30%;
    text-align: right;
    padding-right: 15px;
}

.form-group input,
.form-group select {
    width: 70%;
}



#flowList, #functionList {
    max-height: calc(100vh - 200px); /* 상단 여백 고려 */
    overflow-y: auto;
}

/* 스크롤바 스타일링 (선택사항) */
#flowList::-webkit-scrollbar,
#functionList::-webkit-scrollbar {
    width: 5px;
}

#flowList::-webkit-scrollbar-track,
#functionList::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#flowList::-webkit-scrollbar-thumb,
#functionList::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 5px;
}

#flowList::-webkit-scrollbar-thumb:hover,
#functionList::-webkit-scrollbar-thumb:hover {
    background: #555;
}
/* --- (1) wrapper 관련: display:flex 해제 (필요시) ---
SB Admin 2에서 #wrapper 디폴트가 display:flex라면, 
position: fixed인 sidebar에 맞춰서 layout만 보정해도 됩니다.
만약 충돌이 있다면, 아래처럼 #wrapper를 블록화할 수도 있습니다.
*/
#wrapper {
display: block !important; /* flex를 해제해서, 사이드바를 고정시켜도 레이아웃 꼬이지 않도록 */
position: relative;
}

/* --- (2) 사이드바 고정 & 스크롤 --- */
.sidebar {
position: fixed !important; /* 화면에 고정 */
top: 0;
left: 0;
z-index: 9999;              /* 위계 조정 (필요시) */
width: 6.5rem !important;
height: 100vh !important;   /* 전체 높이 */
overflow-y: auto !important;/* 세로 스크롤 */
overflow-x: hidden;         /* 가로는 숨김 */
/* SB Admin 2가 .sidebar-light일 경우 배경색 유지 or 바꿔도 됨 */
}
.sidebar.toggled { width: 6.5rem !important; }

/* --- (3) 본문 쪽 조정 ---
사이드바를 fixed로 빼버렸으므로, 
본문(wrapper, content 등)이 사이드바만큼 오른쪽으로 밀려 있어야 충돌없음
*/
/* --- (4) 사이드바 토글버튼(#sidebarToggle) 사용 시 ---
.sidebar.toggled 등을 sb-admin-2가 만들어 주는데,
그 때 width를 0으로 만드는 부분들이 있으므로, !important로 오버라이드.
*/


.sidebar.toggled {
width: 14rem !important;  
}
.sidebar.toggled #sidebarToggle::after {
/* 아이콘 모양만 바꿀지? 필요 없으면 건너뛰기 */
content: "\f105" !important;
}

/* (선택) 만약 상단 Navbar 높이(예: 4.375rem)만큼 띄우고 싶으면 */
.navbar {
z-index: 10000; /* 사이드바보다 위 */
}
.sidebar {
top: 4.375rem !important; /* 상단 navbar 높이 만큼 띄우기 */
height: calc(100vh - 4.375rem) !important; /* navbar 제외한 높이 */
}

/* 상단 Navbar 라이트(연한 회색) */
.navbar {
    background-color: #f9f9f9 !important;
    border-bottom: 1px solid #ddd;
}

/* 카드 배경, 본문 배경 등 */
body {
    background-color: #f6f6f6;
}
.card {
    background-color: #fff; /* 정말 약간의 차이를 주려면 #fdfdfd 정도 */
    border: 1px solid #ececec;
}

/* 버튼 색상 예: 회색 계열로 */
.btn-primary {
    background-color: #999 !important;
    border-color: #999 !important;
}
.btn-primary:hover {
    background-color: #777 !important;
    border-color: #777 !important;
}

/* 사이드바 안쪽에 토글 버튼 컨테이너 */
.sidebar-toggle-container {
position: absolute;
top: 10px;
left: 10px;
z-index: 10001; /* 사이드바 내부 요소보다 더 위로 */
}

/* 필요 시 .btn-secondary 등도 원하는 색으로 */
    
/* 공통 버튼 위치 */

/* 사이드바 안쪽에 토글 버튼 컨테이너 */
.sidebar-toggle-container {
position: absolute;
top: 10px;
left: 10px;
z-index: 10001; /* 사이드바 내부 요소보다 더 위로 */
}

/* --- (1) 기본 버튼 위치(본문 왼쪽 상단) 설정 --- */
.mySidebarToggleBtn {
position: fixed;  
top: 1rem;
left: 1rem;
z-index: 1000;
padding: 0.5rem;
font-size: 1.25rem;
line-height: 1;
background: white;
border: 1px solid #ddd;
border-radius: 4px;
cursor: pointer;
}

#myExpandButton {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1100;
    display: none; /* 기본 숨김 처리 */
}

body.collapsed #myExpandButton {
    display: block;
}

/* 사이드바가 접혔을 때만 버튼 표시 */
.left-sidebar.collapsed ~ #content-wrapper .mySidebarToggleBtn {
    display: block;
}

/* 기본적으로 버튼 숨김 */
.mySidebarToggleBtn {
display: none;
}

/* 사이드바가 접힌 상태(.collapsed)일 때만 버튼을 표시 */
.left-sidebar.collapsed ~ #content-wrapper .mySidebarToggleBtn {
display: block;
}

/* (A) 사이드바 내부에 있는 버튼은 항상 보이도록 */
.sidebar-toggle-container .mySidebarToggleBtn {
display: block !important; 
}


/*
(C) 사이드바가 접혀 있을 때만
Topbar 버튼(#myExpandButton)을 보이게 한다
*/
+ /* #myExpandButton은 .mySidebarToggleBtn 과 동일하게 처리 */
#myExpandButton {
display: none; /* 기본적으로 숨김 */
}
.left-sidebar.collapsed ~ #content-wrapper #myExpandButton {
display: block; /* 사이드바가 접혔을 때만 표시 */
}

.sidebar:not(.toggled) ~ #content-wrapper #myExpandButton {
display: none !important;
}
.sidebar.toggled ~ #content-wrapper #myExpandButton {
display: inline-block !important;
}

/* 사용자 메시지 */
.chat-msg-user {
    display: inline-block;
    max-width: 60%;
    background-color: #444444; /* 짙은 회색 배경 */
    color: #ffffff;
    text-align: right; 
    margin-left: auto;
    margin-right: 0;
    border-radius: 8px;
    padding: 6px 10px;
}

/* 챗봇 메시지 */
.chat-msg-assistant {
    display: inline-block;
    max-width: 60%;
    background-color: transparent; /* 투명 배경 */
    color: #000000;
    text-align: left;
    margin-left: 0;
    margin-right: auto;
    border-radius: 8px;
    padding: 6px 10px;
}

/* 함수 호출(툴) 관련 메시지 */
.chat-msg-tool {
    display: inline-block;
    max-width: 60%;
    background-color: #fff9db; /* 연한 노란색 배경 */
    color: #000000;
    text-align: left;
    margin-left: 0;
    margin-right: auto;
    border-radius: 8px;
    padding: 6px 10px;
}

/* 시스템/상태(Log) 메시지 */
.chat-msg-system {
    display: inline-block;
    max-width: 80%;
    background-color: #f3f3f3; /* 연한 회색 배경 */
    color: #666666;
    font-style: italic;
    text-align: center;
    margin: 5px auto;
    border-radius: 8px;
    padding: 4px 8px;
}

/* 채팅 메시지 공통 스타일 */
.chat-message {
    position: relative;
    clear: both;
    margin: 8px 0;
    max-width: 60%;
    padding: 6px 10px;
    border-radius: 8px;
    word-wrap: break-word;
    line-height: 1.4;
}

/* 사용자 메시지: 우측 정렬, 짙은 회색 배경 */
.chat-msg-user {
    float: right;
    background-color: #444444;
    color: #ffffff;
    text-align: left;
    margin-right: 10px;
}

/* 챗봇 메시지: 좌측 정렬, 투명 배경 */
.chat-msg-assistant {
    float: left;
    background-color: transparent;
    color: #000000;
    text-align: left;
    margin-left: 10px;
}

/* 함수 호출(툴) 메시지: 좌측, 연한 노란색 배경 */
.chat-msg-tool {
    float: left;
    background-color: #fff9db;
    color: #000000;
    text-align: left;
    margin-left: 10px;
}

/* 시스템/상태(Log) 메시지: 가운데, 연한 회색 배경, 기울임체 */
.chat-msg-system {
    clear: both;
    display: block;
    margin: 8px auto;
    max-width: 80%;
    background-color: #f3f3f3;
    color: #666666;
    font-style: italic;
    text-align: center;
    padding: 4px 8px;
    border-radius: 8px;
}

/* 공통 채팅 메시지 컨테이너 */
.chat-message {
    display: flex;
    align-items: flex-end;
    margin: 8px 0;
    max-width: 60%;
    word-wrap: break-word;
    line-height: 1.4;
}

/* 프로필 아바타 영역 */
.chat-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin: 0 8px;
    border-radius: 50%;
    background-color: #ddd;
    font-weight: bold;
    color: #333;
}
.chat-avatar-initial {
    font-size: 14px;
}

/* 실제 메시지 내용(말풍선) 영역 */
.chat-message-bubble {
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14px;
    overflow-wrap: break-word;
}

/* 사용자 메시지: 오른쪽 정렬 + 짙은 회색 배경 */
.chat-msg-user {
    float: right; 
    margin-left: auto; 
    text-align: right; 
    justify-content: flex-end; 
}
.chat-msg-user .chat-avatar {
    order: 2; /* 아바타를 오른쪽으로 */
}
.chat-msg-user .chat-message-bubble {
    order: 1;
    background-color: #444444;
    color: #ffffff;
    margin-right: 10px;
}

/* 에이전트(챗봇) 메시지: 왼쪽 정렬 + 투명 배경 */
.chat-msg-assistant {
    float: left; 
    margin-right: auto; 
    text-align: left;
    justify-content: flex-start;
}
.chat-msg-assistant .chat-avatar {
    order: 1; /* 아바타 왼쪽 */
}
.chat-msg-assistant .chat-message-bubble {
    order: 2;
    background-color: transparent;
    color: #000000;
    margin-left: 10px;
}

/* 함수 호출(툴) 메시지: 왼쪽, 연한 노란색 배경 */
.chat-msg-tool {
    float: left;
    margin-right: auto;
    justify-content: flex-start;
}
.chat-msg-tool .chat-avatar {
    background-color: #f9db76;
    color: #000;
    order: 1;
}
.chat-msg-tool .chat-message-bubble {
    order: 2;
    background-color: #fff9db;
    color: #000000;
    margin-left: 10px;
}

/* 시스템/상태(Log) 메시지: 중앙, 연한 회색 배경, 기울임체 */
.chat-msg-system {
    clear: both; 
    display: block; 
    margin: 8px auto; 
    max-width: 80%; 
    background-color: #f3f3f3; 
    color: #666666; 
    font-style: italic; 
    text-align: center; 
    padding: 4px 8px; 
    border-radius: 8px;
}

/* 사이드바 내부 토글 버튼 스타일 (sidebarToggleBtnInSidebar) */
.sidebar-toggle-container .sidebarToggleBtnInSidebar {
    display: block;
    /* 사이드바 내부 고정 버튼이라면 position: absolute */
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 10001;
    /* 나머지 스타일은 기존 취향에 맞춰 적용 */
}

/* 탑바 쪽(페이지 상단)에 있는 토글 버튼 (sidebarToggleBtnInPage) */
.sidebarToggleBtnInPage {
    display: none; /* 기본적으로 숨김 */
    /* 필요 시 스타일 추가 */
}

/* 사이드바가 접혔을 때, 탑바 버튼만 보이도록 */
.left-sidebar.collapsed ~ #content-wrapper .sidebarToggleBtnInPage {
    display: block; /* 접힐 때만 보이기 */
}