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

/* Modern color palette - clean and professional */
:root {
  /* Primary colors */
  --primary-600: #4f46e5;      /* Indigo - primary actions */
  --primary-700: #4338ca;
  --primary-50: #eef2ff;
  
  /* Gray scale */
  --gray-900: #111827;         /* Dark text */
  --gray-800: #1f2937;
  --gray-700: #374151;
  --gray-600: #4b5563;         /* Muted text */
  --gray-500: #6b7280;
  --gray-400: #9ca3af;
  --gray-300: #d1d5db;         /* Borders */
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;         /* Light backgrounds */
  --gray-50: #f9fafb;          /* Page background */

  /* Semantic colors */
  --success-500: #10b981;
  --success-50: #ecfdf5;
  --error-500: #ef4444;
  --error-50: #fef2f2;
  
  /* App theme mapping */
  --primary-color: var(--primary-600);
  --background-color: var(--gray-50);
  --text-color: var(--gray-900);
  --muted-text: var(--gray-600);
  --border-color: var(--gray-300);
  --card-bg: #ffffff;
  
  /* Design system */
  --border-radius: 12px;
  --border-radius-lg: 16px;
  --spacing: 1rem;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--background-color);
  color: var(--text-color);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
}

/* Layout containers */
header,
main {
  width: 100%;
  max-width: 640px;
}

header {
  text-align: center;
  margin-bottom: 3rem;
  padding-top: 2rem;
}

@media (min-width: 768px) {
  header {
    padding-top: 4rem;
  }
  
  body {
    padding: 2rem;
  }
}

/* Typography */
h1 {
  font-size: clamp(2rem, 4vw, 2.5rem);
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 0.5rem;
  letter-spacing: -0.025em;
}

h2, h3 {
  color: var(--gray-800);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

p {
  color: var(--muted-text);
  margin-bottom: var(--spacing);
}

/* Main form card */
form {
  background: var(--card-bg);
  padding: 2.5rem;
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@media (max-width: 640px) {
  form {
    padding: 1.5rem;
  }
}

/* Form elements */
label {
  display: block;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="text"],
textarea {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-family: inherit;
  background: var(--card-bg);
  transition: all 0.2s ease;
  appearance: none;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgb(79 70 229 / 0.1);
}

input[type="text"]::placeholder,
textarea::placeholder {
  color: var(--gray-500);
}

/* Buttons */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

/* Primary button */
button[type="submit"] {
  background: var(--primary-color);
  color: white;
  box-shadow: var(--shadow);
}

button[type="submit"]:hover:not(:disabled) {
  background: var(--primary-700);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

button[type="submit"]:active {
  transform: translateY(0);
}

button[type="submit"]:disabled {
  background: var(--gray-400);
  cursor: not-allowed;
  transform: none;
}

/* Copy buttons */
button[type="button"] {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--border-color);
  padding: 0.75rem;
  font-size: 0.875rem;
  min-width: 80px;
}

button[type="button"]:hover {
  background: var(--gray-200);
  border-color: var(--gray-400);
}

/* Input groups */
.input-group {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.input-group input[type="text"] {
  flex: 1;
}

/* PIN section */
.pin-section {
  background: var(--primary-50);
  border: 1px solid rgb(79 70 229 / 0.2);
  border-radius: var(--border-radius);
  padding: 1.5rem;
}

.pin-section label {
  color: var(--primary-700);
  margin-bottom: 0.75rem;
}

.pin-display {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.pin-display input[type="text"] {
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  font-weight: 600;
  font-size: 1.125rem;
  text-align: center;
  background: white;
  border: 2px solid var(--primary-color);
  flex: 1;
  letter-spacing: 0.1em;
}

.pin-help {
  font-size: 0.875rem;
  color: var(--primary-700);
  margin: 0;
  line-height: 1.5;
}

#copy-pin-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  min-width: auto;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
}

#copy-pin-btn:hover {
  background: var(--primary-700);
}

/* Copy button in input group */
#copy-btn {
  background: var(--primary-color);
  color: white;
  border: 1px solid var(--primary-color);
  border-radius: var(--border-radius);
  padding: 0.875rem 1rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

#copy-btn:hover {
  background: var(--primary-700);
  border-color: var(--primary-700);
}

/* Success/error states */
.success-state {
  background: var(--success-50);
  border-color: var(--success-500);
}

.success-state button {
  background: var(--success-500);
}

/* Messages */
.message {
  padding: 1rem 1.25rem;
  border-radius: var(--border-radius);
  margin-bottom: 1.5rem;
  font-weight: 500;
  border: 1px solid;
}

.message-success {
  background: var(--success-50);
  color: #065f46;
  border-color: #34d399;
}

.message-error {
  background: var(--error-50);
  color: #991b1b;
  border-color: #f87171;
}

.message-info {
  background: var(--primary-50);
  color: var(--primary-700);
  border-color: rgb(79 70 229 / 0.3);
}

/* Loading states */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.loading {
  animation: pulse 2s ease-in-out infinite;
}

/* Focus visible for accessibility */
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .input-group {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  
  .pin-display {
    flex-direction: column;
    align-items: stretch;
  }
  
  #copy-pin-btn {
    width: 100%;
    border-radius: var(--border-radius);
    height: 2.75rem;
  }
}