/**
 * KT AI 기반 소상공인 이벤트 자동 생성 서비스
 * 공통 스타일시트
 *
 * 작성일: 2025-01-20
 * 버전: 1.0
 * 디자인 원칙: Mobile First, 접근성 우선, 일관성
 */

/* ============================================
   1. CSS Variables (Design Tokens)
   ============================================ */
:root {
  /* Primary Colors */
  --color-primary-main: #E31E24;
  --color-primary-light: #FF4D52;
  --color-primary-dark: #C71820;

  /* Secondary Colors */
  --color-secondary-main: #0066FF;
  --color-secondary-light: #4D94FF;
  --color-secondary-dark: #004DBF;

  /* Grayscale */
  --color-black: #1A1A1A;
  --color-gray-700: #4A4A4A;
  --color-gray-500: #9E9E9E;
  --color-gray-300: #D9D9D9;
  --color-gray-100: #F5F5F5;
  --color-white: #FFFFFF;

  /* Semantic Colors */
  --color-success: #00C853;
  --color-warning: #FFA000;
  --color-error: #D32F2F;
  --color-info: #0288D1;

  /* Typography */
  --font-family-base: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', system-ui, sans-serif;

  /* Font Sizes (Mobile First) */
  --font-size-display: 28px;
  --font-size-h1: 24px;
  --font-size-h2: 20px;
  --font-size-h3: 18px;
  --font-size-body-l: 16px;
  --font-size-body-m: 14px;
  --font-size-body-s: 12px;
  --font-size-button: 16px;

  /* Font Weights */
  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  /* Line Heights */
  --line-height-tight: 1.3;
  --line-height-normal: 1.4;
  --line-height-relaxed: 1.5;

  /* Spacing (4px Grid System) */
  --spacing-xs: 4px;
  --spacing-s: 8px;
  --spacing-m: 16px;
  --spacing-l: 24px;
  --spacing-xl: 32px;
  --spacing-2xl: 48px;

  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 50%;

  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 8px 24px rgba(0, 0, 0, 0.2);

  /* Transitions */
  --transition-fast: 100ms ease-out;
  --transition-normal: 200ms ease-out;
  --transition-slow: 300ms ease-out;

  /* Z-index */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-toast: 1060;
}

/* Tablet */
@media (min-width: 768px) {
  :root {
    --font-size-display: 32px;
    --font-size-h1: 28px;
    --font-size-h2: 22px;
    --font-size-h3: 20px;
    --font-size-body-l: 18px;
    --font-size-body-m: 16px;
    --font-size-body-s: 14px;
  }
}

/* Desktop */
@media (min-width: 1024px) {
  :root {
    --font-size-display: 36px;
    --font-size-h1: 32px;
    --font-size-h2: 24px;
  }
}

/* ============================================
   2. Reset & Base Styles
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-body-m);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-relaxed);
  color: var(--color-black);
  background-color: var(--color-gray-100);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   3. Typography System
   ============================================ */
.display {
  font-size: var(--font-size-display);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  letter-spacing: -0.5px;
}

h1, .h1 {
  font-size: var(--font-size-h1);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  letter-spacing: -0.3px;
}

h2, .h2 {
  font-size: var(--font-size-h2);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-normal);
  letter-spacing: -0.2px;
}

h3, .h3 {
  font-size: var(--font-size-h3);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-normal);
}

.body-l {
  font-size: var(--font-size-body-l);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-relaxed);
}

.body-m {
  font-size: var(--font-size-body-m);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-relaxed);
}

.body-s {
  font-size: var(--font-size-body-s);
  font-weight: var(--font-weight-regular);
  line-height: var(--line-height-relaxed);
}

/* ============================================
   4. Layout
   ============================================ */
.container {
  width: 100%;
  margin: 0 auto;
  padding: 0 20px;
}

@media (min-width: 768px) {
  .container {
    padding: 0 40px;
  }
}

@media (min-width: 1024px) {
  .container {
    max-width: 1200px;
    padding: 0 80px;
  }
}

/* App Layout */
.app-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--color-gray-100);
}

.app-content {
  flex: 1;
  padding-bottom: 80px; /* Bottom Navigation 공간 */
}

/* ============================================
   5. Top App Bar
   ============================================ */
.app-bar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  background-color: var(--color-white);
  border-bottom: 1px solid var(--color-gray-300);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 var(--spacing-s);
}

.app-bar__back {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--color-gray-700);
  border-radius: var(--radius-full);
  transition: background-color var(--transition-fast);
}

.app-bar__back:hover {
  background-color: var(--color-gray-100);
}

.app-bar__title {
  flex: 1;
  font-size: var(--font-size-h3);
  font-weight: var(--font-weight-semibold);
  text-align: center;
  margin-right: 48px; /* 뒤로가기 버튼과 균형 */
}

/* ============================================
   6. Bottom Navigation
   ============================================ */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-fixed);
  background-color: var(--color-white);
  border-top: 1px solid var(--color-gray-300);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
  height: 60px;
  display: flex;
}

