/* CSS Custom Properties for Theme Management */
:root {
    /* Typography tokens - Apple System Fonts */
    --font-family-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'SF Pro Text', 'Helvetica Neue', 'Apple SD Gothic Neo', sans-serif;
    --font-family-heading: var(--font-family-sans);
    --font-family-mono: 'SF Mono', 'Monaco', 'Menlo', 'Courier New', monospace;
    --font-weight-regular: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.375rem;
    --font-size-2xl: clamp(1.75rem, 1.2rem + 1.8vw, 2.5rem);
    --font-size-3xl: clamp(2.25rem, 1.8rem + 2.2vw, 3.125rem);
    --body-line-height: 1.6;
    --heading-line-height-tight: 1.2;
    --heading-letter-spacing: -0.02em;
    --body-letter-spacing: -0.01em;

    /* Neutral palette for white theme */
    --neutral-white: #FFFFFF;
    --neutral-gray-050: #F5F5F5;
    --neutral-gray-100: #E0E0E0;
    --neutral-gray-200: #D6D6D6;
    --neutral-gray-300: #B0B0B0;
    --neutral-gray-600: #4A4A4A;
    --neutral-gray-800: #2E2E2E;
    --neutral-black: #000000;

    /* Gradient, shadow, and glow utilities derived from neutral palette */
    --gradient-light: linear-gradient(180deg, #FFFFFF 0%, #E0E0E0 100%);
    --gradient-medium: linear-gradient(145deg, #B0B0B0 0%, #4A4A4A 100%);
    --gradient-deep: linear-gradient(160deg, #2E2E2E 0%, #000000 100%);
    --overlay-glass-white: rgba(255, 255, 255, 0.1);
    --overlay-black: rgba(0, 0, 0, 0.5);
    --shadow-soft-layer: 0px 2px 6px rgba(0, 0, 0, 0.15);
    --shadow-deep-layer: 0px 4px 12px rgba(0, 0, 0, 0.35);
    --glow-white: 0px 0px 8px rgba(255, 255, 255, 0.8);
    --glow-dark: 0px 0px 6px rgba(0, 0, 0, 0.6);

    /* Design system colors */
    --color-primary: #2153C8;
    --color-secondary: var(--neutral-gray-100);
    --color-background: var(--neutral-gray-100);
    --color-dark-bg: #1a1e3c;

    /* Light Theme Colors */
    --primary-color: var(--color-primary);
    --primary-hover: #1a4bb5;
    --secondary-color: var(--color-primary);
    --background-color: var(--neutral-white);
    --background-muted: var(--neutral-gray-100);
    --surface-color: var(--neutral-white);
    --surface-muted: color-mix(in srgb, var(--neutral-white) 86%, var(--neutral-gray-100) 14%);
    --surface-tint: rgba(224, 224, 224, 0.45);
    --text-primary: var(--neutral-black);
    --text-secondary: var(--neutral-gray-600);
    --text-tertiary: var(--neutral-gray-300);
    --border-color: color-mix(in srgb, var(--neutral-gray-100) 70%, transparent);
    --divider-color: rgba(176, 176, 176, 0.35);
    --shadow-light: rgba(0, 0, 0, 0.08);
    --shadow-medium: rgba(0, 0, 0, 0.18);
    --shadow-strong: rgba(0, 0, 0, 0.3);

    /* Interactive Colors */
    --hover-overlay: rgba(0, 0, 0, 0.04);
    --active-overlay: rgba(0, 0, 0, 0.07);
    --focus-ring: rgba(33, 83, 200, 0.28);

    /* Elevated surface tokens */
    --app-background-gradient: var(--gradient-light);
    --surface-gradient: linear-gradient(135deg, rgba(255, 255, 255, 0.96) 0%, rgba(224, 224, 224, 0.9) 100%);
    --floating-surface: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(224, 224, 224, 0.82));
    --frosted-border: color-mix(in srgb, var(--neutral-gray-100) 65%, transparent);
    --favorite-surface: linear-gradient(135deg, rgba(224, 224, 224, 0.45), rgba(176, 176, 176, 0.35));
    --favorite-icon-shadow: rgba(74, 74, 74, 0.25);

    /* Animation Properties */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);

    /* Touch Target Sizes */
    --touch-target-min: 44px;
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --mobile-header-height: 4.5rem;
    --mobile-footer-height: 4.75rem;
}

/* Global typography: Prefer Pretendard Variable with robust fallbacks */
html, body, button, input, select, textarea {
    font-family: var(--font-family-sans);
    font-weight: var(--font-weight-regular);
    font-variant-numeric: tabular-nums; /* align dashboard numbers */
    font-optical-sizing: auto;
    font-synthesis: none;
    letter-spacing: var(--body-letter-spacing);
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

code, pre, kbd, samp {
    font-family: var(--font-family-mono);
}

/* Dark Theme Support */
[data-theme="dark"] {
    --color-secondary: #252a4a;
    --color-background: var(--color-dark-bg);
    --primary-color: var(--color-primary);
    --primary-hover: #1a4bb5;
    --secondary-color: #60a5fa;
    --background-color: var(--color-background);
    --background-muted: #1f2744;
    --surface-color: #252a4a;
    --surface-muted: #20253d;
    --surface-tint: rgba(59, 130, 246, 0.2);
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --border-color: #334155;
    --divider-color: rgba(148, 163, 184, 0.2);
    --shadow-light: rgba(0, 0, 0, 0.3);
    --shadow-medium: rgba(0, 0, 0, 0.4);
    --shadow-strong: rgba(0, 0, 0, 0.5);
    --hover-overlay: rgba(59, 130, 246, 0.2);
    --active-overlay: rgba(59, 130, 246, 0.3);
    --focus-ring: rgba(59, 130, 246, 0.45);
    --app-background-gradient: linear-gradient(180deg, #1a1e3c 0%, #10152d 60%, #0b1224 100%);
    --surface-gradient: linear-gradient(135deg, rgba(37, 42, 74, 0.92), rgba(26, 32, 58, 0.92));
    --floating-surface: linear-gradient(135deg, rgba(37, 42, 74, 0.96), rgba(20, 25, 45, 0.92));
    --frosted-border: rgba(59, 130, 246, 0.35);
    --favorite-surface: linear-gradient(135deg, rgba(33, 83, 200, 0.28), rgba(33, 83, 200, 0.18));
    --favorite-icon-shadow: rgba(15, 23, 42, 0.45);
}

/* Dark theme specific component overrides */
[data-theme="dark"] .floating-menu-toggle {
    background: rgba(30, 41, 59, 0.95) !important; /* Dark background */
    border: 2px solid rgba(51, 65, 85, 0.8) !important; /* Dark border */
    color: #f8fafc !important; /* Light text */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important; /* Darker shadow */
}

[data-theme="dark"] .floating-menu-toggle:hover {
    background: rgba(30, 41, 59, 1) !important; /* Darker hover background */
    border-color: rgba(100, 116, 139, 0.8) !important; /* Lighter border on hover */
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4) !important; /* Enhanced dark shadow */
}

[data-theme="dark"] .floating-menu-toggle:focus {
    box-shadow: 0 0 0 0.25rem rgba(59, 130, 246, 0.4) !important; /* Blue focus ring */
}

[data-theme="dark"] .floating-menu-toggle .navbar-toggler-icon {
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 30 30' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(248, 250, 252, 0.9)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 7h22M4 15h22M4 23h22'/%3E%3C/svg%3E");
}

[data-theme="dark"] .sidebar .nav-link {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .sidebar .nav-link:hover {
    background-color: var(--hover-overlay) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .sidebar .nav-link.active {
    background-color: var(--primary-color) !important;
    color: #ffffff !important;
}

[data-theme="dark"] .navbar-toggler-icon {
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 30 30' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(248, 250, 252, 0.9)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 7h22M4 15h22M4 23h22'/%3E%3C/svg%3E");
}

html, body {
    font-family: var(--font-family-sans);
    font-size: var(--font-size-base);
    line-height: var(--body-line-height);
    letter-spacing: var(--body-letter-spacing);
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden; /* 가로 스크롤 방지 */
    background-color: var(--background-color);
    background-image: var(--app-background-gradient);
    background-repeat: no-repeat;
    background-size: cover;
    background-attachment: fixed;
    color: var(--text-primary);
    transition: background-color var(--transition-normal), color var(--transition-normal), background-image var(--transition-slow);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-family-heading);
    font-weight: var(--font-weight-semibold);
    line-height: var(--heading-line-height-tight);
    letter-spacing: var(--heading-letter-spacing);
    color: var(--text-primary);
    margin-top: 0;
}

h1 {
    font-size: var(--font-size-3xl);
}

h2 {
    font-size: var(--font-size-2xl);
}

h3 {
    font-size: var(--font-size-xl);
}

h4 {
    font-size: var(--font-size-lg);
}

h5 {
    font-size: var(--font-size-base);
}

h6 {
    font-size: var(--font-size-sm);
    letter-spacing: 0;
}

/* Force clean white background on desktop/tablet */
@media (min-width: 768px) {
  html, body {
    background-color: var(--background-color) !important;
    background-image: var(--app-background-gradient) !important;
  }
}

/* White theme utility helpers */
.white-theme {
    background: var(--background-color);
    color: var(--text-primary);
}

.white-theme-surface {
    background: var(--surface-color);
    color: var(--text-primary);
    box-shadow: var(--shadow-soft-layer);
}

.white-theme-surface-muted {
    background: var(--surface-muted);
    color: var(--text-secondary);
}

.white-theme-glass {
    background: var(--overlay-glass-white);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--frosted-border);
    box-shadow: var(--shadow-soft-layer);
}

.white-theme-gradient-light {
    background: var(--gradient-light);
}

.white-theme-gradient-medium {
    background: var(--gradient-medium);
    color: var(--neutral-white);
}

.white-theme-gradient-deep {
    background: var(--gradient-deep);
    color: var(--neutral-white);
}

.white-theme-overlay-dark {
    background-color: var(--overlay-black);
}

.white-theme-border {
    border: 1px solid var(--divider-color); /* base fallback */
    border: 1px solid rgba(224,224,224,0.55); /* approximate of color-mix for older Chrome */
}

/* Use color-mix only when supported */
@supports (color: color-mix(in srgb, black, white)) {
    .white-theme-border {
        border: 1px solid color-mix(in srgb, var(--neutral-gray-100) 55%, transparent);
    }
}

.text-glow-white {
    text-shadow: var(--glow-white);
}

.text-glow-dark {
    text-shadow: var(--glow-dark);
}

.shadow-soft {
    box-shadow: var(--shadow-soft-layer);
}

.shadow-deep {
    box-shadow: var(--shadow-deep-layer);
}

body.nav-open {
    overflow: hidden;
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: var(--secondary-color);
    transition: color var(--transition-fast);
}

a:hover, .btn-link:hover {
    color: var(--primary-hover);
}

.btn-primary {
    color: #fff;
    background-color: var(--primary-color);
    border-color: var(--primary-hover);
    transition: all var(--transition-fast);
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px var(--shadow-medium);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px var(--shadow-light);
}

.content {
    padding-top: 0; /* 상단 여백 제거 */
    width: 100%;
    padding-left: var(--spacing-md);
    padding-right: var(--spacing-md);
    min-height: 100vh; /* 전체 화면 높이 사용 */
    background: var(--surface-gradient, var(--surface-color));
    border-radius: 1.5rem;
    border: 1px solid var(--divider-color);
    box-shadow: var(--shadow-soft-layer), 0 24px 48px rgba(0, 0, 0, 0.06);
    margin: var(--spacing-lg) auto var(--spacing-xl);
    max-width: min(1200px, 100%);
    transition: background-color var(--transition-normal), box-shadow var(--transition-normal), border-color var(--transition-normal);
}

/* Navigation styles - 반응형 디자인 */
.page {
    --sidebar-width: min(90vw, 320px);
    min-height: 100vh;
    transition: margin-left 0.3s ease-in-out;
    /* 기본적으로 전체 화면 사용 */
    margin-left: 0;
    width: 100%;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

/* Navigation styles - 반응형 디자인 */
.sidebar {
    --nav-accent-color: var(--primary-color, #2153C8);
    background: linear-gradient(180deg, rgba(114, 99, 255, 0.08) 0%, rgba(114, 99, 255, 0.02) 100%), var(--surface-gradient, var(--surface-color));
    background: linear-gradient(180deg, color-mix(in srgb, var(--nav-accent-color) 14%, transparent) 0%, color-mix(in srgb, var(--nav-accent-color) 4%, transparent) 100%), var(--surface-gradient, var(--surface-color));
    border-right: none;
    width: var(--sidebar-width);
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10001;
    transition: transform var(--transition-normal);
    will-change: transform;
    box-shadow: 0 24px 48px var(--shadow-light);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    transform: translateX(-100%);
    overflow: hidden;
}

/* Layout helpers: ensure page-level content containers sit to the right of
   the fixed nav rail and below the fixed page header. Uses JS-updated
   --app-shell-page-header-offset and the shared --sidebar-width variable.
   These rules are intentionally low-specificity so page authors can still
   override them for special cases. */
.layout-content-container {
    /* push content to the right of the fixed rail */
    margin-left: var(--sidebar-width, 0px);
    /* ensure the container begins below the (possibly fixed) page header */
    margin-top: var(--app-shell-page-header-offset, 0px);
    /* give content a comfortable max width and preserve existing utility classes */
    box-sizing: border-box;
}

/* On narrow screens, the rail becomes an overlay so content should be full-bleed
   and only account for header height. */
@media (max-width: 767px) {
    .layout-content-container {
        margin-left: 0 !important;
        margin-top: var(--app-shell-page-header-offset-mobile, var(--mobile-header-height, 72px)) !important;
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* collapse 클래스가 없을 때만 보이기 (메뉴 열림) */
.sidebar:not(.collapse) {
    transform: translateX(0);
}

/* collapse 클래스가 있을 때는 강제로 숨김 (메뉴 닫힘) */
.sidebar.collapse {
    transform: translateX(-100%) !important;
}

.nav-drawer {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: 100%;
    padding: 1.75rem 1.5rem 2rem;
    box-sizing: border-box;
}

.nav-drawer__header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.35); /* Fallback for Chrome < 111 (no color-mix support) */
}

/* Use color-mix only when supported */
@supports (color: color-mix(in srgb, black, white)) {
    .nav-drawer__header {
        border-bottom: 1px solid color-mix(in srgb, rgba(255, 255, 255, 0.65) 50%, transparent);
    }
}

.nav-drawer__logo {
    width: 3rem;
    height: 3rem;
    border-radius: 1.1rem;
    display: grid;
    place-items: center;
    font-size: 1.35rem;
    color: #fff;
    background: linear-gradient(135deg, rgba(114, 99, 255, 0.95), rgba(88, 73, 228, 0.9));
    background: linear-gradient(135deg, color-mix(in srgb, var(--nav-accent-color) 82%, #6b4dff 18%), color-mix(in srgb, var(--nav-accent-color) 65%, #4c3ac1 35%));
    box-shadow: 0 14px 28px rgba(114, 99, 255, 0.25);
}

@media (max-width: 767px) {
    .nav-drawer__logo {
        /* Fallback styles for browsers without color-mix support */
        background: linear-gradient(135deg, rgba(33, 83, 200, 0.75), rgba(33, 83, 200, 0.55));
        box-shadow: 0 12px 24px rgba(33, 83, 200, 0.18);
        border: 1px solid rgba(33, 83, 200, 0.18);
    }
}

/* Enhanced styles only when color-mix is supported (Chrome 111+, modern browsers) */
@supports (color: color-mix(in srgb, black, white)) {
    @media (max-width: 767px) {
        .nav-drawer__logo {
            background: linear-gradient(
                135deg,
                color-mix(in srgb, var(--primary-color) 65%, var(--surface-color) 35%),
                color-mix(in srgb, var(--primary-color) 45%, var(--surface-muted) 55%)
            );
            box-shadow: 0 12px 24px color-mix(in srgb, var(--primary-color) 18%, transparent);
            border: 1px solid color-mix(in srgb, var(--primary-color) 26%, transparent);
        }
    }
}

.nav-drawer__title {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.nav-drawer__content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.nav-scroll-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    overflow-y: auto;
    padding-right: 0.35rem;
    margin: 0;
    /* Removed 'scrollbar-width: thin;' for broader browser compatibility;
       Firefox will use default width, WebKit styling handled below */
}

.nav-scroll-container::-webkit-scrollbar {
    width: 0.4rem;
}

.nav-scroll-container::-webkit-scrollbar-thumb {
    background-color: rgba(33, 83, 200, 0.18);
    border-radius: 999px;
}

.nav-scroll-container::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar .nav-item {
    margin: 0;
}

.sidebar .nav-item.px-3 {
    padding: 0;
}

.sidebar .nav-item.mt-auto {
    margin-top: auto !important;
}

/* 기존 top-row 숨김 - 더 이상 사용하지 않음 */
.top-row {
    display: none;
}

/* 플로팅 햄버거 메뉴 버튼 */
.floating-menu-toggle {
    position: fixed !important;
    top: calc(env(safe-area-inset-top) + 1rem) !important;
    right: 1.5rem !important;
    background: var(--floating-surface, rgba(255, 255, 255, 0.95)) !important; /* Light theme background */
    border: 1px solid var(--frosted-border) !important; /* Light border */
    color: var(--text-primary) !important; /* Dark text for light background */
    padding: 0.875rem !important; /* Increased for better touch target (minimum 44px) */
    min-width: 2.75rem !important; /* Ensure minimum 44px touch target */
    min-height: 2.75rem !important; /* Ensure minimum 44px touch target */
    border-radius: 0.75rem !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important; /* Smoother easing */
    -webkit-backdrop-filter: blur(10px) !important;
    backdrop-filter: blur(10px) !important;
    z-index: 9999 !important; /* Very high z-index to ensure it's always visible */
    box-shadow: 0 18px 32px var(--shadow-light) !important; /* Light shadow */
    /* Improve accessibility */
    -webkit-tap-highlight-color: transparent !important;
    -webkit-user-select: none !important;
    user-select: none !important;
    pointer-events: auto !important; /* Ensure it's clickable */
}

.floating-menu-toggle:hover {
    background: var(--surface-color) !important; /* Light hover background */
    border-color: rgba(120, 141, 196, 0.5) !important; /* Darker border on hover */
    transform: scale(1.05);
    box-shadow: 0 22px 40px var(--shadow-medium) !important; /* Enhanced shadow */
}

.floating-menu-toggle:focus {
    outline: none;
    box-shadow: 0 0 0 0.25rem var(--focus-ring) !important; /* Blue focus ring for light theme */
}

/* Active state for better mobile feedback */
.floating-menu-toggle:active {
    transform: scale(0.98);
    transition-duration: 0.1s;
}

.floating-menu-toggle .navbar-toggler-icon {
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 30 30' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(55, 65, 81, 0.9)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 7h22M4 15h22M4 23h22'/%3E%3C/svg%3E");
    display: inline-block;
    width: 1.5em;
    height: 1.5em;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.floating-menu-toggle:hover .navbar-toggler-icon {
    transform: rotate(90deg);
}

.navbar-toggler:hover {
    background-color: rgba(55, 65, 81, 0.1);
    border-color: rgba(156, 163, 175, 0.3);
}

.navbar-toggler:focus {
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(59, 130, 246, 0.25);
}

.navbar-toggler-icon {
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 30 30' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath stroke='rgba(55, 65, 81, 0.9)' stroke-width='2' stroke-linecap='round' stroke-miterlimit='10' d='M4 7h22M4 15h22M4 23h22'/%3E%3C/svg%3E");
    display: inline-block;
    width: 1.5em;
    height: 1.5em;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.85rem 1rem;
    margin: 0;
    border: none;
    text-decoration: none;
    text-align: left;
    border-radius: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-secondary) !important;
    background: transparent;
    transition: transform var(--transition-fast), color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

.sidebar .nav-link::before {
    display: none;
}

.sidebar .nav-link i {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.85rem;
    display: grid;
    place-items: center;
    font-size: 1.05rem;
    color: var(--primary-color);
    background: rgba(33, 83, 200, 0.12);
    background: color-mix(in srgb, var(--primary-color) 22%, transparent);
    box-shadow: 0 10px 18px rgba(33, 83, 200, 0.12);
    transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.sidebar .nav-link:hover {
    color: var(--primary-color) !important;
    background: rgba(33, 83, 200, 0.08);
    background: color-mix(in srgb, var(--primary-color) 12%, transparent);
    transform: translateX(6px);
    box-shadow: 0 18px 32px rgba(33, 83, 200, 0.12);
}

.sidebar .nav-link:hover i {
    background: rgba(33, 83, 200, 0.22);
    background: color-mix(in srgb, var(--primary-color) 32%, transparent);
    box-shadow: 0 18px 32px rgba(33, 83, 200, 0.2);
}

.sidebar .nav-link.active {
    color: #ffffff !important;
    background: linear-gradient(135deg, rgba(33, 83, 200, 0.35), rgba(33, 83, 200, 0.22));
    background: linear-gradient(135deg, color-mix(in srgb, var(--primary-color) 38%, transparent), color-mix(in srgb, var(--primary-color) 24%, transparent));
    box-shadow: 0 22px 42px rgba(33, 83, 200, 0.24);
}

.sidebar .nav-link.active i {
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 18px 32px rgba(33, 83, 200, 0.32);
}

.sidebar .nav-link.btn-link {
    text-decoration: none;
    padding-left: 1rem;
    padding-right: 1rem;
}

.sidebar .nav-link.btn-link:hover {
    text-decoration: none;
}

.nav-submenu {
    padding-left: 3.25rem;
    display: grid;
    gap: 0.25rem;
}

.sidebar .nav-link.submenu-link {
    padding: 0.7rem 0.85rem;
    margin: 0.15rem 0;
    font-size: 0.95rem;
    border-radius: 0.85rem;
}

.sidebar .nav-link.submenu-link i {
    width: 2rem;
    height: 2rem;
    border-radius: 0.7rem;
    font-size: 0.95rem;
    box-shadow: 0 10px 18px rgba(33, 83, 200, 0.1);
}

.nav-section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin: 0.35rem 0;
    border-radius: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}

.nav-section-header i {
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 0.8rem;
    display: grid;
    place-items: center;
    font-size: 1.05rem;
    color: var(--primary-color);
    background: rgba(33, 83, 200, 0.1);
    background: color-mix(in srgb, var(--primary-color) 16%, transparent);
    box-shadow: 0 12px 20px rgba(33, 83, 200, 0.12);
}

.nav-section-header .submenu-toggle {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--text-secondary);
    transition: transform var(--transition-fast), color var(--transition-fast);
}

.nav-section-header .submenu-toggle.expanded {
    transform: rotate(180deg);
}

.nav-section-header:hover {
    color: var(--primary-color);
    background: rgba(33, 83, 200, 0.08);
    background: color-mix(in srgb, var(--primary-color) 12%, transparent);
    box-shadow: 0 16px 30px rgba(33, 83, 200, 0.12);
}

.nav-section-header:hover i {
    background: rgba(33, 83, 200, 0.2);
    background: color-mix(in srgb, var(--primary-color) 28%, transparent);
}

.sidebar .nav-link span {
    margin-right: 0;
}

.collapse {
    display: none;
}

/* 메뉴 오버레이 - 모든 화면에서 작동 */
.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.25), rgba(15, 23, 42, 0.45));
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    z-index: 1090; /* Below the header but above main content */
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    opacity: 0;
    left: var(--sidebar-width, 0);
}

/* JavaScript will handle the overlay visibility instead of :has() for better browser support */
.mobile-overlay.show {
    display: block;
    pointer-events: auto;
    opacity: 1;
}

/* 태블릿 환경 (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .sidebar .nav-link {
        padding: 0.85rem 1rem;
        font-size: 0.95rem;
        min-height: 2.75rem;
    }

    .sidebar .nav-link i {
        width: 2.25rem;
        height: 2.25rem;
    }
    
    .floating-menu-toggle {
        top: calc(env(safe-area-inset-top) + 1.5rem);
        right: 1.5rem;
    }
}

/* 모바일 환경 (768px 이하) */
@media (max-width: 768px) {
    .sidebar .nav-link {
        padding: 0.95rem 1.1rem;
        font-size: 1rem;
        min-height: 2.75rem;
    }

    .sidebar .nav-link i {
        width: 2.3rem;
        height: 2.3rem;
        font-size: 1rem;
    }

    .sidebar .nav-link:hover {
        transform: translateX(4px);
        background-color: var(--hover-overlay);
    }

    .sidebar .nav-link:active {
        background-color: var(--active-overlay);
        transition-duration: 0.1s;
    }

    .sidebar .nav-link span {
        margin-right: 0;
        font-size: inherit;
    }

    .content {
        margin: 0;
        border-radius: 1rem;
        box-shadow: 0 16px 32px var(--shadow-light);
        border-color: rgba(148, 163, 184, 0.18);
        background: rgba(255, 255, 255, 0.94);
    }
    
    /* Improved submenu spacing for mobile */
    .sidebar .nav-submenu .submenu-link {
        padding: 0.875rem 1.5rem 0.875rem 2.5rem !important;
        min-height: 2.5rem;
    }
    
    /* MainDashboard integration */
    .content:has([data-page="main-dashboard"]) {
        padding: 0 !important;
    }
    
    .floating-menu-toggle {
        top: calc(env(safe-area-inset-top) + 1rem);
        right: 1rem;
        /* Ensure button is easily reachable on mobile */
    }
    
    /* Hide dashboard top navigation bar on mobile */
    .dashboard-top-nav {
        display: none !important;
    }
    
    /* Hide dashboard sidebar on mobile (in case it's present) */
    .dashboard-sidebar {
        display: none !important;
    }
}

/* Desktop & tablet navigation layout */
@media (min-width: 768px) {
    .page {
        --sidebar-width: clamp(260px, 24vw, 320px);
    }

    /* Offset the main document content by the fixed navigation rail width on
       desktop/tablet so content does not get covered when the rail is fixed. */
    body {
        padding-left: var(--sidebar-width);
        transition: padding-left var(--transition-normal);
        box-sizing: border-box;
        overflow-x: hidden; /* Prevent leftover horizontal scrolling on desktop */
    }

    /* Hide legacy .sidebar (mobile drawer) on desktop/tablet to avoid having two
       sidebars rendered at once (the fixed NavigationRail is used on desktop). */
    .sidebar {
        display: none !important;
    }

    /* Edge-to-edge layout on tablet and above */
    .page.desktop-layout {
        --desktop-shell-gap: 0; /* No gap between sidebar and content */
        --desktop-shell-padding: 0; /* Remove outer padding so content fills */
        display: grid;
        grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
        gap: var(--desktop-shell-gap);
        width: 100%;
        margin: 0;
        padding: 0; /* No outer padding */
        min-height: 100vh;
        box-sizing: border-box;
        align-items: start;
    }

    .desktop-layout .sidebar {
        position: fixed; /* Make rail flush with viewport */
        top: 0;
        left: 0;
        transform: none !important;
        width: var(--sidebar-width);
        max-width: var(--sidebar-width);
        height: 100vh;
        max-height: 100vh;
        border-radius: 0; /* No outer rounding */
        border-right: 1px solid #E5E7EB; /* neutral divider like image */
        border-left: none;
        border-top: none;
        border-bottom: none;
        background: #F3F4F6; /* neutral gray */
        box-shadow: none; /* flush */
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        padding: 0;
        overflow: hidden;
    }

    .desktop-layout .sidebar.collapse {
        transform: none !important;
    }

    .desktop-layout .nav-drawer {
        height: 100%;
        padding: clamp(2rem, 4.5vw, 2.85rem) clamp(1.75rem, 3.5vw, 2.65rem);
        gap: clamp(1.75rem, 3.2vw, 2.25rem);
    }

    .desktop-layout .nav-scroll-container {
        margin-right: -0.5rem;
        padding-right: 0.75rem;
    }

    .desktop-layout .nav-drawer__footer {
        padding-top: clamp(1.25rem, 3vw, 2rem);
    }

    .desktop-layout .mobile-overlay {
        display: none !important;
    }

    .desktop-layout main {
        grid-column: 2; /* ensure main sits to the right of the rail */
        width: 100%;
        min-height: 100vh;
        display: flex;
        flex-direction: column; /* stack header above content */
        padding: 0; /* flush to edges */
    }

    /* Desktop page header within content column */
    .desktop-page-header {
        position: sticky;
        top: 0;
        z-index: 5;
        display: grid;
        grid-template-columns: auto 1fr auto;
        align-items: center;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
        background: #FFFFFF;
        border-bottom: 1px solid #E5E7EB;
    }

    .desktop-page-header .page-title {
        font-size: 1.1rem;
        font-weight: 700;
        letter-spacing: -0.02em;
        color: #111827;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
    }

    .desktop-page-header .nav-menu-button {
        width: 2.6rem;
        height: 2.6rem;
        border-radius: 0.9rem;
        display: grid;
        place-items: center;
        border: 1px solid transparent; /* transparent by default like notif-button */
        background: transparent; /* transparent default */
        color: #111827;
        transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
        cursor: pointer;
    }

    .desktop-page-header .nav-menu-button:hover {
        background: #FFFFFF;
        border-color: #D1D5DB;
        box-shadow: 0 8px 18px rgba(17,24,39,0.08);
        transform: translateY(-1px);
    }

    .desktop-page-header .nav-menu-button:active {
        transform: translateY(0);
        box-shadow: 0 4px 10px rgba(17,24,39,0.06);
    }

    /* Notification button on header-right */
    .desktop-page-header,
    .desktop-page-header .header-right {
        /* ensure absolutely-positioned badge can overflow without clipping */
        overflow: visible;
    }

    .desktop-page-header .notif-button {
        position: relative;
        width: 2.6rem;
        height: 2.6rem;
        border-radius: 0.9rem;
        display: grid;
        place-items: center;
        border: 1px solid transparent; /* transparent by default per request */
        background: transparent; /* transparent so the badge is clearly visible */
        color: #111827;
        transition: transform var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
        overflow: visible; /* do not clip the badge */
        cursor: pointer;
    }

    .desktop-page-header .notif-button:hover {
        background: rgba(243, 244, 246, 0.8); /* subtle hover surface */
        border-color: #D1D5DB;
        box-shadow: 0 8px 18px rgba(17,24,39,0.08);
        transform: translateY(-1px);
    }

    .desktop-page-header .notif-button:active {
        transform: translateY(0);
        box-shadow: 0 4px 10px rgba(17,24,39,0.06);
    }

    /* hover feedback on the bell icon */
    .desktop-page-header .notif-button i {
        transition: transform var(--transition-fast), color var(--transition-fast);
    }

    .desktop-page-header .notif-button:hover i {
        transform: scale(1.06);
        color: #0f172a; /* a tad darker for emphasis */
    }

    .desktop-page-header .notif-badge {
        position: absolute;
        /* sit even closer to the bell */
        top: -1px;
        right: -1px;
        min-width: 18px;
        height: 18px;
        padding: 0 4px;
        border-radius: 999px;
        background: #EF4444; /* red */
        color: #FFFFFF;
        font-size: 11px;
        font-weight: 700;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border: 2px solid #FFFFFF; /* ring to separate from button */
        line-height: 1;
        z-index: 2; /* ensure it sits above the button and header */
        pointer-events: none; /* clicks go to the button */
    }

    /* Make article fill all available width, no outer chrome (match top header color) */
    .desktop-layout .content {
        margin: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        max-width: 100% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        background: #FFFFFF !important; /* unify with desktop-page-header */
    }

    .desktop-layout .content {
        margin: 0;
        max-width: 100%;
        width: 100%;
        min-height: 100%;
        border-radius: 2rem;
        padding: clamp(2.25rem, 5vw, 3rem);
        background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(244, 247, 255, 0.92));
        /* Fallback border for browsers without color-mix (e.g., Chrome < 111) */
        border: 1px solid rgba(176, 176, 176, 0.2);
        box-shadow: 0 32px 64px rgba(15, 23, 42, 0.12);
        display: flex;
        flex-direction: column;
        gap: clamp(1.5rem, 3vw, 2.25rem);
        flex: 1;
    }
    /* Enhance border when color-mix is supported */
    @supports (color: color-mix(in srgb, black, white)) {
        .desktop-layout .content {
            border: 1px solid color-mix(in srgb, var(--divider-color) 55%, transparent);
        }
    }

    .desktop-layout .floating-menu-toggle {
        display: none !important;
    }

    @supports (height: 100dvh) {
        .desktop-layout .sidebar {
            height: calc(100dvh - (var(--desktop-shell-padding) * 2));
            max-height: calc(100dvh - (var(--desktop-shell-padding) * 2));
        }

        .desktop-layout main {
            min-height: calc(100dvh - (var(--desktop-shell-padding) * 2));
        }
    }
}

/* Mobile dashboard enhancements */
.dashboard-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    min-height: 44px; /* Ensure minimum touch target */
}

.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.dashboard-card:active,
.dashboard-card.clicked {
    transform: scale(0.97) translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Touch-friendly button styling */
.dashboard-button {
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px; /* Ensure adequate touch target size */
    min-width: 44px;
}

.dashboard-button:active {
    transform: scale(0.95);
    opacity: 0.8;
}

/* Smooth scrolling enhancement */
html {
    scroll-behavior: smooth;
}

/* Global mobile touch enhancements */
button, .btn, input[type="submit"], input[type="button"] {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 44px; /* Ensure minimum touch target size */
    min-width: 44px;
}

/* Input field touch enhancements */
input, select, textarea {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Mobile-friendly input sizing */
@media (max-width: 767px) {
    input, select, textarea, button, .btn {
        font-size: 16px; /* Prevent zoom on iOS */
        border-radius: 8px; /* More modern rounded corners */
    }
    
    input, select, textarea {
        padding: 12px 16px; /* Better touch padding */
        min-height: 44px;
    }
    
    button, .btn {
        padding: 12px 20px;
        font-weight: 500;
    }
}

/* Form control enhancements */
.form-control, .form-select {
    transition: all 0.2s ease-in-out;
}

.form-control:focus, .form-select:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Mobile dashboard responsive improvements */
@media (max-width: 767px) {
    .dashboard-card {
        padding: 1.5rem 1rem;
        margin: 0.5rem 0;
        min-height: 60px;
        border-radius: 12px;
    }
    
    .dashboard-card h2 {
        font-size: 1.1rem;
        line-height: 1.4;
    }
    
    .dashboard-button {
        padding: 0.875rem;
        font-size: 1rem;
        border-radius: 8px;
    }
    
    /* Hide dashboard sidebar on mobile - handled by JS but fallback CSS */
    .dashboard-sidebar {
        display: none !important;
    }
    
    /* Hide dashboard top navigation on mobile */
    .dashboard-top-nav {
        display: none !important;
    }
    
    /* Adjust dashboard main content for mobile */
    .dashboard-main-content {
        max-width: 100% !important;
        padding: 1rem !important;
    }
    
    /* Improve dashboard grid layout on mobile */
    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 1rem;
    }
    
    /* Mobile-optimized table container */
    .dashboard-table-container {
        overflow-x: auto;
        overscroll-behavior-x: contain; /* prevent parent scroll chaining */
    }
    
    /* Better touch scrolling for dashboard */
    .dashboard-container {
        overscroll-behavior: contain; /* standards-based scroll behavior without deprecated vendor property */
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .dashboard-card {
        padding: 1.25rem 1rem;
        font-size: 0.95rem;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    /* Stack dashboard elements vertically on very small screens */
    .dashboard-main-content .flex-wrap {
        flex-direction: column;
    }
    
    /* Improve search container on mobile */
    .search-container {
        min-width: 100%;
        max-width: 100%;
    }
}
@media (max-width: 480px) {
    .sidebar {
        width: var(--sidebar-width); /* 매우 작은 화면에서도 공유 폭으로 일관성 유지 */
    }
    
    .sidebar .nav-link {
        padding: 1.05rem 1.2rem;
        font-size: 1.05rem;
        min-height: 3rem;
    }

    .sidebar .nav-link i {
        width: 2.35rem;
        height: 2.35rem;
    }

    .sidebar .nav-link span {
        margin-right: 0;
        font-size: inherit;
    }

    .sidebar .nav-submenu .submenu-link {
        padding: 1rem 1.5rem 1rem 3rem !important;
        min-height: 2.75rem;
    }
    
    .floating-menu-toggle {
        top: calc(env(safe-area-inset-top) + 0.75rem);
        right: 0.75rem;
        min-width: 3rem; /* Larger on very small screens */
        min-height: 3rem;
        padding: 1rem;
    }
    
    /* Remove unwanted padding on login page for mobile devices */
    .content:has(.relative.flex.size-full.min-h-screen) {
        padding-top: 0 !important;
    }
    
    /* Hide dashboard top navigation bar on small mobile */
    .dashboard-top-nav {
        display: none !important;
    }
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MS4wODUgOTQuMDcyIDI5MS4wODUgOTQuNzkyQzI5MS4wODUgOTUuODg0IDI5MC42MzYgOTYuNSA5MC4wNTYgOTYuNSIyODkuNDg2IDk2LjUgMjg5LjA5IDk2LjE1MSAyODguODg0IDk1LjY0MUMyODguMDIxIDk0LjM1MiAyODcuNTg1IDkzLjAxNiAyODcuMDk5IDkxLjYyN0wyNjMuNTg2IDUzLjAxM0MyNjMuNDg0IDUyLjcyMyAyNjMuMzgyIDUyLjQzMyAyNjMuMzgyIDUyLjE0M0MyNjMuMzgyIDUxLjY2MyAyNjMuNTg2IDUxIDI2My41MDYgNTFaIiBmaWxsPSIjRkU1NDU0IiBmaWxsLXJ1bGU9ImV2ZW5vZGQiLz48cGF0aCBkPSJNMjg2LjU4NyA5NUMyODYuNDg1IDk1LjI4OSAyODYuMzkzIDk1LjU3OSAyODYuMzkzIDk1Ljg2OUMyODYuMzkzIDk2LjM0OSAyODYuNTk3IDk2LjUgMjg2LjY3NyA5Ni41TDI4OS44NzcgOTYuNUMyOTAuMDI5IDk2LjUgMjkwLjIyNSA5Ni4xNDggMjkwLjIyNSA5NS42NjdDMjkwLjIyNSA5NC40OTggMjkwLjYxOSA5My4xNTIgMjkwLjkwNSA5MS44MTdMMjg2LjU4NyA5NVoiIGZpbGw9IiNDNzMyNzMiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

/* Loading Spinner Animation - Enhanced */
.loader {
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: var(--spacing-md) auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   ENHANCED ANIMATIONS & MICRO-INTERACTIONS
   ============================================ */

/* Page transition animations */
.page-fade-enter,
.page-fade-exit {
    will-change: opacity, transform;
    backface-visibility: hidden;
}

.page-fade-enter {
    opacity: 0;
    transform: translateY(10px);
    animation: fadeInUp var(--transition-normal) forwards;
}

.page-fade-exit {
    opacity: 1;
    animation: fadeOutDown var(--transition-normal) forwards;
}

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

@media (prefers-reduced-motion: reduce) {
    .page-fade-enter,
    .page-fade-exit {
        animation: none;
        opacity: 1;
        transform: none;
    }
}

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

/* Enhanced card animations */
.card, .dashboard-card {
    transition: all var(--transition-normal);
    transform-origin: center;
}

.card:hover, .dashboard-card:hover {
    transform: translateY(-2px) scale(1.01);
    box-shadow: 0 8px 25px var(--shadow-medium);
}

.card:active, .dashboard-card:active {
    transform: translateY(0) scale(0.99);
    transition-duration: var(--transition-fast);
}

/* Ripple effect for buttons and interactive elements */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: var(--focus-ring);
    transform: translate(-50%, -50%);
    transition: width var(--transition-normal), height var(--transition-normal);
    pointer-events: none;
}

.ripple:active::before {
    width: 300px;
    height: 300px;
}

/* Enhanced button interactions */
button, .btn, input[type="submit"], input[type="button"] {
    position: relative;
    overflow: hidden;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: var(--touch-target-min);
    min-width: var(--touch-target-min);
}

button:hover, .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--shadow-medium);
}

button:active, .btn:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 4px var(--shadow-light);
}

/* Loading skeleton animation */
.skeleton {
    background: linear-gradient(90deg, var(--border-color) 25%, var(--surface-color) 50%, var(--border-color) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 4px;
}

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

/* Pulse animation for loading states */
.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Slide-in animations for mobile menu */
.slide-in-left {
    animation: slideInLeft var(--transition-normal) ease-out;
}

.slide-out-left {
    animation: slideOutLeft var(--transition-normal) ease-in;
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutLeft {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-100%);
        opacity: 0;
    }
}

/* Enhanced focus indicators for accessibility */
*:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    transition: outline-offset var(--transition-fast);
}

button:focus, .btn:focus, input:focus, select:focus, textarea:focus {
    box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Enhanced navigation link interactions */
.nav-link {
    transition: all var(--transition-fast);
    position: relative;
}

.nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 0;
    height: 2px;
    background-color: var(--primary-color);
    transition: width var(--transition-normal);
}

.nav-link:hover::before, .nav-link.active::before {
    width: 100%;
}

/* Toast notification animations */
.toast-enter {
    animation: toastSlideIn var(--transition-normal) ease-out;
}

.toast-exit {
    animation: toastSlideOut var(--transition-normal) ease-in;
}

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

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

/* Progress bar animation */
.progress-bar {
    height: 4px;
    background-color: var(--border-color);
    overflow: hidden;
    border-radius: 2px;
}

.progress-bar::before {
    content: '';
    display: block;
    height: 100%;
    background-color: var(--primary-color);
    width: 0;
    transition: width var(--transition-normal);
}

.progress-bar.loading::before {
    animation: progressLoading 2s infinite;
}

@keyframes progressLoading {
    0% {
        width: 0;
        margin-left: 0;
    }
    50% {
        width: 50%;
        margin-left: 25%;
    }
    100% {
        width: 0;
        margin-left: 100%;
    }
}

/* Enhanced mobile touch feedback */
@media (max-width: 767px) {
    .touch-feedback:active {
        background-color: var(--active-overlay);
        transform: scale(0.97);
        transition-duration: var(--transition-fast);
    }
    
    /* Ensure all interactive elements have adequate touch targets */
    button, .btn, a, input, select, textarea {
        min-height: var(--touch-target-min);
        min-width: var(--touch-target-min);
        padding: var(--spacing-sm) var(--spacing-md);
    }
    
    /* Enhanced mobile navigation animations */
    .mobile-menu-slide {
        transition: transform var(--transition-normal) cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }
}

/* ============================================
   THEME TOGGLE BUTTON
   ============================================ */

.theme-toggle-button {
    position: fixed;
    top: 1rem;
    right: 1rem; /* 더 접근하기 쉬운 우측 끝 위치 */
    width: var(--touch-target-min);
    height: var(--touch-target-min);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--surface-color);
    color: var(--text-primary);
    cursor: pointer;
    z-index: 10000; /* 햄버거 메뉴보다 높은 z-index */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px var(--shadow-light);
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none !important;
}

