/*
 * TotalLiving Dark Mode Common Styles
 * 다크모드 공통 CSS (모든 페이지에서 사용)
 */

/* ============================================================================
   CSS Variables - Dark Mode Color Palette
   ============================================================================ */
:root {
    /* Background Colors */
    --bg-primary: #1a1a1a;          /* 메인 배경 (가장 어두움) */
    --bg-secondary: #2d2d2d;        /* 카드 배경 */
    --bg-tertiary: #3a3a3a;         /* 테이블 헤더, 버튼 배경 */
    --bg-hover: #353535;            /* 호버 상태 */
    --bg-input: #252525;            /* Input 배경 */

    /* Text Colors */
    --text-primary: #f1f1f1;        /* 주요 텍스트 (밝은 회색) */
    --text-secondary: #b0b0b0;      /* 보조 텍스트 */
    --text-muted: #808080;          /* 비활성/회색 텍스트 */
    --text-inverse: #1a1a1a;        /* 역방향 텍스트 (배지 등) */

    /* Border & Shadow */
    --border-color: #4a4a4a;        /* 테두리 색상 */
    --border-light: #3a3a3a;        /* 연한 테두리 */
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 20px rgba(102, 126, 234, 0.3);

    /* Primary Colors (청록/민트 그라디언트) */
    --primary-start: #06B6D4;       /* Primary 그라디언트 시작 (시안) */
    --primary-end: #10B981;         /* Primary 그라디언트 끝 (민트) */
    --primary-color: #06B6D4;       /* Primary 단색 */
    --primary-hover: #0891b2;       /* Primary 호버 */

    /* Status Colors (KT UI 참고) */
    --success-color: #10B981;       /* 정상 (민트 초록) */
    --success-bg: rgba(16, 185, 129, 0.1);
    --success-border: rgba(16, 185, 129, 0.3);

    --warning-color: #F59E0B;       /* 주의 (노랑) */
    --warning-bg: rgba(245, 158, 11, 0.1);
    --warning-border: rgba(245, 158, 11, 0.3);

    --danger-color: #EF4444;        /* 비정상/긴급 (빨강) */
    --danger-bg: rgba(239, 68, 68, 0.1);
    --danger-border: rgba(239, 68, 68, 0.3);

    --high-color: #F97316;          /* 높음 (오렌지) */
    --high-bg: rgba(249, 115, 22, 0.1);
    --high-border: rgba(249, 115, 22, 0.3);

    --info-color: #06B6D4;          /* 정보 (청록) */
    --info-bg: rgba(6, 182, 212, 0.1);
    --info-border: rgba(6, 182, 212, 0.3);

    /* Chart Colors */
    --chart-line-1: #667eea;        /* 평균 전류 */
    --chart-line-2: #F97316;        /* 최대 전류 */
    --chart-bar-1: #10B981;         /* 투입량 */
    --chart-bar-2: #06B6D4;         /* 감소량 */
    --chart-donut-1: #EF4444;       /* CRITICAL */
    --chart-donut-2: #F97316;       /* HIGH */
    --chart-donut-3: #F59E0B;       /* MEDIUM */
    --chart-donut-4: #10B981;       /* LOW */

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans KR', 'Apple SD Gothic Neo', sans-serif;
    color: var(--text-primary);
    background: var(--bg-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================================================
   Header Styles (간소화 - 아이콘 제거, 패딩 축소)
   ============================================================================ */
.header {
    background: white;
    color: #1a1a1a;
    padding: 0.75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid #e5e5e5;
    height: 60px;
}

.header-container {
    max-width: 100%;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo {
    height: 40px;
    /* 로고 이미지 그대로 사용 (필터 제거) */
}

.logo-text {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.current-time {
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.3px;
    color: #1a1a1a;
}

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

.user-name {
    font-weight: 500;
    font-size: 0.85rem;
    color: #1a1a1a;
}

.logout-btn {
    background: #f5f5f5;
    border: 1px solid #e5e5e5;
    color: #1a1a1a;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-normal);
    font-size: 0.85rem;
    font-weight: 500;
}

.logout-btn:hover {
    background: #e5e5e5;
    border-color: #d4d4d4;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ============================================================================
   Navigation Styles (간소화 - 아이콘 제거, 패딩 축소)
   ============================================================================ */
.navigation {
    background: var(--bg-secondary);
    box-shadow: var(--shadow);
    position: sticky;
    top: 60px;
    z-index: 999;
    border-bottom: 1px solid var(--border-color);
    height: 55px;
}

.nav-container {
    max-width: 100%;
    margin: 0 auto;
    display: flex;
    gap: 0;
    height: 100%;
}

.nav-item {
    flex: 1;
    text-align: center;
    padding: 0.75rem 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    transition: all var(--transition-normal);
    border-bottom: 3px solid transparent;
    position: relative;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: var(--bg-hover);
}

.nav-item.active::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-start), var(--primary-end));
    box-shadow: var(--shadow-glow);
}

/* ============================================================================
   Main Container (패딩 축소)
   ============================================================================ */
.main-container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    flex: 1;
}

/* ============================================================================
   Cards
   ============================================================================ */
.card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    transition: all var(--transition-normal);
    border: 1px solid var(--border-light);
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-header {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-primary);
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 0.5rem 0;
}

