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

/* hidden atribut ba'zan display:flex bilan urishadigan holatlarni to'g'rilaydi */
[hidden] { display: none !important; }

body {
  font-family: 'Inter', sans-serif;
  background: #f7f8fa;
  color: #111;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ---- navbar ---- */
.nav {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  height: 54px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
}

.nav-in {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: #111;
}

/* ---- main page layout ---- */
.page {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 52px 28px 80px;
}

/* ---- search area ---- */
.top-section h1 {
  font-size: 28px;
  font-weight: 700;
  color: #111;
  margin-bottom: 8px;
  letter-spacing: -0.4px;
}

.top-section p {
  font-size: 15px;
  color: #6b7280;
  margin-bottom: 24px;
  line-height: 1.6;
}

.search-wrap {
  display: flex;
  align-items: center;
  background: #fff;
  border: 1.5px solid #d1d5db;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.search-wrap:focus-within {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

#ip-input {
  flex: 1;
  min-width: 0;
  height: 46px;
  border: none;
  background: transparent;
  padding: 0 12px 0 16px;
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  color: #111;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

#ip-input:focus {
  border: none !important;
  box-shadow: none !important;
}

#ip-input::placeholder {
  color: #9ca3af;
}

#btn-search {
  height: 46px;
  padding: 0 24px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}

#btn-search:hover { background: #1d4ed8; }
#btn-search:active { background: #1e40af; }
#btn-search:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-spin svg {
  display: block;
  animation: spin 0.65s linear infinite;
}

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

#btn-myip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(37, 99, 235, 0.05);
  border: 1px solid rgba(37, 99, 235, 0.15);
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #2563eb;
  cursor: pointer;
  padding: 8px 14px;
  transition: all 0.15s ease;
  margin-top: 8px;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}

#btn-myip:hover {
  background: rgba(37, 99, 235, 0.1);
  border-color: #2563eb;
  color: #1d4ed8;
}

#btn-myip:active {
  transform: scale(0.98);
}

#btn-myip:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.err-box {
  margin-top: 12px;
  padding: 10px 14px;
  background: #fef2f2;
  border: 1.5px solid #fecaca;
  border-radius: 8px;
  font-size: 13px;
  color: #dc2626;
}

