/* ============================================================================
   TaxBaik Admin UI - Enterprise Grade Design System
   - CSS Custom Properties (Design Tokens)
   - Material Design 3 Principles
   - WCAG 2.1 AA Accessibility
   - Modern responsive design
   ============================================================================ */

/* ============================================================================
   Design Tokens (Color, Spacing, Typography, Shadow)
   ============================================================================ */

:root {
  /* Color System */
  --primary-color: #1F4E79;
  --primary-light: #E8F0F7;
  --primary-lighter: #D6E3F0;
  --primary-dark: #163A5C;
  --primary-darker: #102D47;
  --primary-contrast: #FFFFFF;

  --secondary-color: #2B6F6A;
  --secondary-light: #E6F2F1;
  --secondary-dark: #1F5854;
  --secondary-contrast: #FFFFFF;

  --tertiary-color: #A96A3B;
  --tertiary-light: #F4E9DF;
  --tertiary-dark: #7E4D28;
  --tertiary-contrast: #FFFFFF;

  --success-color: #16A34A;
  --success-light: #DCFCE7;
  --success-dark: #15803D;

  --warning-color: #F59E0B;
  --warning-light: #FEF3C7;
  --warning-dark: #B45309;

  --error-color: #DC2626;
  --error-light: #FEE2E2;
  --error-dark: #991B1B;

  --info-color: #06B6D4;
  --info-light: #CFFAFE;
  --info-dark: #0E7490;

  /* Semantic Colors */
  --text-primary: #1A1A1A;
  --text-secondary: #64748B;
  --text-tertiary: #94A3B8;
  --text-disabled: #CBD5E1;
  --text-inverse: #FFFFFF;

  --bg-primary: #FFFFFF;
  --bg-secondary: #F4F7FA;
  --bg-tertiary: #E9EEF4;
  --bg-overlay: rgba(15, 23, 42, 0.08);
  --bg-overlay-strong: rgba(15, 23, 42, 0.12);

  --border-color: #D6DFE8;
  --border-color-light: #E6EDF3;
  --border-color-strong: #B7C4D1;

  /* Spacing Scale */
  --space-0: 0;
  --space-1: 3px;
  --space-2: 6px;
  --space-3: 10px;
  --space-4: 12px;
  --space-5: 16px;
  --space-6: 20px;
  --space-7: 24px;
  --space-8: 28px;
  --space-10: 34px;
  --space-12: 40px;
  --space-16: 52px;

  /* Border Radius */
  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-full: 9999px;

  /* Typography Scale */
  --font-family-base: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-xs: 0.7rem;
  --font-size-sm: 0.75rem;
  --font-size-base: 0.82rem;
  --font-size-lg: 0.95rem;
  --font-size-xl: 1.1rem;
  --font-size-2xl: 1.3rem;
  --font-size-3xl: 1.6rem;
  --font-size-4xl: 2rem;

  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;

  --line-height-tight: 1.2;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;

  /* Shadow System (Elevation) */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1);
  --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.15);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Z-Index Scale */
  --z-dropdown: 100;
  --z-modal-backdrop: 1000;
  --z-modal: 1001;
  --z-popover: 1050;
  --z-tooltip: 1100;
}

/* ============================================================================
   Global Reset & Base Styles
   ============================================================================ */

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html, body {
  font-family: var(--font-family-base);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
}

/* ============================================================================
   Utility Classes
   ============================================================================ */

.d-flex {
  display: flex;
}

.align-center {
  align-items: center;
}

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

.justify-space-between {
  justify-content: space-between;
}

.pa-8 {
  padding: var(--space-8) !important;
}

.mb-4 {
  margin-bottom: var(--space-4) !important;
}

.mb-6 {
  margin-bottom: var(--space-6) !important;
}

.mt-4 {
  margin-top: var(--space-4) !important;
}

.text-center {
  text-align: center;
}

.ml-3 {
  margin-left: var(--space-3) !important;
}

.cursor-pointer {
  cursor: pointer;
}

.font-weight-bold {
  font-weight: var(--font-weight-bold) !important;
}

/* ============================================================================
   Focus Visible (Accessibility)
   ============================================================================ */

:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* ============================================================================
   Login Page Styles
   ============================================================================ */

.admin-login-page.mud-container {
  width: 100%;
  margin: 0 auto;
}

.admin-login-page.mud-container-maxwidth-small {
  max-width: 480px !important;
}

.admin-login-page .mud-paper {
  background-color: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-8);
}

.admin-login-page .mud-paper.elevation-3 {
  box-shadow: var(--shadow-lg);
}

.admin-login-page .mud-typography {
  color: var(--text-primary);
  line-height: var(--line-height-normal);
}

.admin-login-page .mud-typography--h4 {
  font-size: var(--font-size-3xl);
  font-weight: var(--font-weight-semibold);
  color: var(--primary-color);
  margin-bottom: var(--space-4);
}

.admin-login-page .mud-typography--body1 {
  font-size: var(--font-size-base);
}

.admin-login-page input[type="text"],
.admin-login-page input[type="password"] {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--font-size-base);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 44px;
}

.admin-login-page input[type="text"]:focus,
.admin-login-page input[type="password"]:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.admin-login-page label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
}

.admin-login-page button {
  width: 100%;
  padding: var(--space-3) var(--space-6);
  margin-top: var(--space-4);
  background-color: var(--primary-color);
  color: var(--primary-contrast);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  transition: background-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
  min-height: 44px;
}

.admin-login-page button:hover {
  background-color: var(--primary-dark);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.admin-login-page button:active {
  transform: translateY(0);
}

.admin-login-page button:disabled {
  background-color: var(--text-disabled);
  cursor: not-allowed;
  transform: none;
}

.admin-login-page .mud-alert {
  padding: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
  border-radius: var(--radius-md);
  border-left: 4px solid transparent;
}

.admin-login-page .mud-alert--error {
  background-color: var(--error-light);
  color: var(--error-dark);
  border-left-color: var(--error-color);
}

.admin-login-page .mud-alert--success {
  background-color: var(--success-light);
  color: var(--success-dark);
  border-left-color: var(--success-color);
}

.admin-login-page .mud-alert--info {
  background-color: var(--info-light);
  color: var(--info-dark);
  border-left-color: var(--info-color);
}

/* Reconnect Modal */
.admin-reconnect-modal {
  display: none;
}

.admin-reconnect-modal.components-reconnect-show,
.admin-reconnect-modal.components-reconnect-failed,
.admin-reconnect-modal.components-reconnect-rejected {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(4px);
}

.admin-reconnect-card {
  width: min(420px, 100%);
  padding: var(--space-6);
  border-radius: var(--radius-xl);
  background: var(--bg-primary);
  box-shadow: var(--shadow-2xl);
  animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.admin-reconnect-card strong,
.admin-reconnect-card span {
  display: block;
}

.admin-reconnect-card strong {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-3);
}

.admin-reconnect-card span {
  margin-top: var(--space-2);
  color: var(--text-secondary);
  font-size: var(--font-size-sm);
}

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

/* ============================================================================
   Admin Shell (Main Layout)
   ============================================================================ */

.admin-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: var(--bg-secondary);
}

.admin-shell .mud-typography--h4 {
  font-size: 1.35rem;
  line-height: 1.2;
}

.admin-shell .mud-typography--h6 {
  font-size: 0.88rem;
  line-height: 1.2;
}

.admin-shell .mud-typography--subtitle1 {
  font-size: 0.82rem;
  line-height: 1.3;
}

.admin-shell .mud-typography--body1 {
  font-size: 0.82rem;
  line-height: 1.4;
}

.admin-shell .mud-typography--body2 {
  font-size: 0.75rem;
  line-height: 1.35;
}

.admin-shell .mud-typography--caption {
  font-size: 0.68rem;
  line-height: 1.2;
}

.admin-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  min-height: 44px !important;
  background: linear-gradient(180deg, #FFFFFF 0%, #FAFCFE 100%);
  border-bottom: 1px solid var(--border-color);
  z-index: var(--z-dropdown);
  box-shadow: none !important;
}

.admin-menu-button {
  margin-right: var(--space-2);
}