.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-xs);
  border: none;
  background: none;
  color: var(--color-gray-500);
  cursor: pointer;
  text-decoration: none;
  transition: color var(--transition-fast);
  min-width: 44px;
  min-height: 44px;
}

.bottom-nav__item:hover {
  color: var(--color-primary-main);
}

.bottom-nav__item.active {
  color: var(--color-primary-main);
}

.bottom-nav__icon {
  font-size: 24px;
  font-family: 'Material Icons';
  font-weight: normal;
  font-style: normal;
  display: inline-block;
}

.bottom-nav__label {
  font-size: var(--font-size-body-s);
  font-weight: var(--font-weight-regular);
}

/* ============================================
   7. Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-s);
  font-family: var(--font-family-base);
  font-size: var(--font-size-button);
  font-weight: var(--font-weight-semibold);
  line-height: 1.5;
  text-align: center;
  text-decoration: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-normal);
  min-width: 44px;
  min-height: 44px;
}

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

/* Primary Button */
.btn-primary {
  background-color: var(--color-primary-main);
  color: var(--color-white);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--color-primary-light);
}

.btn-primary:active:not(:disabled) {
  background-color: var(--color-primary-dark);
  transform: scale(0.95);
}

.btn-primary:disabled {
  background-color: var(--color-gray-300);
  color: var(--color-gray-500);
}

/* Secondary Button */
.btn-secondary {
  background-color: var(--color-white);
  color: var(--color-primary-main);
  border: 2px solid var(--color-primary-main);
}

.btn-secondary:hover:not(:disabled) {
  background-color: rgba(227, 30, 36, 0.05);
}

.btn-secondary:active:not(:disabled) {
  background-color: rgba(227, 30, 36, 0.1);
  transform: scale(0.95);
}

/* Text Button */
.btn-text {
  background-color: transparent;
  color: var(--color-primary-main);
}

.btn-text:hover:not(:disabled) {
  background-color: rgba(227, 30, 36, 0.05);
}

/* Button Sizes */
.btn-lg {
  padding: 16px 24px;
  height: 48px;
}

.btn-md {
  padding: 12px 20px;
  height: 44px;
  font-size: var(--font-size-body-m);
}

.btn-sm {
  padding: 8px 16px;
  height: 36px;
  font-size: var(--font-size-body-s);
}

/* Full Width Button */
.btn-block {
  width: 100%;
}

/* ============================================
   8. Cards
   ============================================ */
.card {
  background-color: var(--color-white);
  border: 1px solid rgba(224, 224, 224, 1);
  border-radius: var(--radius-md);
  padding: var(--spacing-l);
  box-shadow: var(--shadow-md);
  transition: all var(--transition-normal);
}

.card:hover {
  border-color: var(--color-primary-main);
  box-shadow: var(--shadow-lg);
}

.card.selected {
  border: 2px solid var(--color-primary-main);
  background-color: rgba(227, 30, 36, 0.02);
}

.card__header {
  margin-bottom: var(--spacing-m);
}

.card__title {
  font-size: var(--font-size-h3);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--spacing-s);
}

.card__body {
  color: var(--color-gray-700);
  font-size: var(--font-size-body-m);
}

.card__footer {
  margin-top: var(--spacing-m);
  padding-top: var(--spacing-m);
  border-top: 1px solid var(--color-gray-300);
}

/* ============================================
   9. Form Elements
   ============================================ */
.form-group {
  margin-bottom: var(--spacing-m);
}

.form-label {
  display: block;
  font-size: var(--font-size-body-m);
  font-weight: var(--font-weight-medium);
  color: var(--color-black);
  margin-bottom: var(--spacing-s);
}

.form-label.required::after {
  content: '*';
  color: var(--color-error);
  margin-left: var(--spacing-xs);
}

.form-input {
  width: 100%;
  height: 48px;
  padding: var(--spacing-m);
  font-family: var(--font-family-base);
  font-size: var(--font-size-body-l);
  font-weight: var(--font-weight-regular);
  color: var(--color-black);
  background-color: var(--color-white);
  border: 1px solid var(--color-gray-300);
  border-radius: var(--radius-sm);
  transition: all var(--transition-normal);
}

.form-input::placeholder {
  color: var(--color-gray-500);
}

.form-input:focus {
  outline: none;
  border: 2px solid var(--color-secondary-main);
  box-shadow: 0 0 0 4px rgba(0, 102, 255, 0.1);
}

.form-input:disabled {
  background-color: var(--color-gray-100);
  color: var(--color-gray-500);
  cursor: not-allowed;
}

.form-input.error {
  border: 2px solid var(--color-error);
  box-shadow: 0 0 0 4px rgba(211, 47, 47, 0.1);
}

.form-error {
  display: block;
  margin-top: var(--spacing-s);
  font-size: var(--font-size-body-s);
  color: var(--color-error);
}

/* Textarea */
.form-textarea {
  min-height: 120px;
  resize: vertical;
  padding: var(--spacing-m);
  font-size: var(--font-size-body-m);
  line-height: var(--line-height-relaxed);
}

