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

:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --bg: #eef2f7;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 16px;
}

/* ===== Kerangka aplikasi (tampilan seperti mobile app) ===== */
.app {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ===== Header ===== */
.app__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff;
  padding: 20px;
  border-radius: 18px 18px 8px 8px;
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.25);
}

.app__title h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.app__title p {
  font-size: 13px;
  opacity: 0.85;
}

/* Tombol Refresh */
.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 9px 14px;
  border: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.refresh-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.refresh-btn:active {
  transform: scale(0.96);
}

.refresh-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Ikon berputar saat data sedang dimuat */
.refresh-btn.is-loading .refresh-btn__icon {
  animation: spin 0.8s linear infinite;
}

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

/* ===== Pesan status ===== */
.status {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  min-height: 20px;
}

.status.is-error {
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 10px 12px;
}

.status.is-loading {
  color: var(--primary-dark);
}

/* ===== Daftar koin ===== */
.coin-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Kartu setiap cryptocurrency */
.coin {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.coin:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

/* Badge nomor rank */
.coin__rank {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #eef2ff;
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 700;
}

/* Nama dan simbol koin */
.coin__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.coin__name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.coin__symbol {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--primary-dark);
  background: #eef2ff;
  border-radius: 6px;
  padding: 1px 7px;
}

/* Harga dalam USD */
.coin__price {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
}

.coin__price-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.6px;
  color: var(--muted);
  text-transform: uppercase;
}

.coin__price-value {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

/* ===== Skeleton saat loading ===== */
.skeleton {
  height: 66px;
  border-radius: 14px;
  background: linear-gradient(90deg, #e9eef5 25%, #f4f7fb 50%, #e9eef5 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ===== Footer ===== */
.app__footer {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 0 12px;
}

.app__footer a {
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 600;
}

.app__footer a:hover {
  text-decoration: underline;
}

/* ===== Responsif untuk layar HP kecil ===== */
@media (max-width: 380px) {
  body {
    padding: 10px;
  }

  .app__header {
    padding: 16px;
  }

  .app__title h1 {
    font-size: 17px;
  }

  .coin {
    padding: 12px;
    gap: 10px;
  }

  .coin__rank {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }

  .coin__name {
    font-size: 14px;
  }

  .coin__price-value {
    font-size: 13px;
  }

  .refresh-btn span {
    display: none;
  }
}

/* ===== Responsif untuk layar desktop ===== */
@media (min-width: 768px) {
  body {
    padding: 32px;
  }

  .app__header {
    padding: 24px 28px;
  }

  .app__title h1 {
    font-size: 24px;
  }

  .coin {
    padding: 16px 20px;
  }

  .coin__name {
    font-size: 16px;
  }

  .coin__price-value {
    font-size: 16px;
  }
}
