/* --- VARIABLES & RESET --- */
:root {
  --primary-color: #6366f1; /* Indigo 500 */
  --primary-dark: #4338ca; /* Indigo 700 */
  --secondary-color: #1f2937; /* Gray 800 */
  --bg-color: #0f172a; /* Slate 900 */
  --text-main: #f8fafc; /* Slate 50 */
  --text-muted: #94a3b8; /* Slate 400 */
  --danger-color: #ef4444;
  --success-color: #10b981;
  
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea {
  font-family: inherit;
}

.hidden {
  display: none !important;
}

.container {
  width: 100%;
  max-width: 600px; /* Mobile-focused max width */
  margin: 0 auto;
  padding: 0 1rem;
}

/* --- ANIMATIONS --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scan-move {
  0% { top: 0; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

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

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 15px rgba(99, 102, 241, 0.2); }
  50% { box-shadow: 0 0 25px rgba(99, 102, 241, 0.5); }
}

/* --- BUTTONS --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem; /* Larger touch target */
  font-weight: 600;
  font-size: 1rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: transform 0.1s ease, background-color 0.2s;
  width: auto;
}

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

.btn-full {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

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

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

.btn-large {
  padding: 1rem 2rem;
  font-size: 1.125rem;
  border-radius: var(--radius-full);
}

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  cursor: pointer;
}

.btn-icon:active {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.btn-icon-danger {
  color: var(--danger-color);
  background: rgba(239, 68, 68, 0.1);
}

/* --- WELCOME SCREEN --- */
.welcome-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  background: radial-gradient(circle at top, #1e1b4b, var(--bg-color));
}

.welcome-icon-container {
  width: 120px;
  height: 120px;
  background: rgba(99, 102, 241, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 2rem;
  animation: pulse-glow 3s infinite;
}

.welcome-icon {
  font-size: 4rem;
  color: var(--primary-color);
}

.welcome-title {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 1rem;
  background: linear-gradient(to right, white, #a5b4fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome-subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 3rem;
  line-height: 1.6;
}

/* --- CONTACT LIST --- */
.contact-list-wrapper {
  min-height: 100dvh;
  background: var(--bg-color);
  padding-bottom: 80px; /* Space for FAB */
}

.list-header {
  padding: 1.5rem 1rem;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.list-title {
  font-size: 1.5rem;
  font-weight: 700;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}

.empty-state-icon {
  font-size: 4rem;
  opacity: 0.3;
  margin-bottom: 1rem;
}

.contact-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
}

.contact-item {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.2s;
}

.contact-item:active {
  background: rgba(30, 41, 59, 1);
}

.contact-name {
  font-weight: 600;
  font-size: 1.1rem;
  color: white;
  margin-bottom: 0.25rem;
}

.contact-detail {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.contact-email {
  font-size: 0.8rem;
  color: var(--primary-color);
  margin-top: 0.25rem;
}

/* --- FAB --- */
.scanner-fab {
  position: fixed;
  bottom: 2rem;
  right: 1.5rem;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  border: none;
  box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.5);
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 100;
  transition: transform 0.2s;
}

.scanner-fab:active {
  transform: scale(0.9);
}

/* --- CAMERA --- */
.camera-overlay {
  position: fixed;
  inset: 0;
  background: black;
  z-index: 200;
  display: flex;
  flex-direction: column;
}

.camera-container {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-cutout-container {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Semi-transparent dark overlay around the cutout */
  background: rgba(0, 0, 0, 0.4); 
}

/* The hole in the overlay */
.camera-cutout {
  width: 85%;
  max-width: 400px;
  aspect-ratio: 85/54; /* ID Card Ratio */
  position: relative;
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5); /* The dark overlay logic */
}

.cutout-border-container {
  position: absolute;
  inset: 0;
  border-radius: 16px;
  overflow: hidden;
}

/* Corner Brackets */
.cutout-corner {
  position: absolute;
  width: 40px;
  height: 40px;
  border: 3px solid white;
  border-radius: 4px;
  box-shadow: 0 0 4px rgba(0,0,0,0.5);
}

.top-left { top: -2px; left: -2px; border-bottom: none; border-right: none; }
.top-right { top: -2px; right: -2px; border-bottom: none; border-left: none; }
.bottom-left { bottom: -2px; left: -2px; border-top: none; border-right: none; }
.bottom-right { bottom: -2px; right: -2px; border-top: none; border-left: none; }

.scan-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary-color);
  box-shadow: 0 0 10px var(--primary-color);
  animation: scan-move 2.5s linear infinite;
}

.camera-controls {
  position: absolute;
  bottom: 3rem;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  pointer-events: none; /* Allow clicks through transparent areas */
}

.camera-message {
  color: white;
  background: rgba(0,0,0,0.6);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
  backdrop-filter: blur(4px);
}

.capture-button {
  pointer-events: auto;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 4px solid rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.capture-button-inner {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: white;
  transition: transform 0.1s;
}

.capture-button:active .capture-button-inner {
  transform: scale(0.9);
}

/* --- EDITOR SCREEN --- */
.editor-screen {
  background: var(--bg-color);
  min-height: 100dvh;
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.editor-form-container {
  background: #1e293b;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  margin-bottom: 2rem;
}

.editor-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.form-fields {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input,
.form-group textarea {
  width: 100%;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 0.75rem 1rem; /* Comfortable tap area */
  color: white;
  font-size: 16px; /* Prevents iOS zoom */
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
}

.btn-add-phone {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--primary-color);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.5rem 0;
  cursor: pointer;
}

.form-actions {
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-footer {
  margin-top: 1rem;
}

/* --- MODAL --- */
.modal-content {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 400px;
  background: #1e293b;
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  z-index: 300;
  padding: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: fadeIn 0.2s ease-out;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 2rem;
  line-height: 0.5;
  padding: 0.5rem;
  cursor: pointer;
}

.confirmation-modal {
  text-align: center;
}

.confirmation-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

.confirmation-actions .btn {
  flex: 1;
}

/* --- LOADING / AI STATUS --- */
.loading-screen {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  z-index: 400;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-left-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1.5rem;
}

.loading-message {
  font-size: 1.25rem;
  font-weight: 600;
  color: white;
}

/* --- PWA BANNER --- */
.pwa-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--primary-color);
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 500;
  box-shadow: 0 -4px 10px rgba(0,0,0,0.2);
}

.pwa-content {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.pwa-icon {
  font-size: 1.5rem;
}

.pwa-text p {
  margin: 0;
}

.pwa-title {
  font-weight: 700;
  font-size: 1rem;
}

.pwa-subtitle {
  font-size: 0.8rem;
  opacity: 0.9;
}

.pwa-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-pwa-install, .btn-pwa-dismiss {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

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

.btn-pwa-dismiss {
  background: rgba(0,0,0,0.2);
  color: white;
}

/* --- UTILS --- */
.address-display {
  white-space: pre-wrap;
  line-height: 1.4;
}
