/* General Resets and Font Imports */
@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap");

:root {
  --sidebar-bg: #1e293b; /* 어두운 남색 계열 */
  --sidebar-text: #e2e8f0; /* 밝은 회색 */
  --sidebar-active-bg: #334155; /* 더 어두운 남색 */
  --sidebar-active-border: #38bdf8; /* 밝은 하늘색 포인트 */
  --main-bg: #f1f5f9; /* 매우 밝은 회색 */
  --card-bg: #ffffff;
  --text-primary: #0f172a; /* 거의 검은색 */
  --text-secondary: #64748b; /* 중간 회색 */
  --border-color: #e2e8f0; /* 밝은 회색 테두리 */
  --primary-color: #0ea5e9; /* 주요 색상 (하늘색) */
  --primary-color-dark: #0284c7; /* 더 어두운 하늘색 */
  --shadow-color: rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  font-family: "Roboto", sans-serif;
  background-color: var(--main-bg);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  font-size: 15px; /* 기본 폰트 크기 살짝 줄이기 */
}

/* Main Layout */
.dashboard-container {
  display: flex;
  height: 100%;
}

.sidebar {
  width: 260px;
  background-color: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 24px;
  text-align: center;
  border-bottom: 1px solid var(--sidebar-active-bg);
}

.sidebar-header h3 {
  margin: 10px 0 5px;
  font-weight: 500;
}

.sidebar-header p {
  font-size: 0.9em;
  color: var(--text-secondary);
}

.sidebar-nav {
  flex-grow: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 15px 25px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 500;
  transition: background-color 0.3s ease;
  border-left: 4px solid transparent;
}

.nav-item i {
  margin-right: 15px;
  width: 20px;
  text-align: center;
}

.nav-item:hover {
  background-color: var(--sidebar-active-bg);
}

.nav-item.active {
  background-color: var(--sidebar-active-bg);
  border-left-color: var(--sidebar-active-border);
}

.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background-color: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.main-header h1 {
  font-size: 1.5rem;
  font-weight: 500;
}

.header-buttons button {
  background-color: #6c757d;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 5px;
  cursor: pointer;
  margin-left: 10px;
  transition: background-color 0.3s;
}

.header-buttons button:hover {
  background-color: #5a6268;
}

.content-area {
  padding: 20px;
  flex-grow: 1;
}

/* API Grid and Form Styles from the new design */
.api-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 1.5rem;
}

fieldset {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 6px; /* 살짝 줄이기 */
  padding: 1.25rem; /* 살짝 줄이기 */
  box-shadow: 0 1px 2px var(--shadow-color);
  transition: box-shadow 0.2s ease;
}

fieldset:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
}

legend {
  font-weight: 600; /* 살짝 줄이기 */
  color: var(--text-primary); /* 주요 텍스트 색상 사용 */
  padding: 0 0.5em;
  font-size: 1.05rem; /* 살짝 줄이기 */
}

/* General Form Styles */
form {
  display: flex;
  flex-direction: column;
}

label {
  font-size: 0.85rem; /* 살짝 줄이기 */
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
  margin-top: 0.85rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 10px; /* 살짝 줄이기 */
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: #f8fafc; /* 밝은 회색 배경 */
  color: var(--text-primary);
  font-size: 0.95rem; /* 살짝 줄이기 */
  box-sizing: border-box;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

textarea {
  resize: vertical;
  min-height: 70px; /* 살짝 줄이기 */
}

button,
input[type="submit"] {
  background-color: #4a5568; /* 진한 회색 */
  color: white;
  border: none;
  padding: 10px 15px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.2s;
  width: 100%;
  margin-top: 10px;
}

button:hover,
input[type="submit"]:hover {
  background-color: #2d3748; /* 더 진한 회색 */
}

button:disabled {
  background-color: #ccc;
}

pre {
  background-color: #f8fafc; /* Light gray background */
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 1rem;
  margin-top: 1rem;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  color: #334155; /* Dark blue-gray text */
  white-space: pre-wrap;
  word-wrap: break-word;
  word-break: break-all; /* 긴 단어 강제 줄바꿈 추가 */
  max-height: 400px;
  overflow-y: auto;
}

/* Status messages inside pre tags (optional but good) */
pre.success {
  background: #d4edda;
  color: #155724;
  border-color: #c3e6cb;
}

.status.error,
.result.error {
  background: #f8d7da;
  color: #721c24;
  border-color: #f5c6cb;
}

.status.info,
.result.info {
  background: #d1ecf1;
  color: #0c5460;
  border-color: #bee5eb;
}

small {
  display: block;
  margin-top: -0.5em;
  margin-bottom: 1em;
  font-style: italic;
  color: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 900px) {
  .dashboard-container {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }
  .sidebar-header {
    display: none; /* Hide header on small screens */
  }
  .sidebar-nav {
    display: flex;
    flex-direction: row;
  }
  .nav-item {
    border-left: none;
    border-bottom: 4px solid transparent;
  }
  .nav-item.active {
    border-bottom-color: var(--sidebar-active-border);
  }
  .main-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-buttons {
    margin-top: 10px;
  }
}
