/* 
  common.css
  Design System for AI Self-Diagnosis App
  Colors: Primary #043b8d, Secondary #ffd26a, Accent #e8f1ff
  Font: Pretendard
*/

@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css');

:root {
    --primary: #1a365d;
    --primary-light: #1e3a8a;
    --secondary: #e8f0fe;
    --accent: #e2e8f0;
    --text-dark: #1e293b;
    --text-gray: #64748b;
    --bg-light: #f4f7f6;
    --white: #ffffff;
    --border-light: #e2e8f0;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);

    --app-max-width: 480px;
    /* Mobile first approach, max-width for desktop view */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #e9ecef;
    /* Gray background on desktop */
    color: var(--text-dark);
    line-height: 1.6;
    display: flex;
    justify-content: center;
    background-attachment: fixed;
    /* Safari background fix */
    min-height: 100vh;
    min-height: -webkit-fill-available;
}

/* App Container (Mobile Simulator) */
.app-container {
    width: 100%;
    max-width: var(--app-max-width);
    background-color: var(--white);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background-color: var(--primary);
    color: var(--white);
    padding: 16px 20px;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.app-header p {
    font-size: 0.85rem;
    opacity: 0.9;
}

.progress-container {
    background-color: var(--white);
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 68px;
    /* Adjust based on header height */
    z-index: 99;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 8px;
}

.progress-bg {
    height: 6px;
    background-color: var(--border-light);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background-color: var(--primary);
    width: 0%;
    transition: width 0.5s ease-in-out;
}

/* Chat Area */
.chat-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: var(--bg-light);
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: calc(100dvh - 129px);
}

.chat-container::after {
    content: "";
    display: block;
    min-height: var(--chat-bottom-padding, 20px);
    flex-shrink: 0;
}

/* Messages */
.message {
    display: flex;
    max-width: 85%;
    animation: fadeInUp 0.3s ease forwards;
    opacity: 0;
    transform: translateY(10px);
}

.message.ai {
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
    position: relative;
}

.btn-edit-bubble {
    position: absolute;
    left: -36px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--white);
    border: 1px solid var(--border-light);
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    color: var(--primary);
}

.edit-confirm {
    position: absolute;
    left: -120px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 4px;
}

.btn-edit-confirm,
.btn-edit-cancel {
    height: 28px;
    padding: 0 10px;
    border-radius: 14px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.btn-edit-confirm {
    background: var(--primary);
    color: var(--white);
    border: 1px solid var(--primary);
}

.btn-edit-cancel {
    background: var(--white);
    color: var(--text-gray);
    border: 1px solid var(--border-light);
}

.avatar-wrapper {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
}

.message.user .avatar-wrapper {
    margin-right: 0;
    margin-left: 12px;
    background-color: #ddd;
}

.avatar-wrapper svg {
    width: 20px;
    height: 20px;
    fill: var(--white);
}

.bubble {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    word-break: keep-all;
}

.message.ai .bubble {
    background-color: var(--white);
    border-top-left-radius: 4px;
    border: 1px solid var(--border-light);
}

.message.user .bubble {
    background-color: var(--secondary);
    color: var(--text-dark);
    border-top-right-radius: 4px;
}

/* Typing Indicator & Thinking State */
.thinking-box {
    background-color: rgba(255, 255, 255, 0.7);
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    border: 1px solid var(--accent);
    align-self: center;
    animation: pulse 1.5s infinite;
}

.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2px 0;
}

.loading span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: var(--primary);
    border-radius: 50%;
    animation: loading 1s linear infinite;
}

.loading span:nth-child(1) {
    animation-delay: 0s;
}

.loading span:nth-child(2) {
    animation-delay: 0.2s;
    margin: 0px 6px;
}

.loading span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes loading {

    0%,
    100% {
        opacity: 0;
        transform: scale(0.5);
    }

    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Input Area (Sticky Bottom) */
.input-area {
    position: fixed;
    bottom: 0;
    width: 100%;
    max-width: var(--app-max-width);
    background-color: var(--white);
    padding: 16px 20px;
    border-top: 1px solid var(--border-light);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    z-index: 100;
    transition: transform 0.3s ease;
}

.input-area:empty {
    padding: 0;
    border: none;
    box-shadow: none;
    background: transparent;
}

/* Input Components */
.input-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}


