/* ========================================================
   Common & Base Styles - QR 출석 관리 시스템
   ======================================================== */

@import './variables.css';

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

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

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  letter-spacing: -0.02em;
}

a {
  color: var(--primary-light);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary);
}

/* Glassmorphism Card Container */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
}

.glass-card:hover {
  border-color: var(--border-subtle);
}

/* App Header & Navbar */
.app-header {
  height: 70px;
  background: var(--bg-surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  text-decoration: none;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: var(--primary-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.25rem;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.realtime-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--success);
  white-space: nowrap;
  flex-shrink: 0;
}

.realtime-dot {
  width: 8px;
  height: 8px;
  background: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--success);
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%);
  box-shadow: 0 6px 20px var(--primary-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-main);
  border-color: var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-elevated);
  border-color: var(--border-subtle);
}

.btn-success {
  background: rgba(16, 185, 129, 0.22);
  color: #046E50;
  border-color: rgba(16, 185, 129, 0.5);
  font-weight: 700;
}

.btn-success:hover {
  background: rgba(16, 185, 129, 0.35);
  border-color: rgba(16, 185, 129, 0.7);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.22);
  color: #BE123C;
  border-color: rgba(244, 63, 94, 0.5);
  font-weight: 700;
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.35);
  border-color: rgba(244, 63, 94, 0.7);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Form Controls */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.input-field, .select-field {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.95rem;
  font-family: inherit;
  transition: all var(--transition-fast);
  outline: none;
}

.input-field:focus, .select-field:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--bg-surface);
}

.input-field::placeholder {
  color: var(--text-muted);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge-present {
  background: rgba(16, 185, 129, 0.2);
  color: #046E50;
  border: 1px solid rgba(16, 185, 129, 0.5);
  font-weight: 800;
}

.badge-late {
  background: rgba(245, 158, 11, 0.2);
  color: #92400E;
  border: 1px solid rgba(245, 158, 11, 0.5);
  font-weight: 800;
}

.badge-absent {
  background: rgba(244, 63, 94, 0.2);
  color: #BE123C;
  border: 1px solid rgba(244, 63, 94, 0.5);
  font-weight: 800;
}

.badge-pending {
  background: rgba(148, 163, 184, 0.2);
  color: var(--text-secondary);
  border: 1px solid rgba(148, 163, 184, 0.45);
  font-weight: 800;
}

/* Modal Dialog */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.active {
  display: flex !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px) scale(0.97);
  transition: transform var(--transition-normal);
  padding: 2rem;
}

.modal-overlay.active .modal-box {
  transform: translateY(0) scale(1);
}

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

.modal-title {
  font-size: 1.35rem;
  font-weight: 700;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.25rem;
  transition: color var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-main);
}

/* Toast Container */
#toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 400px;
  padding: 0.9rem 1.25rem;
  background: var(--bg-surface);
  
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: all 0.3s ease;
}

.toast-success {
  border-left: 4px solid var(--success);
}

.toast-error {
  border-left: 4px solid var(--danger);
}

.toast-info {
  border-left: 4px solid var(--primary-light);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(15px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

/* ========================================================
   Mobile & Responsive Optimization across all screen sizes
   ======================================================== */

/* Scrollbar refinement */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-surface);
}
::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.3);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.6);
}

/* Visibility utilities */
.hide-mobile {
  display: inline-flex;
}
.show-mobile-only {
  display: none !important;
}

@media (max-width: 768px) {
  .hide-tablet {
    display: none !important;
  }
}

@media (max-width: 680px) {
  .hide-mobile {
    display: none !important;
  }
  .show-mobile-only {
    display: inline-flex !important;
  }

  .app-header {
    height: 60px;
    padding: 0 0.85rem;
    gap: 0.5rem;
  }

  .brand-logo {
    font-size: 1rem;
    gap: 0.5rem;
  }

  .brand-icon {
    width: 32px;
    height: 32px;
    font-size: 1.05rem;
    border-radius: var(--radius-sm);
  }

  /* 모바일 화면에서 뱃지 텍스트를 숨겨 세련된 원형 펄스 인디케이터로 축소 (찌그러짐 방지) */
  .realtime-badge {
    padding: 0;
    gap: 0;
    width: 26px;
    height: 26px;
    min-width: 26px;
    max-width: 26px;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden;
  }

  .realtime-badge span:not(.realtime-dot) {
    display: none !important;
  }

  .nav-actions {
    gap: 0.4rem;
  }

  .btn {
    padding: 0.5rem 0.85rem;
    font-size: 0.82rem;
  }

  .modal-box {
    padding: 1.5rem 1.15rem;
    border-radius: var(--radius-lg);
    max-width: 95vw;
    width: 95vw;
    margin: 0 auto;
  }

  #toast-container {
    bottom: 1rem;
    right: 0.75rem;
    left: 0.75rem;
  }

  .toast {
    min-width: unset;
    max-width: 100%;
    font-size: 0.85rem;
    padding: 0.75rem 1rem;
  }
}

@media (max-width: 420px) {
  .app-header {
    padding: 0 0.65rem;
  }

  .brand-logo span {
    font-size: 0.92rem;
    max-width: 130px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .btn {
    padding: 0.45rem 0.75rem;
    font-size: 0.8rem;
  }
}


/* 스타일 가이드 버튼 변형: Primary / Secondary / Inverted / Outlined */
.btn-primary:hover { background: var(--primary-strong); }
.btn-secondary { background: var(--primary-soft); color: var(--primary-strong); border-color: transparent; }
.btn-secondary:hover { background: #D2E0FF; }
.btn-inverted { background: var(--inverted); color: #fff; border-color: transparent; }
.btn-inverted:hover { background: var(--bg-surface); }
.btn-outlined { background: transparent; color: var(--inverted); border-color: var(--neutral); }
.btn-outlined:hover { background: var(--bg-elevated); }

/* ---- 반응형 보정 (전 페이지 공통) ---- */
html, body { max-width: 100%; overflow-x: hidden; }
img, svg, video, canvas { max-width: 100%; }
.app-header { height: auto; min-height: 70px; flex-wrap: wrap; gap: .5rem .75rem; padding-top: .55rem; padding-bottom: .55rem; }
.nav-actions { flex-wrap: wrap; justify-content: flex-end; min-width: 0; gap: .5rem; }
.brand-logo { min-width: 0; }
@media (max-width: 760px) {
  .app-header { padding-left: .85rem; padding-right: .85rem; }
  .nav-actions { width: 100%; justify-content: flex-start; }
  .nav-actions .btn { padding: .45rem .8rem; font-size: .82rem; }
}
@media (max-width: 480px) {
  .realtime-badge span:not(.realtime-dot) { display: none; }
  .realtime-badge { padding: .35rem .5rem; }
}
