/* ============================================================
   Calculation Result Styles - Markdown Beautification
   ============================================================ */

/* --- Result Container --- */
#dataResult {
    position: relative;
    min-height: 60px;
    line-height: 1.8;
    font-size: 15px;
    color: #333;
    user-select: text;
    -webkit-user-select: text;
}

#dataResult .result-content {
    padding: 20px 24px;
    background: linear-gradient(135deg, #fefefe 0%, #f5f0f0 100%);
    border-radius: 12px;
    border: 1px solid #e8dede;
    box-shadow: 0 2px 12px rgba(99, 19, 22, 0.06);
    user-select: text;
    -webkit-user-select: text;
    cursor: text;
}

/* --- Markdown Typography --- */
#dataResult .result-content h1,
#dataResult .result-content h2,
#dataResult .result-content h3,
#dataResult .result-content h4 {
    color: #12264f;
    font-weight: 700;
    margin-top: 1.4em;
    margin-bottom: 0.6em;
    line-height: 1.4;
    position: relative;
}

#dataResult .result-content h1:first-child,
#dataResult .result-content h2:first-child,
#dataResult .result-content h3:first-child {
    margin-top: 0;
}

#dataResult .result-content h1 { font-size: 1.6em; }
#dataResult .result-content h2 { font-size: 1.4em; }

#dataResult .result-content h3 {
    font-size: 1.15em;
    color: #12264f;
    padding-left: 14px;
    border-left: 4px solid #631316;
}

#dataResult .result-content h4 {
    font-size: 1.05em;
    color: #4a5568;
}

#dataResult .result-content p {
    margin: 0.6em 0;
    line-height: 1.9;
    color: #444;
}

#dataResult .result-content strong {
    color: #12264f;
    font-weight: 600;
    background: linear-gradient(to bottom, transparent 60%, rgba(99, 19, 22, 0.12) 60%);
    padding: 0 2px;
}

#dataResult .result-content em {
    color: #631316;
    font-style: italic;
}

/* --- Lists --- */
#dataResult .result-content ol,
#dataResult .result-content ul {
    padding-left: 1.2em;
    margin: 0.8em 0;
}

#dataResult .result-content ol > li,
#dataResult .result-content ul > li {
    margin-bottom: 0.7em;
    padding-left: 0.4em;
    line-height: 1.8;
}

#dataResult .result-content ol > li {
    list-style-type: decimal;
}

#dataResult .result-content ul > li {
    list-style-type: disc;
}

#dataResult .result-content ol > li::marker {
    color: #631316;
    font-weight: 700;
}

#dataResult .result-content ul > li::marker {
    color: #631316;
}

/* --- Blockquotes --- */
#dataResult .result-content blockquote {
    border-left: 4px solid #631316;
    background: rgba(99, 19, 22, 0.04);
    margin: 1em 0;
    padding: 12px 20px;
    border-radius: 0 8px 8px 0;
    color: #4a5568;
}

#dataResult .result-content blockquote p {
    margin: 0.3em 0;
}

/* --- Code --- */
#dataResult .result-content code {
    background: #f5f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    color: #631316;
}

#dataResult .result-content pre {
    background: #12264f;
    color: #e2e8f0;
    padding: 16px 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 1em 0;
}

#dataResult .result-content pre code {
    background: none;
    color: inherit;
    padding: 0;
}

/* --- Tables --- */
#dataResult .result-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

#dataResult .result-content table th {
    background: #12264f;
    color: #fff;
    padding: 10px 14px;
    font-weight: 600;
    text-align: left;
}

#dataResult .result-content table td {
    padding: 10px 14px;
    border-bottom: 1px solid #e8ecf1;
}

#dataResult .result-content table tr:nth-child(even) {
    background: #f7fafc;
}

/* --- Horizontal Rule --- */
#dataResult .result-content hr {
    border: none;
    height: 2px;
    background: linear-gradient(to right, #631316, #12264f);
    margin: 1.5em 0;
    border-radius: 2px;
    opacity: 0.3;
}

/* ============================================================
   Thinking / Loading Animation
   ============================================================ */

.calc-thinking {
    display: flex;
    align-items: center;
    padding: 20px 24px;
    background: linear-gradient(135deg, #fefefe 0%, #f5f0f0 100%);
    border-radius: 12px;
    border: 1px solid #e8dede;
    animation: thinking-pulse 2s ease-in-out infinite;
}

@keyframes thinking-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.calc-thinking-icon {
    width: 36px;
    height: 36px;
    margin-right: 16px;
    flex-shrink: 0;
    position: relative;
}

.calc-thinking-icon .brain-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #631316 0%, #12264f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: brain-spin 3s linear infinite;
}