.admin-topbar-title {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.admin-topbar-title span {
  color: var(--text-primary);
}

.admin-brand-text {
  font-size: 0.82rem !important;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.admin-brand-subtitle {
  font-size: 0.86rem !important;
  font-weight: 600 !important;
  color: #1F2937 !important;
}

.admin-topbar-action {
  white-space: nowrap;
  min-height: 32px;
  padding: 4px 10px;
  font-size: 0.8rem;
}

.admin-shell .mud-button-root {
  min-height: 32px;
  font-size: 0.8rem;
}

.admin-drawer {
  width: 228px;
  background-color: var(--bg-primary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.admin-drawer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color-light);
}

.admin-brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  color: var(--primary-contrast);
  font-weight: var(--font-weight-bold);
  font-size: 1rem;
  flex-shrink: 0;
}

.admin-nav {
  padding: 4px 0;
  flex: 1;
  overflow-y: auto;
}

.admin-nav .mud-nav-link,
.admin-nav .mud-nav-group-header {
  margin: 1px 6px !important;
  border-radius: 6px !important;
  transition: all var(--transition-base) !important;
}

.admin-nav .mud-nav-link {
  min-height: 32px;
  font-size: 0.78rem;
}

.admin-nav .mud-nav-group-header {
  min-height: 32px;
  font-size: 0.78rem;
}

.admin-nav .mud-nav-link:hover {
  background-color: var(--primary-light) !important;
}

.admin-nav .mud-nav-link.active {
  background-color: var(--primary-light) !important;
  color: var(--primary-dark) !important;
  font-weight: var(--font-weight-semibold) !important;
}

.admin-nav .mud-nav-link::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background-color: var(--primary-color);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.admin-nav .mud-nav-link.active::before {
  opacity: 1;
}

.admin-drawer-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--border-color-light);
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
}

.admin-drawer-version {
  margin-top: auto;
  padding: var(--space-4);
  border-top: 1px solid var(--border-color-light);
  font-size: 0.72rem;
  color: var(--text-tertiary);
  line-height: 1.35;
}

.admin-drawer-version-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
  color: var(--text-secondary);
  font-weight: var(--font-weight-semibold);
}

.admin-drawer-version-value {
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.admin-drawer-version-built {
  margin-top: 2px;
  word-break: break-word;
}

.admin-main {
  flex: 1;
  overflow-y: auto;
  background-color: var(--bg-secondary);
}

.admin-content {
  padding: 16px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ============================================================================
   Dashboard Page Styles
   ============================================================================ */

.admin-page-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.admin-page-hero > div:first-child {
  flex: 1;
}

.admin-eyebrow {
  display: block;
  color: var(--primary-color);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0;
  margin-bottom: var(--space-1);
}

.admin-page-title {
  display: block;
  color: var(--text-primary);
  font-weight: var(--font-weight-semibold);
  margin-bottom: 2px;
  font-size: 1.45rem;
  line-height: var(--line-height-tight);
}

.admin-page-subtitle {
  display: block;
  color: var(--text-secondary);
  font-size: 0.8rem;
  line-height: 1.35;
}

/* Metrics Grid */
.admin-metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  width: 100%;
}

/* Metric Card - Enterprise Grade */
.admin-metric-card {
  padding: 12px;
  border-radius: var(--radius-lg);
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  transition: all var(--transition-base);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 116px;
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
}

.admin-metric-card-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 100%;
}

.admin-metric-card-label {
  font-size: 0.68rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  font-weight: var(--font-weight-semibold);
}

.admin-metric-card-value-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex: 1;
  gap: 8px;
}

.admin-metric-card-value {
  font-size: 1.45rem;
  font-weight: var(--font-weight-bold);
  line-height: 1;
}

.admin-metric-card-icon {
  font-size: 1.9rem;
  opacity: 0.14;
  line-height: 1;
}

.admin-metric-card-caption {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.admin-metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, currentColor, transparent);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.admin-metric-card:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--border-color-strong);
  transform: translateY(-4px);
}

.admin-metric-card:hover::before {
  opacity: 1;
}

.admin-metric-card:active {
  transform: translateY(-2px);
}