/* ============================================================================
   Stat Cards (통계 카드 - KT UI 스타일)
   ============================================================================ */
.stat-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow);
    transition: all var(--transition-normal);
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-start), var(--primary-end));
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.stat-card.critical::before {
    background: var(--danger-color);
}

.stat-card.high::before {
    background: var(--high-color);
}

.stat-card.warning::before {
    background: var(--warning-color);
}

.stat-card.success::before {
    background: var(--success-color);
}

.stat-card.info::before {
    background: var(--info-color);
}

.stat-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 0.5rem 0;
    background: linear-gradient(135deg, var(--primary-start), var(--primary-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card.critical .stat-value {
    background: var(--danger-color);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card.high .stat-value {
    background: var(--high-color);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card.warning .stat-value {
    background: var(--warning-color);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card.success .stat-value {
    background: var(--success-color);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card.info .stat-value {
    background: var(--info-color);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

/* ============================================================================
   Buttons
   ============================================================================ */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    text-decoration: none;
    display: inline-block;
    font-size: 1rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-start), var(--primary-end));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

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

.btn-secondary:hover {
    background: var(--bg-hover);
}

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

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

.btn-warning {
    background: var(--warning-color);
    color: var(--text-inverse);
}

.btn-info {
    background: var(--info-color);
    color: white;
}

/* ============================================================================
   Badges (KT UI 참고)
   ============================================================================ */
.badge {
    display: inline-block;
    padding: 0.4rem 1rem;
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success-color);
    border: 1px solid var(--success-border);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger-color);
    border: 1px solid var(--danger-border);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning-color);
    border: 1px solid var(--warning-border);
}

.badge-high {
    background: var(--high-bg);
    color: var(--high-color);
    border: 1px solid var(--high-border);
}

.badge-info {
    background: var(--info-bg);
    color: var(--info-color);
    border: 1px solid var(--info-border);
}

.badge-primary {
    background: linear-gradient(135deg, var(--primary-start), var(--primary-end));
    color: white;
}

/* ============================================================================
   Loading Overlay
   ============================================================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 26, 26, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-overlay .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* ============================================================================
   Tables
   ============================================================================ */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
}

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

thead {
    background: var(--bg-tertiary);
}

th {
    padding: 1rem;
    text-align: left;
    font-weight: 700;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
}

tbody tr {
    transition: all var(--transition-fast);
}

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

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

/* ============================================================================
   Grid System
   ============================================================================ */
.grid {
    display: grid;
    gap: 1.5rem;
}

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

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.grid-6 {
    grid-template-columns: repeat(6, 1fr);
}

/* ============================================================================
   Footer
   ============================================================================ */
.footer {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 2rem;
    margin-top: auto;
    border-top: 1px solid var(--border-color);
}

.footer-container {
    max-width: 1800px;
    margin: 0 auto;
    text-align: center;
}

.footer-text {
    font-size: 0.9rem;
}

/* ============================================================================
   Utility Classes
   ============================================================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success-color); }
.text-danger { color: var(--danger-color); }
.text-warning { color: var(--warning-color); }
.text-info { color: var(--info-color); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--spacing-sm); }
.mt-2 { margin-top: var(--spacing-md); }
.mt-3 { margin-top: var(--spacing-lg); }
.mt-4 { margin-top: var(--spacing-xl); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--spacing-sm); }
.mb-2 { margin-bottom: var(--spacing-md); }
.mb-3 { margin-bottom: var(--spacing-lg); }
.mb-4 { margin-bottom: var(--spacing-xl); }

.p-0 { padding: 0; }
.p-1 { padding: var(--spacing-sm); }
.p-2 { padding: var(--spacing-md); }
.p-3 { padding: var(--spacing-lg); }
.p-4 { padding: var(--spacing-xl); }

/* ============================================================================
   Animations
   ============================================================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

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

.fade-in {
    animation: fadeIn 0.5s ease-out;
}

/* ============================================================================
   Loading Spinner
   ============================================================================ */
.spinner {
    border: 4px solid var(--bg-tertiary);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

.spinner-small {
    width: 24px;
    height: 24px;
    border-width: 3px;
}

/* ============================================================================
   Responsive Design
   ============================================================================ */
@media (max-width: 1400px) {
    .grid-6 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .header-container {
        padding: 0 1rem;
    }

    .logo-text {
        font-size: 1.2rem;
    }

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

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

    .nav-item {
        font-size: 0.9rem;
        padding: 0.75rem;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 0.75rem 1rem;
    }

    .logo {
        height: 36px;
    }

    .logo-text {
        font-size: 1rem;
    }

    .current-time {
        display: none;
    }

    .navigation {
        top: 60px;
    }

    .nav-item {
        font-size: 0.8rem;
        padding: 0.6rem 0.5rem;
    }

    .main-container {
        padding: 0 1rem;
    }

    .grid-2,
    .grid-3,
    .grid-4,
    .grid-6 {
        grid-template-columns: 1fr;
    }

    .stat-value {
        font-size: 2rem;
    }

    .stat-icon {
        font-size: 2rem;
    }

    .card {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .user-name {
        display: none;
    }

    .stat-value {
        font-size: 1.5rem;
    }

    .card-header {
        font-size: 1rem;
    }
}
