/* ===== 공통 창 틀 ===== */
.win {
  position: absolute;
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #9a9a9a;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  pointer-events: auto;
  user-select: none;
  animation: win-open 140ms ease-out;
  min-width: 240px;
  min-height: 120px;
}

.win.is-active {
  border-color: #6f6f6f;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.win.is-minimized {
  display: none;
}

.win.is-maximized {
  left: 0 !important;
  top: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border: none;
  box-shadow: none;
}

.win.is-dragging {
  transition: none;
}

.win.is-closing {
  animation: win-close 120ms ease-in forwards;
  pointer-events: none;
}

@keyframes win-open {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes win-close {
  to { opacity: 0; transform: scale(0.98); }
}

/* 제목 표시줄 (기본: 밝은 색. 앱별로 덮어쓴다) */
.win-titlebar {
  height: 32px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 8px;
  background: #fff;
  color: #000;
  font-size: 12px;
  border-bottom: 1px solid #e5e5e5;
}

.win:not(.is-active) .win-titlebar {
  color: #7a7a7a;
}

.win-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.win-icon svg {
  width: 16px;
  height: 16px;
}

.win-title {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.win-controls {
  display: flex;
  align-self: stretch;
  flex: 0 0 auto;
}

.win-ctrl {
  width: 46px;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}

.win-ctrl:hover {
  background: rgba(0, 0, 0, 0.08);
}

.win-ctrl-close:hover {
  background: #e81123;
  color: #fff;
}

.win-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.win-body > * {
  flex: 1 1 auto;
  min-height: 0;
}

/* ===== 대화상자 ===== */
.win--dialog {
  min-height: 0;
}

/* 아이콘 없는 확인창은 제목을 왼쪽 끝에서 시작한다 */
.win--dialog .win-icon:empty {
  display: none;
}

.dlg {
  display: flex;
  flex-direction: column;
  padding: 16px 20px 14px;
  background: #fff;
  height: 100%;
}

.dlg-message {
  font-size: 13px;
  margin-bottom: 14px;
  white-space: pre-line;
}

.dlg-label {
  font-size: 12px;
  color: #444;
  margin-bottom: 4px;
}

.dlg-input {
  height: 28px;
  padding: 0 8px;
  border: 1px solid #8a8a8a;
  font: inherit;
  font-size: 13px;
  outline: none;
}

.dlg-input:focus {
  border-color: var(--accent);
}

.dlg-error {
  min-height: 18px;
  margin-top: 6px;
  font-size: 12px;
  color: #c42b1c;
}

.dlg-hint {
  font-size: 12px;
  color: #555;
}

.dlg-buttons {
  margin-top: auto;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.dlg-btn {
  min-width: 80px;
  height: 28px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 12px;
  cursor: default;
}

.dlg-btn:hover {
  background: var(--btn-bg-hover);
}

.dlg-btn-primary {
  border-color: #0078d7;
  box-shadow: inset 0 0 0 1px #0078d7;
}

.dlg.is-shaking {
  animation: dlg-shake 300ms ease;
}

@keyframes dlg-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* 잠긴 파일 표시 */
.lock-badge {
  position: absolute;
  right: -4px;
  bottom: -2px;
  width: 18px;
  height: 18px;
}

.lock-badge svg {
  width: 100%;
  height: 100%;
}

/* ===== 앱별 제목 표시줄 ===== */
.win--excel .win-titlebar {
  background: var(--xl-green);
  color: #fff;
  border-bottom: none;
}

.win--excel:not(.is-active) .win-titlebar {
  background: #3f8a63;
  color: rgba(255, 255, 255, 0.85);
}

.win--excel .win-ctrl:hover {
  background: rgba(255, 255, 255, 0.15);
}

.win--excel .win-ctrl-close:hover {
  background: #e81123;
}
