/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #22c55e;
  --error: #ef4444;
}

html {
  height: 100%;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Header */
header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 1rem;
}

nav {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  flex-shrink: 0;
}

.logo-short {
  display: none;
}

@media (max-width: 768px) {
  .logo-full {
    display: none;
  }
  .logo-short {
    display: inline;
  }
}

.nav-wrapper {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  position: relative;
}

nav ul {
  display: flex;
  list-style: none;
  gap: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 0.5rem 0;
}

nav ul::-webkit-scrollbar {
  display: none;
}

.nav-arrow {
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: 6px;
  cursor: pointer;
  font-size: 1.25rem;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all 0.2s;
}

.nav-arrow:hover {
  background: var(--bg);
  color: var(--text);
  border-color: var(--primary);
}

.nav-arrow.nav-prev {
  margin-right: 0.5rem;
}

.nav-arrow.nav-next {
  margin-left: 0.5rem;
}

.nav-arrow.hidden {
  opacity: 0.3;
  pointer-events: none;
}

nav a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  white-space: nowrap;
  transition: all 0.2s;
}

nav a:hover {
  color: var(--primary);
  background: var(--bg);
}

nav a.active {
  background: var(--primary);
  color: white;
}

/* PC에서 화살표 버튼 표시 */
@media (min-width: 769px) {
  .nav-arrow.visible {
    display: flex;
  }
}

/* Header Search */
.nav-search {
  position: relative;
  flex-shrink: 0;
  margin-left: 0.5rem;
}

.search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}

.search-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.search-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 280px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 1000;
  overflow: hidden;
}

.search-dropdown.open {
  display: block;
}

.search-dropdown input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  outline: none;
}

.search-dropdown ul {
  display: block;
  list-style: none;
  max-height: 160px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
  gap: 0;
}

.search-dropdown li {
  display: block;
}

.search-dropdown li.hidden {
  display: none;
}

.search-dropdown a {
  display: block;
  padding: 0.65rem 1rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background 0.15s;
}

.search-dropdown a:hover {
  background: var(--bg);
}

.search-dropdown .no-match {
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Main */
main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
}

/* Hero */
.hero {
  text-align: center;
  padding: 2rem 0;
}

.hero h1 {
  font-size: 2rem;
  margin-bottom: 1rem;
}

.hero p {
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* Search Box */
.search-box {
  max-width: 400px;
  margin: 0 auto;
}

.search-box input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.no-results {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

/* Tools Grid */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.tool-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s, box-shadow 0.2s;
}

.tool-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.tool-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.tool-card h2 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.tool-card p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* IP Page */
.ip-container {
  max-width: 600px;
  margin: 0 auto;
}

.ip-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.ip-box h2 {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.ip-address {
  font-size: 1.75rem;
  font-weight: 600;
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  word-break: break-all;
}

.ip-version {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
  margin-left: 0.5rem;
}

.ip-version.v4 {
  background: #dbeafe;
  color: #1d4ed8;
}

.ip-version.v6 {
  background: #dcfce7;
  color: #16a34a;
}

.ip-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.875rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.connected {
  background: var(--success);
}

.status-dot.disconnected {
  background: var(--error);
}

.ip-details {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.ip-details-row {
  display: flex;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.ip-details-row:last-child {
  border-bottom: none;
}

.ip-details-label {
  color: var(--text-muted);
}

.ip-details-value {
  font-weight: 500;
  text-align: right;
}

/* Copy Button */
.copy-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  transition: background 0.2s;
}

.copy-btn:hover {
  background: var(--primary-dark);
}

.copy-btn.copied {
  background: var(--success);
}

/* QR Page */
.qr-container {
  max-width: 500px;
  margin: 0 auto;
}

.qr-input-group {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.qr-input-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.qr-input-group input,
.qr-input-group textarea,
.qr-input-group select {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
}

.qr-input-group textarea {
  min-height: 100px;
  resize: vertical;
}

.qr-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.qr-tab {
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s;
}

.qr-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.qr-preview {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
}

.qr-preview canvas,
.qr-preview img {
  max-width: 100%;
}

.qr-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
  justify-content: center;
}

.btn {
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
}

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

/* Loading */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Footer */
footer {
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 1.5rem 2rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
  header {
    padding: 0.5rem 0.75rem;
  }

  nav {
    gap: 0.75rem;
  }

  .logo {
    font-size: 1.1rem;
  }

  nav ul {
    gap: 0.25rem;
  }

  nav a {
    font-size: 0.8rem;
    padding: 0.35rem 0.6rem;
  }

  main {
    padding: 1rem;
  }

  .hero {
    padding: 1.5rem 0;
  }

  .hero h1 {
    font-size: 1.5rem;
  }

  .hero p {
    font-size: 1rem;
  }

  .tools-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .tool-card {
    padding: 1.25rem;
  }

  .ip-address {
    font-size: 1.25rem;
  }

  .ip-details-row {
    flex-direction: column;
    gap: 0.25rem;
  }

  .ip-details-value {
    text-align: left;
  }

  .qr-actions {
    flex-direction: column;
  }

  .qr-tabs {
    flex-wrap: wrap;
  }

  footer {
    padding: 1rem;
  }
}

/* 광고 영역 - AdSense 승인 전 숨김 */
.ad-container {
  display: none;
  /* AdSense 승인 후 아래 스타일 활성화 */
  /*
  background: var(--card-bg);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  margin: 1.5rem 0;
  min-height: 90px;
  */
}

/* AdSense 승인 후 광고 표시시 사용 */
.ad-container.active {
  display: block;
  background: var(--card-bg);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  margin: 1.5rem 0;
  min-height: 90px;
}