/* ---- result block ---- */
.result-block {
  margin-top: 32px;
  animation: fadeUp 0.22s ease;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ip top card */
.ip-card {
  background: #fff;
  border: 1.5px solid #e5e7eb;
  border-radius: 14px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.ip-card-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

#ip-flag {
  width: 44px;
  height: 30px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.small-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #9ca3af;
  margin-bottom: 3px;
}

.ip-display {
  font-size: 24px;
  font-weight: 700;
  color: #111;
  letter-spacing: -0.4px;
  word-break: break-all;
}

.ip-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.btn-country {
  height: 34px;
  padding: 0 14px;
  background: #eff6ff;
  border: 1.5px solid #bfdbfe;
  border-radius: 7px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #2563eb;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}

.btn-country:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

.btn-copy {
  height: 34px;
  padding: 0 14px;
  background: #f3f4f6;
  border: 1.5px solid #e5e7eb;
  border-radius: 7px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: #374151;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.btn-copy:hover { background: #e9eaec; }

.btn-copy.ok {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #16a34a;
}

/* ---- data table ---- */
.data-table {
  background: #fff;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
}

.dt-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid #f0f1f3;
}

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

.dt-row.dt-full {
  grid-template-columns: 1fr;
}

.dt-cell {
  padding: 16px 20px;
  border-right: 1px solid #f0f1f3;
}

.dt-cell:last-child { border-right: none; }
.dt-cell.dt-empty { background: #fafafa; }
.dt-cell.full { border-right: none; }

.dt-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9ca3af;
  margin-bottom: 6px;
}

.dt-val {
  font-size: 15px;
  font-weight: 500;
  color: #111;
  word-break: break-word;
  line-height: 1.4;
}

/* ---- modal overlay ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.modal-overlay.open {
  display: flex;
  animation: overlayIn 0.2s ease;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: #fff;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  border-radius: 16px 16px 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid #f0f1f3;
  gap: 12px;
  flex-shrink: 0;
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.m-flag {
  width: 52px;
  height: 36px;
  object-fit: cover;
  border-radius: 5px;
  border: 1px solid #e5e7eb;
  flex-shrink: 0;
}

.m-country-name {
  font-size: 17px;
  font-weight: 700;
  color: #111;
  letter-spacing: -0.2px;
}

.m-official-name {
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}

.modal-close {
  width: 32px;
  height: 32px;
  background: #f3f4f6;
  border: none;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
  color: #374151;
}

.modal-close:hover { background: #e5e7eb; }

.modal-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 20px;
  font-size: 14px;
  color: #6b7280;
}

.modal-loading svg { animation: spin 0.65s linear infinite; }

.modal-body {
  overflow-y: auto;
  flex: 1;
}

.m-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid #f0f1f3;
}

.m-item {
  padding: 13px 16px;
  border-right: 1px solid #f0f1f3;
  border-bottom: 1px solid #f0f1f3;
}

.m-item:nth-child(3n) { border-right: none; }

.m-item.m-wide {
  grid-column: 1 / -1;
  border-right: none;
}

.m-lbl {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #9ca3af;
  margin-bottom: 5px;
}

.m-val {
  font-size: 13.5px;
  font-weight: 500;
  color: #111;
  word-break: break-word;
  line-height: 1.45;
}

.m-footer {
  padding: 14px 20px;
}

.m-maps-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #2563eb;
  text-decoration: none;
}

.m-maps-link:hover { text-decoration: underline; }

.modal-err {
  padding: 20px;
  font-size: 13px;
  color: #dc2626;
  background: #fef2f2;
}

/* ---- footer ---- */
.footer {
  text-align: center;
  padding: 16px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  font-size: 12px;
  color: #d1d5db;
}

/* ---- mobile ---- */
@media (max-width: 600px) {
  .page { padding: 24px 14px 60px; }

  .top-section h1 { font-size: 20px; }

  .top-section p { font-size: 14px; margin-bottom: 18px; }

  .search-wrap {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 0 !important;
    padding: 3px !important;
    border-radius: 10px !important;
    border: 1.5px solid #b0b5c4 !important;
    background: #fff !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03) !important;
  }

  .search-wrap:focus-within {
    border-color: #2563eb !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12) !important;
  }

  #ip-input {
    width: auto !important;
    flex: 1 !important;
    height: 42px !important;
    font-size: 15px !important;
    padding: 0 8px 0 12px !important;
    border: none !important;
    background: transparent !important;
    -webkit-box-shadow: none !important;
    box-shadow: none !important;
    -webkit-appearance: none !important;
  }

  #ip-input:focus {
    border: none !important;
    -webkit-box-shadow: none !important;
    box-shadow: none !important;
  }

  #btn-search {
    width: auto !important;
    height: 42px !important;
    padding: 0 16px !important;
    border-radius: 7px !important;
    font-size: 14px !important;
    justify-content: center !important;
  }

  .dt-row {
    grid-template-columns: 1fr 1fr;
  }

  .dt-row.dt-full {
    grid-template-columns: 1fr;
  }

  /* 3. cell ni alt qatorga tushiramiz */
  .dt-cell:nth-child(3) {
    grid-column: 1 / -1;
    border-right: none;
  }

  .dt-cell.dt-empty {
    display: none;
  }

  .m-grid {
    grid-template-columns: 1fr 1fr;
  }

  .m-item.m-wide {
    grid-column: 1 / -1;
  }

  .m-item:nth-child(3n) {
    border-right: 1px solid #f0f1f3;
  }

  .m-item:nth-child(2n) {
    border-right: none;
  }

  .ip-display { font-size: 16px; }

  .ip-card { flex-direction: column; align-items: flex-start; }

  .ip-card-actions { width: 100%; }

  .btn-country { flex: 1; justify-content: center; text-align: center; }

  .modal { max-height: 92vh; }
}

@media (max-width: 380px) {
  .dt-row {
    grid-template-columns: 1fr;
  }

  .dt-cell {
    border-right: none;
  }
}

/* ---- intro section ---- */
.intro-block {
  margin-top: 56px;
  animation: fadeUp 0.3s ease;
}

.intro-title {
  font-size: 17px;
  font-weight: 700;
  color: #111;
  margin-bottom: 16px;
  letter-spacing: -0.2px;
}

.intro-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.intro-card {
  background: #fff;
  border: 1.5px solid #e5e7eb;
  border-radius: 12px;
  padding: 22px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
  overflow: hidden;
}

.intro-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  border-color: #d1d5db;
}

.intro-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.intro-icon.bg-blue {
  background: #eff6ff;
  color: #2563eb;
}

.intro-icon.bg-green {
  background: #f0fdf4;
  color: #16a34a;
}

.intro-icon.bg-purple {
  background: #faf5ff;
  color: #9333ea;
}

.intro-icon.bg-orange {
  background: #fff7ed;
  color: #ea580c;
}

.intro-card h3 {
  font-size: 14.5px;
  font-weight: 600;
  color: #111;
  margin-bottom: 6px;
}

.intro-card p {
  font-size: 13px;
  color: #6b7280;
  line-height: 1.5;
}

@media (max-width: 600px) {
  .intro-block {
    margin-top: 44px;
  }
  .intro-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .intro-card {
    padding: 16px !important;
  }
}

