/* src/pages/agent-office/AgentOffice.css */

/* ===== Root Layout ===== */
.ao-root {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #0f172a;
  color: #e2e8f0;
  font-family: 'Courier New', monospace;
  overflow: hidden;
}

/* ===== Top Bar ===== */
.ao-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  padding: 0 16px;
  background: #1a1a2e;
  border-bottom: 1px solid #333;
  flex-shrink: 0;
}
.ao-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.ao-topbar-title {
  font-weight: bold;
  font-size: 15px;
  color: #8b5cf6;
}
.ao-topbar-status { font-size: 11px; }
.ao-topbar-status.connected { color: #22c55e; }
.ao-topbar-status.disconnected { color: #ef4444; }

/* ===== Main Area ===== */
.ao-main {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* ===== Grid Wrap ===== */
.ao-grid-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}
.ao-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  width: 100%;
}

/* ===== Agent Card ===== */
.ao-card {
  position: relative;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  cursor: pointer;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: inherit;
  color: inherit;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}
.ao-card:hover {
  transform: translateY(-2px);
  border-color: var(--card-accent, #60a5fa);
}
.ao-card.active {
  border-color: var(--card-accent, #60a5fa);
  box-shadow: 0 0 0 2px var(--card-accent, #60a5fa);
}
.ao-card.placeholder {
  opacity: 0.55;
}

.ao-card-dot {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #6b7280;
  box-shadow: 0 0 0 2px #0f172a;
}
.ao-card-dot.working          { background: #22c55e; }
.ao-card-dot.error            { background: #ef4444; }
.ao-card-dot.waiting_approval { background: #f59e0b; }
.ao-card-dot.pulse {
  animation: ao-pulse 1.6s ease-in-out infinite;
}
@keyframes ao-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.45; transform: scale(1.2); }
}

.ao-card-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: #ef4444;
  color: #fff;
  border-radius: 9px;
  font-size: 10px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ao-card-image {
  width: 100%;
  aspect-ratio: 941 / 1672;
  border-radius: 8px;
  overflow: hidden;
  background: #0f172a;
  margin-bottom: 8px;
}
.ao-card-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.ao-card-name {
  font-size: 12px;
  color: #e2e8f0;
  text-align: center;
}

/* ===== Side Panel ===== */
.ao-sidepanel {
  width: 320px;
  background: #111;
  border-left: 1px solid #333;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  animation: slideIn 0.2s ease-out;
}
.ao-sidepanel-initial {
  display: flex;
  align-items: center;
  justify-content: center;
}
@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.ao-sidepanel-header {
  padding: 12px;
  border-bottom: 1px solid #333;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ao-sidepanel-agent {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ao-sidepanel-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 2px solid #444;
  overflow: hidden;
  flex-shrink: 0;
}
.ao-sidepanel-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.ao-sidepanel-name {
  font-weight: bold;
  font-size: 14px;
}
.ao-sidepanel-state {
  font-size: 11px;
  color: #94a3b8;
}
.ao-sidepanel-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.ao-sidepanel-close {
  background: none;
  border: none;
  color: #666;
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
}
.ao-sidepanel-close:hover { color: #fff; }
/* 전체 화면 토글 — 모바일 전용 (데스크톱에서는 숨김) */
.ao-sidepanel-expand {
  display: none;
  background: none;
  border: none;
  color: #888;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.ao-sidepanel-expand:hover { color: #fff; }

/* Tabs */
.ao-sidepanel-tabs {
  display: flex;
  border-bottom: 1px solid #333;
}
.ao-sidepanel-tab {
  flex: 1;
  padding: 8px 4px;
  text-align: center;
  font-size: 12px;
  font-family: inherit;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #666;
  cursor: pointer;
}
.ao-sidepanel-tab.active {
  color: #8b5cf6;
  border-bottom-color: #8b5cf6;
  font-weight: bold;
}
.ao-sidepanel-tab:hover { color: #aaa; }
.ao-sidepanel-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

/* ===== Command Tab ===== */
.ao-command-tab { display: flex; flex-direction: column; gap: 12px; }
.ao-section { margin-bottom: 4px; }
.ao-section-label {
  color: #888;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.ao-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ao-btn-quick {
  background: #2a2a4e;
  color: #8b5cf6;
  border: 1px solid #4c1d95;
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
}
.ao-btn-quick:hover { background: #3a3a5e; }
.ao-btn-quick:disabled { opacity: 0.4; }

.ao-param-row { display: flex; gap: 6px; }
.ao-input {
  flex: 1;
  background: #1a1a2e;
  border: 1px solid #333;
  color: #fff;
  padding: 7px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
}
.ao-input::placeholder { color: #555; }
.ao-btn-send {
  background: #4c1d95;
  color: #fff;
  border: none;
  padding: 7px 14px;
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.ao-btn-send:hover { background: #5b21b6; }
.ao-btn-send:disabled { opacity: 0.4; }

.ao-approval-card {
  background: rgba(146,64,14,0.15);
  border: 1px solid #92400e;
  border-radius: 6px;
  padding: 10px;
}
.ao-approval-title { color: #fbbf24; font-size: 12px; font-weight: bold; margin-bottom: 4px; }
.ao-approval-desc { color: #ddd; font-size: 11px; margin-bottom: 8px; word-break: break-all; }
.ao-approval-actions { display: flex; gap: 6px; }
.ao-btn-approve {
  flex: 1; background: #065f46; color: #fff; border: none;
  padding: 7px; border-radius: 4px; font-size: 12px; cursor: pointer;
}
.ao-btn-reject {
  flex: 1; background: #7f1d1d; color: #fff; border: none;
  padding: 7px; border-radius: 4px; font-size: 12px; cursor: pointer;
}

/* ===== Task Tab ===== */
.ao-task-tab { display: flex; flex-direction: column; gap: 4px; }
.ao-task-item { background: #1a1a2e; border-radius: 4px; padding: 8px; cursor: pointer; }
.ao-task-item:hover { background: #222240; }
.ao-task-header { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.ao-task-type { color: #ccc; font-weight: bold; flex: 1; }
.ao-task-badge { padding: 1px 6px; border-radius: 3px; font-size: 10px; }
.ao-task-time { color: #666; font-size: 10px; }
.ao-task-result {
  margin-top: 6px; background: #0d0d1a; padding: 6px; border-radius: 3px;
  font-size: 10px; color: #aaa; max-height: 200px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-all;
}

/* ===== Token Tab ===== */
.ao-token-tab { display: flex; flex-direction: column; gap: 12px; }
.ao-token-period { display: flex; gap: 4px; }
.ao-btn-period {
  flex: 1; background: #1a1a2e; color: #888; border: 1px solid #333;
  padding: 5px; border-radius: 4px; font-size: 11px; font-family: inherit; cursor: pointer;
}
.ao-btn-period.active { background: #4c1d95; color: #fff; border-color: #4c1d95; }
.ao-token-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ao-token-card { background: #1a1a2e; border-radius: 6px; padding: 10px; text-align: center; }
.ao-token-label { font-size: 10px; color: #888; text-transform: uppercase; margin-bottom: 4px; }
.ao-token-value { font-size: 18px; font-weight: bold; color: #fff; }
.ao-token-bar { margin-top: 4px; }
.ao-token-bar-label { font-size: 10px; color: #888; margin-bottom: 4px; }
.ao-token-bar-track { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: #1a1a2e; }
.ao-token-bar-fill.input { background: #3b82f6; }
.ao-token-bar-fill.output { background: #8b5cf6; }
.ao-token-bar-legend { display: flex; gap: 12px; font-size: 10px; color: #888; margin-top: 4px; }
.ao-token-bar-legend .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.ao-token-bar-legend .dot.input { background: #3b82f6; }
.ao-token-bar-legend .dot.output { background: #8b5cf6; }
.ao-token-detail { display: flex; justify-content: space-between; font-size: 10px; color: #666; }

/* ===== Log Tab ===== */
.ao-log-tab {
  max-height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;
}
.ao-log-item {
  display: flex; gap: 6px; font-size: 11px; padding: 3px 0; border-bottom: 1px solid #1a1a2e;
}
.ao-log-time { color: #555; min-width: 60px; }
.ao-log-level { min-width: 48px; font-weight: bold; }
.ao-log-msg { color: #ccc; word-break: break-all; }

/* ===== Common ===== */
.ao-empty {
  color: #94a3b8;
  text-align: center;
  padding: 24px;
  font-size: 13px;
  line-height: 1.6;
}

/* ===== Mobile (< 768px) ===== */
@media (max-width: 768px) {
  .ao-grid-wrap { padding: 12px; }
  .ao-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .ao-main { flex-direction: column; }

  .ao-sidepanel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    height: 55vh;
    max-height: 55vh;
    border-left: none;
    border-top: 1px solid #333;
    border-radius: 16px 16px 0 0;
    animation: slideUp 0.25s ease-out;
    z-index: 100;
    transition: height 0.25s ease, max-height 0.25s ease, border-radius 0.25s ease;
  }
  /* 전체 화면으로 확장 */
  .ao-sidepanel.expanded {
    top: 0;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border-top: none;
  }
  @keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .ao-sidepanel-expand { display: inline-block; }
  .ao-sidepanel-header { padding: 8px 12px; }
  .ao-sidepanel-header::before {
    content: '';
    display: block;
    width: 32px;
    height: 4px;
    background: #555;
    border-radius: 2px;
    margin: 0 auto 8px;
  }
  .ao-sidepanel-tab { font-size: 11px; padding: 6px 2px; }
  .ao-sidepanel-content {
    padding: 8px 12px;
    padding-bottom: env(safe-area-inset-bottom, 16px);
  }
}