/* Card Accent Colors */
.accent-blue {
  background: linear-gradient(135deg, var(--primary-light) 0%, #F7FAFC 100%);
  border-color: #C9D8E6;
  color: var(--primary-dark);
}

.accent-blue:hover {
  background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
  border-color: #90CAF9;
}

.accent-amber {
  background: linear-gradient(135deg, #F7EFE8 0%, #F1E3D7 100%);
  border-color: var(--tertiary-color);
  color: var(--tertiary-dark);
}

.accent-amber:hover {
  background: linear-gradient(135deg, #FFE0B2 0%, #FFCC80 100%);
  border-color: #FFAB91;
}

.accent-slate {
  background: linear-gradient(135deg, #F5F7FA 0%, #F1F5F9 100%);
  border-color: #CBD5E1;
  color: #455A64;
}

.accent-slate:hover {
  background: linear-gradient(135deg, #F1F5F9 0%, #E2E8F0 100%);
  border-color: #94A3B8;
}

.accent-green {
  background: linear-gradient(135deg, #E7F2EE 0%, #D7E8E3 100%);
  border-color: var(--success-color);
  color: var(--success-dark);
}

.accent-green:hover {
  background: linear-gradient(135deg, #C8E6C9 0%, #A5D6A7 100%);
  border-color: #81C784;
}

/* Surfaces & Containers */
.admin-surface {
  padding: 10px !important;
  border-radius: var(--radius-md) !important;
  background-color: var(--bg-primary) !important;
  border: 1px solid var(--border-color) !important;
  margin-bottom: 10px !important;
  box-shadow: var(--shadow-xs);
}

.admin-section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color-light);
}

.admin-section-header > div:first-child {
  flex: 1;
}

.admin-section-header h6 {
  font-size: 0.85rem;
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-bottom: 2px;
}

.admin-section-header p {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 0;
}

/* Tables */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.admin-table thead {
  background-color: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}

.admin-table thead th {
  padding: 5px 8px;
  text-align: left;
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.admin-table tbody tr {
  border-bottom: 1px solid var(--border-color-light);
  transition: background-color var(--transition-fast);
}

.admin-table tbody tr:hover {
  background-color: var(--bg-overlay);
}

.admin-table tbody tr:focus-within {
  background-color: var(--bg-overlay-strong);
}

.admin-table tbody td {
  padding: 5px 8px;
  color: var(--text-primary);
  vertical-align: middle;
}

.admin-table .mud-chip {
  font-size: 0.68rem;
  height: 22px;
}

.admin-table tbody a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: var(--font-weight-semibold);
  transition: color var(--transition-fast);
}

.admin-table tbody a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.admin-table tbody a:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.admin-table .mud-chip-small {
  height: 24px !important;
  font-size: var(--font-size-xs) !important;
  font-weight: var(--font-weight-medium);
  min-width: 60px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Loading States */
.admin-skeleton {
  background: linear-gradient(90deg, var(--bg-overlay) 0%, var(--bg-overlay-strong) 50%, var(--bg-overlay) 100%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

.admin-skeleton-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0;
}

.admin-skeleton-row {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 0.6fr;
  gap: 12px;
  align-items: center;
}

.admin-skeleton-block {
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--bg-overlay) 0%, var(--bg-overlay-strong) 50%, var(--bg-overlay) 100%);
  background-size: 200% 100%;
  animation: loading 1.4s infinite;
}

.admin-skeleton-block.w-40 { width: 40%; }
.admin-skeleton-block.w-25 { width: 25%; }
.admin-skeleton-block.w-20 { width: 20%; }

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

/* Empty States */
.admin-empty-state {
  text-align: center;
  padding: var(--space-12);
  color: var(--text-secondary);
}

.admin-empty-state-icon {
  font-size: 3rem;
  margin-bottom: var(--space-4);
  opacity: 0.5;
}

.admin-empty-state-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}

.admin-empty-state-description {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

/* ============================================================================
   Responsive Design - Mobile First
   ============================================================================ */

/* Desktop XXL: 1920px+ */
@media (min-width: 1920px) {
  .admin-content {
    padding: var(--space-10);
    max-width: 100%;
  }

  .admin-metric-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-6);
  }

  .admin-metric-card {
    min-height: 180px;
    padding: var(--space-7);
  }

  .admin-page-hero {
    gap: var(--space-8);
    margin-bottom: var(--space-10);
    padding-bottom: var(--space-8);
  }
}

/* Desktop XL: 1440px */
@media (min-width: 1440px) and (max-width: 1919px) {
  .admin-metric-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-6);
  }

  .admin-metric-card {
    min-height: 170px;
    padding: var(--space-6);
  }
}

/* Desktop L: 1024px */
@media (min-width: 1024px) and (max-width: 1439px) {
  .admin-drawer {
    width: 280px;
  }

  .admin-content {
    padding: var(--space-7);
  }

  .admin-metric-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-5);
  }

  .admin-metric-card {
    min-height: 160px;
    padding: var(--space-5);
  }

  .admin-page-hero {
    gap: var(--space-6);
  }

  .admin-topbar {
    padding: var(--space-3) var(--space-5);
  }
}