.btn-choice {
    background-color: var(--white);
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 14px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn-choice:hover,
.btn-choice:focus {
    background-color: var(--accent);
}

.btn-choice.selected {
    background-color: var(--primary);
    color: var(--white);
}

/* Number Pad / Direct Input */
.number-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-direct-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-direct-wrapper span {
    position: absolute;
    right: 12px;
    font-size: 1.1rem;
    color: var(--text-gray);
    font-weight: 600;
    pointer-events: none;
}

.input-direct {
    width: 100%;
    font-size: 1.5rem;
    font-weight: 700;
    text-align: right;
    padding: 12px 50px 12px 12px;
    border: none;
    border-bottom: 2px solid var(--primary);
    color: var(--primary);
    outline: none;
    background: transparent;
    border-radius: 0;
}

.input-direct::placeholder {
    color: #ccc;
    font-size: 1.1rem;
}

.quick-adds {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-top: 5px;
    margin-bottom: 10px;
}

.quick-adds button {
    padding: 10px 0;
    font-size: 0.9rem;
    background-color: var(--bg-light);
    color: var(--text-dark);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.quick-adds button:active {
    background-color: var(--primary);
    color: var(--white);
}

.btn-reset {
    background-color: var(--white) !important;
    color: #ff5252 !important;
    border-color: #ff5252 !important;
}

.btn-reset:active {
    background-color: #ff5252 !important;
    color: var(--white) !important;
}

.btn-submit {
    width: 100%;
    padding: 16px;
    background-color: var(--primary);
    color: var(--white);
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 700;
    margin-top: 12px;
    cursor: pointer;
}

.btn-submit:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse {
    0% {
        opacity: 0.7;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.7;
    }
}

/* Utility */
.hidden {
    display: none !important;
}

.mb-2 {
    margin-bottom: 8px;
}

.mt-2 {
    margin-top: 8px;
}

/* AI Loading Overlay */
.ai-loading-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: var(--primary);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease;
}

.ai-loading-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.ai-loading-icon {
    width: 56px;
    height: 56px;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.ai-loading-icon svg {
    width: 32px;
    height: 32px;
    fill: white;
}

.ai-loading-overlay .loading span {
    background-color: white;
}

.ai-loading-text {
    font-size: 0.95rem;
    color: rgba(255,255,255,0.9);
    font-weight: 600;
    letter-spacing: -0.3px;
    min-height: 1.4em;
}

/* AI Comment Card */
.ai-comment-card {
    border-left: 3px solid var(--primary);
}

.ai-comment-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.ai-comment-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-comment-avatar svg {
    width: 18px;
    height: 18px;
    fill: white;
}

.ai-comment-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 0.3px;
}

.ai-comment-text {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-dark);
    margin-bottom: 16px;
}

/* AI Key Points */
.ai-key-points {
    background: var(--bg-light);
    border-radius: 8px;
    padding: 14px 16px;
}

.ai-key-points-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 10px;
    letter-spacing: 0.3px;
}

.ai-key-points-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-key-points-list li {
    font-size: 0.875rem;
    color: var(--text-dark);
    padding-left: 18px;
    position: relative;
    line-height: 1.5;
}

.ai-key-points-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: #10b981;
    font-weight: 700;
}

/* Dashboard / Result Page Styles */
.result-header {
    text-align: center;
    padding: 30px 20px;
    background-color: var(--primary);
    color: var(--white);
}

.result-header h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.result-celebration {
    font-size: 3rem;
    margin-bottom: 10px;
    animation: tada 1s ease;
}

.card {
    background: var(--white);
    border-radius: 16px;
    padding: 28px 24px;
    margin: 20px 20px;
    box-shadow: var(--shadow);
    position: relative;
    border: 1px solid var(--border-light);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card-highlight {
    border: 2px solid #10b981;
    background: linear-gradient(to bottom, #ffffff, #f0fdf4);
    margin-top: 50px;
}

.card-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 16px;
    text-align: center;
    letter-spacing: -0.5px;
}

/* Bar Chart */
.bar-chart-container {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 30px;
    height: 160px;
    margin-top: 16px;
    margin-bottom: 8px;
    position: relative;
}

.bar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    width: 80px;
    height: 100%;
    position: relative;
}

.bar {
    width: 100%;
    border-radius: 6px 6px 0 0;
    position: relative;
    transition: height 1.5s cubic-bezier(0.1, 0.8, 0.2, 1);
}

.bar.before {
    background: linear-gradient(to top, #475569, #94a3b8);
    /* Neutral gray */
    height: 0;
    /* JS will animate this */
}

.bar.after {
    background: linear-gradient(to top, #059669, #34d399);
    /* Vibrant green */
    height: 0;
    /* JS will animate this */
}

.bar-label {
    margin-top: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-gray);
}

.bar-value {
    position: absolute;
    top: -24px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 700;
}

.savings-badge {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--secondary);
    color: var(--primary);
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 1.1rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
    z-index: 10;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    opacity: 0;
    animation-delay: 1s;
}

/* Gauge Chart (CSS based) */
.gauge-container {
    position: relative;
    width: 200px;
    height: 100px;
    margin: 0 auto 20px;
    overflow: hidden;
}

