/**
 * QR Giriş/Çıkış Sistemi
 * Microsoft Fluent 2 Design + Glassmorphism
 */

/* ==================== CSS VARIABLES ==================== */
:root {
  /* Fluent 2 Colors */
  --color-background: #f5f5f5;
  --color-surface: rgba(255, 255, 255, 0.85);
  --color-surface-solid: #ffffff;
  --color-border: rgba(0, 0, 0, 0.05);
  --color-border-strong: rgba(0, 0, 0, 0.1);
  
  /* Text */
  --color-text-primary: #242424;
  --color-text-secondary: #616161;
  --color-text-tertiary: #959595;
  
  /* Accent - sadece gerekli yerlerde */
  --color-accent: #0078d4;
  --color-accent-hover: #106ebe;
  --color-success: #107c10;
  --color-warning: #ffb900;
  --color-danger: #d13438;
  
  /* Shadows - Fluent elevation */
  --shadow-2: 0 1px 2px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-4: 0 2px 4px rgba(0, 0, 0, 0.04), 0 4px 8px rgba(0, 0, 0, 0.06);
  --shadow-8: 0 4px 8px rgba(0, 0, 0, 0.04), 0 8px 16px rgba(0, 0, 0, 0.06);
  --shadow-16: 0 8px 16px rgba(0, 0, 0, 0.06), 0 16px 32px rgba(0, 0, 0, 0.08);
  
  /* Glassmorphism */
  --glass-blur: 20px;
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.5);
  
  /* Spacing */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

/* ==================== RESET & BASE ==================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI Variable', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--color-background);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Subtle background pattern */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle at 20% 20%, rgba(0, 120, 212, 0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(0, 120, 212, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
}

/* ==================== CONTAINER ==================== */
.container {
  width: 100%;
  max-width: 400px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-radius: var(--radius-xl);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-16);
  overflow: hidden;
}

/* ==================== STEPS ==================== */
.step {
  display: none;
  padding: 2rem;
  animation: fadeIn 0.3s ease;
}

.step.active {
  display: block;
}

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

/* ==================== TYPOGRAPHY ==================== */
h1 {
  text-align: center;
  color: var(--color-text-primary);
  font-size: 1.375rem;
  font-weight: 600;
  margin-bottom: 1.75rem;
  letter-spacing: -0.01em;
}

/* ==================== ACTION BUTTONS ==================== */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-solid);
  color: var(--color-text-primary);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-2);
  position: relative;
  overflow: hidden;
}

.action-btn::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--action-color);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.action-btn:hover {
  background: var(--color-surface-solid);
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-4);
  transform: translateY(-1px);
}

.action-btn:hover::before {
  opacity: 1;
}

.action-btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-2);
}

.action-icon {
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-background);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.action-label {
  flex: 1;
  text-align: left;
}

/* ==================== FORM ELEMENTS ==================== */
form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

label {
  font-weight: 500;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
}

input[type="text"] {
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: 1.125rem;
  font-family: inherit;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface-solid);
  color: var(--color-text-primary);
  text-align: center;
  letter-spacing: 2px;
  transition: all var(--transition-fast);
}

input[type="text"]:hover {
  border-color: var(--color-text-tertiary);
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.15);
}

input[type="text"]::placeholder {
  letter-spacing: normal;
  color: var(--color-text-tertiary);
}

/* ==================== BUTTONS ==================== */
button {
  padding: 0.875rem 1.25rem;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Primary Button */
#tcSubmitBtn,
.submit-btn {
  background: var(--color-accent);
  color: white;
  box-shadow: var(--shadow-2);
}

#tcSubmitBtn:hover:not(:disabled),
.submit-btn:hover:not(:disabled) {
  background: var(--color-accent-hover);
  box-shadow: var(--shadow-4);
}

#tcSubmitBtn:active:not(:disabled),
.submit-btn:active:not(:disabled) {
  box-shadow: var(--shadow-2);
}

/* Capture Button */
.capture-btn {
  background: var(--color-surface-solid);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border-strong);
  box-shadow: var(--shadow-2);
}

.capture-btn:hover {
  background: var(--color-background);
  box-shadow: var(--shadow-4);
}

/* Retake Button */
.retake-btn {
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border-strong);
}

.retake-btn:hover {
  background: var(--color-background);
  color: var(--color-text-primary);
}

/* Back Button */
.back-btn {
  background: transparent;
  color: var(--color-text-tertiary);
  font-size: 0.875rem;
  margin-top: 0.75rem;
  padding: 0.625rem 1rem;
}