/* Checkbox & Radio */
.form-check {
  display: flex;
  align-items: center;
  gap: var(--spacing-s);
  cursor: pointer;
  min-height: 44px;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 24px;
  height: 24px;
  cursor: pointer;
  accent-color: var(--color-primary-main);
}

/* ============================================
   10. Progress & Loading
   ============================================ */
.progress-bar {
  width: 100%;
  height: 8px;
  background-color: var(--color-gray-100);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  background-color: var(--color-primary-main);
  transition: width var(--transition-slow);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-gray-100);
  border-top-color: var(--color-primary-main);
  border-radius: var(--radius-full);
  animation: spin 0.8s linear infinite;
}

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

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
}

/* ============================================
   11. Toast Notification
   ============================================ */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  background-color: rgba(26, 26, 26, 0.9);
  color: var(--color-white);
  padding: var(--spacing-m) var(--spacing-l);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-body-m);
  box-shadow: var(--shadow-xl);
  animation: toast-show 200ms ease-out;
  max-width: calc(100% - 40px);
}

@keyframes toast-show {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.toast.hide {
  animation: toast-hide 200ms ease-in forwards;
}

@keyframes toast-hide {
  to {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
  }
}

/* ============================================
   12. Modal
   ============================================ */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: var(--z-modal-backdrop);
  animation: fade-in 250ms ease-out;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: var(--z-modal);
  background-color: var(--color-white);
  border-radius: var(--radius-lg);
  padding: var(--spacing-l);
  max-width: 400px;
  width: calc(100% - 40px);
  box-shadow: var(--shadow-xl);
  animation: modal-show 250ms ease-out;
}

@keyframes modal-show {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-m);
}

.modal__title {
  font-size: var(--font-size-h2);
  font-weight: var(--font-weight-bold);
}

.modal__close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--color-gray-700);
  border-radius: var(--radius-full);
  transition: background-color var(--transition-fast);
}

.modal__close:hover {
  background-color: var(--color-gray-100);
}

.modal__body {
  margin-bottom: var(--spacing-l);
  color: var(--color-gray-700);
}

.modal__footer {
  display: flex;
  gap: var(--spacing-s);
  justify-content: flex-end;
}

/* ============================================
   13. Bottom Sheet
   ============================================ */
.bottom-sheet-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: var(--z-modal-backdrop);
  animation: fade-in 300ms ease-out;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-modal);
  background-color: var(--color-white);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
  animation: slide-up 300ms ease-out;
}

@keyframes slide-up {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.bottom-sheet__handle {
  width: 40px;
  height: 4px;
  background-color: var(--color-gray-300);
  border-radius: 2px;
  margin: var(--spacing-m) auto;
}

.bottom-sheet__content {
  padding: 0 var(--spacing-l) var(--spacing-l);
}

/* ============================================
   14. Utility Classes
   ============================================ */
/* Display */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-grid { display: grid !important; }

/* Flex */
.flex-column { flex-direction: column !important; }
.flex-wrap { flex-wrap: wrap !important; }
.justify-center { justify-content: center !important; }
.justify-between { justify-content: space-between !important; }
.align-center { align-items: center !important; }
.gap-xs { gap: var(--spacing-xs) !important; }
.gap-s { gap: var(--spacing-s) !important; }
.gap-m { gap: var(--spacing-m) !important; }
.gap-l { gap: var(--spacing-l) !important; }

/* Spacing */
.mt-s { margin-top: var(--spacing-s) !important; }
.mt-m { margin-top: var(--spacing-m) !important; }
.mt-l { margin-top: var(--spacing-l) !important; }
.mb-s { margin-bottom: var(--spacing-s) !important; }
.mb-m { margin-bottom: var(--spacing-m) !important; }
.mb-l { margin-bottom: var(--spacing-l) !important; }
.p-m { padding: var(--spacing-m) !important; }
.p-l { padding: var(--spacing-l) !important; }

/* Text */
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.text-primary { color: var(--color-primary-main) !important; }
.text-secondary { color: var(--color-secondary-main) !important; }
.text-success { color: var(--color-success) !important; }
.text-error { color: var(--color-error) !important; }
.text-muted { color: var(--color-gray-500) !important; }

/* Background */
.bg-white { background-color: var(--color-white) !important; }
.bg-gray { background-color: var(--color-gray-100) !important; }
.bg-primary { background-color: var(--color-primary-main) !important; }

/* Border */
.border { border: 1px solid var(--color-gray-300) !important; }
.border-top { border-top: 1px solid var(--color-gray-300) !important; }
.border-bottom { border-bottom: 1px solid var(--color-gray-300) !important; }

/* Visibility */
.hidden { visibility: hidden !important; }
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ============================================
   15. Accessibility
   ============================================ */
/* Focus Visible */
*:focus-visible {
  outline: 2px solid var(--color-secondary-main);
  outline-offset: 2px;
}

/* Skip Link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background-color: var(--color-primary-main);
  color: var(--color-white);
  padding: var(--spacing-s) var(--spacing-m);
  text-decoration: none;
  z-index: 9999;
}

.skip-link:focus {
  top: 0;
}

/* ============================================
   16. Animations
   ============================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