.gauge-bg {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    /* Updated gradient to use neutral grays for risk and bright green/blue for success */
    background: conic-gradient(#94a3b8 0deg 45deg, #cbd5e1 45deg 90deg, #10b981 90deg 135deg, #3b82f6 135deg 180deg, transparent 180deg 360deg);
    position: absolute;
    top: 0;
    left: 0;
    transform: rotate(-90deg);
}

.gauge-mask {
    width: 160px;
    height: 160px;
    background-color: var(--white);
    border-radius: 50%;
    position: absolute;
    top: 20px;
    left: 20px;
}

.gauge-needle {
    width: 4px;
    height: 90px;
    background-color: var(--text-dark);
    position: absolute;
    bottom: 0px;
    left: 50%;
    transform-origin: bottom center;
    transform: translateX(-50%) rotate(-90deg);
    /* Start at -90 */
    transition: transform 2s cubic-bezier(0.1, 0.8, 0.2, 1);
    z-index: 5;
}

.gauge-needle::after {
    content: '';
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--text-dark);
    position: absolute;
    bottom: -6px;
    left: -4px;
}

.gauge-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    padding: 0 10px;
    font-size: 0.75rem;
    color: var(--text-gray);
    font-weight: 600;
}

.result-text {
    text-align: center;
    font-size: 1.1rem;
    line-height: 1.5;
}

.highlight {
    color: var(--primary);
    font-weight: 800;
    font-size: 1.2rem;
}

/* Summary Table */
.summary-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.summary-table th,
.summary-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
}

.summary-table th {
    color: var(--text-gray);
    font-weight: 500;
    width: 40%;
}

.summary-table td {
    font-weight: 700;
    text-align: right;
    color: var(--text-dark);
}

.summary-table tr:last-child th,
.summary-table tr:last-child td {
    border-bottom: none;
}

.text-danger {
    color: #ff5252;
}

.text-success {
    color: #4caf50;
}

.text-primary {
    color: var(--primary);
}

.cta-section {
    padding: 20px 20px 40px;
    text-align: center;
    background: linear-gradient(to bottom, transparent, #ffffff);
}

.trust-badge {
    display: inline-block;
    background-color: #f1f5f9;
    color: var(--text-gray);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 20px;
    border: 1px solid var(--border-light);
}

.cta-text {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 20px;
    line-height: 1.5;
    letter-spacing: -0.5px;
}

.btn-cta {
    background: linear-gradient(135deg, #1d4ed8, #1e3a8a);
    color: var(--white);
    border: none;
    padding: 18px 30px;
    border-radius: 30px;
    font-size: 1.15rem;
    font-weight: 800;
    width: 100%;
    box-shadow: 0 6px 20px rgba(29, 78, 216, 0.4);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.pulse-btn {
    animation: cta-pulse 2s infinite;
}

@keyframes cta-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(29, 78, 216, 0.6);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(29, 78, 216, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(29, 78, 216, 0);
    }
}

.btn-cta:active {
    transform: scale(0.98);
}

.btn-call {
    display: inline-block;
    background-color: var(--white);
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 16px 30px;
    border-radius: 30px;
    font-size: 1.15rem;
    font-weight: 800;
    width: 100%;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    box-sizing: border-box;
    margin-bottom: 12px;
}

.btn-call:active {
    background-color: var(--accent);
    transform: scale(0.98);
}

.urgency-msg {
    font-size: 0.85rem;
    color: var(--text-dark);
    margin-top: 16px;
    line-height: 1.4;
}

@keyframes tada {
    0% {
        transform: scale(1);
    }

    10%,
    20% {
        transform: scale(0.9) rotate(-3deg);
    }

    30%,
    50%,
    70%,
    90% {
        transform: scale(1.1) rotate(3deg);
    }

    40%,
    60%,
    80% {
        transform: scale(1.1) rotate(-3deg);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes popIn {
    0% {
        opacity: 0;
        transform: translate(-50%, 20px) scale(0.5);
    }

    100% {
        opacity: 1;
        transform: translate(-50%, 0) scale(1);
    }
}

@keyframes pulse-shadow {
    0% {
        box-shadow: 0 0 0 0 rgba(4, 59, 141, 0.4);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(4, 59, 141, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(4, 59, 141, 0);
    }
}

/* Parenthesis Sub-text */
.text-paren {
    font-size: 0.85em;
    color: var(--text-gray);
}

/* Key Question Highlight */
.chat-question {
    display: inline;
    font-weight: 700;
    background: linear-gradient(transparent 55%, rgba(255, 235, 59, 0.5) 55%);
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}

/* Multi-select styling */
.checkbox-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    padding: 14px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background-color: var(--white);
}

.checkbox-label:hover {
    background-color: var(--bg-light);
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    accent-color: var(--primary);
}

.checkbox-label.selected {
    border-color: var(--primary);
    background-color: var(--accent);
}

/* Privacy Consent Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--white);
    width: 90%;
    max-width: 400px;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 10px;
}

.modal-header h3 {
    font-size: 1.1rem;
    color: var(--text-dark);
}

.btn-close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-gray);
}

.modal-body {
    max-height: 40vh;
    overflow-y: auto;
    font-size: 0.85rem;
    color: var(--text-gray);
    line-height: 1.6;
    margin-bottom: 20px;
}

.modal-footer .btn-cta {
    padding: 12px;
    font-size: 1rem;
    border-radius: 8px;
    animation: none;
    box-shadow: none;
}