/* ===================================
   StockTracker Pro - Custom Styles
   =================================== */

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

body {
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Navigation Links */
.nav-link {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    color: #6B7280;
    font-weight: 500;
    text-decoration: none;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
}

.nav-link:hover {
    color: #1A2332;
    background-color: #F3F4F6;
}

.dark .nav-link:hover {
    color: #FFD700;
    background-color: #374151;
}

.nav-link.active {
    color: #FFD700;
    background-color: #1A2332;
}

.dark .nav-link.active {
    color: #FFD700;
    background-color: #4B5563;
}

/* Mobile Navigation Links */
.mobile-nav-link {
    display: block;
    padding: 0.75rem 1rem;
    color: #6B7280;
    font-weight: 500;
    text-decoration: none;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
}

.mobile-nav-link:hover {
    color: #1A2332;
    background-color: #F3F4F6;
}

.dark .mobile-nav-link:hover {
    color: #FFD700;
    background-color: #374151;
}

.mobile-nav-link.active {
    color: #FFD700;
    background-color: #1A2332;
}

.dark .mobile-nav-link.active {
    color: #FFD700;
    background-color: #4B5563;
}

/* Page Content */
.page-content {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.page-content.active {
    display: block;
}

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

/* Stock Card Styles */
.stock-card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid #E5E7EB;
    position: relative;
    overflow: hidden;
}

.dark .stock-card {
    background: #1F2937;
    border-color: #374151;
}

.stock-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* 왼쪽 세로 라인 (이미지와 동일한 스타일) */
.stock-card.up::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #FF4560;
    border-radius: 1rem 0 0 1rem;
}

.stock-card.down::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #008FFB;
    border-radius: 1rem 0 0 1rem;
}

.stock-card.neutral::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #9CA3AF;
    border-radius: 1rem 0 0 1rem;
}

.stock-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.stock-code {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: #F3F4F6;
    color: #6B7280;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 0.375rem;
}

.dark .stock-code {
    background: #374151;
    color: #9CA3AF;
}

.stock-name {
    font-size: 2.5rem;
    font-weight: 700;
    color: #1A2332;
    margin-bottom: 1rem;
    margin-top: 0.5rem;
    line-height: 1.2;
}

.dark .stock-name {
    color: white;
}

.stock-price {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}

.stock-price.up {
    color: #FF4560;
}

.stock-price.down {
    color: #008FFB;
}

.stock-change {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0.375rem;
}

.stock-change.up {
    background: #FEE2E2;
    color: #DC2626;
}

.stock-change.down {
    background: #DBEAFE;
    color: #2563EB;
}

.dark .stock-change.up {
    background: #7F1D1D;
    color: #FCA5A5;
}

.dark .stock-change.down {
    background: #1E3A8A;
    color: #93C5FD;
}

/* Badge Styles */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
}

.badge-up {
    background: #FEE2E2;
    color: #DC2626;
}

.badge-down {
    background: #DBEAFE;
    color: #2563EB;
}

.badge-neutral {
    background: #F3F4F6;
    color: #6B7280;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 1rem;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    animation: slideUp 0.3s ease;
    z-index: 101;
}

