/**
 * LogisFit - 3PL 물류 관리 시스템
 * 커스텀 스타일시트
 */

/* ============================================
   기본 설정
   ============================================ */

:root {
    --sidebar-width: 200px;
    --sidebar-bg: #2c3e50;
    --sidebar-active-bg: #34495e;
    --primary-color: #3498db;
    --secondary-color: #2ecc71;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --body-bg: #f5f6fa;
    --card-bg: #fff;
    --card-border: #eee;
    --card-shadow: rgba(0, 0, 0, 0.05);
    --navbar-bg: #fff;
    --navbar-border: #dee2e6;
    --text-primary: #333;
    --text-muted: #6c757d;
    --table-hover-bg: #f8f9fa;
    --table-header-bg: #f8f9fa;
    --auth-card-bg: #fff;
    --auth-shadow: rgba(0, 0, 0, 0.15);
    --input-group-bg: #f8f9fa;
}

[data-bs-theme="dark"] {
    --body-bg: #1a1d23;
    --card-bg: #22262d;
    --card-border: #2e3238;
    --card-shadow: rgba(0, 0, 0, 0.2);
    --navbar-bg: #22262d;
    --navbar-border: #2e3238;
    --sidebar-bg: #16191e;
    --sidebar-active-bg: #1e2229;
    --text-primary: #e0e0e0;
    --text-muted: #8b929a;
    --table-hover-bg: #282c34;
    --table-header-bg: #282c34;
    --auth-card-bg: #22262d;
    --auth-shadow: rgba(0, 0, 0, 0.4);
    --input-group-bg: #2e3238;
}

* {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    background-color: var(--body-bg);
    min-height: 100vh;
}

/* ============================================
   레이아웃
   ============================================ */

.wrapper {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

@media (max-width: 991.98px) {
    .main-content {
        margin-left: 0;
        width: 100%;
    }
}

/* ============================================
   사이드바
   ============================================ */

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }
}

.sidebar-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.sidebar-brand {
    color: #fff;
    text-decoration: none;
    display: flex;
    align-items: center;
}

.sidebar-brand img {
    max-width: 100%;
}

.sidebar-brand i {
    font-size: 1.75rem;
    color: var(--primary-color);
}

.sidebar-toggle {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.25rem;
    cursor: pointer;
}

.sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-header-text {
    padding: 1rem 1.5rem 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* 섹션 토글 */
.sidebar-section-toggle {
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

.sidebar-section-toggle:hover {
    color: rgba(255, 255, 255, 0.8);
}

.sidebar-section-label {
    flex: 1;
}

.sidebar-section-chevron {
    font-size: 0.6rem;
    transition: transform 0.25s ease;
    margin-left: auto;
}

.sidebar-section-toggle.collapsed .sidebar-section-chevron {
    transform: rotate(-90deg);
}

.sidebar-section-item {
    overflow: hidden;
    max-height: 60px;
    transition: max-height 0.25s ease, opacity 0.25s ease, margin 0.25s ease;
    opacity: 1;
}

.sidebar-section-item.section-hidden {
    max-height: 0;
    opacity: 0;
    margin: 0 0.75rem !important;
}

/* 즐겨찾기 버튼 */
.sidebar-item {
    margin: 0.25rem 0.75rem;
    position: relative;
    display: flex;
    align-items: center;
}

.sidebar-item .sidebar-link {
    flex: 1;
    min-width: 0;
}

.sidebar-fav-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.2);
    font-size: 0.7rem;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
    z-index: 1;
}

.sidebar-item:hover .sidebar-fav-btn {
    opacity: 1;
}

.sidebar-fav-btn:hover {
    color: #f5c518;
}

.sidebar-fav-btn.is-fav {
    color: #f5c518;
    opacity: 1;
}

.sidebar-fav-btn.is-fav i {
    font-weight: bold;
}

/* 즐겨찾기 섹션 */
.sidebar-favorites-section {
    list-style: none;
}

.sidebar-favorites-section .sidebar-header-text {
    padding-bottom: 0.25rem;
}

.sidebar-favorites-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-favorites-list .sidebar-item {
    margin: 0.15rem 0.75rem;
}

.sidebar-favorites-list .sidebar-link {
    font-size: 0.82rem;
    padding: 0.2rem 1rem;
    background: rgba(245, 197, 24, 0.08);
    border-radius: 0.5rem;
}

.sidebar-favorites-list .sidebar-link:hover {
    background: rgba(245, 197, 24, 0.15);
}

.sidebar-favorites-list .sidebar-link.active {
    background-color: var(--primary-color);
}

