/* ========================================
   성과운영 시스템 - Base Styles
   ======================================== */

/* CSS Custom Properties */
:root {
    /* Primary Colors - 성과/목표 테마 */
    --primary-color: #6366f1;        /* Indigo - 목표/성과 */
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;

    /* Semantic Colors */
    --success-color: #10b981;        /* Green - 달성/완료 */
    --danger-color: #ef4444;         /* Red - 위험/지연 */
    --warning-color: #f59e0b;        /* Amber - 주의 */
    --info-color: #3b82f6;           /* Blue - 정보 */

    /* Signal Light Colors */
    --signal-red: #ef4444;           /* 위험 (<40%) */
    --signal-yellow: #f59e0b;        /* 주의 (40-70%) */
    --signal-green: #10b981;         /* 양호 (70%+) */

    /* Growth Theme Colors */
    --growth-color: #8b5cf6;         /* Purple - 성장/역량 */
    --growth-light: #a78bfa;

    /* Neutral Colors */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Layout */
    --header-height: 64px;
    --sidebar-width: 260px;
    --sidebar-icon-width: 72px;
    --content-max-width: 1400px;

    /* Spacing */
    --gap-sm: 0.5rem;
    --gap-md: 1rem;
    --gap-lg: 1.5rem;
    --gap-xl: 2rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

    /* Transitions */
    --transition-fast: 150ms;
    --transition-base: 200ms;
    --transition-slow: 300ms;
}

/* ========================================
   Base Styles
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--gray-800);
    background-color: var(--gray-50);
    overflow-x: hidden;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color var(--transition-base);
}

a:hover {
    color: var(--primary-dark);
}

/* ========================================
   Layout Structure
   ======================================== */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    z-index: 1000;
    transition: left var(--transition-base);
}

.app-header.with-sidebar {
    left: var(--sidebar-width);
}

.app-header.with-sidebar-icon {
    left: var(--sidebar-icon-width);
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
}

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

.header-search {
    flex: 1;
    max-width: 500px;
    margin: 0 2rem;
}

.header-search input {
    width: 100%;
    padding: 0.5rem 1rem 0.5rem 2.5rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-lg);
    background: var(--gray-50);
    transition: all var(--transition-base);
}

.header-search input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-action {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--gray-600);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
}

.header-action:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.header-action.active {
    background: var(--primary-light);
    color: white;
}

.header-action .badge {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--danger-color);
    color: white;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: background var(--transition-base);
}

.user-menu:hover {
    background: var(--gray-100);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    color: var(--gray-900);
    font-size: 0.875rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* Sidebar */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--gray-200);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transition: width var(--transition-base);
    overflow: hidden;
}

.app-sidebar.icon-mode {
    width: var(--sidebar-icon-width);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
    white-space: nowrap;
}

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

.sidebar-toggle {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--gray-600);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-base);
}

.sidebar-toggle:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 0;
}

.sidebar-nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

.nav-item {
    margin: 0.25rem 0.75rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: var(--gray-700);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
}

.nav-link:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.nav-link.active {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
}

.nav-link i {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

.nav-label {
    flex: 1;
}

.nav-badge {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--danger-color);
    color: white;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-link.active .nav-badge {
    background: rgba(255, 255, 255, 0.3);
}

/* Accordion Menu */
.nav-accordion {
    margin: 0.25rem 0.75rem;
}

.accordion-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: var(--gray-700);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
}

.accordion-header:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.accordion-header.active {
    color: var(--primary-color);
}

.accordion-header i.icon {
    font-size: 1.25rem;
    width: 24px;
    text-align: center;
}

.accordion-header i.chevron {
    margin-left: auto;
    transition: transform var(--transition-base);
}

.accordion-header.active i.chevron {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-base);
}

.accordion-content.open {
    max-height: 500px;
}

.accordion-content .nav-link {
    padding: 0.5rem 1rem 0.5rem 3.5rem;
    font-weight: 400;
    font-size: 0.875rem;
}

/* Main Content */
.app-main {
    margin-top: var(--header-height);
    margin-left: var(--sidebar-width);
    padding: 2rem;
    transition: margin-left var(--transition-base);
    min-height: calc(100vh - var(--header-height));
}

.app-main.with-sidebar-icon {
    margin-left: var(--sidebar-icon-width);
}

.app-main.no-sidebar {
    margin-left: 0;
}

.page-header {
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.page-subtitle {
    color: var(--gray-600);
    font-size: 0.875rem;
}

/* ========================================
   Components
   ======================================== */

/* Stat Card */
.stat-card {
    background: white;
    border: 1px solid var(--gray-200);
    transition: all var(--transition-base);
}

.stat-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
}

