
/* ============================================================
   TOPS Design System v1.0
   - 디자인 토큰 (CSS Custom Properties)
   - 유틸리티 클래스
   - 컴포넌트 클래스
   
   사용법: 기존 main-style.css 앞에 로드
   <link rel="stylesheet" href="design-system.css">
   ============================================================ */

/* ============================================================
   1. DESIGN TOKENS
   ============================================================ */
:root {
    /* --- Colors: Brand (네이비+그린 리스킨) --- */
    --ds-primary: var(--primary-color, #1A2140);
    --ds-primary-light: var(--primary-light, #273154);
    --ds-secondary: var(--secondary-color, #1CB877);
    --ds-secondary-hover: var(--secondary-hover, #12995E);
    --ds-accent: #5B6BB5;

    /* --- Colors: Chart (다계열 차트 전용 단일 소스) ---
       차트는 계열 구분에 다색이 필요하지만, 페이지마다 팔레트를 따로 들고 있으면 같은 조직
       데이터가 화면마다 다른 색으로 보인다. 브랜드 네이비·그린에서 출발해 채도를 낮춘 6색을
       여기서만 정의하고 skills·admin·project가 공유한다. UI 배지에는 쓰지 말 것(색은 의미가
       있을 때만) — 배지는 --ds-tier-* 또는 무채색을 쓴다. */
    --ds-chart-1: #1A2140;
    --ds-chart-2: #1CB877;
    --ds-chart-3: #3B6EA5;
    --ds-chart-4: #E0A417;
    --ds-chart-5: #5B6BB5;
    --ds-chart-6: #7F93A8;

    /* --- Colors: Tier (자격증 등급처럼 '순서 있는 값') ---
       색상환에 흩어놓으면 위계가 읽히지 않는다. 하나의 네이비 계열에서 명도만 계단으로
       내려 상위 등급일수록 진하게. 배경은 전부 무채색. */
    --ds-tier-4: #1A2140;   /* Professional */
    --ds-tier-3: #3B6EA5;   /* Specialty */
    --ds-tier-2: #64748b;   /* Associate */
    --ds-tier-1: #94a3b8;   /* Foundational */

    /* --- Colors: Semantic --- */
    --ds-success: var(--success-color, #1CB877);
    --ds-success-hover: var(--success-hover, #12995E);
    --ds-warning: var(--warning-color, #E0A417);
    --ds-danger: var(--danger-color, #E24A4A);
    --ds-info: var(--info-color, #3B6EA5);

    /* --- Colors: Neutral (Slate scale) --- */
    --ds-gray-50: #f8f9fa;
    --ds-gray-100: #f1f5f9;
    --ds-gray-200: #e2e8f0;
    --ds-gray-300: #dee2e6;
    --ds-gray-400: #94a3b8;
    --ds-gray-500: #64748b;
    --ds-gray-600: #475569;
    --ds-gray-700: #374151;
    --ds-gray-800: #1e293b;
    --ds-gray-900: #0f172a;
    --ds-white: #ffffff;
    --ds-border: var(--ds-gray-200);
    --ds-muted: var(--ds-gray-500);

    /* --- Colors: AI --- */
    --ds-ai: #12995E;
    --ds-ai-bg: #E4F7EF;
    --ds-ai-border: #B7E9D1;

    /* --- Colors: OKR Levels --- */
    --ds-level-company: #5B6BB5;
    --ds-level-group: #3B4A73;
    --ds-level-team: #3B6EA5;
    --ds-level-individual: #1CB877;

    /* --- Typography --- */
    --ds-font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --ds-text-2xs: 10px;
    --ds-text-xs: 11px;
    --ds-text-sm: 12px;
    --ds-text-base: 13px;
    --ds-text-md: 14px;
    --ds-text-lg: 16px;
    --ds-text-xl: 18px;
    --ds-text-2xl: 22px;
    --ds-text-3xl: 28px;
    --ds-font-normal: 400;
    --ds-font-medium: 500;
    --ds-font-semibold: 600;
    --ds-font-bold: 700;
    --ds-leading-tight: 1.3;
    --ds-leading-normal: 1.5;
    --ds-leading-relaxed: 1.7;

    /* --- Spacing (4px base) --- */
    --ds-space-0: 0;
    --ds-space-1: 4px;
    --ds-space-2: 6px;
    --ds-space-3: 8px;
    --ds-space-4: 10px;
    --ds-space-5: 12px;
    --ds-space-6: 14px;
    --ds-space-7: 16px;
    --ds-space-8: 20px;
    --ds-space-9: 24px;
    --ds-space-10: 32px;
    --ds-space-12: 40px;
    --ds-space-16: 64px;

    /* --- Border Radius --- */
    --ds-radius-sm: 4px;
    --ds-radius-md: 6px;
    --ds-radius-lg: 8px;
    --ds-radius-xl: 12px;
    --ds-radius-full: 50%;

    /* --- Shadows --- */
    --ds-shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
    --ds-shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
    --ds-shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --ds-shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --ds-shadow-xl: 0 20px 60px rgba(0,0,0,0.2);
    --ds-shadow-accent: 0 4px 12px rgba(102,126,234,0.3);

    /* --- Transitions --- */
    --ds-transition-fast: 0.15s ease;
    --ds-transition-base: 0.2s ease;
    --ds-transition-slow: 0.3s ease;

    /* --- Z-index --- */
    --ds-z-dropdown: 100;
    --ds-z-sticky: 200;
    --ds-z-modal-backdrop: 9998;
    --ds-z-modal: 9999;
    --ds-z-toast: 10000;
}


/* ============================================================
   2. UTILITY CLASSES
   ============================================================ */

/* --- Display & Flex --- */
.ds-flex          { display: flex; }
.ds-inline-flex   { display: inline-flex; }
.ds-grid          { display: grid; }
.ds-hidden        { display: none; }
.ds-block         { display: block; }

.ds-items-center  { align-items: center; }
.ds-items-start   { align-items: flex-start; }
.ds-items-end     { align-items: flex-end; }
.ds-justify-center   { justify-content: center; }
.ds-justify-between  { justify-content: space-between; }
.ds-justify-end      { justify-content: flex-end; }
.ds-flex-col      { flex-direction: column; }
.ds-flex-wrap     { flex-wrap: wrap; }
.ds-flex-1        { flex: 1; }
.ds-flex-shrink-0 { flex-shrink: 0; }

/* --- Gap --- */
.ds-gap-1  { gap: var(--ds-space-1); }
.ds-gap-2  { gap: var(--ds-space-2); }
.ds-gap-3  { gap: var(--ds-space-3); }
.ds-gap-4  { gap: var(--ds-space-4); }
.ds-gap-5  { gap: var(--ds-space-5); }
.ds-gap-6  { gap: var(--ds-space-6); }
.ds-gap-8  { gap: var(--ds-space-8); }

/* --- Padding --- */
.ds-p-0  { padding: 0; }
.ds-p-3  { padding: var(--ds-space-3); }
.ds-p-4  { padding: var(--ds-space-4); }
.ds-p-5  { padding: var(--ds-space-5); }
.ds-p-8  { padding: var(--ds-space-8); }
.ds-p-9  { padding: var(--ds-space-9); }
.ds-px-3 { padding-left: var(--ds-space-3); padding-right: var(--ds-space-3); }
.ds-px-5 { padding-left: var(--ds-space-5); padding-right: var(--ds-space-5); }
.ds-py-3 { padding-top: var(--ds-space-3); padding-bottom: var(--ds-space-3); }
.ds-py-5 { padding-top: var(--ds-space-5); padding-bottom: var(--ds-space-5); }

/* --- Margin --- */
.ds-m-0   { margin: 0; }
.ds-mb-1  { margin-bottom: var(--ds-space-1); }
.ds-mb-2  { margin-bottom: var(--ds-space-2); }
.ds-mb-3  { margin-bottom: var(--ds-space-3); }
.ds-mb-4  { margin-bottom: var(--ds-space-4); }
.ds-mb-5  { margin-bottom: var(--ds-space-5); }
.ds-mb-8  { margin-bottom: var(--ds-space-8); }
.ds-mt-3  { margin-top: var(--ds-space-3); }
.ds-mt-5  { margin-top: var(--ds-space-5); }

/* --- Typography --- */
.ds-text-2xs { font-size: var(--ds-text-2xs); }
.ds-text-xs  { font-size: var(--ds-text-xs); }
.ds-text-sm  { font-size: var(--ds-text-sm); }
.ds-text-base{ font-size: var(--ds-text-base); }
.ds-text-md  { font-size: var(--ds-text-md); }
.ds-text-lg  { font-size: var(--ds-text-lg); }
.ds-text-xl  { font-size: var(--ds-text-xl); }
.ds-text-2xl { font-size: var(--ds-text-2xl); }
.ds-text-3xl { font-size: var(--ds-text-3xl); }

.ds-font-normal   { font-weight: var(--ds-font-normal); }
.ds-font-medium   { font-weight: var(--ds-font-medium); }
.ds-font-semibold { font-weight: var(--ds-font-semibold); }
.ds-font-bold     { font-weight: var(--ds-font-bold); }

.ds-leading-tight   { line-height: var(--ds-leading-tight); }
.ds-leading-normal  { line-height: var(--ds-leading-normal); }
.ds-leading-relaxed { line-height: var(--ds-leading-relaxed); }

.ds-text-center { text-align: center; }
.ds-text-right  { text-align: right; }
.ds-text-nowrap { white-space: nowrap; }
.ds-truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Colors --- */
.ds-text-primary  { color: var(--ds-primary); }
.ds-text-muted    { color: var(--ds-muted); }
.ds-text-gray-600 { color: var(--ds-gray-600); }
.ds-text-gray-700 { color: var(--ds-gray-700); }
.ds-text-white    { color: var(--ds-white); }
.ds-text-success  { color: var(--ds-success); }
.ds-text-danger   { color: var(--ds-danger); }
.ds-text-accent   { color: var(--ds-accent); }
.ds-text-ai       { color: var(--ds-ai); }

.ds-bg-white   { background: var(--ds-white); }
.ds-bg-gray-50 { background: var(--ds-gray-50); }
.ds-bg-gray-100{ background: var(--ds-gray-100); }

/* --- Border --- */
.ds-border     { border: 1px solid var(--ds-border); }
.ds-border-b   { border-bottom: 1px solid var(--ds-border); }
.ds-rounded-sm { border-radius: var(--ds-radius-sm); }
.ds-rounded    { border-radius: var(--ds-radius-md); }
.ds-rounded-lg { border-radius: var(--ds-radius-lg); }
.ds-rounded-xl { border-radius: var(--ds-radius-xl); }
.ds-rounded-full { border-radius: var(--ds-radius-full); }

/* --- Shadow --- */
.ds-shadow-sm { box-shadow: var(--ds-shadow-sm); }
.ds-shadow    { box-shadow: var(--ds-shadow-md); }
.ds-shadow-lg { box-shadow: var(--ds-shadow-lg); }

/* --- Width --- */
.ds-w-full { width: 100%; }

/* --- Cursor --- */
.ds-cursor-pointer { cursor: pointer; }
.ds-select-none    { user-select: none; }


/* ============================================================
   3. COMPONENT CLASSES
   ============================================================ */

/* --- Card --- */
.ds-card {
    background: var(--ds-white);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-xl);
    padding: var(--ds-space-9);
    box-shadow: var(--ds-shadow-sm);
}
.ds-card-compact {
    background: var(--ds-white);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    padding: var(--ds-space-7);
}

/* --- Modal --- */
.ds-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: var(--ds-z-modal-backdrop);
    display: flex;
    align-items: center;
    justify-content: center;
}
.ds-modal {
    background: var(--ds-white);
    border-radius: var(--ds-radius-xl);
    box-shadow: var(--ds-shadow-xl);
    max-height: 90vh;
    overflow-y: auto;
    width: 90%;
    max-width: 600px;
}
.ds-modal-lg { max-width: 800px; }
.ds-modal-xl { max-width: 1000px; }
.ds-modal-header {
    padding: var(--ds-space-8);
    border-bottom: 1px solid var(--ds-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.ds-modal-body { padding: var(--ds-space-8); }
.ds-modal-footer {
    padding: var(--ds-space-7) var(--ds-space-8);
    border-top: 1px solid var(--ds-border);
    display: flex;
    justify-content: flex-end;
    gap: var(--ds-space-3);
}

/* --- Form --- */
.ds-form-label {
    display: block;
    font-size: var(--ds-text-base);
    font-weight: var(--ds-font-semibold);
    color: var(--ds-gray-600);
    margin-bottom: var(--ds-space-2);
}
.ds-form-input,
.ds-form-select,
.ds-form-textarea {
    width: 100%;
    padding: var(--ds-space-4) var(--ds-space-5);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    font-size: var(--ds-text-base);
    font-family: var(--ds-font-family);
    color: var(--ds-gray-800);
    background: var(--ds-white);
    transition: border-color var(--ds-transition-fast);
}
.ds-form-input:focus,
.ds-form-select:focus,
.ds-form-textarea:focus {
    outline: none;
    border-color: var(--ds-secondary);
    box-shadow: 0 0 0 3px rgba(52,152,219,0.15);
}
.ds-form-group {
    margin-bottom: var(--ds-space-7);
}

/* --- Button --- */
.ds-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--ds-space-2);
    padding: var(--ds-space-3) var(--ds-space-7);
    border: none;
    border-radius: var(--ds-radius-md);
    font-size: var(--ds-text-md);
    font-weight: var(--ds-font-semibold);
    font-family: var(--ds-font-family);
    cursor: pointer;
    transition: all var(--ds-transition-base);
    white-space: nowrap;
}
.ds-btn:hover { transform: translateY(-1px); }
.ds-btn:active { transform: translateY(0); }

.ds-btn-primary {
    background: var(--ds-secondary);
    color: var(--ds-white);
}
.ds-btn-primary:hover {
    background: var(--ds-secondary-hover);
    color: var(--ds-white);
    box-shadow: 0 4px 12px rgba(52,152,219,0.3);
}
.ds-btn-accent {
    background: var(--ds-accent);
    color: var(--ds-white);
}
.ds-btn-accent:hover {
    background: #5a6fd6;
    color: var(--ds-white);
    box-shadow: var(--ds-shadow-accent);
}
.ds-btn-success {
    background: var(--ds-success);
    color: var(--ds-white);
}
.ds-btn-success:hover {
    background: var(--ds-success-hover);
    color: var(--ds-white);
}
.ds-btn-danger {
    background: var(--ds-danger);
    color: var(--ds-white);
}
.ds-btn-danger:hover {
    background: #c82333;
    color: var(--ds-white);
}
.ds-btn-ghost {
    background: transparent;
    color: var(--ds-gray-600);
}
.ds-btn-ghost:hover {
    background: var(--ds-gray-100);
}
.ds-btn-outline {
    background: var(--ds-white);
    color: var(--ds-gray-700);
    border: 1px solid var(--ds-gray-300);
}
.ds-btn-outline:hover {
    background: var(--ds-gray-50);
    border-color: var(--ds-gray-400);
}
.ds-btn-sm {
    padding: var(--ds-space-2) var(--ds-space-4);
    font-size: var(--ds-text-sm);
}
.ds-btn-lg {
    padding: var(--ds-space-5) var(--ds-space-9);
    font-size: var(--ds-text-lg);
    min-height: 48px;
}

/* --- Badge --- */
.ds-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px var(--ds-space-3);
    border-radius: var(--ds-radius-sm);
    font-size: var(--ds-text-xs);
    font-weight: var(--ds-font-semibold);
    white-space: nowrap;
}
.ds-badge-pill { border-radius: 999px; }
.ds-badge-primary { background: rgba(52,152,219,0.12); color: var(--ds-secondary); }
.ds-badge-success { background: rgba(39,174,96,0.12); color: var(--ds-success); }
.ds-badge-warning { background: rgba(243,156,18,0.12); color: var(--ds-warning); }
.ds-badge-danger  { background: rgba(220,53,69,0.12); color: var(--ds-danger); }
.ds-badge-gray    { background: var(--ds-gray-100); color: var(--ds-gray-600); }
.ds-badge-accent  { background: rgba(102,126,234,0.12); color: var(--ds-accent); }

/* --- Table --- */
.ds-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--ds-text-base);
}
.ds-table th {
    text-align: left;
    padding: var(--ds-space-4) var(--ds-space-5);
    background: var(--ds-gray-50);
    font-weight: var(--ds-font-semibold);
    color: var(--ds-gray-600);
    border-bottom: 2px solid var(--ds-border);
    font-size: var(--ds-text-sm);
}
.ds-table td {
    padding: var(--ds-space-4) var(--ds-space-5);
    border-bottom: 1px solid var(--ds-gray-100);
    color: var(--ds-gray-700);
}
.ds-table tbody tr:hover {
    background: var(--ds-gray-50);
}
.ds-table-sortable th {
    cursor: pointer;
    user-select: none;
}

/* --- Toast --- */
.ds-toast {
    position: fixed;
    top: var(--ds-space-8);
    right: var(--ds-space-8);
    padding: var(--ds-space-5) var(--ds-space-7);
    border-radius: var(--ds-radius-lg);
    color: var(--ds-white);
    font-size: var(--ds-text-md);
    font-weight: var(--ds-font-medium);
    z-index: var(--ds-z-toast);
    box-shadow: var(--ds-shadow-lg);
    animation: ds-toast-in 0.3s ease;
}
.ds-toast-success { background: var(--ds-success); }
.ds-toast-error   { background: var(--ds-danger); }
.ds-toast-warning { background: var(--ds-warning); }
.ds-toast-info    { background: var(--ds-info); }

@keyframes ds-toast-in {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- Progress Bar --- */
.ds-progress {
    width: 100%;
    height: 8px;
    background: var(--ds-gray-200);
    border-radius: var(--ds-radius-full);
    overflow: hidden;
}
.ds-progress-bar {
    height: 100%;
    border-radius: var(--ds-radius-full);
    background: var(--ds-secondary);
    transition: width var(--ds-transition-slow);
}

/* --- Divider --- */
.ds-divider {
    border: none;
    border-top: 1px solid var(--ds-border);
    margin: var(--ds-space-8) 0;
}

/* --- Loading Spinner --- */
.ds-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--ds-gray-200);
    border-top-color: var(--ds-secondary);
    border-radius: var(--ds-radius-full);
    animation: ds-spin 0.8s linear infinite;
}
.ds-spinner-lg { width: 48px; height: 48px; border-width: 4px; }

@keyframes ds-spin {
    to { transform: rotate(360deg); }
}

/* --- AI Highlight --- */
.ds-ai-card {
    background: var(--ds-ai-bg);
    border: 1px solid var(--ds-ai-border);
    border-radius: var(--ds-radius-lg);
    padding: var(--ds-space-7);
}

/* --- Empty State --- */
.ds-empty {
    text-align: center;
    padding: var(--ds-space-16) var(--ds-space-8);
    color: var(--ds-muted);
}
.ds-empty-icon {
    font-size: 48px;
    margin-bottom: var(--ds-space-5);
    opacity: 0.5;
}

/* --- Sortable Header Arrow --- */
.ds-sort-asc::after  { content: ' ▲'; font-size: 10px; }
.ds-sort-desc::after { content: ' ▼'; font-size: 10px; }
