/* 기본 레이아웃 */
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css');

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    /* background-color: #f0f2f5; /* Removed to inherit from style.css */
    margin: 0;
    /* padding: 20px; /* Removed to prevent interference with sticky footer */
    color: #333;
    line-height: 1.6;
}

/* Only apply these styles to containers in the main content, not in the footer */
.main-page-content .container {
    max-width: 1000px;
    margin: auto;
    background-color: #fff;
    padding: 25px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
    border-radius: 8px;
}
.page-header {
    margin-bottom: 4rem;
    margin-top: 4rem;
}
/* 헤더 섹션 */
.header-section {
    margin-bottom: 30px;
    border-bottom: 1px solid #eaeaea;
    padding-bottom: 20px;
}

.main-page-content h1 {
    text-align: center;
    color: #003366;
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 28px;
}

.main-page-content h2, .main-page-content h3 {
    color: #003366;
    margin-top: 0;
    font-weight: 600;
}

/* 섹션 헤더 스타일 */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8f9fa;
    padding: 12px 15px;
    border-radius: 6px 6px 0 0;
    border-left: 4px solid #003366;
    margin-bottom: 15px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.section-header h3 {
    margin: 0;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #003366;
}

.section-header h3 i {
    color: #003366;
    font-size: 16px;
}

.section-tools {
    display: flex;
    gap: 8px;
}

.explanation-toggle-link {
    display: inline-block;
    color: #007bff; /* Standard link blue */
    text-decoration: none;
    font-size: 14px; /* Slightly smaller than section header text */
    font-weight: normal;
    padding: 5px 0; /* Minimal padding */
    background-color: transparent;
    border: none;
    cursor: pointer;
    transition: color 0.3s ease;
}

.explanation-toggle-link:hover {
    color: #0056b3; /* Darker blue on hover */
}

.explanation-toggle-link i {
    margin-left: 5px; /* Space between text and icon */
    transition: transform 0.3s ease; /* Smooth icon rotation */
}

/* Style for when the panel is open (JS will add/remove .active to the link) */
.explanation-toggle-link.active i {
    transform: rotate(180deg);
}

.explanation-panel {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    margin-bottom: 0;
    border-top: 1px solid transparent; /* Prepare for border animation */
    transition: max-height 0.5s ease-in-out, opacity 0.5s ease-in-out, padding-top 0.5s ease-in-out, padding-bottom 0.5s ease-in-out, margin-top 0.5s ease-in-out, margin-bottom 0.5s ease-in-out, border-color 0.5s ease-in-out;
}

.explanation-panel.active {
    max-height: 1000px; /* Adjust if necessary for very long content */
    opacity: 1;
    padding-top: 15px;
    padding-bottom: 15px;
    margin-top: 10px;
    margin-bottom: 10px;
    border-color: #e1e4e8; /* Fade in border */
}

.model-description {
    text-align: center;
    color: #666;
    font-size: 14px;
    max-width: 700px;
    margin: 0 auto;
}

/* 입력 카드 스타일 */
.input-card {
    background-color: #fff;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    margin-bottom: 30px;
    overflow: hidden;
}

.card-header {
    background-color: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 1px solid #e1e4e8;
}

.card-header h2 {
    margin: 0;
    font-size: 18px;
    display: flex;
    align-items: center;
}

.card-header h2 i {
    margin-right: 10px;
    color: #003366;
}

/* Only apply padding to forms in the main content, not in the footer */
.main-page-content form:not(.footer-custom form) {
    padding: 20px;
    margin-bottom: 0;
}

/* 폼 레이아웃 */
.form-row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
}

.form-row .form-group {
    flex: 1;
    padding: 10px 10px;
    min-width: 200px;
}

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

/* Chart Container style */
.chart-container {
    width: 100%;
    overflow: hidden; /* Optional: to contain elements that might briefly overflow */
    margin-bottom: 20px; /* Add some space below charts */
}

/* --- Tabbed Content --- */
.tab-container {
  overflow: hidden;
  border: 1px solid #ccc;
  background-color: #f1f1f1;
  margin-bottom: 15px;
  border-radius: 5px;
}

.tab-container button {
  background-color: inherit;
  float: left;
  border: none;
  outline: none;
  cursor: pointer;
  padding: 14px 16px;
  transition: 0.3s;
  font-size: 1em;
  font-weight: bold;
  color: #555;
  border-right: 1px solid #ccc;
}

.tab-container button:last-child {
    border-right: none;
}

.tab-container button:hover {
  background-color: #ddd;
}

.tab-container button.active {
  background-color: #007bff;
  color: white;
}