.stat-icon.success {
    background: linear-gradient(135deg, var(--success-color), #34d399);
    color: white;
}

.stat-icon.danger {
    background: linear-gradient(135deg, var(--danger-color), #f87171);
    color: white;
}

.stat-icon.warning {
    background: linear-gradient(135deg, var(--warning-color), #fbbf24);
    color: white;
}

.stat-icon.growth {
    background: linear-gradient(135deg, var(--growth-color), var(--growth-light));
    color: white;
}

.stat-trend {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
}

.stat-trend.up {
    background: #d1fae5;
    color: var(--success-color);
}

.stat-trend.down {
    background: #fee2e2;
    color: var(--danger-color);
}

/* Red Flag Alert */
.red-flag-section {
    margin-bottom: 2rem;
}

.red-flag-alert {
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    border: 2px solid var(--danger-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.red-flag-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.red-flag-header i {
    font-size: 1.5rem;
    color: var(--danger-color);
}

.red-flag-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--danger-color);
}

.red-flag-item {
    background: white;
    border-left: 4px solid var(--danger-color);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.red-flag-item:last-child {
    margin-bottom: 0;
}

.red-flag-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--danger-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.red-flag-content {
    flex: 1;
}

.red-flag-label {
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 0.25rem;
}

.red-flag-description {
    font-size: 0.875rem;
    color: var(--gray-600);
}

/* Signal Light */
.signal-light {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-lg);
    font-weight: 600;
}

.signal-light.red {
    background: #fee2e2;
    color: var(--signal-red);
}

.signal-light.yellow {
    background: #fef3c7;
    color: var(--signal-yellow);
}

.signal-light.green {
    background: #d1fae5;
    color: var(--signal-green);
}

.signal-light i {
    font-size: 1.25rem;
}

/* Progress Bar */
.progress-bar-container {
    margin: 1rem 0;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.progress-bar {
    height: 10px;
    background: var(--gray-200);
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 5px;
    transition: width var(--transition-slow);
}

.progress-fill.red {
    background: linear-gradient(90deg, var(--signal-red), #f87171);
}

.progress-fill.yellow {
    background: linear-gradient(90deg, var(--signal-yellow), #fbbf24);
}

.progress-fill.green {
    background: linear-gradient(90deg, var(--signal-green), #34d399);
}

/* Quick Menu */
.quick-menu {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.quick-menu-item {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
}

.quick-menu-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.quick-menu-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
}

.quick-menu-label {
    font-weight: 600;
    color: var(--gray-900);
}

/* Chart Container */
.chart-container {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.chart-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--gray-900);
}

.chart-actions {
    display: flex;
    gap: 0.5rem;
}

/* Table */
.table-container {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

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

.table thead {
    background: var(--gray-50);
}

.table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--gray-700);
    border-bottom: 2px solid var(--gray-200);
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.table tbody tr {
    transition: background var(--transition-base);
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 600;
}

.badge.primary {
    background: var(--primary-light);
    color: white;
}

.badge.success {
    background: var(--success-color);
    color: white;
}

.badge.danger {
    background: var(--danger-color);
    color: white;
}

.badge.warning {
    background: var(--warning-color);
    color: white;
}

.badge.growth {
    background: var(--growth-color);
    color: white;
}

/* ========================================
   Responsive Design
   ======================================== */

/* Tablet */
@media (max-width: 1024px) {
    .app-sidebar {
        width: var(--sidebar-icon-width);
    }

    .app-header.with-sidebar {
        left: var(--sidebar-icon-width);
    }

    .app-main {
        margin-left: var(--sidebar-icon-width);
    }

    .header-search {
        max-width: 300px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-sidebar.open {
        transform: translateX(0);
    }

    .app-header {
        left: 0 !important;
    }

    .app-main {
        margin-left: 0;
        padding: 1rem;
    }

    .header-search {
        display: none;
    }

    .quick-menu {
        grid-template-columns: repeat(2, 1fr);
    }

    .user-info {
        display: none;
    }
}

/* ========================================
   Organization Chart Styles
   ======================================== */
.org-chart {
    padding: 2rem;
    overflow-x: auto;
}

.org-node {
    display: inline-block;
    margin: 0 1rem;
    vertical-align: top;
}

.org-node.root {
    display: block;
    text-align: center;
    margin-bottom: 3rem;
}

.org-level {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.org-sublevel {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
    justify-content: center;
}

.org-card {
    background: white;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1rem;
    min-width: 200px;
    text-align: center;
    transition: all var(--transition-base);
    cursor: pointer;
}

.org-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.org-node.small .org-card {
    min-width: 150px;
    padding: 0.75rem;
}

.org-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.5rem;
    margin: 0 auto 0.75rem;
}

.org-avatar.small {
    width: 40px;
    height: 40px;
    font-size: 1rem;
}

.org-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.org-role {
    color: var(--gray-600);
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.org-count {
    color: var(--gray-500);
    font-size: 0.75rem;
}
