/* ============================================
   CSM - Cyclic Schedule Manager
   Premium Dark Glassmorphism Theme
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ============================================
   CSS Custom Properties (Design Tokens)
   ============================================ */
:root {
  /* Colors - Default Light Mode */
  --bg-primary: #f8fafc;
  --bg-secondary: #e2e8f0;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-card-hover: rgba(255, 255, 255, 0.98);
  --bg-input: #f1f5f9;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --primary: #4f46e5;
  --primary-hover: #6366f1;
  --primary-glow: rgba(79, 70, 229, 0.15);

  --task-packing-bg: #e0e7ff;
  --task-packing-text: #3730a3;
  --task-shipping-bg: #ffedd5;
  --task-shipping-text: #9a3412;
  --task-off-bg: #d1fae5;
  --task-off-text: #065f46;

  --holiday: #ef4444;
  --holiday-bg: rgba(239, 68, 68, 0.08);

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  --border: rgba(148, 163, 184, 0.2);
  --border-light: rgba(0, 0, 0, 0.06);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 15px var(--primary-glow);

  --blur: blur(8px);

  --transition-fast: 0.12s ease;
  --transition-normal: 0.25s ease;
  --transition-slow: 0.4s ease;

  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Dark Mode Overrides */
body.dark-mode {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: rgba(30, 41, 59, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.9);
  --bg-input: rgba(15, 23, 42, 0.6);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-glow: rgba(99, 102, 241, 0.3);

  --task-packing-bg: #312e81;
  --task-packing-text: #c7d2fe;
  --task-shipping-bg: #7c2d12;
  --task-shipping-text: #fed7aa;
  --task-off-bg: #064e3b;
  --task-off-text: #a7f3d0;

  --border: rgba(148, 163, 184, 0.1);
  --border-light: rgba(255, 255, 255, 0.08);

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(59, 130, 246, 0.05) 0%, transparent 50%);
}

body.light-mode {
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.05) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.04) 0%, transparent 50%);
}

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

::selection {
  background: var(--primary);
  color: white;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ============================================
   Animations & Keyframes
   ============================================ */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes modalOut {
  to {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }
}

@keyframes overlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--primary-glow); }
  50% { box-shadow: 0 0 0 8px transparent; }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(100%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(100%) scale(0.9);
  }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes ripple {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

@keyframes badgePulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(99, 102, 241, 0);
  }
}

/* ============================================
   App Header
   ============================================ */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 64px;
  background: var(--bg-card);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #818cf8, #6366f1, #4f46e5);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.logo-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 400;
  letter-spacing: 0.5px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================
   Navigation
   ============================================ */
.app-nav {
  display: flex;
  gap: 4px;
  background: var(--bg-input);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.tab-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: rgba(99, 102, 241, 0.1);
}

.tab-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* ============================================
   Main Content
   ============================================ */
/* ============================================
   Dashboard Layout
   ============================================ */
.dashboard-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px;
}

.dashboard-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.dashboard-main {
  display: flex;
  flex-direction: column;
}

.dashboard-sidebar .card {
  box-shadow: var(--shadow-sm);
}

.dashboard-sidebar .card-header {
  padding: 12px 16px;
}

.dashboard-sidebar .card-body {
  padding: 16px;
}

.compact-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
}

.backup-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.quick-selects {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 12px 0;
}

.company-holiday-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.w-full {
  width: 100% !important;
}

.p-0 {
  padding: 0 !important;
}

/* ============================================
   Cards (Glassmorphism)
   ============================================ */
.card {
  background: var(--bg-card);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.card-body {
  padding: 24px;
}

/* ============================================
   Toolbar
   ============================================ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 0;
  margin-bottom: 16px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-title {
  font-size: 1.15rem;
  font-weight: 600;
  min-width: 140px;
  text-align: center;
  letter-spacing: -0.3px;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.btn:hover {
  background: var(--bg-card-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: translateY(0);
}

.btn:disabled,
.btn-primary:disabled,
.btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed !important;
  transform: none !important;
  box-shadow: none !important;
  pointer-events: none;
}

/* Button Ripple Effect */
.btn .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  animation: ripple 0.6s linear;
  pointer-events: none;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: white;
  border-color: transparent;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #818cf8, #6366f1);
  box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: linear-gradient(135deg, #f87171, #ef4444);
  box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: transparent;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn.active {
  background: var(--primary);
  color: white;
  border-color: transparent;
}

/* ============================================
   Form Elements
   ============================================ */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
  letter-spacing: 0.2px;
}

.input,
.select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-family);
  font-size: 0.9rem;
  transition: all var(--transition-fast);
  outline: none;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

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

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