.tab-content {
  display: none;
  padding: 15px 12px;
  border: 1px solid #ccc;
  border-top: none;
  background-color: #fff;
  border-radius: 0 0 5px 5px;
  line-height: 1.6;
}

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

/* --- Tooltips --- */
.tooltip-icon {
  cursor: help;
  color: #007bff;
  font-weight: bold;
  margin-left: 5px;
  position: relative;
  display: inline-block;
}

.tooltip-text {
  visibility: hidden;
  width: 220px;
  background-color: #555;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 8px;
  position: absolute;
  z-index: 1;
  bottom: 125%; /* Position the tooltip above the icon */
  left: 50%;
  margin-left: -110px; /* Use half of the width to center the tooltip */
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 0.9em;
  font-weight: normal;
}

.tooltip-icon:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* --- Quiz --- */
.quiz-container {
  margin-top: 20px;
  padding: 15px;
  border: 1px solid #e0e0e0;
  border-radius: 5px;
  background-color: #f9f9f9;
}

.quiz-question {
  font-weight: bold;
  margin-bottom: 10px;
}

.quiz-answers button {
  display: block;
  width: 100%;
  padding: 10px;
  margin-bottom: 8px;
  background-color: #007bff;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.2s;
}

.quiz-answers button:hover {
  background-color: #0056b3;
}

.quiz-feedback {
  margin-top: 10px;
  padding: 10px;
  border-radius: 4px;
  font-weight: bold;
}

.quiz-feedback.correct {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.quiz-feedback.incorrect {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

/* --- Accordion (Collapsible Details) --- */
.accordion-header {
  background-color: #f1f1f1;
  color: #444;
  cursor: pointer;
  padding: 12px 18px;
  width: 100%;
  border: none;
  text-align: left;
  outline: none;
  font-size: 1em;
  transition: 0.4s;
  margin-top: 10px;
  border-radius: 4px;
  font-weight: bold;
}

.accordion-header:hover, .accordion-header.active {
  background-color: #ddd;
}

.accordion-header::after {
  content: '\002B'; /* Unicode character for "+" sign */
  font-size: 1.2em;
  color: #777;
  float: right;
  margin-left: 5px;
}

.accordion-header.active::after {
  content: "\2212"; /* Unicode character for "-" sign */
}

.accordion-content {
  padding: 0 18px;
  background-color: white;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.2s ease-out;
  border: 1px solid #f1f1f1;
  border-top: none;
  border-radius: 0 0 4px 4px;
  margin-bottom: 10px;
}

.accordion-content p {
    margin-top: 10px;
    margin-bottom: 10px;
}

/* 레이블 스타일 */
label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #444;
    font-size: 14px;
}

label i {
    margin-right: 5px;
    color: #003366;
}

/* 사용자 레벨 선택 버튼 스타일 */
.level-selector {
    display: flex;
    gap: 10px; /* 버튼 사이 간격 */
    margin-top: 5px;
}

.level-selector input[type="radio"] {
    display: none; /* 기본 라디오 버튼 숨기기 */
}

.level-selector .level-btn {
    padding: 10px 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: normal; /* 레이블 기본 스타일과 다르게 일반 굵기로 */
    color: #555;
    background-color: #f9f9f9;
    transition: background-color 0.3s, border-color 0.3s, color 0.3s;
    display: inline-block; /* margin-bottom 적용을 위해 */
    margin-bottom: 0; /* form-group의 margin-bottom과 중복 방지 */
}

.level-selector input[type="radio"]:checked + .level-btn {
    background-color: #0056b3; /* 선택 시 배경색 (submit-btn과 유사하게) */
    color: white;
    border-color: #004085; /* 선택 시 테두리 색 */
}

.level-selector .level-btn:hover {
    background-color: #e9e9e9;
    border-color: #bbb;
}

.level-selector input[type="radio"]:checked + .level-btn:hover {
    background-color: #004085; /* 선택된 버튼 호버 시 약간 더 어둡게 */
}

/* 입력 필드 스타일 */
input[type="text"], 
input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    box-sizing: border-box;
    border: 1px solid #cfd7e6;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus, 
input[type="number"]:focus {
    border-color: #007acc;
    box-shadow: 0 0 0 3px rgba(0, 122, 204, 0.15);
    outline: none;
}

/* 입력 필드 아이콘 */
.input-with-icon {
    position: relative;
}

.input-with-icon input {
    padding-right: 30px;
}

.input-with-icon:hover .tooltip {
    visibility: visible;
    opacity: 1;
}

.tooltip {
    position: absolute;
    top: -40px;
    left: 0;
    background-color: #003366;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 100;
    width: 200px;
}

.tooltip:after {
    content: "";
    position: absolute;
    top: 100%;
    left: 15px;
    border-width: 5px;
    border-style: solid;
    border-color: #003366 transparent transparent transparent;
}

/* 티커 검색 링크 */
.ticker-lookup {
    margin-top: 5px;
    font-size: 12px;
}

.ticker-lookup a {
    color: #007acc;
    text-decoration: none;
}

.ticker-lookup a:hover {
    text-decoration: underline;
}

/* 도움말 텍스트 */
.helper-text {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

/* 성장률 슬라이더 */
.growth-rate-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

input[type="range"] {
    flex: 1;
    height: 5px;
    -webkit-appearance: none;
    appearance: none;
    background: #e1e4e8;
    border-radius: 5px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #003366;
    cursor: pointer;
}

#growth_rate {
    width: 80px;
    text-align: center;
}

#growth_percentage {
    width: 50px;
    font-weight: bold;
    color: #003366;
}

