/* ???????????????????????????????????????????????????
   메인 대시보드
   ??????????????????????????????????????????????????? */

.main-page {
    display: flex;
    min-height: 100vh;
}

/* 사이드바 */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.sidebar-brand {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--gradient-subtle);
    color: var(--accent-cyan);
    border: 1px solid rgba(0, 240, 255, 0.15);
}

.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px;
    border-top: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.85rem;
    color: #0a0e17;
}

.user-detail {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-role {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.logout-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--accent-red);
}

.logout-btn svg {
    width: 18px;
    height: 18px;
}

/* 메인 콘텐츠 */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 28px 32px;
    min-height: 100vh;
    overflow: auto;
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tab-header {
    margin-bottom: 24px;
}

.tab-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
}

.tab-title svg {
    width: 28px;
    height: 28px;
    color: var(--accent-cyan);
}

.tab-description {
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin-top: 6px;
}

/* ── 검색 ── */
.search-section {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
}

.search-bar {
    flex: 1;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    pointer-events: none;
    z-index: 2;
}

.search-bar input {
    width: 100%;
    padding: 14px 16px 14px 48px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    outline: none;
    transition: all 0.25s;
}

.search-bar input:focus {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.1);
}

.search-bar input::placeholder {
    color: var(--text-muted);
}

.search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    max-height: 320px;
    overflow-y: auto;
    z-index: 50;
    box-shadow: var(--shadow-lg);
}

.search-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-color);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background: rgba(0, 240, 255, 0.05);
}

.result-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.result-symbol {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--accent-cyan);
}

.result-name {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.result-exchange {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 3px 8px;
    border-radius: 4px;
}

.result-exchange.rec-badge {
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.2);
}

/* 액션 버튼 */
.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
    white-space: nowrap;
}

.action-btn svg {
    width: 18px;
    height: 18px;
}

.save-btn {
    background: var(--gradient-primary);
    color: #0a0e17;
}

.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 240, 255, 0.25);
}

.reset-btn {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.reset-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.15);
}

.add-btn {
    background: var(--accent-green);
    color: #fff;
}

.add-btn:hover {
    background: #059669;
}

/* 선택된 종목 */
.selected-stock-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--gradient-subtle);
    border: 1px solid rgba(0, 240, 255, 0.15);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}

.stock-symbol {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 1rem;
    color: var(--accent-cyan);
}

.stock-name {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.stock-price {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    color: var(--text-primary);
}

/* ── 차트 컨트롤 ── */
.chart-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.chart-timeframes {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 3px;
}

.tf-btn {
    padding: 6px 14px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tf-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.tf-btn.active {
    background: rgba(0, 240, 255, 0.1);
    color: var(--accent-cyan);
    font-weight: 600;
}

.chart-indicators {
    display: flex;
    gap: 4px;
    align-items: center;
    overflow-x: auto;
    padding-bottom: 2px;
}

.ind-btn {
    padding: 5px 10px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ind-btn:hover {
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--text-secondary);
}

.ind-btn.active[data-sma="5"] {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.4);
    color: #f59e0b;
}

.ind-btn.active[data-sma="20"] {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #ef4444;
}

.ind-btn.active[data-sma="60"] {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.4);
    color: #10b981;
}

.ind-btn.active[data-sma="120"] {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.4);
    color: #8b5cf6;
}

.tv-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    margin-left: 4px;
}

.tv-link:hover {
    border-color: rgba(0, 240, 255, 0.3);
    color: var(--accent-cyan);
    background: rgba(0, 240, 255, 0.05);
}

.tv-link svg {
    flex-shrink: 0;
}

/* ???????????????????????????????????????????????????
   반응형
   ??????????????????????????????????????????????????? */

@media (max-width: 1024px) {
    .market-indices-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .market-top-grid {
        grid-template-columns: 1fr;
    }

    .finder-content {
        grid-template-columns: 1fr;
        height: auto;
    }

    .chart-section {
        min-height: 450px;
    }

    .news-section {
        max-height: 400px;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }

    .sidebar {
        transform: translateX(-100%);
        width: 260px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 20px 16px;
    }

    .recommendations-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        flex-direction: column;
    }

    .form-row input {
        width: 100%;
    }
}

