@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;500;700&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-dark: #f8fafc; /* Slate 50 - Very clean, light background */
    --bg-card: rgba(255, 255, 255, 0.75); /* Light glassmorphism card */
    --bg-card-hover: rgba(255, 255, 255, 0.95);
    --border-glass: rgba(15, 23, 42, 0.08); /* Soft slate border */
    --text-primary: #0f172a; /* Slate 900 */
    --text-secondary: #64748b; /* Slate 500 */
    --primary: #2563eb; /* Royal blue */
    --primary-glow: rgba(37, 99, 235, 0.15);
    --accent: #7c3aed; /* Vibrant violet */
    --accent-glow: rgba(124, 58, 237, 0.15);
    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;
    --sidebar-width: 260px;
    --header-height: 70px;
    --font-main: 'Outfit', 'Noto Sans KR', sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 0% 0%, rgba(37, 99, 235, 0.06) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(124, 58, 237, 0.06) 0px, transparent 50%);
    color: var(--text-primary);
    font-family: var(--font-main);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

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

/* 폼 요소 스타일링 */
input, select, textarea {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 10px 16px;
    font-family: var(--font-main);
    font-size: 0.95rem;
    transition: var(--transition-smooth);
    width: 100%;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

button, .btn {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-main);
    font-weight: 500;
    padding: 10px 20px;
    transition: var(--transition-smooth);
    gap: 8px;
}

button:hover, .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--primary-glow);
    filter: brightness(1.1);
}

.btn-secondary {
    background: rgba(15, 23, 42, 0.04);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background: rgba(15, 23, 42, 0.08);
    box-shadow: none;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #f43f5e);
}
.btn-danger:hover {
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.35);
}

/* 메인 구조 레이아웃 */
#app-layout {
    display: flex;
    min-height: 100vh;
}

/* 사이드바 스타일 */
aside.sidebar {
    width: var(--sidebar-width);
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    transition: var(--transition-smooth);
}

.sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-glass);
}

.sidebar-brand h1 {
    font-size: 1.4rem;
    font-weight: 700;
    background: linear-gradient(135deg, #1d4ed8, #6d28d9);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.5px;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px;
    list-style: none;
}

.sidebar-menu li {
    margin-bottom: 8px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition-smooth);
    gap: 12px;
}

.sidebar-menu a:hover, .sidebar-menu li.active a {
    color: var(--text-primary);
    background: rgba(15, 23, 42, 0.04);
}

.sidebar-menu li.active a {
    background: linear-gradient(90deg, rgba(37, 99, 235, 0.08) 0%, rgba(124, 58, 237, 0.02) 100%);
    border-left: 3px solid var(--primary);
    padding-left: 13px;
}

.sidebar-user {
    padding: 20px;
    border-top: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-user .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.sidebar-user .user-meta {
    flex: 1;
    overflow: hidden;
}

.sidebar-user .user-name {
    font-size: 0.95rem;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.sidebar-user .user-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* 우측 메인 콘텐츠 */
main.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

header.top-header {
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.content-container {
    padding: 32px;
    flex: 1;
}

/* 카드 및 박스 컴포넌트 */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 24px;
    transition: var(--transition-smooth);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
}

.card:hover {
    background: var(--bg-card-hover);
    border-color: rgba(15, 23, 42, 0.12);
    box-shadow: 0 10px 30px rgba(37, 99, 235, 0.06);
}

.card-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* 테이블 스타일 */
.table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border-glass);
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
}

table.data-table th {
    background: rgba(15, 23, 42, 0.03);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-glass);
    white-space: nowrap;
}

table.data-table td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-glass);
    color: var(--text-primary);
    transition: var(--transition-smooth);
}

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

table.data-table tbody tr:hover td {
    background: rgba(15, 23, 42, 0.02);
}

/* 로그인 / 회원가입 센터 카드 */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    padding: 40px;
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #60a5fa, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

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

.auth-footer a:hover {
    text-decoration: underline;
}

/* 뱃지 / 상태 태그 */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(5, 150, 105, 0.1);
    color: #047857;
    border: 1px solid rgba(5, 150, 105, 0.15);
}

.badge-danger {
    background: rgba(220, 38, 38, 0.1);
    color: #b91c1c;
    border: 1px solid rgba(220, 38, 38, 0.15);
}

.badge-warning {
    background: rgba(217, 119, 6, 0.1);
    color: #b45309;
    border: 1px solid rgba(217, 119, 6, 0.15);
}

.badge-info {
    background: rgba(37, 99, 235, 0.1);
    color: #1d4ed8;
    border: 1px solid rgba(37, 99, 235, 0.15);
}

/* 유틸리티 */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-4 { margin-top: 1.5rem; }
.mb-4 { margin-bottom: 1.5rem; }
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-10 { gap: 10px; }