.select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* ============================================
   Calendar Grid
   ============================================ */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  animation: fadeIn 0.3s ease;
}

.calendar-header {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.calendar-header-cell {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 8px 0;
}

.calendar-cell {
  background: var(--bg-card);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px;
  min-height: 120px;
  cursor: default;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.calendar-cell:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(99, 102, 241, 0.3);
}

.calendar-cell.empty {
  background: transparent;
  border: 1px dashed var(--border);
  min-height: 120px;
}

.calendar-cell.empty:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--border);
}

.calendar-cell .date-number {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.calendar-cell .date-number .holiday-label {
  font-size: 0.65rem;
  font-weight: 500;
  color: var(--holiday);
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-cell.today {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow), var(--shadow-md);
}

.calendar-cell.today .date-number::before {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  animation: badgePulse 2s infinite;
}

.calendar-cell.holiday {
  background: var(--holiday-bg);
  border-color: rgba(248, 113, 113, 0.2);
}

.calendar-cell.holiday .date-number {
  color: var(--holiday);
}

.calendar-cell.weekend {
  background: var(--holiday-bg);
  border-color: rgba(248, 113, 113, 0.15);
}

/* ============================================
   Task Badges
   ============================================ */
.task-badges {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.task-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  transition: all var(--transition-fast);
  letter-spacing: 0.2px;
}

.task-badge:hover {
  transform: scale(1.02);
}

.task-badge .worker-name-badge {
  font-weight: 500;
  font-size: 0.72rem;
  opacity: 0.9;
}

.task-badge .task-label {
  font-weight: 700;
  font-size: 0.7rem;
}

.task-badge.task-포장 {
  background: var(--task-packing-bg);
  color: var(--task-packing-text);
}

.task-badge.task-발송 {
  background: var(--task-shipping-bg);
  color: var(--task-shipping-text);
}

.task-badge.task-비번 {
  background: var(--task-off-bg);
  color: var(--task-off-text);
}

/* Fallback for additional tasks */
.task-badge.task-default {
  background: rgba(148, 163, 184, 0.3);
  color: var(--text-primary);
}

/* ============================================
   List / Table View
   ============================================ */
.schedule-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-light);
  animation: fadeIn 0.3s ease;
}

.schedule-table th {
  background: rgba(99, 102, 241, 0.1);
  padding: 14px 16px;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.schedule-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  vertical-align: middle;
  transition: background var(--transition-fast);
}

.schedule-table tr:hover td {
  background: rgba(99, 102, 241, 0.05);
}

.schedule-table tr:last-child td {
  border-bottom: none;
}

.schedule-table tr.row-holiday td {
  background: var(--holiday-bg);
  color: var(--holiday);
}

.schedule-table .date-col {
  font-weight: 600;
  white-space: nowrap;
}

.schedule-table .day-col {
  color: var(--text-secondary);
  font-size: 0.8rem;
}

/* ============================================
   Worker Cards
   ============================================ */
.worker-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.worker-card {
  background: var(--bg-card);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all var(--transition-normal);
  cursor: default;
  position: relative;
  overflow: hidden;
}

.worker-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--primary), #818cf8);
  border-radius: 4px 0 0 4px;
}

.worker-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg), 0 0 20px var(--primary-glow);
  border-color: rgba(99, 102, 241, 0.3);
}

.worker-card .worker-order {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.worker-card .worker-info {
  flex: 1;
  min-width: 0;
}

.worker-card .worker-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.worker-card .worker-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.worker-card .worker-actions {
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.worker-card:hover .worker-actions {
  opacity: 1;
}

.worker-card .drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 1.2rem;
  padding: 4px;
  user-select: none;
}

.worker-card .drag-handle:active {
  cursor: grabbing;
}

.worker-card.dragging {
  opacity: 0.5;
  transform: scale(0.98);
}

.worker-card.drag-over {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

/* ============================================
   Holidays
   ============================================ */
.holiday-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.holiday-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  border: 1px solid transparent;
}

.holiday-item:hover {
  background: rgba(99, 102, 241, 0.05);
  border-color: var(--border);
}

.holiday-item .holiday-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.holiday-date {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  min-width: 110px;
  font-variant-numeric: tabular-nums;
}

.holiday-name {
  font-size: 0.9rem;
  color: var(--text-primary);
}

.holiday-item .holiday-type {
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 500;
}

.holiday-type.national {
  background: rgba(248, 113, 113, 0.15);
  color: var(--holiday);
}

.holiday-type.company {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary-hover);
}

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: overlayIn 0.2s ease;
}