/* ???????????????????????????????????????????????????
   PC / Phone 모드 선택 (로그인 화면)
   ??????????????????????????????????????????????????? */
.mode-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.mode-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.mode-toggle {
    display: flex;
    gap: 8px;
}

.mode-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
}

.mode-btn svg {
    width: 18px;
    height: 18px;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.mode-btn.active {
    background: var(--gradient-subtle);
    border-color: rgba(0, 240, 255, 0.3);
    color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.1);
}

/* ???????????????????????????????????????????????????
   사이드바 모드 전환 버튼
   ??????????????????????????????????????????????????? */
.mode-switch-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--accent-cyan);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
}

.mode-switch-btn:hover {
    background: var(--gradient-subtle);
    border-color: rgba(0, 240, 255, 0.3);
    box-shadow: 0 0 12px rgba(0, 240, 255, 0.1);
}

/* ???????????????????????????????????????????????????
   PC 모드 ? 최소 크기 + 스크롤바
   ??????????????????????????????????????????????????? */
body.mode-pc .main-page {
    min-width: 1200px;
}

body.mode-pc .main-content {
    min-width: 900px;
    overflow: auto;
}

body.mode-pc .finder-content {
    min-width: 860px;
}

body.mode-pc .chart-controls {
    min-width: 600px;
}

body.mode-pc .discussion-layout {
    min-width: 700px;
}

/* ???????????????????????????????????????????????????
   Phone 모드 ? 모바일 최적화 레이아웃
   ??????????????????????????????????????????????????? */
body.mode-phone .sidebar {
    display: none !important;
}

body.mode-phone .main-content {
    margin-left: 0 !important;
    padding: 16px !important;
    padding-bottom: 80px !important;
}

/* 하단 네비게이션 바 */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: none;
    justify-content: space-around;
    align-items: center;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 8px 0;
    z-index: 2000;
    height: 64px;
    backdrop-filter: blur(10px);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.68rem;
    cursor: pointer;
    transition: color 0.2s;
    padding: 4px 8px;
}

.bottom-nav-item svg {
    width: 22px;
    height: 22px;
}

.bottom-nav-item.active {
    color: var(--accent-cyan);
}

.bottom-nav-item:hover {
    color: var(--text-primary);
}

/* 플로팅 Phone 복구 버튼 (PC 모드에서 표시) */
.floating-mode-btn {
    position: fixed;
    right: 24px;
    bottom: 24px;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 56px;
    height: 56px;
    background: var(--gradient-primary);
    border: none;
    border-radius: 50%;
    color: #0a0e17;
    font-size: 0.6rem;
    font-weight: 700;
    box-shadow: var(--shadow-md), 0 0 20px rgba(0, 240, 255, 0.3);
    cursor: pointer;
    z-index: 1000;
    transition: transform 0.2s, box-shadow 0.2s;
}

.floating-mode-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg), 0 0 25px rgba(0, 240, 255, 0.4);
}

.floating-mode-btn svg {
    width: 22px;
    height: 22px;
}

/* Phone 모드 ? 그리드/레이아웃 재구성 */
body.mode-phone .finder-content {
    grid-template-columns: 1fr !important;
    gap: 16px;
}

/* Phone 모드 — 뉴스 사이드 패널 접기 (헤더 유지, 본문만 숨김) */
body.mode-phone .side-panel {
    width: auto !important;
    min-width: 0 !important;
}

body.mode-phone .side-panel.collapsed {
    width: auto !important;
    min-width: 0 !important;
}

body.mode-phone .side-panel.collapsed .side-panel-header {
    position: static;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    flex-direction: row;
}

body.mode-phone .side-panel.collapsed .side-panel-title {
    display: inline;
}

body.mode-phone .side-panel.collapsed .side-panel-toggle-btn {
    writing-mode: horizontal-tb;
    padding: 4px 10px;
    margin-left: auto;
}

body.mode-phone .news-panel {
    max-height: none;
}