.theme-toggle-button:hover {
    background-color: var(--hover-overlay);
    transform: scale(1.05);
    box-shadow: 0 4px 12px var(--shadow-medium);
}

.theme-toggle-button:active {
    transform: scale(0.98);
}

.theme-toggle-button:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.theme-light-icon,
.theme-dark-icon {
    transition: all var(--transition-fast);
}

/* Theme icon visibility - default to light theme (show dark icon) */
.theme-toggle-button .theme-light-icon {
    display: none;
}

.theme-toggle-button .theme-dark-icon {
    display: inline;
}

/* Hide appropriate icon based on theme */
[data-theme="dark"] .theme-toggle-button .theme-dark-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle-button .theme-light-icon {
    display: inline;
}

/* For elements that don't have data-theme attribute but body/html does */
:root[data-theme="dark"] .theme-toggle-button .theme-dark-icon,
html[data-theme="dark"] .theme-toggle-button .theme-dark-icon,
body[data-theme="dark"] .theme-toggle-button .theme-dark-icon {
    display: none;
}

:root[data-theme="dark"] .theme-toggle-button .theme-light-icon,
html[data-theme="dark"] .theme-toggle-button .theme-light-icon,
body[data-theme="dark"] .theme-toggle-button .theme-light-icon {
    display: inline;
}