.modal-overlay.hidden {
  display: none !important;
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), 0 0 40px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  animation: modalIn 0.3s ease;
}

.modal-content.closing {
  animation: modalOut 0.2s ease forwards;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 1.2rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ============================================
   Admin
   ============================================ */
.admin-only {
  display: none !important;
}

body.admin-mode .admin-only {
  display: flex !important;
}

/* For block elements in admin mode */
body.admin-mode .admin-only.admin-block {
  display: block !important;
}

.admin-badge {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #78350f;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-lock {
  transition: all var(--transition-normal);
}

body.admin-mode .admin-lock {
  color: var(--warning);
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 500;
  pointer-events: all;
  animation: toastIn 0.3s ease;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  max-width: 380px;
}

.toast.removing {
  animation: toastOut 0.3s ease forwards;
}

.toast-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

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

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

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

/* ============================================
   Swap Mode
   ============================================ */
.swap-mode .calendar-cell:not(.empty) {
  cursor: pointer;
}

.swap-mode .calendar-cell:not(.empty):hover {
  outline: 2px solid rgba(251, 191, 36, 0.5);
  border-color: rgba(251, 191, 36, 0.3);
}

.calendar-cell.swap-selected {
  outline: 3px solid #fbbf24 !important;
  box-shadow: 0 0 16px rgba(251, 191, 36, 0.3), var(--shadow-md) !important;
}

.calendar-cell.swap-source {
  outline: 3px dashed #6366f1 !important;
  box-shadow: 0 0 16px var(--primary-glow), var(--shadow-md) !important;
}

.swap-mode-indicator {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #78350f;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  margin-bottom: 12px;
  animation: fadeIn 0.3s ease;
}

/* ============================================
   Rotation Preview Table
   ============================================ */
.rotation-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.rotation-table th {
  padding: 10px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-align: center;
  background: rgba(99, 102, 241, 0.08);
  border-bottom: 1px solid var(--border);
}

.rotation-table td {
  padding: 8px 12px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}

.rotation-table tr:last-child td {
  border-bottom: none;
}

/* ============================================
   Quick Select Buttons (Generate Modal)
   ============================================ */
.quick-select {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.quick-select .btn {
  flex: 1;
  min-width: 70px;
}

.quick-select .btn.active {
  background: var(--primary);
  color: white;
}

/* ============================================
   Generate Preview
   ============================================ */
.generate-preview {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.generate-preview strong {
  color: var(--primary-hover);
}

/* ============================================
   Day Detail Modal
   ============================================ */
.day-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.day-detail-date {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-hover);
}

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

.day-detail-assignments {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.day-assignment-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.day-assignment-row .worker-label {
  font-weight: 600;
  font-size: 0.9rem;
}

.day-assignment-row .task-select {
  width: auto;
  min-width: 100px;
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state-desc {
  font-size: 0.85rem;
  max-width: 400px;
  margin: 0 auto;
  line-height: 1.7;
}

/* ============================================
   Utility Classes
   ============================================ */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ============================================
   Responsive Design
   ============================================ */

/* Tablets and below */
@media (max-width: 1024px) {
  .main-content {
    padding: 16px;
  }

  .calendar-cell {
    min-height: 100px;
    padding: 8px;
  }

  .calendar-cell .date-number {
    font-size: 0.85rem;
  }

  .task-badge {
    padding: 3px 8px;
    font-size: 0.7rem;
  }

  .task-badge .worker-name-badge {
    font-size: 0.65rem;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    height: auto;
    padding: 12px 16px;
    gap: 12px;
  }

  .header-left {
    width: 100%;
    justify-content: center;
  }

  .app-nav {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .app-nav::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    padding: 6px 12px;
    font-size: 0.78rem;
  }

  .header-right {
    position: absolute;
    top: 12px;
    right: 16px;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-group {
    justify-content: center;
  }

  .calendar-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .calendar-header {
    display: none;
  }

  .calendar-cell {
    min-height: auto;
    padding: 12px;
  }

  .calendar-cell .date-number {
    font-size: 1rem;
  }

  .worker-list {
    grid-template-columns: 1fr;
  }

  .modal-content {
    max-width: 100%;
    margin: 10px;
    border-radius: var(--radius-lg);
  }

  .schedule-table {
    font-size: 0.8rem;
  }

  .schedule-table th,
  .schedule-table td {
    padding: 8px 10px;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .card-header h2 {
    font-size: 1rem;
  }
}

/* Small phones */
@media (max-width: 480px) {
  .main-content {
    padding: 10px;
  }

  .card-body {
    padding: 16px;
  }

  .toolbar-title {
    font-size: 1rem;
    min-width: 120px;
  }

  .logo {
    font-size: 1.2rem;
  }

  .logo-subtitle {
    display: none;
  }

  .toast {
    max-width: calc(100vw - 48px);
    font-size: 0.8rem;
    padding: 10px 14px;
  }
}

/* Normal mode: hide print header */
.print-header {
  display: none;
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
  @page {
    size: landscape;
    margin: 8mm 10mm;
  }

  /* 인쇄 시 불필요한 UI 숨김 */
  .app-header,
  .dashboard-sidebar,
  .toolbar,
  .toast-container,
  .modal-overlay,
  .btn,
  .quick-selects,
  .no-print,
  .app-footer,
  #statistics-panel,
  #correction-suggestion-panel,
  .dashboard-main > .card:not(.calendar-card),
  .swap-mode-indicator,
  .manual-edit-icon {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 12px;
    margin: 0 !important;
    padding: 0 !important;
  }

  .dashboard-layout {
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    max-width: 100% !important;
  }

  .dashboard-main {
    width: 100% !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .card, .calendar-card {
    background: #ffffff !important;
    box-shadow: none !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* 인쇄용 헤더 (해당 월 + 작업자 & 작업내용) */
  .print-header {
    display: block !important;
    text-align: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #000000;
  }

  .print-month-title {
    font-size: 24px !important;
    font-weight: 800 !important;
    margin: 0 0 6px 0 !important;
    color: #000000 !important;
    line-height: 1.2 !important;
    letter-spacing: -0.5px;
  }

  .print-meta-bar {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 16px !important;
    font-size: 13px !important;
    color: #000000 !important;
  }

  .print-meta-item {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
  }

  .print-meta-label {
    font-weight: 700 !important;
  }

  .print-meta-value {
    font-weight: 500 !important;
  }

  .print-meta-divider {
    color: #64748b;
    font-weight: 300;
  }

  .calendar-grid {
    grid-template-columns: repeat(5, 1fr) !important;
    gap: 0 !important;
    border-top: 1px solid #000000;
    border-left: 1px solid #000000;
  }

  .calendar-header {
    border-top: 1px solid #000000;
    border-bottom: 1px solid #000000;
    border-left: 1px solid #000000;
    border-right: 1px solid #000000;
    background: #f1f5f9 !important;
    color: #000000 !important;
    padding: 6px !important;
    font-weight: bold;
    text-align: center;
  }

  .calendar-cell {
    min-height: 92px !important;
    background: #ffffff !important;
    border-right: 1px solid #000000 !important;
    border-bottom: 1px solid #000000 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    page-break-inside: avoid;
    padding: 4px 6px !important;
  }

  /* 인쇄 시 작업 배지를 흑백 프린터에서도 구별 가능하게 경계선 테두리 적용 */
  .task-badge {
    border: 1px solid #000000 !important;
    background: #ffffff !important;
    color: #000000 !important;
    margin-top: 3px !important;
    padding: 2px 4px !important;
    border-radius: 3px !important;
    font-size: 11px !important;
  }

  .task-badge.task-포장 {
    border-left: 4px solid #4f46e5 !important;
  }

  .task-badge.task-발송 {
    border-left: 4px solid #f97316 !important;
  }

  .task-badge.task-비번 {
    border-left: 4px solid #10b981 !important;
    color: #64748b !important;
    border-color: #cbd5e1 !important;
  }

  .calendar-cell.holiday {
    background: #fef2f2 !important;
  }

  .calendar-cell.holiday .date-number {
    color: #ef4444 !important;
    font-weight: bold;
  }
}

/* ============================================
   Task Statistics & Auto-Correction Panel Styles
   ============================================ */
#statistics-panel {
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin-bottom: 12px;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  transition: all var(--transition-normal);
}

.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border);
}

.stats-title-text {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.balance-status-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.balance-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.balance-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.balance-badge.stable {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid var(--success);
}

.balance-badge.warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  border: 1px solid var(--warning);
}

.balance-badge.danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid var(--danger);
  animation: pulse 2s infinite;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.stats-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

body.light-mode .stats-card {
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(0, 0, 0, 0.03);
}

.stats-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.stats-worker-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.stats-task-count {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
}

.stats-bar-bg {
  height: 6px;
  background: var(--bg-secondary);
  border-radius: 3px;
  overflow: hidden;
}

body.dark-mode .stats-bar-bg {
  background: var(--bg-input);
}

.stats-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-hover), var(--primary));
  border-radius: 3px;
  transition: width var(--transition-slow);
}

.stats-detail-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.stats-detail-item {
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
}

body.light-mode .stats-detail-item {
  background: rgba(0, 0, 0, 0.04);
}

/* Auto-Correction Banner */
#correction-suggestion-panel {
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(139, 92, 246, 0.08));
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  animation: slideDown var(--transition-normal);
}

