/* ================================================================
   global.css — 공통 디자인 시스템 (Light Enterprise)
   ================================================================ */

/* ── CSS 변수 (라이트 테마) ────────────────────────── */
:root {
    /* 배경 */
    --bg-primary:     #f7f8fc;
    --bg-secondary:   #ffffff;
    --bg-tertiary:    #f1f3f9;
    --bg-card:        #ffffff;
    --bg-hover:       #f1f3f9;
    --bg-input:       #ffffff;

    /* 텍스트 */
    --text-primary:   #1a1d2e;
    --text-secondary: #5a6178;
    --text-muted:     #8f95a8;
    --text-inverse:   #ffffff;

    /* 브랜드 */
    --brand-primary:  #4f5fe5;
    --brand-secondary:#6c5ce7;
    --brand-gradient: linear-gradient(135deg, #4f5fe5, #6c5ce7);
    --brand-light:    #eef0ff;

    /* 상태 */
    --color-success:  #0ea47a;
    --color-warning:  #e5a100;
    --color-danger:   #e5453d;
    --color-info:     #3b82f6;

    /* 사이드바 */
    --sidebar-width:       240px;
    --sidebar-collapsed:   72px;
    --sidebar-bg:          #ffffff;

    /* 레이아웃 */
    --radius-sm:      8px;
    --radius-md:      12px;
    --radius-lg:      16px;
    --border-color:   #e4e7f1;
    --shadow-card:    0 1px 3px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.03);
    --shadow-popup:   0 12px 40px rgba(0,0,0,.1), 0 4px 12px rgba(0,0,0,.06);
    --shadow-sm:      0 1px 2px rgba(0,0,0,.04);

    /* 애니메이션 */
    --transition-fast:   0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow:   0.4s ease;

    /* 폰트 */
    --font-sans: 'Pretendard Variable', 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}


/* ── 리셋 ────────────────────────────────────────── */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

img {
    max-width: 100%;
    display: block;
}

input,
select,
textarea {
    font: inherit;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(79, 95, 229, .1);
}


/* ── 스크롤바 ────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: #d0d4e0;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #b0b5c5;
}


/* ── 레이아웃: 사이드바 + 콘텐츠 ─────────────────── */
.layout {
    display: flex;
    min-height: 100vh;
}

.content-area {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    padding: 28px 32px;
    transition: margin-left var(--transition-normal);
}

body.sidebar-collapsed .content-area {
    margin-left: var(--sidebar-collapsed);
}


/* ── 사이드바 ────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width var(--transition-normal);
    border-right: 1px solid #eceef5;
    overflow: hidden;
}

body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed);
}

/* ── 로고 영역 ── */
.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 16px;
    flex-shrink: 0;
    border-bottom: 1px solid #eceef5;
}

.sidebar-logo-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.sidebar-logo-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: linear-gradient(145deg, #4f5fe5, #7c6cf0);
    color: #fff;
    font-size: 15px;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(79,95,229,.25);
}

.sidebar-logo {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: #1a1d2e;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-toggle {
    display: none;
}

