@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

/* --- Custom Properties --- */
:root {
  --white: #ffffff;
  --black: #111111;
  --grey-100: #f5f5f5;
  --grey-300: #d1d1d1;
  --grey-500: #888888;
  --accent: #1a1a1a;
  --error: #c0392b;
  --radius: 6px;
  --font-base: 'Inter', sans-serif;
}

/* --- Reset --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* --- Base --- */
html {
  font-size: 16px;
}

body {
  font-family: var(--font-base);
  background-color: var(--grey-100);
  color: var(--black);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
}

/* prevent Safari/WebKit from applying system button styling */
button {
  -webkit-appearance: none;
  appearance: none;
}

/* --- Header --- */
.site-header {
  background-color: var(--white);
  border-bottom: 1px solid var(--grey-300);
  padding: 20px 24px;
}

.header-inner {
  max-width: 720px;
  margin: 0 auto;
}

.app-title {
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--black);
}

.app-tagline {
  font-size: 0.875rem;
  color: var(--grey-500);
  margin-top: 4px;
}

/* --- Main --- */
.main-content {
  flex: 1;
  padding: 32px 24px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

/* --- Card --- */
.card {
  background-color: var(--white);
  border: 1px solid var(--grey-300);
  border-radius: var(--radius);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  width: 100%;
  max-width: 720px;
  display: flex;
  overflow: hidden;
}

/* --- Input Panel --- */
.input-panel {
  flex: 1;
  padding: 28px 24px;
  border-right: 1px solid var(--grey-300);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* --- Tab Selector --- */
.type-selector {
  display: flex;
  border-bottom: 1px solid var(--grey-300);
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 16px;
  font-family: var(--font-base);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--grey-500);
  cursor: pointer;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
  color: var(--black);
}

.tab-btn.active {
  color: var(--black);
  border-bottom-color: var(--accent);
}

/* --- Input Area --- */
.input-wrapper {
  position: relative;
}

.qr-input {
  width: 100%;
  padding: 10px 36px 10px 12px;
  border: 1px solid var(--grey-300);
  border-radius: var(--radius);
  font-family: var(--font-base);
  font-size: 0.9375rem;
  color: var(--black);
  background-color: var(--white);
  transition: border-color 0.15s;
  outline: none;
  resize: none;
}

.qr-input:focus {
  border-color: var(--accent);
}

.qr-input.error {
  border-color: var(--error);
}

.clear-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--grey-500);
  font-size: 1.125rem;
  line-height: 1;
  padding: 4px;
  display: none;
}

.clear-btn:hover {
  color: var(--black);
}

.clear-btn.visible {
  display: block;
}

.input-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  min-height: 20px;
}

.error-msg {
  font-size: 0.8125rem;
  color: var(--error);
}

.char-count {
  font-size: 0.8125rem;
  color: var(--grey-500);
  margin-left: auto;
}

.char-count.over-limit {
  color: var(--error);
  font-weight: 500;
}

/* --- Generate Button --- */
.generate-btn {
  width: 100%;
  height: 44px;
  background-color: var(--accent);
  color: var(--white);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-base);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}

.generate-btn:hover {
  opacity: 0.85;
}

.generate-btn:active {
  opacity: 0.7;
}

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

/* --- Output Panel --- */
.output-panel {
  flex: 1;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* --- QR Display --- */
.qr-display {
  width: 100%;
  min-height: 280px;
  background-color: var(--grey-100);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.qr-display canvas,
.qr-display img {
  max-width: 100%;
  height: auto;
  display: block;
}

.placeholder-box {
  border: 2px dashed var(--grey-300);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
}

.placeholder-text {
  font-size: 0.875rem;
  color: var(--grey-500);
}

/* --- Download Bar --- */
.download-bar {
  display: flex;
  gap: 8px;
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
}

.download-btn {
  flex: 1;
  min-width: 90px;
  height: 44px;
  background-color: var(--white);
  color: var(--black);
  border: 1px solid var(--grey-300);
  border-radius: var(--radius);
  font-family: var(--font-base);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.download-btn:hover:not(.disabled) {
  border-color: var(--accent);
  background-color: var(--grey-100);
}

.download-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* --- Footer --- */
.site-footer {
  padding: 16px 24px;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--grey-500);
  border-top: 1px solid var(--grey-300);
  background-color: var(--white);
}

/* --- Responsive: stack panels vertically on mobile --- */
@media (max-width: 640px) {
  .main-content {
    padding: 16px 12px;
  }

  .card {
    flex-direction: column;
  }

  .input-panel {
    border-right: none;
    border-bottom: 1px solid var(--grey-300);
  }

  .download-bar {
    gap: 6px;
  }

  /* ensure tap targets meet the 44px minimum on mobile */
  .download-btn {
    min-width: 80px;
    min-height: 44px;
    font-size: 0.8125rem;
  }

  .tab-btn {
    min-height: 44px;
    padding: 10px 16px;
  }
}