.dark .modal-content {
    background: #1F2937;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Calendar Styles */
.calendar-day {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.calendar-day:hover {
    background: #F3F4F6;
}

.dark .calendar-day:hover {
    background: #374151;
}

.calendar-day.has-stock-pink {
    background: linear-gradient(135deg, #FFE5F0 0%, #FFD6E8 100%);
    border: 2px solid #FF69B4;
    box-shadow: 0 2px 8px rgba(255, 105, 180, 0.2);
}

.dark .calendar-day.has-stock-pink {
    background: linear-gradient(135deg, #4A1F3B 0%, #5C2B4A 100%);
    border: 2px solid #FF69B4;
}

.calendar-day.selected {
    background: #FFD700;
    color: #1A2332;
    font-weight: 700;
}

.calendar-day.other-month {
    opacity: 0.3;
}

.calendar-day-header {
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    padding: 0.5rem;
    color: #6B7280;
}

.dark .calendar-day-header {
    color: #9CA3AF;
}

/* Table Styles */
table {
    width: 100%;
    border-collapse: collapse;
}

/* 테이블 스크롤 컨테이너 */
.overflow-x-auto {
    max-height: 600px;
    overflow-y: auto;
    position: relative;
}

table th {
    position: sticky;
    top: 0;
    background: #F9FAFB;
    z-index: 20;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.dark table th {
    background: #374151;
    z-index: 20;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

table tbody tr {
    transition: background 0.2s ease;
}

table tbody tr:hover {
    background: #F9FAFB;
}

.dark table tbody tr:hover {
    background: #374151;
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 400px;
    width: 100%;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #F3F4F6;
    border-radius: 4px;
}

.dark ::-webkit-scrollbar-track {
    background: #374151;
}

::-webkit-scrollbar-thumb {
    background: #9CA3AF;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #6B7280;
}

.dark ::-webkit-scrollbar-thumb {
    background: #6B7280;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #9CA3AF;
}

/* Loading Spinner */
.spinner {
    border: 3px solid #F3F4F6;
    border-top: 3px solid #FFD700;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Analysis Note Styles */
.analysis-note {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    border-left: 4px solid #FFD700;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.dark .analysis-note {
    background: #1F2937;
}

.analysis-note:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.analysis-note-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.analysis-note-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1A2332;
}

.dark .analysis-note-title {
    color: white;
}

.analysis-note-content {
    color: #4B5563;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.dark .analysis-note-content {
    color: #D1D5DB;
}

/* 분석 노트 이미지 자동 크기 조정 */
.analysis-note img {
    width: 100%;
    height: auto;
    max-width: 100%;
    object-fit: contain;
    border-radius: 0.5rem;
    margin: 1rem 0;
}

.analysis-note-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 1rem;
    border-top: 1px solid #E5E7EB;
}

.dark .analysis-note-footer {
    border-top-color: #374151;
}

/* Comment Styles */
.comment {
    background: #F9FAFB;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.dark .comment {
    background: #374151;
}

.comment-content {
    color: #4B5563;
    font-size: 0.875rem;
    line-height: 1.5;
}

.dark .comment-content {
    color: #D1D5DB;
}

.comment-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #9CA3AF;
}

/* Utility Classes */
.text-up {
    color: #FF4560;
}

.text-down {
    color: #008FFB;
}

.bg-up {
    background-color: #FF4560;
}

.bg-down {
    background-color: #008FFB;
}

/* 관심종목 & 주요종목: 모바일 스타일로 1열 표시 */
#stockCardsContainer {
    max-width: 600px; /* 모바일과 동일한 최대 너비 */
    margin: 0 auto; /* 중앙 정렬 */
}

/* 주요종목: PC에서도 카드 표시 (테이블 숨김) */
#portfolio .bg-white.dark\:bg-gray-800.rounded-xl.shadow-sm {
    display: none; /* 테이블 컨테이너 숨김 */
}

/* portfolioCardContainer는 JavaScript에서 동적으로 grid 클래스를 관리하므로 CSS에서 고정하지 않음 */
#portfolioCardContainer {
    /* display와 grid-template-columns는 Tailwind 클래스로 제어 */
    /* max-width 제한 없음 - 선택한 개수에 따라 자동으로 조정됨 */
    /* gap은 Tailwind의 gap-6 클래스로 제어 */
}

/* Tailwind grid 클래스가 확실히 적용되도록 보장 */
#portfolioCardContainer.grid {
    display: grid !important;
}

#portfolioCardContainer.grid-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
}

#portfolioCardContainer.md\:grid-cols-2 {
    grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
}

@media (min-width: 768px) {
    #portfolioCardContainer.md\:grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
    
    #portfolioCardContainer.md\:grid-cols-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
}

