/* shadcn/ui CSS Variables - Light & Dark Theme */

:root {
  --background: 0 0% 100%;
  --foreground: 222.2 84% 4.9%;
  --card: 0 0% 100%;
  --card-foreground: 222.2 84% 4.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 222.2 84% 4.9%;
  --primary: 221.2 83.2% 65.3%;
  --primary-foreground: 210 40% 98%;
  --secondary: 210 40% 96.1%;
  --secondary-foreground: 222.2 47.4% 11.2%;
  --muted: 210 40% 96.1%;
  --muted-foreground: 215.4 16.3% 46.9%;
  --accent: 210 40% 96.1%;
  --accent-foreground: 222.2 47.4% 11.2%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 210 40% 98%;
  --border: 214.3 31.8% 91.4%;
  --input: 214.3 31.8% 91.4%;
  --ring: 221.2 83.2% 65.3%;
  --radius: 0.5rem;
  --success: 142.1 76.2% 36.3%;
  --success-foreground: 210 40% 98%;
  --warning: 38 92% 50%;
  --warning-foreground: 222.2 84% 4.9%;
}

.dark {
  --background: 222.2 84% 4.9%;
  --foreground: 210 40% 98%;
  --card: 217.2 32.6% 11%;
  --card-foreground: 210 40% 98%;
  --popover: 217.2 32.6% 11%;
  --popover-foreground: 210 40% 98%;
  --primary: 217.2 91.2% 59.8%;
  --primary-foreground: 222.2 47.4% 11.2%;
  --secondary: 217.2 32.6% 17.5%;
  --secondary-foreground: 210 40% 98%;
  --muted: 217.2 32.6% 17.5%;
  --muted-foreground: 215 20.2% 65.1%;
  --accent: 217.2 32.6% 17.5%;
  --accent-foreground: 210 40% 98%;
  --destructive: 0 62.8% 50.6%;
  --destructive-foreground: 210 40% 98%;
  --border: 217.2 32.6% 17.5%;
  --input: 217.2 32.6% 17.5%;
  --ring: 224.3 76.3% 48%;
  --success: 142.1 70.6% 45.3%;
  --success-foreground: 210 40% 98%;
  --warning: 38 92% 50%;
  --warning-foreground: 210 40% 98%;
}

/* Base styles */
* {
  border-color: hsl(var(--border));
}

body {
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-feature-settings: "rlig" 1, "calt" 1;
}

/* Focus ring utility */
.focus-ring {
  outline: none;
}
.focus-ring:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: hsl(var(--muted));
}
::-webkit-scrollbar-thumb {
  background: hsl(var(--muted-foreground) / 0.3);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--muted-foreground) / 0.5);
}

/* Animation utilities */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-4px); }
}
@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
@keyframes slideInLeft {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.animate-fade-in {
  animation: fadeIn 0.2s ease-out;
}
.animate-scale-in {
  animation: scaleIn 0.2s ease-out;
}
.animate-slide-in-right {
  animation: slideInRight 0.3s ease-out;
}
.animate-slide-in-left {
  animation: slideInLeft 0.3s ease-out;
}

/* iOS 입력 줌 방지 */
@media screen and (max-width: 768px) {
  input[type="text"], input[type="email"], input[type="number"],
  input[type="date"], input[type="tel"], input[type="password"],
  select, textarea {
    font-size: 16px !important;
  }
}

/* ========================================
   Mobile: Table → Card layout
   ======================================== */
@media (max-width: 767px) {
  /* Remove outer table border/overflow — cards have own borders */
  .responsive-table {
    overflow: visible !important;
    border: none !important;
    border-radius: 0 !important;
    background: transparent;
  }

  /* Hide table header */
  .responsive-table > table > thead {
    display: none;
  }

  /* Stack rows as cards */
  .responsive-table > table,
  .responsive-table > table > tbody {
    display: block;
  }

  .responsive-table > table > tbody {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  /* Each row = card */
  .responsive-table > table > tbody > tr {
    display: flex !important;
    flex-direction: column;
    border: 1px solid hsl(var(--border)) !important;
    border-radius: 0.75rem;
    padding: 0.875rem 1rem;
    background: hsl(var(--card));
  }

  .responsive-table > table > tbody > tr:hover {
    background: hsl(var(--accent) / 0.3);
  }

  /* Each cell = label–value row */
  .responsive-table > table > tbody > tr > td {
    display: flex !important;       /* overrides column_classes hidden */
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.25rem 0 !important;
    border: none !important;
    gap: 0.5rem;
  }

  /* Label from data-label attribute */
  .responsive-table > table > tbody > tr > td::before {
    content: attr(data-label);
    font-weight: 500;
    font-size: 0.75rem;
    line-height: 1.5rem;
    color: hsl(var(--muted-foreground));
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 5rem;
  }

  /* Value side */
  .responsive-table > table > tbody > tr > td > * {
    max-width: 100%;
  }

  /* Last cell (action buttons) — separator, no label */
  .responsive-table > table > tbody > tr > td:last-child {
    padding-top: 0.625rem !important;
    margin-top: 0.25rem;
    border-top: 1px solid hsl(var(--border)) !important;
    justify-content: flex-end;
  }
  .responsive-table > table > tbody > tr > td:last-child::before {
    display: none;
  }

  /* Empty state — keep centered */
  .responsive-table > table > tbody > tr.responsive-table-empty {
    align-items: center;
    justify-content: center;
  }
  .responsive-table > table > tbody > tr.responsive-table-empty > td {
    justify-content: center;
  }
  .responsive-table > table > tbody > tr.responsive-table-empty > td::before {
    display: none;
  }
  .responsive-table > table > tbody > tr.responsive-table-empty > td:last-child {
    border-top: none !important;
    padding-top: 0.25rem !important;
    margin-top: 0;
  }
}

/* ========================================
   Sticky Pagination
   ======================================== */
.pagination-sticky {
  position: sticky;
  bottom: 0;
  z-index: 10;
  background: hsl(var(--background) / 0.95);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  padding: 0.75rem 1rem;
  margin-top: 1.5rem;
  border-top: 1px solid hsl(var(--border));
  margin-left: -1rem;
  margin-right: -1rem;
}
@media (min-width: 640px) {
  .pagination-sticky {
    margin-left: -1.5rem;
    margin-right: -1.5rem;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}