body.mode-phone .side-panel-body {
    max-height: 560px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

body.mode-phone .side-panel-body::-webkit-scrollbar {
    width: 4px;
}

body.mode-phone .side-panel-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

body.mode-phone .chart-controls {
    flex-direction: column;
    gap: 6px;
}

/* Phone 모드 ? 타임프레임 + 차트유형 한 줄 표시 */
body.mode-phone .chart-timeframes {
    width: 100%;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 2px;
    padding: 2px;
}

body.mode-phone .tf-btn {
    padding: 4px 8px;
    font-size: 0.68rem;
}

body.mode-phone .chart-type-btn {
    padding: 4px 8px;
    font-size: 0.68rem;
}

/* Phone 모드 ? 차트 분석도구 한 줄 표시 */
body.mode-phone .chart-indicators {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    gap: 3px;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

body.mode-phone .chart-indicators::-webkit-scrollbar {
    height: 3px;
}

body.mode-phone .chart-indicators::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

body.mode-phone .ind-btn {
    padding: 3px 6px;
    font-size: 0.62rem;
    white-space: nowrap;
    flex-shrink: 0;
}

body.mode-phone .ind-group-label {
    font-size: 0.58rem;
    white-space: nowrap;
    flex-shrink: 0;
}

body.mode-phone .ind-sep {
    height: 14px;
    margin: 0 2px;
    flex-shrink: 0;
}

body.mode-phone .ind-input {
    width: 32px;
    padding: 2px 4px;
    font-size: 0.62rem;
    flex-shrink: 0;
}

body.mode-phone .tv-link {
    padding: 3px 6px;
    font-size: 0.62rem;
    white-space: nowrap;
    flex-shrink: 0;
}

body.mode-phone .recommendations-grid {
    grid-template-columns: 1fr !important;
}

body.mode-phone .form-row {
    flex-direction: column;
}

body.mode-phone .form-row input {
    width: 100%;
}

body.mode-phone .search-bar input,
body.mode-phone .action-btn {
    padding: 14px;
    font-size: 1rem;
}

body.mode-phone .save-btn {
    font-size: 0;
    padding: 10px;
    gap: 0;
}

body.mode-phone .save-btn svg {
    width: 20px;
    height: 20px;
}

body.mode-phone .reset-btn {
    font-size: 0;
    padding: 10px;
    gap: 0;
}

body.mode-phone .reset-btn svg {
    width: 20px;
    height: 20px;
}

body.mode-phone .selected-stock-info {
    flex-wrap: wrap;
    gap: 4px 10px;
    padding: 10px 14px;
}

body.mode-phone .stock-price {
    width: 100%;
    margin-left: 0;
    font-size: 0.88rem;
    padding-top: 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

body.mode-phone .tab-title {
    font-size: 1.2rem;
}

/* Phone 모드 ? 토론 레이아웃 */
body.mode-phone .discussion-layout {
    grid-template-columns: 1fr !important;
}

body.mode-phone .users-panel {
    max-height: 150px;
    order: -1;
}

body.mode-phone .chat-input-area {
    padding: 12px;
}

body.mode-phone .chat-input-area input {
    padding: 14px;
    font-size: 1rem;
}

/* Phone 모드 ? 관리 탭 테이블 가로 스크롤 */
body.mode-phone .users-table-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px;
}

body.mode-phone .users-table {
    min-width: 700px;
}

body.mode-phone .admin-add-user {
    overflow-x: visible;
}

/* Phone 모드 증시 현황 */
body.mode-phone .market-indices-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

body.mode-phone .market-index-card {
    padding: 14px;
}

body.mode-phone .mic-price {
    font-size: 1.1rem;
}

body.mode-phone .market-top-grid {
    grid-template-columns: 1fr;
    gap: 12px;
}

body.mode-phone .market-top-section {
    padding: 14px;
}

body.mode-phone .market-top-table {
    font-size: 0.68rem;
}

body.mode-phone .market-top-table td {
    padding: 7px 4px;
}

body.mode-phone .market-top-table .mtt-name {
    max-width: 80px;
    font-size: 0.68rem;
}

body.mode-phone .market-top-table .mtt-rank {
    width: 22px;
}

body.mode-phone .market-top-table thead th {
    font-size: 0.62rem;
    padding: 6px 4px;
}

body.mode-phone .market-investor-grid {
    grid-template-columns: 1fr;
    gap: 10px;
}

body.mode-phone .investor-subtitle {
    font-size: 0.75rem;
}