.suggestion-text {
  font-size: 0.85rem;
  color: var(--text-primary);
  line-height: 1.5;
}

.btn-correct {
  background: linear-gradient(135deg, #818cf8, #6366f1);
  color: white;
  border: none;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(99, 102, 241, 0.3);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-correct:hover {
  background: linear-gradient(135deg, #93c5fd, #818cf8);
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.4);
  transform: translateY(-1px);
}

.btn-correct:active {
  transform: translateY(0);
}

@media (max-width: 768px) {
  #correction-suggestion-panel {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .btn-correct {
    width: 100%;
    text-align: center;
  }
}

@media print {
  #statistics-panel,
  #correction-suggestion-panel {
    display: none !important;
  }
}

/* ============================================
   Weekend Layout & Styling (7 columns)
   ============================================ */
.calendar-grid.weekend-active {
  grid-template-columns: repeat(7, 1fr);
}

.calendar-header.weekend-active {
  grid-template-columns: repeat(7, 1fr);
}

/* Weekend colors */
.calendar-header-cell.sat {
  color: #3b82f6 !important; /* Blue color for Saturday */
}
.calendar-header-cell.sun {
  color: #ef4444 !important; /* Red color for Sunday */
}

.calendar-cell.sat {
  background: rgba(59, 130, 246, 0.03);
}
.calendar-cell.sun {
  background: rgba(239, 68, 68, 0.03);
}