/* Responsive */
@media (max-width: 768px) {
    /* 기본 폰트 크기 */
    body {
        font-size: 14px;
    }
    
    /* 네비게이션 */
    nav h1 {
        font-size: 1.1rem;
    }
    
    nav .w-10 {
        width: 2rem;
        height: 2rem;
    }
    
    /* 카드 패딩 */
    .stock-card {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .stock-card-header {
        margin-bottom: 0.5rem;
    }
    
    /* 종목명 */
    .stock-name {
        font-size: 0.95rem;
        font-weight: 600;
        margin-bottom: 0.25rem;
    }
    
    /* 종목코드 */
    .stock-code {
        font-size: 0.65rem;
        padding: 0.2rem 0.5rem;
    }
    
    /* 가격 */
    .stock-price {
        font-size: 1.1rem;
        font-weight: 700;
        margin-bottom: 0.25rem;
    }
    
    /* 등락률 */
    .stock-change {
        font-size: 0.7rem;
        padding: 0.2rem 0.5rem;
    }
    
    /* 배지 */
    .badge {
        font-size: 0.65rem;
        padding: 0.2rem 0.5rem;
    }
    
    /* 대시보드 통계 카드 */
    .bg-white.rounded-xl.p-6 {
        padding: 1rem;
    }
    
    /* 대시보드 그리드 */
    .grid {
        gap: 0.75rem;
    }
    
    /* 대시보드 통계 카드 그리드 - 모바일에서 2x2 */
    .grid.grid-cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
    
    /* 통계 수치 */
    .text-3xl {
        font-size: 1.5rem;
    }
    
    .text-2xl {
        font-size: 1.25rem;
    }
    
    .text-xl {
        font-size: 1rem;
    }
    
    /* 테이블 폰트 */
    table {
        font-size: 0.75rem;
    }
    
    table th {
        font-size: 0.7rem;
        padding: 0.5rem 0.3rem;
    }
    
    table td {
        padding: 0.5rem 0.3rem;
    }
    
    /* 주요종목: 모바일에서도 카드 표시 (기본 스타일과 동일) */
    
    /* 모달 */
    .modal-content {
        padding: 1rem;
        font-size: 0.85rem;
        width: 95%;
        max-width: 500px;
    }
    
    .modal-content h3 {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }
    
    /* 폼 레이블 */
    label {
        font-size: 0.8rem;
        margin-bottom: 0.25rem;
    }
    
    /* 버튼 */
    button {
        font-size: 0.85rem;
        padding: 0.6rem 1.2rem;
        min-height: 44px; /* 터치 영역 최소 크기 */
    }
    
    .btn-primary, .modal-content button[type="submit"] {
        padding: 0.85rem 1.5rem;
        font-size: 0.95rem;
        min-height: 48px;
    }
    
    /* 주요 액션 버튼 (파일 업로드, 종목 추가) */
    #uploadExcelBtn, #addStockBtn, #fabBtn {
        min-height: 48px;
        font-size: 0.95rem;
        padding: 0.85rem 1.5rem;
    }
    
    /* 입력 필드 */
    input, select, textarea {
        font-size: 0.85rem;
        padding: 0.6rem 0.75rem;
    }
    
    /* 차트 */
    .chart-container {
        height: 250px;
    }
    
    /* 제목 */
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.2rem;
    }
    
    h3 {
        font-size: 1rem;
    }
    
    h4 {
        font-size: 0.9rem;
    }
    
    /* 페이지 컨테이너 */
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    /* FAB 버튼 */
    .fixed.bottom-6.right-6 {
        bottom: 1rem;
        right: 1rem;
        width: 3rem;
        height: 3rem;
    }
    
    /* 아이콘 크기 조정 */
    .fas, .far {
        font-size: inherit;
    }
    
    /* 종목 이미지 */
    .stock-card img {
        height: 100px;
    }
    
    /* 캘린더 최적화 */
    .calendar-day {
        padding: 0.25rem;
        font-size: 0.7rem;
    }
    
    .calendar-day-header {
        font-size: 0.65rem;
        padding: 0.25rem;
    }
    
    /* 분석 노트 최적화 */
    .analysis-note {
        padding: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .analysis-note-title {
        font-size: 0.95rem;
    }
    
    .analysis-note-content {
        font-size: 0.8rem;
        line-height: 1.5;
    }
    
    /* 댓글 최적화 */
    .comment {
        padding: 0.75rem;
        margin-bottom: 0.5rem;
    }
    
    .comment-content {
        font-size: 0.75rem;
    }
    
    .comment-meta {
        font-size: 0.65rem;
    }
    
    /* 상세 페이지 최적화 */
    .page-content {
        padding: 0.75rem;
    }
    
    /* 검색 모달 최적화 */
    #searchModal .modal-content {
        max-width: 95%;
    }
    
    /* 그리드 컬럼 최적화 */
    /* portfolioCardContainer는 제외 - JavaScript에서 동적으로 제어 */
    .grid-cols-1:not(#portfolioCardContainer) {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }
    
    .grid-cols-2:not(#portfolioCardContainer) {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }
    
    .md\:grid-cols-2:not(#portfolioCardContainer),
    .md\:grid-cols-3:not(#portfolioCardContainer),
    .md\:grid-cols-4:not(#portfolioCardContainer) {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }
    
    /* 간격 최적화 */
    .space-x-4 > * + * {
        margin-left: 0.5rem;
    }
    
    .space-y-4 > * + * {
        margin-top: 0.5rem;
    }
    
    /* 패딩 최적화 */
    .p-6 {
        padding: 1rem;
    }
    
    .px-6 {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .py-6 {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }
    
    .p-8 {
        padding: 1.25rem;
    }
    
    /* 마진 최적화 */
    .mb-6 {
        margin-bottom: 1rem;
    }
    
    .mb-8 {
        margin-bottom: 1.25rem;
    }
    
    /* 상세 정보 카드 */
    .bg-white.dark\:bg-gray-800.rounded-xl {
        border-radius: 0.75rem;
    }
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }
}

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

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Focus Styles */
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #FFD700;
    outline-offset: 2px;
}

/* Disabled State */
button:disabled,
input:disabled,
select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 드롭다운 메뉴 스타일 */
#fileMenuDropdown {
    position: relative;
}

#fileMenuDropdownContent {
    animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#fileMenuDropdownContent a {
    transition: all 0.2s ease;
}

#fileMenuDropdownContent a:hover {
    background-color: #F3F4F6;
}

.dark #fileMenuDropdownContent a:hover {
    background-color: #374151;
}
