/* UI 전용 스타일 (상단 툴바/레이아웃/사이드바/에디터 컨테이너)
   - 본문(에디터) 스타일은 content.css로 분리
   - 모달 내부 UI는 Shadow DOM 안에서 스타일링되어 여기의 영향을 받지 않습니다. */

*{box-sizing:border-box}
body{margin:0;font-family:Inter,system-ui,sans-serif;height:100vh;display:flex;flex-direction:column}

.doc-info-bar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding:4px 8px;
  background:#0f172a;
  color:#e2e8f0;
  font-size:12px;
}
.doc-title-display{
  font-weight:600;
}
.doc-status-display{
  flex:1;
  text-align:center;
  color:#cbd5e1;
}

.topbar{display:flex;flex-direction:column;gap:4px;padding:6px 8px;border-bottom:1px solid #ddd;background:#f1f5f9}

.topbar-row{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap}
.ribbon-tabs{display:flex;gap:4px;align-items:flex-end}
.ribbon-tab{border-radius:8px 8px 0 0;border:1px solid transparent;border-bottom:none;background:transparent;padding:4px 10px;font-size:13px;color:#334155;display:flex;align-items:center;gap:4px}
.ribbon-tab img{width:14px;height:14px}
.ribbon-tab.active{background:#ffffff;border-color:#cbd5e1;border-bottom-color:#ffffff;font-weight:600}

.ribbon-bars{border-radius:8px;border:1px solid #cbd5e1;background:#ffffff;padding:6px 8px;display:flex;flex-direction:column;gap:6px}
.ribbon-bar{display:none;gap:16px;flex-wrap:wrap;align-items:flex-start}
.ribbon-bar.active{display:flex}
.ribbon-group{min-width:140px;display:flex;flex-direction:column;gap:4px}
.ribbon-group-title{font-size:11px;color:#64748b}
.ribbon-group-row{display:flex;flex-wrap:wrap;gap:4px;align-items:center}

/* 기존 버튼/셀렉트 스타일은 그대로 유지 */
button{border:1px solid #cbd5e1;background:#fff;border-radius:8px;padding:5px 10px;cursor:pointer}
button:hover{background:#f8fafc}
select{height:32px;border:1px solid #cbd5e1;border-radius:8px;padding:0 10px}

.title-label{height:32px;display:inline-flex;align-items:center;border:1px solid #cbd5e1;border-radius:10px;padding:0 10px;min-width:220px;max-width:260px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;background:#fff;color:#0f172a}

.color-label{display:flex;align-items:center;gap:4px;font-size:12px;color:#334155}
.color-label input{width:28px;height:24px;border:0;padding:0;background:transparent}

.popup-wrap{position:relative}
.popup{position:absolute;top:36px;left:0;background:#fff;border:1px solid #cbd5e1;border-radius:8px;box-shadow:0 8px 24px rgba(0,0,0,.12);display:flex;flex-direction:column;padding:6px;gap:6px;z-index:20;min-width:170px}
.popup hr{border:0;border-top:1px solid #e2e8f0;margin:4px 0}
.hidden{display:none}

.layout{position:relative;display:flex;min-height:0;flex:1;margin:0 8px}

.sidebar-wrap{position:relative;width:0}
.sidebar{
  position:fixed;
  left:0;
  top:72px; /* doc-info-bar + 리본 높이 대략 */
  bottom:0;
  width:260px;
  border-right:1px solid #ddd;
  padding:8px;
  overflow:auto;
  background:#ffffff;
  transform:translateX(-260px); /* 완전히 숨김 (핸들만 보이게) */
  transition:transform 0.15s ease-out;
  z-index:50;
}
.sidebar-handle{
  position:fixed;
  left:0;
  top:50%;
  width:8px;
  height:60px;
  transform:translateY(-50%);
  background:linear-gradient(to right,#0f172a,transparent);
  opacity:.3;
  cursor:pointer;
  z-index:60;
}
.sidebar-wrap:hover .sidebar{transform:translateX(0);}
.sidebar-wrap:hover .sidebar-handle{opacity:.1;}

.sidebar-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px;font-size:13px;color:#0f172a}
.sidebar-small-btn{font-size:12px;padding:2px 4px;border-radius:4px;min-width:auto;line-height:1}
.btn-rename,.btn-move,.btn-copy,.btn-delete{font-size:14px}
.btn-copy{position:relative;padding-right:6px}
.btn-copy::after{content:'+';position:absolute;right:1px;top:-2px;font-size:9px}

.doc-item{
  position:relative;
  padding:6px 8px;
  border:1px solid #e2e8f0;
  border-radius:6px;
  margin-bottom:3px;
  cursor:pointer;
  font-size:12px;
  display:flex;
  align-items:center;
}
.doc-item.active{background:#eff6ff;border-color:#60a5fa}

.doc-item-actions{
  position:absolute;
  right:4px;
  top:50%;
  transform:translateY(-50%);
  display:none;
  gap:2px;
}
.doc-item:hover .doc-item-actions{display:inline-flex}
.editor-wrap{flex:1;padding:16px 0;overflow:auto;background:#f8fafc;position:relative}
#status{font-size:12px;color:#475569}

/* ---- 표 삽입 모달 ---- */
.table-insert-card{
  background:#f8fafc;
  border-radius:10px;
  padding:12px 14px;
  min-width:260px;
  max-width:320px;
  color:#0f172a;
  border:1px solid #cbd5e1;
  box-shadow:0 8px 24px rgba(15,23,42,.2); /* 모달 박스 그림자 */
}
.table-insert-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:8px;
  font-size:13px;
}
.table-insert-grid{
  display:grid;
  grid-template-columns:repeat(10,24px);
  grid-template-rows:repeat(10,24px);
  gap:4px;
  margin:8px 0;
  padding:4px;
  border:1px solid #cbd5e1;
  box-sizing:border-box;
  min-height:260px; /* 높이가 0이 되지 않도록 강제 */
}
.table-insert-cell{
  width:24px;
  height:24px;
  display:block;
  border-radius:3px;
  border:1px solid #64748b;
  cursor:pointer;
  background:#e2e8f0;
}
.table-insert-cell.active{
  background:#38bdf8;
  border-color:#38bdf8;
}
.table-insert-footer{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-top:8px;
  font-size:12px;
}
.table-insert-modes{display:flex;gap:6px;align-items:center}
.table-insert-modes label{display:flex;align-items:center;gap:3px;cursor:pointer;font-size:12px}
.table-insert-actions{display:flex;gap:6px}

/* ---- 표 기본 스타일 (table 기반) ---- */

/* wrapper: inline/float 전환용 컨테이너 */
.wp-table-inline,
.wp-table-floating {
  position: relative;
  display: inline-block;
}

/* 실제 표 엘리먼트 */
.wp-table {
  border-collapse: collapse;
  width: 100%;
  height: 100%;
}

/* 행은 기본 table-row 레이아웃 사용 */
.wp-table-row {
  /* <tr> 기본 레이아웃 사용 */
}

/* 셀: 레이아웃 최소 제약만, 나머지 시각 스타일은 content.css 에서 */
.wp-table-cell {
  position: relative;
  box-sizing: border-box;
  min-width: 40px;
  min-height: 24px;
}

/* 셀 리사이즈 핸들 (가로/세로) */
.wp-table-cell-resize-x,
.wp-table-cell-resize-y {
  position: absolute;
  background: transparent;
  user-select: none;
}
.wp-table-cell-resize-x {
  right: -3px;
  top: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
}
.wp-table-cell-resize-y {
  left: 0;
  bottom: -3px;
  width: 100%;
  height: 6px;
  cursor: row-resize;
}

/* 표 전체 크기 조절 핸들 (우하단) */
.wp-table-resize-table {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 10px;
  height: 10px;
  cursor: se-resize;
  background: rgba(148,163,184,.85);
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(15,23,42,.15);
}

.user-badge{font-size:12px;color:#0f172a;opacity:.9;padding:4px 8px;border:1px solid #e2e8f0;border-radius:999px;background:#fff}

/* 모달 호스트 */
.modal{
  position:fixed;
  top:80px; /* 리본 아래쪽에 고정 */
  left:0;
  right:0;
  display:flex;
  align-items:flex-start;
  justify-content:center;
  background:transparent; /* 화면 어둡게 하지 않음 */
  z-index:100;
}
.modal.hidden{display:none !important}
