/* ==================== Google Index API 页面样式 ==================== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==================== 表单样式 ==================== */
#submitForm {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

#submitForm > div {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

input[type="url"],
input[type="text"],
textarea,
select {
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1rem;
  transition: var(--transition);
  font-family: inherit;
}

input[type="url"]:focus,
input[type="text"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
}

input[type="url"]:hover,
input[type="text"]:hover,
textarea:hover,
select:hover {
  border-color: var(--primary-hover);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

/* ==================== 按钮样式 ==================== */
button {
  padding: 0.875rem 2rem;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

button::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

button:hover::before {
  width: 300px;
  height: 300px;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

button:disabled {
  background: var(--border-color);
  cursor: not-allowed;
  transform: none;
}

/* ==================== 页面标题 ==================== */
.main-content > h1 {
  color: var(--primary-color);
  font-size: 1.5rem;
  margin-bottom: 1rem;
  text-align: center;
  font-weight: 800;
}

/* ==================== 两列布局容器 ==================== */
.gi-container {
  display: flex;
  gap: 1.5rem;
  align-items: stretch; /* ensure equal panel heights */
  max-width: 1100px;
  padding: 0.5rem;
}

.gi-container .panel {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  padding: 2rem;
  box-shadow: var(--shadow-md);
  animation: fadeInUp 0.5s ease;
  display: flex;
  flex-direction: column;
  min-height: 320px; /* sensible minimum */
  max-height: 100%;
  overflow: hidden; /* clip inner scrolling to panel */
}

.gi-container .left {
  flex: 1 1 55%;
  min-width: 400px;
}

.gi-container .right {
  flex: 1 1 45%;
  min-width: 350px;
}

.gi-container h2 {
  color: var(--text-primary);
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
  text-align: center;
}

#result {
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 0.875rem;
  color: var(--text-primary);
  max-height: 100%;
  overflow-y: auto;
  line-height: 1.5;
  transition: var(--transition);
}

/* make left form scroll inside panel and textarea scroll internally */
.gi-container .left form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  height: 100%;
  overflow: auto;
}

.gi-container .left textarea,
.gi-container .left input {
  /* let textarea take remaining space but stay scrollable */
  min-height: 120px;
  max-height: 45vh;
  height: 100%;
  overflow: auto;
  font-size: 0.75rem;
}

#result:not(:empty) {
  animation: fadeIn 0.3s ease;
  margin-top: 1rem;
}

/* ensure table area shows at least header even when no rows */
.table-wrap {
  min-height: 88px;
}

/* keep table header visible when scrolling */
#result thead th {
  position: sticky;
  top: 0;
  background: var(--bg-white);
  z-index: 2;
}

/* 表格样式 */
#result table {
  width: 100%;
  border-collapse: collapse;
}

/* slightly smaller font for table to fit more content */
#result, #result table, #result th, #result td {
  font-size: 0.75rem;
}

#result th, #result td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
  text-align: left;
  word-break: break-word;
}

#result thead th {
  background: transparent;
  font-weight: 700;
  color: var(--text-secondary);
}

#result tbody tr:nth-child(odd) {
  background: rgba(0,0,0,0.02);
}

/* make the table area scrollable without expanding the panel */
.table-wrap {
  flex: 1 1 auto;
  overflow: auto;
  max-height: calc(100% - 48px); /* leave space for summary */
  /* allow horizontal scrolling */
  /*overflow-x: auto;*/
}

/* detail cell content scrolls internally */
.cell-detail {
  /* limit to two lines visually */
  display: -webkit-box;
  line-clamp: 1;
  font-size: 0.75rem;
  overflow:auto;
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
  white-space: normal;
  max-height: 3rem; /* approximately 2 lines */
}

/* ensure long single-word content still allows horizontal scroll on table-wrap */
#result td {
  min-width: 0;
}

#result table {
  min-width: 700px; /* reduce minimum width now that detail column removed */
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* 滚动条样式 */
#result::-webkit-scrollbar {
  width: 8px;
}

#result::-webkit-scrollbar-track {
  background: var(--bg-light);
  border-radius: var(--radius-sm);
}

#result::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-sm);
}

#result::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ==================== 加载状态 ==================== */
.loading {
  position: relative;
}

.loading::after {
  content: '';
  position: absolute;
  right: 1rem;
  top: 50%;
  width: 20px;
  height: 20px;
  border: 3px solid var(--bg-light);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  transform: translateY(-50%);
}

@keyframes spin {
  to {
    transform: translateY(-50%) rotate(360deg);
  }
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
  .gi-container {
    flex-direction: column;
    padding: 1rem;
    margin: 1rem;
  }

  .gi-container h1 {
    font-size: 1.5rem;
  }

  button {
    padding: 0.75rem 1.5rem;
  }
}

@media (max-width: 480px) {
  .gi-container {
    padding: 1rem;
  }

  .gi-container h1 {
    font-size: 1.25rem;
  }

  input[type="url"],
  input[type="text"],
  select,
  button {
    font-size: 0.9rem;
  }
}