.back-btn:hover {
  color: var(--color-text-secondary);
  background: var(--color-background);
}

/* New Entry Button */
.new-entry-btn {
  width: 100%;
  background: var(--color-accent);
  color: white;
  padding: 1rem;
}

.new-entry-btn:hover {
  background: var(--color-accent-hover);
}

/* ==================== CAMERA ==================== */
.student-name {
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--color-background);
  border-radius: var(--radius-sm);
}

/* ==================== EXTRA FIELDS ==================== */
.extra-fields {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.extra-fields.hidden {
  display: none;
}

.extra-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.extra-field label {
  font-weight: 500;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
}

.extra-field label .required {
  color: var(--color-danger);
}

.extra-field input[type="text"],
.extra-field input[type="date"] {
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface-solid);
  color: var(--color-text-primary);
  transition: all var(--transition-fast);
}

.extra-field input[type="text"]:hover,
.extra-field input[type="date"]:hover {
  border-color: var(--color-text-tertiary);
}

.extra-field input[type="text"]:focus,
.extra-field input[type="date"]:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.15);
}

.extra-field input[type="text"]::placeholder {
  color: var(--color-text-tertiary);
}

/* Date input özel stil */
.extra-field input[type="date"] {
  cursor: pointer;
}

.extra-field input[type="date"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.extra-field input[type="date"]:hover::-webkit-calendar-picker-indicator {
  opacity: 1;
}

.camera-wrapper {
  width: 100%;
  aspect-ratio: 4/3;
  background: var(--color-text-primary);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-4);
}

#camera,
#snapshot {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ==================== SUCCESS ==================== */
.success-content {
  text-align: center;
  padding: 1.5rem 0;
}

.success-icon {
  width: 72px;
  height: 72px;
  background: var(--color-success);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  font-size: 2rem;
  color: white;
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 16px rgba(16, 124, 16, 0.25);
}

@keyframes scaleIn {
  from { 
    transform: scale(0); 
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  to { 
    transform: scale(1); 
    opacity: 1;
  }
}

.success-content h1 {
  margin-bottom: 0.5rem;
  color: var(--color-success);
}

.success-message {
  font-size: 1.25rem;
  margin: 1rem 0 2rem;
  color: var(--color-text-primary);
  line-height: 1.5;
}

/* ==================== ERROR MODAL ==================== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 1000;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: var(--color-surface-solid);
  padding: 1.75rem;
  border-radius: var(--radius-lg);
  max-width: 320px;
  width: 100%;
  text-align: center;
  animation: modalIn 0.2s ease;
  box-shadow: var(--shadow-16);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-content p {
  font-size: 0.9375rem;
  color: var(--color-text-primary);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.modal-content button {
  background: var(--color-danger);
  color: white;
  width: 100%;
}

.modal-content button:hover {
  background: #c42b2f;
}

/* ==================== LOADING ==================== */
.btn-loader {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.hidden {
  display: none !important;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 480px) {
  body {
    padding: 0;
    align-items: stretch;
    background: var(--color-surface-solid);
  }

  body::before {
    display: none;
  }

  .container {
    border-radius: 0;
    min-height: 100vh;
    box-shadow: none;
    border: none;
    background: var(--color-surface-solid);
    backdrop-filter: none;
  }

  .step {
    padding: 1.5rem;
  }

  h1 {
    font-size: 1.25rem;
  }
}

/* ==================== DARK MODE SUPPORT ==================== */
@media (prefers-color-scheme: dark) {
  :root {
    --color-background: #1a1a1a;
    --color-surface: rgba(40, 40, 40, 0.85);
    --color-surface-solid: #2a2a2a;
    --color-border: rgba(255, 255, 255, 0.05);
    --color-border-strong: rgba(255, 255, 255, 0.1);
    --color-text-primary: #ffffff;
    --color-text-secondary: #b3b3b3;
    --color-text-tertiary: #737373;
    --glass-bg: rgba(40, 40, 40, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
  }

  body::before {
    background: 
      radial-gradient(circle at 20% 20%, rgba(0, 120, 212, 0.05) 0%, transparent 50%),
      radial-gradient(circle at 80% 80%, rgba(0, 120, 212, 0.05) 0%, transparent 50%);
  }

  input[type="text"] {
    background: #333;
    color: var(--color-text-primary);
  }

  .action-icon {
    background: #333;
  }

  .student-name {
    background: #333;
  }

  .extra-field input[type="text"],
  .extra-field input[type="date"] {
    background: #333;
    color: var(--color-text-primary);
  }
}