@media (max-width: 767px) {
    .theme-toggle-button {
        top: 1rem; /* 햄버거 메뉴와 같은 높이에 배치 */
        right: 4rem; /* 햄버거 메뉴 왼쪽에 배치 */
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

/* ============================================
   THEME-AWARE UTILITY CLASSES
   ============================================ */

/* Background utilities */
.bg-theme-surface {
    background-color: var(--surface-color) !important;
}

.bg-theme-background {
    background-color: var(--background-color) !important;
}

.bg-theme-primary {
    background-color: var(--primary-color) !important;
}

/* Text color utilities */
.text-theme-primary {
    color: var(--text-primary) !important;
}

.text-theme-secondary {
    color: var(--text-secondary) !important;
}

.text-theme-white {
    color: #ffffff !important;
}

/* Border utilities */
.border-theme {
    border-color: var(--border-color) !important;
}

.border-theme-primary {
    border-color: var(--primary-color) !important;
}

/* Common component classes for consistent theming */
.theme-card {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: all var(--transition-normal);
}

.theme-card:hover {
    box-shadow: 0 4px 12px var(--shadow-medium);
}

.theme-button {
    background-color: var(--primary-color);
    color: #ffffff;
    border: 1px solid var(--primary-color);
    transition: all var(--transition-fast);
}

.theme-button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px var(--shadow-medium);
}

.theme-input {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.theme-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

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

/* Override common hardcoded Tailwind classes with theme-aware versions */
.bg-white {
    background-color: var(--surface-color) !important;
}

.text-gray-900,
.text-black {
    color: var(--text-primary) !important;
}

.text-gray-600,
.text-gray-500 {
    color: var(--text-secondary) !important;
}

.border-gray-300,
.border-gray-200 {
    border-color: var(--border-color) !important;
}

/* Specific color overrides for commonly used hex colors in the app */
[class*="text-[#0e131b]"] {
    color: var(--text-primary) !important;
}

[class*="text-[#4d6a99]"] {
    color: var(--text-secondary) !important;
}

[class*="bg-[#ffffff]"],
[class*="bg-white"] {
    background-color: var(--surface-color) !important;
}

[class*="border-[#d0d9e7]"],
[class*="border-[#e5e7eb]"] {
    border-color: var(--border-color) !important;
}

/* Dashboard specific overrides */
.dashboard-card {
    background-color: var(--surface-color);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* Stats and metric cards */
.stat-card,
.metric-card {
    background-color: var(--surface-color);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* Form element improvements */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
select,
textarea {
    background-color: var(--surface-color);
    border-color: var(--border-color);
    color: var(--text-primary);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-secondary);
}

/* Generic responsive helpers for DB list pages */
.desktop-table-view {
    overflow-x: auto;
}

.mobile-card-view {
    display: none;
    padding: 0 12px;
}

.customer-card {
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 767.98px) {
    .desktop-table-view {
        display: none;
    }

    .mobile-card-view {
        display: block;
    }
}

/* Bottom-right login status indicator */
.login-status-indicator {
    position: fixed;
    right: 1rem;
    bottom: calc(1rem + env(safe-area-inset-bottom));
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.65rem;
    border-radius: 999px;
    background: rgba(16, 185, 129, 0.12); /* emerald-500 tint */
    color: #065F46; /* emerald-800 */
    border: 1px solid rgba(16, 185, 129, 0.35);
    box-shadow: 0 12px 28px rgba(16, 185, 129, 0.15);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    z-index: 40;
    pointer-events: none; /* purely informational */
}

.login-status-indicator .indicator-dot {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #10B981; /* emerald-500 */
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.22);
}

.login-status-indicator .indicator-text {
    font-weight: 700;
    letter-spacing: 0.01em;
    font-size: 0.85rem;
    color: #065F46;
}