/* 버튼 스타일 */
button.submit-btn {
    display: block;
    width: 100%;
    padding: 12px;
    background-color: #003366;
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 16px;
    border-radius: 4px;
    transition: background-color 0.2s;
    font-weight: 600;
    margin-top: 10px;
}

button.submit-btn:hover {
    background-color: #004080;
}

button.submit-btn i {
    margin-right: 8px;
}

/* Next Step Button Styling - Enhanced and Centered */
.next-step {
    display: flex; /* Use flex for centering icon and text */
    align-items: center;
    justify-content: center;
    width: fit-content; /* Adjust width to content */
    min-width: 200px; /* Minimum width for better appearance */
    padding: 12px 28px; /* Generous padding */
    font-size: 1.05rem; /* Slightly larger font */
    font-weight: 600; /* Bolder text */
    color: #ffffff;
    background-color: #0056b3; /* Subtle gradient */
    border: none;
    border-radius: 8px; /* More rounded corners */
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0, 91, 179, 0.25); /* Softer, more diffused shadow */
    transition: all 0.3s ease;
    margin-top: 25px; /* Space above the button */
    margin-bottom: 10px; /* Space below the button */
    margin-left: auto; /* Center the button */
    margin-right: auto; /* Center the button */
}

.next-step:hover {
    background-color:#0056b3; /* Darker gradient on hover */
    box-shadow: 0 6px 16px rgba(0, 70, 140, 0.35); /* Lift shadow on hover */
    transform: translateY(-2px) scale(1.02); /* Slight lift and scale effect */
}

.next-step:active {
    background-image: linear-gradient(to right, #003f7f 0%, #002a53 100%); /* Even darker for active state */
    box-shadow: 0 2px 8px rgba(0, 50, 100, 0.3); /* Press down shadow */
    transform: translateY(0px) scale(1); /* Reset transform or slight press down */
}

.next-step i {
    margin-left: 10px; /* More space for icon */
    font-size: 1em; /* Icon size relative to text */
    transition: transform 0.3s ease; /* Smooth transition for icon */
}

.next-step:hover i {
    transform: translateX(3px); /* Icon moves slightly on hover */
}

/* Only apply these styles to buttons in the main content, not in the footer */
.main-page-content .btn:not(.footer-custom .btn) {
    display: inline-block;
    padding: 10px 20px;
    margin: 5px;
    background-color: #007acc;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
}

.main-page-content .btn:not(.footer-custom .btn):hover {
    background-color: #005fa3;
}

/* 다운로드 버튼 컨테이너 중앙 정렬 */
.download-buttons {
    text-align: center;
    margin-bottom: 20px;
}

/* 테이블 wrapper 스타일 */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    text-align: center;
    margin: 20px auto;
}

.table-wrapper table {
    width: 100%;
    table-layout: fixed;
    word-wrap: break-word;
    margin: 0 auto;
}

/* 금융 감각의 테이블 디자인 */
table {
    border-collapse: collapse;
    margin: 20px auto;
}

table th,
table td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: center;
    font-size: 12px;
    white-space: nowrap;
}

/* 왼쪽 인덱스(첫 번째 열)의 너비 제한 */
table th:first-child,
table td:first-child {
    width: 50px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 헤더 셀 스타일 */
table th {
    background-color: #003366;
    color: #ffffff;
    font-weight: bold;
    font-size: 8px;
}

/* 홀수행/짝수행 배경색 */
table tr:nth-child(odd) {
    background-color: #f9f9f9;
}

table tr:nth-child(even) {
    background-color: #ffffff;
}

table tr:hover {
    background-color: #dbe9f4;
}

/* 로딩 스피너 스타일 */
#loading {
    text-align: center;
    margin: 20px 0;
}