body.dark-mode .calendar-cell.sat {
  background: rgba(59, 130, 246, 0.05);
}
body.dark-mode .calendar-cell.sun {
  background: rgba(239, 68, 68, 0.05);
}

/* Manually changed date highlights */
.calendar-cell.manually-changed {
  border: 1.5px solid var(--warning) !important;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.15) !important;
}

body.dark-mode .calendar-cell.manually-changed {
  border: 1.5px solid var(--warning) !important;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.25) !important;
}

/* List view manual highlights */
.schedule-table tr.row-manually-changed {
  background-color: rgba(245, 158, 11, 0.06) !important;
}

body.dark-mode .schedule-table tr.row-manually-changed {
  background-color: rgba(245, 158, 11, 0.1) !important;
}

.schedule-table tr.row-manually-changed td.date-col {
  font-weight: bold;
  color: var(--warning);
}

/* Language Selector Styling */
.lang-select-container {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.lang-select-container:hover {
  border-color: var(--primary);
  box-shadow: 0 0 8px var(--primary-glow);
}

.select-lang-toggle {
  width: auto;
  border: none !important;
  background: transparent !important;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  outline: none;
  padding: 0 20px 0 0 !important;
  margin: 0;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%236366f1' d='M5 7L1 3h8z'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right center !important;
}

body.dark-mode .select-lang-toggle {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%23818cf8' d='M5 7L1 3h8z'/%3E%3C/svg%3E") !important;
}

/* Print overrides for weekend grid */
@media print {
  .calendar-grid.weekend-active {
    grid-template-columns: repeat(7, 1fr) !important;
  }
  .calendar-header.weekend-active {
    grid-template-columns: repeat(7, 1fr) !important;
  }
}