/* Tablet L: 960px */
@media (min-width: 960px) and (max-width: 1023px) {
  .admin-drawer {
    width: 260px;
  }

  .admin-content {
    padding: var(--space-6);
  }

  .admin-metric-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-5);
  }

  .admin-metric-card {
    min-height: 150px;
    padding: var(--space-5);
  }

  .admin-page-title {
    font-size: var(--font-size-2xl);
  }

  .admin-surface {
    padding: var(--space-5) !important;
  }

  .admin-table thead th,
  .admin-table tbody td {
    padding: var(--space-3) var(--space-3);
  }
}

/* Tablet M: 768px */
@media (min-width: 768px) and (max-width: 959px) {
  .admin-shell {
    flex-direction: row;
  }

  .admin-drawer {
    width: 240px;
    min-width: 240px;
  }

  .admin-content {
    padding: var(--space-5);
  }

  .admin-metric-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
  }

  .admin-metric-card {
    min-height: 140px;
    padding: var(--space-4);
    font-size: 0.95rem;
  }

  .admin-page-title {
    font-size: var(--font-size-2xl);
  }

  .admin-page-hero {
    gap: var(--space-4);
    margin-bottom: var(--space-6);
  }

  .admin-surface {
    padding: var(--space-4) !important;
  }

  .admin-table thead th {
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-xs);
  }

  .admin-table tbody td {
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-sm);
  }

  .admin-topbar {
    padding: var(--space-3) var(--space-4);
  }

  .admin-section-header {
    flex-direction: column;
    gap: var(--space-3);
  }
}