.calc-thinking-icon .brain-icon svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

@keyframes brain-spin {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(360deg); }
}

.calc-thinking-text {
    flex: 1;
}

.calc-thinking-text .thinking-title {
    font-size: 15px;
    font-weight: 600;
    color: #12264f;
    margin-bottom: 4px;
}

.calc-thinking-text .thinking-steps {
    font-size: 13px;
    color: #718096;
    display: flex;
    align-items: center;
    gap: 6px;
}

.thinking-dots {
    display: inline-flex;
    gap: 3px;
}

.thinking-dots span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #631316;
    animation: dot-bounce 1.4s ease-in-out infinite;
}

.thinking-dots span:nth-child(1) { animation-delay: 0s; }
.thinking-dots span:nth-child(2) { animation-delay: 0.16s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes dot-bounce {
    0%, 80%, 100% { transform: scale(0.4); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* --- Streaming cursor --- */
.streaming-cursor::after {
    content: '▊';
    display: inline;
    color: #631316;
    animation: cursor-blink 0.8s step-end infinite;
    font-weight: 400;
    margin-left: 2px;
}

@keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ============================================================
   Thinking Status Steps (progress indicators)
   ============================================================ */

.calc-status-bar {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    padding: 12px 0;
}

.calc-status-step {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
    background: #f0eeee;
    color: #999;
    position: relative;
}

.calc-status-step + .calc-status-step {
    margin-left: 6px;
}

.calc-status-step + .calc-status-step::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 2px;
    background: #ddd;
    transition: background 0.3s ease;
}

.calc-status-step.done + .calc-status-step::before,
.calc-status-step.active + .calc-status-step::before {
    background: #631316;
}

.calc-status-step.active {
    background: #631316;
    color: #fff;
    box-shadow: 0 2px 8px rgba(99, 19, 22, 0.25);
}

.calc-status-step.done {
    background: #12264f;
    color: #fff;
}

.calc-status-step .step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    background: rgba(0,0,0,0.08);
    color: inherit;
    flex-shrink: 0;
}

.calc-status-step.active .step-num,
.calc-status-step.done .step-num {
    background: rgba(255,255,255,0.25);
}

.calc-status-step.done .step-check {
    display: inline;
}

.calc-status-step .step-check {
    display: none;
}

/* ============================================================
   Submit Button States
   ============================================================ */

.calc-submit-btn {
    position: relative;
    transition: all 0.3s ease;
    overflow: hidden;
}

.calc-submit-btn.is-loading {
    pointer-events: none;
    opacity: 0.9;
    background: #631316 !important;
}

.calc-submit-btn.is-loading .btn-text {
    visibility: hidden;
}

.calc-submit-btn .btn-spinner {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.calc-submit-btn.is-loading .btn-spinner {
    display: flex;
}

.btn-spinner-circle {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spinner-rotate 0.7s linear infinite;
}

@keyframes spinner-rotate {
    to { transform: rotate(360deg); }
}

.btn-spinner-text {
    color: #fff;
    font-size: 14px;
    font-weight: 500;
}

/* ============================================================
   Completion Animation
   ============================================================ */

.result-complete {
    animation: result-fadeIn 0.5s ease-out;
}

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

/* --- Divider between sections --- */
#dataResult .result-content h3 + ol,
#dataResult .result-content h3 + ul,
#dataResult .result-content h3 + p,
#dataResult .result-content h2 + ol,
#dataResult .result-content h2 + ul,
#dataResult .result-content h2 + p {
    margin-top: 0.4em;
}

/* --- Mobile responsive --- */
@media (max-width: 640px) {
    #dataResult .result-content {
        padding: 14px 16px;
    }
    #dataResult .result-content h3 {
        font-size: 1.05em;
    }
    .calc-thinking {
        padding: 14px 16px;
    }
    .calc-status-bar {
        flex-wrap: wrap;
        gap: 6px 0;
    }
    .calc-status-step {
        padding: 4px 10px;
        font-size: 11px;
    }
    .calc-status-step + .calc-status-step {
        margin-left: 4px;
    }
    .calc-status-step + .calc-status-step::before {
        width: 4px;
        left: -5px;
    }
}