.sidebar-client-badge {
    font-size: 0.6rem;
    background: rgba(76, 175, 80, 0.25);
    color: #81c784;
    padding: 1px 7px;
    border-radius: 10px;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
    white-space: nowrap;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 0.25rem 1rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.sidebar-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.sidebar-link.active {
    background-color: var(--primary-color);
    color: #fff;
}

.sidebar-link i {
    width: 24px;
    margin-right: 0.75rem;
    font-size: 1.1rem;
}

/* 거래처 사이드바 테마 (주황색) */
.sidebar-client {
    --sidebar-bg: #4a2800;
    --sidebar-active-bg: #5e3500;
    background-color: var(--sidebar-bg);
}

.sidebar-client .sidebar-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.sidebar-client .sidebar-link.active {
    background-color: #d4710a;
}

.sidebar-client .sidebar-link:hover {
    background-color: rgba(255, 165, 0, 0.15);
}

/* 거래처명 표시 */
.sidebar-client-info {
    padding: 0.6rem 1.5rem;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-client-info i {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.85rem;
}

/* ============================================
   상단 네비게이션
   ============================================ */

.navbar {
    background-color: var(--navbar-bg) !important;
    border-bottom-color: var(--navbar-border) !important;
    box-shadow: 0 2px 4px var(--card-shadow);
}

.sidebar-toggle-btn {
    color: var(--text-primary);
    padding: 0.5rem;
}

/* 페이지 제목 (반응형) */
.navbar-page-title {
    font-size: 1.15rem;
    font-weight: 600;
}

@media (max-width: 991.98px) {
    .navbar-page-title {
        font-size: 0.9rem;
        max-width: 55vw;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

@media (max-width: 575.98px) {
    .navbar-page-title {
        font-size: 0.85rem;
        max-width: 45vw;
    }
}

.notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    font-size: 0.65rem;
}

/* ============================================
   인증 페이지 (로그인/회원가입)
   ============================================ */

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-container {
    width: 100%;
    max-width: 420px;
}

.auth-card {
    background: var(--auth-card-bg);
    border-radius: 1rem;
    box-shadow: 0 20px 60px var(--auth-shadow);
    padding: 2.5rem;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.auth-logo img {
    filter: invert(1);
    -webkit-user-drag: none;
    -khtml-user-drag: none;
    -moz-user-drag: none;
    -o-user-drag: none;
    user-drag: none;
}

.auth-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.auth-form .form-control {
    padding: 0.75rem 1rem;
}

.auth-form .input-group-text {
    background-color: var(--input-group-bg);
    border-right: none;
}

.auth-form .form-control {
    border-left: none;
}

.auth-form .form-control:focus {
    box-shadow: none;
    border-color: #ced4da;
}

.auth-form .input-group:focus-within .input-group-text,
.auth-form .input-group:focus-within .form-control {
    border-color: var(--primary-color);
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--card-border);
}

.auth-footer a {
    color: var(--primary-color);
    font-weight: 500;
}

/* ============================================
   메시지 알림
   ============================================ */

.messages-container {
    padding: 1rem;
}

.auth-wrapper .messages-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1050;
    max-width: 400px;
}

/* ============================================
   카드
   ============================================ */

.card {
    border: none;
    background-color: var(--card-bg);
    box-shadow: 0 2px 8px var(--card-shadow);
    border-radius: 0.75rem;
}

.card-header {
    background-color: var(--card-bg) !important;
    border-bottom: 1px solid var(--card-border);
    padding: 1rem 1.25rem;
}

.quick-link-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.quick-link-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ============================================
   테이블
   ============================================ */

.table {
    margin-bottom: 0;
}

.table th {
    font-weight: 600;
    border-top: none;
}

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

/* ============================================
   버튼
   ============================================ */

.btn {
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    font-weight: 500;
}

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

.btn-primary:hover {
    background-color: #2980b9;
    border-color: #2980b9;
}

/* ============================================
   푸터
   ============================================ */

.footer {
    margin-top: auto;
    font-size: 0.85rem;
    background-color: var(--table-header-bg);
    border-top: 1px solid var(--card-border);
}

/* ============================================
   유틸리티
   ============================================ */

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.badge {
    font-weight: 500;
    padding: 0.4em 0.8em;
}

/* 스크롤바 스타일 */
.sidebar-body::-webkit-scrollbar {
    width: 6px;
}

.sidebar-body::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-body::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar-body::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* ============================================
   반응형 — 태블릿 (≤991px)
   ============================================ */

@media (max-width: 991.98px) {
    .container-fluid.py-4 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .card-body {
        padding: 1rem;
    }

    .card-header {
        padding: 0.75rem 1rem;
    }
}

/* ============================================
   반응형 — 모바일 (≤767px)
   ============================================ */

@media (max-width: 767.98px) {
    /* 인증 */
    .auth-card { padding: 1.5rem; }
    .auth-logo { height: 60px; }
    .auth-wrapper { padding: 1rem; }

    /* 콘텐츠 */
    .container-fluid.py-4 { padding: 0.75rem !important; }

    /* 카드 */
    .card { border-radius: 0.5rem; }
    .card-body { padding: 0.75rem; }
    .card-header { padding: 0.625rem 0.75rem; font-size: 0.9rem; }

    /* 타이포그래피 */
    h2, .h2 { font-size: 1.25rem; }
    h3, .h3 { font-size: 1.1rem; }
    h4, .h4 { font-size: 1rem; }
    h5, .h5 { font-size: 0.95rem; }

    /* 테이블 */
    .table { font-size: 0.8rem; }
    .table th, .table td { padding: 0.4rem 0.5rem; white-space: nowrap; }

    /* 버튼 터치 최적화 */
    .btn { min-height: 40px; padding: 0.5rem 0.875rem; font-size: 0.85rem; }
    .btn-sm { min-height: 34px; padding: 0.35rem 0.625rem; font-size: 0.8rem; }

    /* 폼 터치 최적화 */
    .form-control, .form-select { min-height: 40px; font-size: 16px !important; }
    .form-control-sm, .form-select-sm { min-height: 34px; }
    .input-group .form-control { min-height: 40px; }
    .form-check-input { width: 1.25em; height: 1.25em; }

    /* 모달 */
    .modal-dialog { margin: 0.5rem; }
    .modal-lg, .modal-xl { max-width: calc(100vw - 1rem); }
    .modal-body { padding: 0.75rem; }
    .modal-header, .modal-footer { padding: 0.625rem 0.75rem; }

    /* 배지 */
    .badge { font-size: 0.7em; padding: 0.3em 0.6em; }

    /* 네비게이션 바 */
    .navbar { padding: 0.375rem 0.75rem; }

    /* 토스트/메시지 */
    .toast-container { left: 0.5rem !important; right: 0.5rem !important; max-width: 100% !important; }
    .auth-wrapper .messages-container { left: 0.5rem; right: 0.5rem; max-width: none; }

    /* 드롭다운 */
    .dropdown-menu { font-size: 0.85rem; }

    /* 인라인 고정너비 오버라이드 */
    [style*="max-width: 500px"],
    [style*="max-width: 350px"],
    [style*="max-width:500px"],
    [style*="max-width:350px"] {
        max-width: 100% !important;
    }
    [style*="width: 200px"],
    [style*="width:200px"] {
        width: 100% !important;
    }

    /* Flex 줄바꿈 */
    .d-flex.gap-2 { flex-wrap: wrap; }
    .btn-group { flex-wrap: wrap; }

    /* 푸터 */
    .footer { font-size: 0.75rem; padding: 0.5rem 0.75rem; }
}

/* ============================================
   반응형 — 소형 모바일 (≤575px)
   ============================================ */

@media (max-width: 575.98px) {
    .container-fluid.py-4 { padding: 0.5rem !important; }
    .card-body { padding: 0.625rem; }

    .table { font-size: 0.75rem; }
    .table th, .table td { padding: 0.3rem 0.4rem; }

    /* 소형 모바일 검색영역 스택 */
    .row.g-2 > [class*="col-md-"],
    .row.g-3 > [class*="col-md-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* 테이블 스크롤 힌트 (우측 그라데이션) */
    .table-responsive {
        position: relative;
    }
    .table-responsive::after {
        content: '';
        position: absolute;
        top: 0; right: 0; bottom: 0;
        width: 20px;
        background: linear-gradient(to left, rgba(0,0,0,0.04), transparent);
        pointer-events: none;
        z-index: 1;
    }

    .auth-card { padding: 1.25rem; border-radius: 0.75rem; }
    .auth-title { font-size: 1.4rem; }
}

/* ============================================
   터치 디바이스 최적화
   ============================================ */

@media (hover: none) and (pointer: coarse) {
    .btn, .nav-link, .dropdown-item, .sidebar-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .sidebar-link { padding: 0.5rem 1rem; }

    .table td, .table th {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }

    .form-control, .form-select { min-height: 44px; }

    .form-check {
        padding-left: 2em;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .form-check-input {
        width: 1.5em;
        height: 1.5em;
        margin-top: 0;
    }
}

/* ============================================
   PWA standalone 모드 (노치/홈바 대응)
   ============================================ */

@media all and (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    .sidebar { padding-top: env(safe-area-inset-top); }
    .navbar { padding-top: max(0.375rem, env(safe-area-inset-top)); }
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .footer {
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
    }
}

/* ============================================
   가로 스크롤 테이블 부드러운 스크롤
   ============================================ */

.table-responsive {
    -webkit-overflow-scrolling: touch;
}

/* ============================================
   다크모드 추가 스타일
   ============================================ */

[data-bs-theme="dark"] .navbar-light {
    background-color: var(--navbar-bg) !important;
}

[data-bs-theme="dark"] .navbar-light .nav-link,
[data-bs-theme="dark"] .navbar-light .navbar-brand,
[data-bs-theme="dark"] .navbar-page-title {
    color: var(--text-primary) !important;
}

[data-bs-theme="dark"] .dropdown-menu {
    background-color: var(--card-bg);
    border-color: var(--card-border);
}

[data-bs-theme="dark"] .dropdown-item {
    color: var(--text-primary);
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus {
    background-color: var(--table-hover-bg);
    color: var(--text-primary);
}

[data-bs-theme="dark"] .dropdown-item-text {
    color: var(--text-muted) !important;
}

[data-bs-theme="dark"] .dropdown-divider {
    border-color: var(--card-border);
}

[data-bs-theme="dark"] .table-light th {
    background-color: var(--table-header-bg) !important;
    color: var(--text-primary);
    border-color: var(--card-border);
}

[data-bs-theme="dark"] .list-group-item {
    background-color: var(--card-bg);
    border-color: var(--card-border);
    color: var(--text-primary);
}

[data-bs-theme="dark"] .list-group-item-action:hover {
    background-color: var(--table-hover-bg);
    color: var(--text-primary);
}

[data-bs-theme="dark"] .stat-card {
    background-color: var(--card-bg) !important;
}

[data-bs-theme="dark"] .auth-logo img {
    filter: invert(0);
}

[data-bs-theme="dark"] .admin-section {
    background: linear-gradient(135deg, #1e2235 0%, #222233 100%);
    border-left-color: #7986cb;
}

[data-bs-theme="dark"] .admin-badge {
    background: #7986cb;
}

[data-bs-theme="dark"] .border-bottom {
    border-bottom-color: var(--card-border) !important;
}

/* 다크모드: 푸터 */
[data-bs-theme="dark"] .footer {
    background-color: var(--navbar-bg);
    border-top-color: var(--card-border);
    color: var(--text-muted);
}

[data-bs-theme="dark"] .footer .text-muted {
    color: var(--text-muted) !important;
}

/* 다크모드: disabled 입력 필드 */
[data-bs-theme="dark"] .form-control:disabled,
[data-bs-theme="dark"] .form-control[readonly],
[data-bs-theme="dark"] .form-select:disabled {
    background-color: #1a1d23;
    color: var(--text-muted);
    border-color: var(--card-border);
    opacity: 0.7;
}

[data-bs-theme="dark"] input:disabled,
[data-bs-theme="dark"] textarea:disabled,
[data-bs-theme="dark"] select:disabled {
    background-color: #1a1d23 !important;
    color: var(--text-muted) !important;
    border-color: var(--card-border) !important;
}

/* 다크모드: 필터바 / 셀렉터바 */
[data-bs-theme="dark"] .filter-bar,
[data-bs-theme="dark"] .selector-bar {
    background: var(--card-bg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

[data-bs-theme="dark"] .filter-bar label,
[data-bs-theme="dark"] .selector-bar label {
    color: var(--text-muted);
}

/* 다크모드: 테이블 카드 */
[data-bs-theme="dark"] .table-card {
    background: var(--card-bg);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

[data-bs-theme="dark"] .table-card .table thead th {
    background: var(--table-header-bg);
    border-bottom-color: var(--card-border);
    color: var(--text-primary);
}

[data-bs-theme="dark"] .table-card .table tbody td {
    border-bottom-color: var(--card-border);
}

[data-bs-theme="dark"] .table-card .table tbody tr:hover {
    background-color: var(--table-hover-bg);
}

[data-bs-theme="dark"] .table-card .table tbody tr.row-synced {
    background-color: var(--table-hover-bg);
}

/* 다크모드: 그룹 카드 */
[data-bs-theme="dark"] .group-card {
    border-color: var(--card-border);
}

[data-bs-theme="dark"] .group-card .group-header {
    background: var(--table-header-bg);
}

[data-bs-theme="dark"] .group-card .group-header:hover {
    background: var(--card-border);
}

/* 다크모드: 업로드 존 */
[data-bs-theme="dark"] .upload-zone {
    border-color: var(--card-border);
    background: var(--card-bg);
}

[data-bs-theme="dark"] .upload-zone:hover,
[data-bs-theme="dark"] .upload-zone.drag-over {
    border-color: var(--primary-color);
    background: #1a2332;
}

[data-bs-theme="dark"] .upload-zone i,
[data-bs-theme="dark"] .upload-zone .icon {
    color: var(--text-muted);
}

[data-bs-theme="dark"] .upload-zone:hover i,
[data-bs-theme="dark"] .upload-zone.drag-over i,
[data-bs-theme="dark"] .upload-zone.drag-over .icon {
    color: var(--primary-color);
}

[data-bs-theme="dark"] .upload-zone .hint {
    color: var(--text-muted);
}

/* 다크모드: 액션 툴바 */
[data-bs-theme="dark"] .action-toolbar {
    background: var(--card-bg);
    border-bottom-color: var(--card-border);
}

/* 다크모드 토글 */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.25rem 1rem;
    cursor: pointer;
}

.theme-toggle-label {
    font-size: 0.875rem;
}

.theme-switch {
    position: relative;
    width: 40px;
    height: 22px;
    background: #ccc;
    border-radius: 11px;
    transition: background 0.3s;
    cursor: pointer;
}

.theme-switch.active {
    background: var(--primary-color);
}

.theme-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.theme-switch.active::after {
    transform: translateX(18px);
}

/* 사이드바 오버레이 (모바일) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

@media (max-width: 991.98px) {
    .sidebar-overlay.show {
        display: block;
    }
}

/* ============================================
   셀(작업대) 전용 레이아웃
   ============================================ */

.cell-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: var(--body-bg);
}

.cell-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background-color: #2c3e50;
    color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    z-index: 100;
}

.cell-brand img {
    height: 28px;
    filter: brightness(0) invert(1);
}

.cell-user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.cell-user-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
}

.cell-logout-btn {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    padding: 0.25rem 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 0.375rem;
    transition: all 0.2s;
}

.cell-logout-btn:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.1);
}

.cell-content {
    flex: 1;
    padding: 0;
    width: 100%;
    overflow: hidden;
}

@media (max-width: 767.98px) {
    .cell-content {
        padding: 0;
}

/* 다크모드: 셀 헤더 */
[data-bs-theme="dark"] .cell-header {
    background-color: #16191e;
}

/* ============================================
   인쇄 전용 (전역)
   ============================================ */

@media print {
    /* 사이드바 완전 제거 */
    .sidebar,
    #sidebar,
    .sidebar-wrapper {
        display: none !important;
        visibility: hidden !important;
        position: absolute !important;
        left: -9999px !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
    }

    /* 네비게이션 바 숨김 */
    .navbar,
    .navbar-light,
    nav.navbar {
        display: none !important;
    }

    /* 레이아웃 리셋 */
    .wrapper {
        display: block !important;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
    }
}

/* ============================================
   B2B 출고 현황 — 주문 헤더 행 + 자식 라인 행
   디자이너 컨펌 토큰 (라이트 + 다크 + sticky-right)
   ============================================ */

:root {
    --sticky-right-bg: #f5f7ff;                    /* 옅은 인디고 워시 — 세로 띠 */
    --sticky-right-header-bg: #e8ecf7;             /* 헤더 행 sticky 좀 더 진하게 */
    --sticky-right-border: rgba(0, 0, 0, 0.08);
    --sticky-right-first-border: #c7d2fe;          /* 좌측 인디고 2px 보더 (영역 경계) */
}
[data-bs-theme="dark"] {
    --sticky-right-bg: #1a1f2e;
    --sticky-right-header-bg: #1e2330;
    --sticky-right-border: rgba(255, 255, 255, 0.08);
    --sticky-right-first-border: #475569;
}

/* ── 주문 헤더 행 — thead 그리드 정렬 (개별 td) ──
   라인 행(#fff)보다 한 단계 옅게 띄운 슬레이트 50 톤으로 그룹 헤더 시각 신호.
   Bootstrap `.table > :not(caption) > * > *` (specificity 0,1,3)가 var(--bs-table-bg)로 덮으므로 !important 필수.
   좌측 인디고 띠 + 상단 보더 + 굵은 글씨로 추가 구분. */
.order-header-row > td {
    background-color: #f8fafc !important;
    border-top: 3px solid #e2e8f0;
    border-bottom: 1px solid #eef0f3;
    padding: 10px 8px;
    vertical-align: middle;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
}
/* 첫 셀(체크박스 또는 출고예정일)에 좌측 인디고 강조 띠 */
.order-header-row > td:first-child {
    box-shadow: inset 4px 0 0 #6366f1;
}
.order-header-row .oh-date {
    font-family: monospace;
    color: #0f172a;
}
.order-header-row .oh-client {
    color: #1e3a8a;
    font-weight: 700;
}
.order-header-row .oh-product .product-link {
    color: #1d4ed8;
}
.order-header-row .oh-product .product-link:hover {
    text-decoration: underline !important;
}
.order-header-row .oh-qty {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
}
.oh-badge {
    font-size: 0.65rem !important;
    padding: 2px 6px !important;
    border-radius: 8px !important;
}

/* ── 라인 행 — 헤더와 같은 흰 배경, 보더만 점선으로 구분 ── */
.order-line-row > td {
    background-color: #ffffff;
    font-size: 0.78rem;
    padding: 5px 8px;
    vertical-align: middle;
    border-bottom: 1px dashed #eef0f3;
}
.order-line-row.is-last > td {
    border-bottom: 1px solid #e2e8f0;
}
.order-line-row:hover > td {
    background-color: #f7f9ff;
}
.order-line-row .ol-qty {
    font-family: 'JetBrains Mono', monospace;
    font-variant-numeric: tabular-nums;
    color: #475569;
}
.order-line-row .ol-product {
    padding-left: 28px !important;
    position: relative;
}
.order-line-row .ol-product::before {
    content: '';
    display: block;
    width: 12px;
    height: 1px;
    border-bottom: 1.5px solid #ced4da;
    position: absolute;
    left: 12px;
    top: 50%;
}
.order-line-row .ol-product-name {
    color: #334155;
    font-weight: 500;
}
.order-line-row .ol-pd {
    color: #475569;
}

/* 미저장 라인 강조 — 좌측 노란 보더 */
.order-line-row.dirty-row > td:first-child {
    box-shadow: inset 3px 0 0 #f59e0b;
}

/* ── 차량/택배 커스텀 select (네이티브 + CSS 화살표) ── */
.ship-method-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border: 1px solid #d1d5db;
    border-radius: 999px;
    padding: 4px 22px 4px 12px;
    font-size: 0.72rem;
    font-weight: 600;
    width: 82px;
    background-color: #f3f4f6;
    color: #6b7280;
    cursor: pointer;
    text-align: left;
    transition: all 0.18s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 10px 10px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.02);
}
.ship-method-select:hover {
    border-color: #9ca3af;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.ship-method-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}
.ship-method-select[data-value="PARCEL"] {
    background-color: #2563eb !important;
    color: #ffffff !important;
    border-color: #1d4ed8 !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-size: 12px 12px !important;
    background-repeat: no-repeat !important;
    background-position: right 8px center !important;
}
.ship-method-select[data-value="TRUCK"] {
    background-color: #dc2626 !important;
    color: #ffffff !important;
    border-color: #b91c1c !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-size: 12px 12px !important;
    background-repeat: no-repeat !important;
    background-position: right 8px center !important;
}
.ship-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
}
.ship-badge.parcel { background-color: #dbeafe; color: #1d4ed8; }
.ship-badge.truck { background-color: #fee2e2; color: #dc2626; }

/* 박스/팔레트 input */
.bp-input {
    width: 116px;
    min-width: 100px;
    font-family: monospace;
    font-size: 0.74rem !important;
    padding: 4px 8px !important;
    height: auto !important;
    border-radius: 6px !important;
}
.bp-input::placeholder {
    font-size: 0.68rem;
    color: #9ca3af;
}

/* 소비기한 input */
.exp-input {
    width: 122px;
    font-size: 0.72rem !important;
    padding: 4px 6px !important;
    height: auto !important;
    border-radius: 6px !important;
}

/* 송장번호 input — sticky 영역 안에 들어가 라인별 편집 */
.inv-input {
    width: 130px;
    font-family: monospace;
    font-size: 0.72rem !important;
    padding: 4px 8px !important;
    height: auto !important;
    border-radius: 6px !important;
}
.inv-input::placeholder { font-size: 0.68rem; color: #9ca3af; }

/* 행 단위 되돌리기 */
.btn-row-revert {
    width: 22px;
    height: 22px;
    padding: 0;
    border: 1px solid #f59e0b;
    background-color: #fff9e6;
    color: #f59e0b;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.68rem;
    transition: all 0.15s;
}
.btn-row-revert:hover {
    background-color: #f59e0b;
    color: #fff;
    transform: rotate(-90deg);
}

/* 일괄 저장 액션바 — 총 N건 옆 인라인. 빨간색 강조 + 펄스 dot으로 가시성 강화 */
.change-action-bar {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    background-color: #fef2f2;
    border: 1.5px solid #ef4444;
    border-radius: 999px;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
    animation: cabFadeIn 0.22s ease-out;
}
.change-action-bar[hidden] { display: none !important; }
@keyframes cabFadeIn {
    from { opacity: 0; transform: translateX(12px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes cabPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    50% { box-shadow: 0 0 0 5px rgba(239, 68, 68, 0); }
}
.change-action-bar .cab-count {
    font-size: 0.95rem;
    color: #b91c1c;
    font-weight: 700;
    padding-right: 10px;
    border-right: 1.5px solid #fca5a5;
    margin-right: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.change-action-bar .cab-count::before {
    content: '';
    display: inline-block;
    width: 9px;
    height: 9px;
    background-color: #dc2626;
    border-radius: 50%;
    margin-right: 4px;
    animation: cabPulse 1.4s ease-in-out infinite;
}
.change-action-bar .cab-count strong {
    color: #991b1b;
    margin: 0 2px;
    font-size: 1.15rem;
    font-variant-numeric: tabular-nums;
}
.change-action-bar .btn { padding: 4px 12px !important; font-size: 0.82rem !important; font-weight: 600 !important; }
.change-action-bar .btn-danger {
    background-color: #dc2626 !important;
    border-color: #b91c1c !important;
    color: #fff !important;
}
.change-action-bar .btn-danger:hover {
    background-color: #b91c1c !important;
    border-color: #991b1b !important;
}
[data-bs-theme="dark"] .change-action-bar {
    background-color: #2a1414;
    border-color: #ef4444;
}
[data-bs-theme="dark"] .change-action-bar .cab-count { color: #fca5a5; border-right-color: #7f1d1d; }
[data-bs-theme="dark"] .change-action-bar .cab-count strong { color: #ef4444; }

[data-bs-theme="dark"] .change-action-bar {
    background-color: #2d2a18;
    border-color: #78350f;
}
[data-bs-theme="dark"] .change-action-bar .cab-count {
    color: #fde68a;
    border-right-color: #78350f;
}
[data-bs-theme="dark"] .change-action-bar .cab-count strong { color: #fbbf24; }

/* ── 체크박스 미니멀 — .row-checkbox-styled 인라인 + 의사 클래스 CSS 보완
   인라인 style이 기본 모양 박고, hover/checked/indeterminate/focus는 CSS만 가능 (의사 클래스).
   !important로 어떤 Bootstrap 룰도 못 깨게 강제. */
input.row-checkbox-styled:hover {
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12) !important;
}
input.row-checkbox-styled:checked {
    background-color: #6366f1 !important;
    border-color: #6366f1 !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23fff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='4 8 7 11 12 5'%3E%3C/polyline%3E%3C/svg%3E") !important;
    background-size: 12px 12px !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
}
input.row-checkbox-styled:indeterminate {
    background-color: #6366f1 !important;
    border-color: #6366f1 !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23fff' stroke-width='2.5' stroke-linecap='round'%3E%3Cline x1='4' y1='8' x2='12' y2='8'%3E%3C/line%3E%3C/svg%3E") !important;
    background-size: 12px 12px !important;
    background-position: center !important;
    background-repeat: no-repeat !important;
}
input.row-checkbox-styled:focus {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25) !important;
    border-color: #6366f1 !important;
}
[data-bs-theme="dark"] input.row-checkbox-styled {
    border-color: #475569 !important;
    background-color: #1e293b !important;
}
[data-bs-theme="dark"] input.row-checkbox-styled:checked,
[data-bs-theme="dark"] input.row-checkbox-styled:indeterminate {
    background-color: #818cf8 !important;
    border-color: #818cf8 !important;
}

/* ── 가로 스크롤 끊김 완화 — GPU 레이어 분리 ──
   sticky 셀이 라인마다 9개 × 페이지 100건 = 900 sticky 셀이라 매 스크롤 프레임마다 reflow.
   contain: layout style + will-change로 페인트 영역 격리 + GPU 가속 hint. */
.sticky-right {
    contain: layout style;
}
.table-responsive {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: auto;
}

/* ── sticky-right (차량/택배 ~ 작업 컬럼) ──
   border-collapse: separate 필수 — collapse면 <td>의 position:sticky가 Firefox/Safari에서 무력화됨
   !important로 Bootstrap .table-card .table tbody td (specificity 0,2,3)보다 강제 우선 보장 */
#ordersTable {
    border-collapse: separate !important;
    border-spacing: 0;
}
.sticky-right {
    position: sticky !important;
    background-color: var(--sticky-right-bg) !important;
    z-index: 2;
    white-space: nowrap;
    overflow: visible;
    box-sizing: border-box;
}
#ordersTable thead .sticky-right {
    background-color: var(--sticky-right-header-bg) !important;
    z-index: 3;
    padding-left: 6px !important;
    padding-right: 6px !important;
    font-size: 0.78rem;
}
/* 첫 sticky 컬럼(가장 안쪽 = 차량/택배)에 좌측 2px 인디고 보더 — 세로 띠 경계 */
.sticky-right.sticky-right-first {
    border-left: 2px solid var(--sticky-right-first-border) !important;
}
/* 주문 헤더 행 / 라인 행 배경 우선순위 — 일반 td 다음 선언으로 specificity 동등 + 순서 우선 */
.order-header-row > td.sticky-right {
    background-color: var(--sticky-right-header-bg);
}
.order-line-row > td.sticky-right {
    background-color: var(--sticky-right-bg);
}
.order-line-row:hover > td.sticky-right {
    background-color: #eef0ff;
}

/* ── 다크모드 ──
   주문 헤더 행: 라인(card-bg #22262d)보다 살짝 진한 톤으로 그룹 신호. !important 동일 적용 */
[data-bs-theme="dark"] .order-header-row > td {
    background-color: #2a2f38 !important;
    border-top-color: var(--border-color, #3a3f47);
    border-bottom-color: var(--border-color, #3a3f47);
}
[data-bs-theme="dark"] .oh-chip {
    background-color: #1f2937;
    border-color: #374151;
}
[data-bs-theme="dark"] .oh-chip .oh-lbl { color: #9ca3af; }
[data-bs-theme="dark"] .oh-chip .oh-val { color: #f3f4f6; }
[data-bs-theme="dark"] .oh-chip .oh-val.oh-strong { color: #93c5fd; }
[data-bs-theme="dark"] .oh-chip .product-link { color: #60a5fa; }

[data-bs-theme="dark"] .order-line-row > td {
    background-color: var(--card-bg);
    border-bottom-color: #2a3038;
}
[data-bs-theme="dark"] .order-line-row.is-last > td {
    border-bottom-color: #3a3f47;
}
[data-bs-theme="dark"] .order-line-row:hover > td {
    background-color: var(--table-hover-bg);
}
[data-bs-theme="dark"] .order-line-row .ol-product::before {
    border-bottom-color: #4b5563;
}
[data-bs-theme="dark"] .order-line-row .ol-product-name { color: #e5e7eb; }
[data-bs-theme="dark"] .order-line-row .ol-pd { color: #cbd5e1; }
[data-bs-theme="dark"] .order-line-row.dirty-row > td:first-child {
    box-shadow: inset 3px 0 0 #fbbf24;
}

[data-bs-theme="dark"] .ship-method-select {
    background-color: #2e3238;
    color: #9ca3af;
    border-color: #3a3f47;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}
[data-bs-theme="dark"] .ship-method-select[data-value="PARCEL"] {
    background-color: #1e3a5f;
    color: #60a5fa;
    border-color: #2c5282;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2360a5fa' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}
[data-bs-theme="dark"] .ship-method-select[data-value="TRUCK"] {
    background-color: #4b1818;
    color: #f87171;
    border-color: #7f1d1d;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23f87171' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}
[data-bs-theme="dark"] .ship-badge.parcel { background-color: #1e3a5f; color: #60a5fa; }
[data-bs-theme="dark"] .ship-badge.truck { background-color: #4b1818; color: #f87171; }

[data-bs-theme="dark"] .btn-row-revert {
    border-color: #fbbf24;
    background-color: #2d2a18;
    color: #fbbf24;
}
[data-bs-theme="dark"] .btn-row-revert:hover {
    background-color: #fbbf24;
    color: #1a1d23;
}
[data-bs-theme="dark"] .order-header-row > td.sticky-right {
    background-color: var(--sticky-right-header-bg);
}
[data-bs-theme="dark"] .order-line-row > td.sticky-right {
    background-color: var(--sticky-right-bg);
}
[data-bs-theme="dark"] .order-line-row:hover > td.sticky-right {
    background-color: #1f2640;
}

/* 모바일에서는 sticky 해제 (일반 스크롤) */
@media (max-width: 767.98px) {
    .sticky-right {
        position: static !important;
        box-shadow: none !important;
    }
}