/* Tablet S: 600px */
@media (min-width: 600px) and (max-width: 767px) {
  .admin-shell {
    flex-direction: column;
  }

  .admin-drawer {
    width: 100%;
    height: auto;
    max-height: 60px;
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
  }

  .admin-drawer-brand {
    padding: var(--space-3) var(--space-4);
    border-bottom: none;
    border-right: 1px solid var(--border-color-light);
    flex-shrink: 0;
  }

  .admin-brand-mark {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  .admin-nav {
    display: flex;
    flex-direction: row;
    padding: var(--space-2);
    gap: var(--space-1);
    overflow-x: auto;
    flex: 1;
  }

  .admin-drawer-footer {
    display: none;
  }

  .admin-main {
    flex: 1;
  }

  .admin-content {
    padding: var(--space-4);
  }

  .admin-metric-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .admin-metric-card {
    min-height: 130px;
    padding: var(--space-4);
  }

  .admin-page-title {
    font-size: var(--font-size-xl);
  }

  .admin-page-hero {
    flex-direction: column;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
    padding-bottom: var(--space-4);
  }

  .admin-surface {
    padding: var(--space-4) !important;
  }

  .admin-section-header {
    flex-direction: column;
    gap: var(--space-3);
  }

  .admin-topbar {
    padding: var(--space-2) var(--space-4);
  }

  .admin-topbar-title {
    display: none;
  }

  .admin-table thead th {
    padding: var(--space-2) var(--space-2);
    font-size: var(--font-size-xs);
  }

  .admin-table tbody td {
    padding: var(--space-2) var(--space-2);
    font-size: var(--font-size-sm);
  }
}

/* Mobile L: 480px */
@media (min-width: 480px) and (max-width: 599px) {
  .admin-shell {
    flex-direction: column;
  }

  .admin-drawer {
    width: 100%;
    height: auto;
    max-height: auto;
    flex-direction: column;
  }

  .admin-drawer-brand {
    padding: var(--space-3) var(--space-4);
  }

  .admin-brand-mark {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }

  .admin-nav {
    display: flex;
    flex-direction: row;
    padding: var(--space-2);
    gap: var(--space-1);
    overflow-x: auto;
  }

  .admin-drawer-footer {
    display: none;
  }

  .admin-content {
    padding: var(--space-3);
  }

  .admin-metric-grid {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .admin-metric-card {
    min-height: 110px;
    padding: var(--space-3);
  }

  .admin-page-title {
    font-size: var(--font-size-lg);
  }

  .admin-page-subtitle {
    font-size: var(--font-size-sm);
  }

  .admin-surface {
    padding: var(--space-3) !important;
  }

  .admin-section-header {
    flex-direction: column;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
  }

  .admin-table thead th {
    padding: var(--space-2) var(--space-1);
    font-size: var(--font-size-xs);
  }

  .admin-table tbody td {
    padding: var(--space-2) var(--space-1);
    font-size: var(--font-size-sm);
  }

  .admin-topbar {
    padding: var(--space-2) var(--space-3);
    gap: var(--space-2);
  }

  .admin-topbar-action {
    padding: var(--space-2) var(--space-2) !important;
    font-size: var(--font-size-xs);
    min-height: 36px;
  }
}

/* Mobile S: <480px */
@media (max-width: 479px) {
  .admin-login-page.mud-container-maxwidth-small {
    max-width: 100% !important;
    padding: var(--space-3);
  }

  .admin-login-page .mud-typography--h4 {
    font-size: var(--font-size-2xl);
  }

  .admin-shell {
    flex-direction: column;
    height: auto;
  }

  .admin-topbar {
    padding: var(--space-2);
    gap: var(--space-2);
  }

  .admin-topbar-action {
    padding: var(--space-2) var(--space-2) !important;
    font-size: var(--font-size-xs);
    min-height: 36px;
  }

  .admin-drawer {
    width: 100%;
    height: auto;
    max-height: 60px;
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
  }

  .admin-drawer-brand {
    padding: var(--space-3) var(--space-4);
    gap: var(--space-2);
    flex-shrink: 0;
    border-bottom: none;
    border-right: 1px solid var(--border-color-light);
  }

  .admin-brand-mark {
    width: 32px;
    height: 32px;
    font-size: var(--font-size-base);
  }

  .admin-nav {
    display: flex;
    flex-direction: row;
    padding: var(--space-2);
    gap: var(--space-1);
    overflow-x: auto;
  }

  .admin-nav .mud-nav-link {
    min-width: 100px;
    font-size: var(--font-size-xs);
  }

  .admin-drawer-footer {
    display: none;
  }

  .admin-main {
    flex: 1;
  }

  .admin-content {
    padding: var(--space-3);
    max-width: 100%;
    margin: 0;
  }

  .admin-page-hero {
    flex-direction: column;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
  }

  .admin-page-title {
    font-size: var(--font-size-lg);
  }

  .admin-page-subtitle {
    font-size: var(--font-size-sm);
    display: block;
  }

  .admin-eyebrow {
    font-size: var(--font-size-xs);
  }

  .admin-metric-grid {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .admin-metric-card {
    min-height: 100px;
    padding: var(--space-3);
    border-radius: var(--radius-md);
  }

  .admin-surface {
    padding: var(--space-3) !important;
    border-radius: var(--radius-md) !important;
  }

  .admin-section-header {
    flex-direction: column;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
  }

  .admin-section-header h6 {
    font-size: var(--font-size-base) !important;
  }

  .admin-section-header .mud-button {
    width: 100%;
  }

  .admin-table {
    font-size: var(--font-size-xs);
  }

  .admin-table thead th {
    padding: var(--space-1) var(--space-2);
    font-size: var(--font-size-xs);
  }

  .admin-table tbody tr {
    line-height: var(--line-height-tight);
  }

  .admin-table tbody td {
    padding: var(--space-1) var(--space-2);
    font-size: var(--font-size-xs);
  }

  /* Touch Target Sizing (WCAG 2.5.5) */
  .mud-button,
  .mud-icon-button,
  a,
  input,
  select,
  textarea {
    min-height: 44px;
    min-width: 44px;
  }
}

/* ============================================================================
   Reduced Motion Support (Accessibility)
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================================
   Print Styles
   ============================================================================ */

@media print {
  .admin-topbar,
  .admin-drawer,
  .admin-topbar-action {
    display: none;
  }

  .admin-shell {
    height: auto;
  }

  .admin-content {
    padding: 0;
    max-width: 100%;
  }

  .admin-metric-card {
    break-inside: avoid;
  }

  .admin-table {
    break-inside: avoid;
  }
}

/* ============================================================================
   Blazor Loading Indicator
   ============================================================================ */

#blazor-loading {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
  z-index: 9999;
  align-items: center;
  justify-content: center;
}

#blazor-loading.show {
  display: flex;
  animation: overlayFadeIn 0.15s ease-out;
}

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

/* Page content fade-in on each route mount */
.admin-page-hero,
.admin-login-page {
  animation: adminPageIn 0.25s ease-out;
}

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

.blazor-loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.blazor-loading-spinner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.blazor-loading-spinner p {
  margin: 0;
  font-size: 1rem;
  color: var(--text-primary);
  font-weight: 500;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--bg-tertiary);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Reconnection Modal */
.admin-reconnect-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9998;
  align-items: center;
  justify-content: center;
}