/* 반응형 모바일 대응 */
@media (max-width: 992px) {
    #mobile-toggle-btn {
        display: inline-flex !important;
    }
    
    #mobile-close-btn {
        display: inline-flex !important;
    }

    aside.sidebar {
        transform: translateX(-100%);
        height: 100vh;
        position: fixed;
        background: rgba(255, 255, 255, 0.96) !important;
        backdrop-filter: blur(25px);
        box-shadow: 0 0 30px rgba(15, 23, 42, 0.1);
    }
    
    main.main-content {
        margin-left: 0 !important;
    }
    
    aside.sidebar.active {
        transform: translateX(0) !important;
    }
    
    header.top-header {
        padding: 0 16px !important;
    }
    
    .content-container {
        padding: 16px !important;
    }

    /* 관리자 폼 및 필터가 모바일에서 개별 줄을 차지하도록 조정 */
    #stock-reg-form {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 15px !important;
    }
    
    #stock-reg-form .form-group {
        width: 100% !important;
    }
    
    #stock-reg-form button {
        width: 100% !important;
        padding: 12px !important;
    }

    .card-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .card-title form {
        width: 100%;
    }
    
    .card-title form input {
        flex: 1;
    }
    
    /* 테이블을 모바일에서 넘치지 않게 터치 스크롤 지원 */
    .table-wrapper {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
}

/* 페이징 네비게이션 스타일 */
.pagination-container {
    display: flex;
    justify-content: center;
    margin-top: 25px;
    margin-bottom: 10px;
}
.pagination {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
    gap: 6px;
    background: rgba(15, 23, 42, 0.03);
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: 30px;
    padding: 6px 12px;
    backdrop-filter: blur(8px);
}
.pagination .page-item {
    display: inline-block;
}
.pagination .page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border-radius: 50%;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.25s ease;
}
.pagination .page-link:hover {
    background: rgba(15, 23, 42, 0.05);
    color: var(--text-primary);
}
.pagination .page-item.active .page-link {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #ffffff;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
}

/* AI 예측 화면 고도화 전용 스타일 */
.badge-strong-buy {
    background: linear-gradient(135deg, #11998e, #38ef7d) !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    box-shadow: 0 2px 8px rgba(56, 239, 125, 0.35);
    border: none !important;
}

.badge-short-squeeze {
    background: linear-gradient(135deg, #8a2be2, #4a00e0) !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    box-shadow: 0 2px 8px rgba(138, 43, 226, 0.35);
    border: none !important;
}

.badge-buy-ready {
    background: linear-gradient(135deg, #00c6ff, #0072ff) !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    box-shadow: 0 2px 8px rgba(0, 114, 255, 0.35);
    border: none !important;
}

.badge-neutral-custom {
    background: linear-gradient(135deg, #bdc3c7, #2c3e50) !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    box-shadow: 0 2px 8px rgba(189, 195, 199, 0.35);
    border: none !important;
}

.badge-risk-exit {
    background: linear-gradient(135deg, #f857a6, #ff5858) !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    box-shadow: 0 2px 8px rgba(255, 88, 88, 0.35);
    border: none !important;
}

.ai-tooltip-trigger {
    position: relative;
    cursor: help;
    display: inline-block;
}

.ai-tooltip {
    visibility: hidden;
    width: 280px;
    background-color: rgba(15, 23, 42, 0.95);
    color: #fff;
    text-align: left;
    border-radius: 8px;
    padding: 12px;
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.8rem;
    line-height: 1.4;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    pointer-events: none;
    white-space: normal;
}

.ai-tooltip-trigger:hover .ai-tooltip {
    visibility: visible;
    opacity: 1;
}

.ai-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: rgba(15, 23, 42, 0.95) transparent transparent transparent;
}

/* AI 확신도 프로그레스 바 */
.gauge-container {
    width: 100px;
    background: rgba(15, 23, 42, 0.08);
    border-radius: 4px;
    height: 8px;
    overflow: hidden;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

.gauge-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease-in-out;
}

.gauge-high {
    background: linear-gradient(90deg, #11998e, #38ef7d);
}

.gauge-medium {
    background: linear-gradient(90deg, #00c6ff, #0072ff);
}

.gauge-low {
    background: linear-gradient(90deg, #f857a6, #ff5858);
}

/* 첫 번째 및 두 번째 행의 툴팁은 위가 아니라 아래로 표시되도록 조정 (상단 가림 방지) */
.data-table tbody tr:nth-child(-n+2) .ai-tooltip {
    bottom: auto;
    top: 125%;
}

.data-table tbody tr:nth-child(-n+2) .ai-tooltip::after {
    top: auto;
    bottom: 100%;
    border-color: transparent transparent rgba(15, 23, 42, 0.95) transparent;
}

/* 헤더 내부 툴팁은 아래로 노출 */
.data-table thead .ai-tooltip {
    bottom: auto;
    top: 125%;
}

.data-table thead .ai-tooltip::after {
    top: auto;
    bottom: 100%;
    border-color: transparent transparent rgba(15, 23, 42, 0.95) transparent;
}