body.sidebar-collapsed .sidebar-logo,
body.sidebar-collapsed .sidebar-label,
body.sidebar-collapsed .sidebar-section-label,
body.sidebar-collapsed .sidebar-user-info,
body.sidebar-collapsed .sidebar-logout-btn span {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

/* ── 네비게이션 ── */
.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #e0e3ef; border-radius: 2px; }

.sidebar-section-label {
    font-size: 11.5px;
    font-weight: 700;
    color: #1a1d2e;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 16px 14px 6px;
    white-space: nowrap;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 10px;
    border-radius: 10px;
    color: #5a6178;
    font-size: 14px;
    font-weight: 500;
    transition: all .2s cubic-bezier(.4,0,.2,1);
    white-space: nowrap;
    position: relative;
}

.sidebar-link-icon {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    background: #f4f5fa;
    flex-shrink: 0;
    transition: all .2s;
}

.sidebar-link-icon i {
    font-size: 14px;
    color: #8a90a5;
    transition: color .2s;
}

.sidebar-link:hover {
    background: #f6f7ff;
    color: #1a1d2e;
}

.sidebar-link:hover .sidebar-link-icon {
    background: #eef0ff;
}

.sidebar-link:hover .sidebar-link-icon i {
    color: #4f5fe5;
}

/* 활성 메뉴 */
.sidebar-link.active {
    background: linear-gradient(135deg, #eef0ff, #ece8ff);
    color: #4f5fe5;
    font-weight: 700;
}

.sidebar-link.active .sidebar-link-icon {
    background: linear-gradient(145deg, #4f5fe5, #7c6cf0);
    box-shadow: 0 2px 8px rgba(79,95,229,.25);
}

.sidebar-link.active .sidebar-link-icon i {
    color: #ffffff;
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 20px;
    border-radius: 0 4px 4px 0;
    background: linear-gradient(180deg, #4f5fe5, #7c6cf0);
}

/* ── 유저 카드 ── */
.sidebar-footer {
    padding: 12px 10px;
    border-top: 1px solid #eceef5;
    flex-shrink: 0;
}

.sidebar-user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 12px;
    background: #f7f8fc;
    border: 1px solid #eef0f6;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(145deg, #4f5fe5, #7c6cf0);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-user-name {
    font-size: 13.5px;
    font-weight: 700;
    color: #1a1d2e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 11.5px;
    color: #8a90a5;
    font-weight: 500;
    white-space: nowrap;
}

.sidebar-logout-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: #b0b5c5;
    font-size: 13px;
    flex-shrink: 0;
    transition: all .15s;
}

.sidebar-logout-btn:hover {
    background: #fee2e2;
    color: #e5453d;
}


/* ── 공통 컴포넌트 ───────────────────────────────── */

/* 카드 */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-card);
}

/* 버튼 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition-fast);
    cursor: pointer;
    border: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--brand-gradient);
    color: #fff;
    box-shadow: 0 2px 8px rgba(79, 95, 229, .25);
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(79, 95, 229, .3);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: #c8cdd9;
}

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* 뱃지 */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}

.badge-success { background: rgba(14,164,122,0.1); color: var(--color-success); }
.badge-warning { background: rgba(229,161,0,0.1);  color: var(--color-warning); }
.badge-danger  { background: rgba(229,69,61,0.1);  color: var(--color-danger);  }
.badge-info    { background: rgba(59,130,246,0.1);  color: var(--color-info);    }
.badge-muted   { background: rgba(143,149,168,0.1); color: var(--text-secondary); }

/* 테이블 */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
}

.table-wrap table {
    width: 100%;
    border-collapse: collapse;
}

.table-wrap th {
    background: var(--bg-tertiary);
    padding: 10px 14px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.table-wrap td {
    padding: 10px 14px;
    font-size: 13px;
    border-top: 1px solid var(--border-color);
}

.table-wrap tr:hover td {
    background: var(--bg-hover);
}

/* 토스트 */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: #fff;
    animation: toastIn 0.3s ease;
    box-shadow: var(--shadow-popup);
}

.toast-success { background: var(--color-success); }
.toast-error   { background: var(--color-danger);  }
.toast-info    { background: var(--color-info);     }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* 페이지네이션 */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 24px;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.pagination a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.pagination .active {
    background: var(--brand-primary);
    color: #fff;
}

/* 모달 */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(6px);
    z-index: 500;
    opacity: 0;
    transition: opacity var(--transition-normal);
    pointer-events: none;
}

.modal-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    z-index: 501;
    box-shadow: var(--shadow-popup);
    opacity: 0;
    transition: all var(--transition-normal);
    pointer-events: none;
    max-height: 85vh;
    overflow-y: auto;
}

.modal.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
    pointer-events: auto;
}

/* 필터 바 */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

/* 빈 상태 */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    text-align: center;
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.3;
}


/* ── 반응형 ──────────────────────────────────────── */

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

    body.sidebar-open .sidebar {
        transform: translateX(0);
        width: var(--sidebar-width);
    }

    .content-area {
        margin-left: 0;
    }
}

@media (max-width: 768px) {
    html {
        font-size: 13px;
    }

    .content-area {
        padding: 16px;
    }
}