.admin-reconnect-modal.components-reconnect-modal {
  display: flex;
}

.admin-reconnect-card {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  text-align: center;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: slideIn 0.3s ease-out;
}

.admin-reconnect-card strong {
  font-size: 1.25rem;
  color: var(--text-primary);
  display: block;
}

.admin-reconnect-card span {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.4;
}

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

/* Improved Topbar & Navigation */
.admin-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-topbar-action {
  white-space: nowrap;
  font-size: 0.9rem;
}

/* Enhanced Drawer Footer */
.admin-drawer-footer {
  border-top: 1px solid var(--divider-color);
  background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.02) 100%);
}

.admin-footer-item {
  display: flex;
  align-items: center;
  margin-bottom: 0.25rem;
  color: var(--text-secondary);
}

.admin-footer-item .mud-icon {
  color: var(--primary-color);
}

/* Responsive Topbar */
@media (max-width: 600px) {
  .admin-topbar-action {
    padding: 4px 8px;
    font-size: 0.8rem;
  }

  .admin-topbar-title {
    min-width: 120px;
  }

  .mud-toolbar > :last-child {
    margin-right: -8px;
  }
}

/* ============================================================================
   더존 ERP 스타일 최적화 (Douzone ERP High-Density Desktop Style)
   - 프레임워크 고유 레이아웃과 이벤트를 방해하는 와일드카드 및 강제 강하 스타일 제거
   - MudBlazor 테마 설정을 기반으로 하며 레이아웃 및 서체 스택만 안전하게 제어
   ============================================================================ */

html, body {
  background-color: #E2E8F0 !important;
  color: #1E293B !important;
  font-family: 'Malgun Gothic', '맑은 고딕', 'Segoe UI', sans-serif !important;
}

/* 어드민 드로워 및 탑바 테마 컬러 보완 */
.mud-drawer {
  border-right: 1px solid #CBD5E1 !important;
}

.mud-drawer-header {
  border-bottom: 1px solid #1E293B !important;
  padding: 8px 12px !important;
}

.mud-nav-link {
  font-size: 12px !important;
}

/* 데이터그리드 헤더 가시성 보완 */
.mud-table-head th {
  background-color: #F1F5F9 !important;
  font-weight: bold !important;
  color: #0F172A !important;
}

/* 페이지 헤더 영역 */
.admin-page-hero {
  padding: 12px 16px !important;
  background-color: #F8FAFC !important;
  border-bottom: 1px solid #E2E8F0 !important;
  margin-bottom: 12px !important;
}

.admin-page-title {
  font-size: 16px !important;
  font-weight: bold !important;
}

.admin-page-subtitle {
  font-size: 12px !important;
  color: #64748B !important;
}

.admin-eyebrow {
  display: none !important;
}