.spinner {
    border: 8px solid #f3f3f3;
    border-top: 8px solid #007acc;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

/* 차트 컨테이너 스타일 */
.chart-container {
    margin: 20px auto;
    padding: 15px;
    border: 1px solid #e1e4e8;
    background-color: #fafafa;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    max-width: 100%;
    width: 100%;
    text-align: center;
    transition: all 0.3s ease;
}

.chart-container:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: #cfd7e6;
}

/* 설명 패널 스타일 */
.explanation-panel {
    background-color: #f8f9fa;
    border: 1px solid #e1e4e8;
    border-radius: 4px;
    padding: 15px;
    margin: 10px 0 20px 0;
    font-size: 14px;
    line-height: 1.6;
    color: #444;
    display: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.explanation-panel.active {
    display: block;
    animation: fadeIn 0.3s ease-in-out;
}

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

.explanation {
    margin-bottom: 12px;
    text-align: left;
}

.explanation strong {
    color: #003366;
    font-weight: 600;
}

.formula {
    display: block;
    background-color: #eef2f7;
    padding: 8px 12px;
    border-radius: 4px;
    margin: 8px 0;
    font-family: 'Courier New', monospace;
    color: #0a3055;
    text-align: center;
    border-left: 3px solid #003366;
}

.metric-trend {
    display: block;
    margin-top: 5px;
    font-style: italic;
    color: #666;
}

.metric-trend i {
    color: #28a745;
    margin-right: 5px;
}

.info-tip {
    background-color: #e8f4fd;
    border-left: 3px solid #007acc;
    padding: 10px 15px;
    margin-top: 15px;
    border-radius: 4px;
}

.info-tip i {
    color: #007acc;
    margin-right: 5px;
}

.calculation-steps {
    padding-left: 25px;
    margin: 10px 0;
}

.calculation-steps li {
    margin-bottom: 5px;
}

/* 버튼 스타일 */
.info-toggle {
    background-color: transparent;
    border: none;
    color: #007acc;
    cursor: pointer;
    font-size: 16px;
    padding: 5px;
    transition: all 0.2s;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.info-toggle:hover {
    background-color: rgba(0, 122, 204, 0.1);
    color: #0056b3;
}

/* Plotly 차트가 컨테이너에 꽉 차도록 설정 */
.chart-container .js-plotly-plot,
.chart-container .plotly-graph-div {
    width: 100% !important;
    height: auto !important;
}

/* Pandas DataFrame에서 생성된 표(.dataframe)에도 동일하게 적용 */
table.dataframe {
    margin: 20px auto;
    border-collapse: collapse;
    width: 100%;
    table-layout: fixed;
    word-wrap: break-word;
}

table.dataframe th,
table.dataframe td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: center;
    font-size: 12px;
    white-space: nowrap;
}

table.dataframe th:first-child,
table.dataframe td:first-child {
    width: 50px;
    overflow: hidden;
    text-overflow: ellipsis;
}

table.dataframe th {
    background-color: #003366;
    color: #ffffff;
    font-weight: bold;
}

table.dataframe tr:nth-child(odd) {
    background-color: #f9f9f9;
}

table.dataframe tr:nth-child(even) {
    background-color: #ffffff;
}

table.dataframe tr:hover {
    background-color: #dbe9f4;
}

/* → Implied Price Range 표는 .implied-table 클래스를 사용하여 첫 번째 열 너비 제한을 오버라이드 */
.implied-table table th:first-child,
.implied-table table td:first-child {
    width: auto !important;
    overflow: visible !important;
    text-overflow: unset !important;
}

/* 단계별 뷰용 스타일 */
.step {
    display: none;
    margin-bottom: 30px;
}
.step.active {
    display: block;
}

/* 설명문 스타일 */
.explanation {
    margin: 15px 0;
    font-size: 14px;
    color: #333;
    line-height: 1.5;
}

/* 다음 단계 및 전체 보기 버튼 */
.next-step, .show-all {
    background-color: #007acc;
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 15px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.next-step:hover, .show-all:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.next-step i {
    font-size: 14px;
    transition: transform 0.2s ease;
}

.next-step:hover i {
    transform: translateX(3px);
}

/* 경험 수준 선택 스타일 */
#experience_level {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #f8f9fa;
    color: #333;
    font-size: 16px;
    font-family: 'Segoe UI', Arial, sans-serif;
    transition: border-color 0.3s ease;
}

#experience_level:focus {
    border-color: #003366;
    outline: none;
}

.input-with-icon select {
    padding-left: 30px;
}

.input-with-icon {
    position: relative;
}

.input-with-icon i {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #003366;
}