/* Process Macro 매개분석 표 스타일 */

/* 기본 레이아웃 */
.analyzer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 2rem 1.25rem;
}

/* 페이지 제목 */
.page-title {
    text-align: center;
    margin-bottom: 1.5rem;
}

.page-title h1 {
    color: #8A4B00;
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.page-title p {
    color: #6b7280;
    font-size: 1.1rem;
}

/* 업로드 섹션 */
.upload-section {
    margin-bottom: 2rem;
}

.upload-area {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    background: #f8fafc;
    transition: border-color 150ms ease-out, background-color 150ms ease-out;
    cursor: pointer;
}

.upload-area:hover {
    border-color: #FFC107;
    background: #FFF8E1;
}

.upload-area.drag-over {
    border-color: #FFA000;
    background: #FFECB3;
}

.upload-icon {
    color: #8F887C;
    line-height: 0;
    margin-bottom: 1rem;
}

.upload-text {
    font-size: 1.2rem;
    color: #475569;
    margin-bottom: 0.75rem;
}

.upload-hint {
    margin-bottom: 1.25rem;
    color: #6b7280;
    font-size: 0.9rem;
}

.upload-button {
    background: #FFC107;
    color: #3E2C00;
    border: none;
    padding: 0.75rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 150ms ease-out;
}

.upload-button:hover {
    background: #FFB300;
}

/* 터치에는 hover 가 없다 — 누른 순간의 색을 따로 둔다 */
.upload-button:active,
.download-button:active {
    background: #F0A500;
}

.file-input {
    display: none;
}

/* 형식 안내 — 토스트와 달리 남아 있는다 */
.pm-message {
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    border: 1px solid #F3C2BE;
    border-left: 4px solid #B3261E;
    border-radius: 8px;
    background: #FDF3F2;
    color: #5F1410;
    font-size: 0.95rem;
    line-height: 1.6;
}

/* 일부만 빠졌을 때 — 표는 만들어졌으므로 오류가 아니라 주의로 알린다 */
.pm-message-warning {
    border-color: #F0D48A;
    border-left-color: #C77800;
    background: #FFF8E1;
    color: #4A3300;
}

.pm-message-title {
    margin: 0 0 0.25rem;
    font-weight: 700;
}

.pm-message ul {
    margin: 0;
    padding-left: 1.25rem;
}

/* 사용 순서 */
.pm-steps {
    margin: 1.25rem 0 0;
    padding-left: 1.5rem;
    color: #475569;
    font-size: 0.95rem;
    line-height: 1.7;
}

/* 결과 섹션 */
.results-section {
    padding: 1.5rem 1.5rem 1rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.results-section h3 {
    color: #8A4B00;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

#analysisResults {
    margin-bottom: 1.5rem;
}

/* 분석 하나 */
.result-card {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.result-card:last-child {
    margin-bottom: 0;
}

.result-card h4 {
    color: #8A4B00;
    margin-bottom: 1rem;
    font-size: 1.2rem;
    font-weight: 700;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #FFC107;
    word-break: keep-all;
    overflow-wrap: anywhere;
}

/* 변수 이름 */
.pm-names {
    margin-bottom: 1.5rem;
}

.pm-names-help {
    margin: 0 0 0.75rem;
    color: #475569;
    font-size: 0.9rem;
}

.pm-name-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
}

.pm-name-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex: 1 1 160px;
    max-width: 240px;
}

.pm-name-label {
    color: #475569;
    font-size: 0.85rem;
    font-weight: 600;
}

.pm-name-input {
    width: 100%;
    box-sizing: border-box;
    padding: 0.55rem 0.7rem;
    border: 1px solid #8F887C;
    border-radius: 8px;
    background: #fff;
    color: #212121;
    font: inherit;
    /* 16px 보다 작으면 iOS Safari 가 입력칸을 누를 때 화면을 확대한다 */
    font-size: 1rem;
    min-height: 44px;
    transition: border-color 150ms ease-out;
}

.pm-name-input:hover {
    border-color: #6F6A60;
}

.pm-name-input:focus-visible {
    outline: 2px solid #A15C00;
    outline-offset: 1px;
    border-color: #A15C00;
}

/* 표 */
.pm-table-block {
    margin-bottom: 1.5rem;
}

.pm-table-block:last-child {
    margin-bottom: 0;
}

.pm-table-block h5 {
    margin: 0 0 0.5rem;
    color: #3E2C00;
    font-size: 1rem;
    font-weight: 700;
}

.pm-nowrap {
    white-space: nowrap;
}

/* 표·그림이 틀보다 넓을 때만 data-display.js 가 보여 준다 */
.pm-scroll-hint {
    margin: 0 0 0.5rem;
    color: #475569;
    font-size: 0.85rem;
}

.pm-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: #fff;
    border-radius: 6px;
}

.result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
}

.result-table th,
.result-table td {
    padding: 0.6rem 0.75rem;
    text-align: center;
    border: 1px solid #e5e7eb;
    white-space: nowrap;
}

.result-table th {
    background: #f3f4f6;
    font-weight: 600;
}

.result-table td:first-child {
    text-align: left;
}

/* 참고 */
.pm-notes {
    margin: 1rem 0 0;
    padding-left: 1.25rem;
    color: #475569;
    font-size: 0.88rem;
    line-height: 1.6;
}

/* 연구모형 그림 */
.pm-diagram {
    margin-top: 1.75rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.pm-diagram h5 {
    margin: 0 0 0.75rem;
    color: #3E2C00;
    font-size: 1rem;
    font-weight: 700;
}

.pm-diagram-options {
    margin: 0 0 1rem;
    padding: 0;
    border: 0;
    min-width: 0;
}

.pm-diagram-options legend {
    margin-bottom: 0.35rem;
    padding: 0;
    color: #475569;
    font-size: 0.85rem;
    font-weight: 600;
}

.pm-diagram-options label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 44px;
    margin-right: 1.5rem;
    color: #212121;
    font-size: 0.95rem;
    cursor: pointer;
}

.pm-diagram-options input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: #C77800;
}

.pm-diagram-options .pm-option-disabled {
    color: #6E6A61;
    cursor: not-allowed;
}

/* 그림 잠금 안내 — 내려받기 전에는 워터마크가 왜 있는지, 뒤에는 열렸다는 것 */
.pm-lock-note {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin: 0 0 0.75rem;
    padding: 0.65rem 0.85rem;
    border: 1px solid #F0D48A;
    border-radius: 6px;
    background: #FFF8E1;
    color: #4A3300;
    font-size: 0.9rem;
    line-height: 1.55;
}

.pm-lock-note svg {
    flex-shrink: 0;
    margin-top: 0.1rem;
    color: #8A4B00;
}

.pm-lock-note-open {
    border-color: #B9DCC0;
    background: #F1F8F2;
    color: #1E4620;
}

.pm-lock-note-open svg {
    color: #2E6B3A;
}

.pm-diagram-frame {
    padding: 1rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.pm-diagram-canvas {
    display: block;
    width: 100%;
    height: auto;
    margin: 0 auto;
}

.pm-diagram-legend {
    margin: 0.75rem 0 1rem;
    color: #475569;
    font-size: 0.88rem;
    line-height: 1.6;
}

.pm-image-button {
    padding: 0.65rem 1.25rem;
    border: 1px solid #8F887C;
    border-radius: 8px;
    background: #fff;
    color: #3E2C00;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 150ms ease-out, border-color 150ms ease-out;
}

.pm-image-button:hover {
    background: #FFF8E1;
    border-color: #C77800;
}

.pm-image-button:active {
    background: #FFEFC2;
}

/* 내려받기 전 — 누르면 이유를 알려 주므로 disabled 대신 aria-disabled 로 둔다 */
.pm-image-button[aria-disabled="true"],
.pm-image-button[aria-disabled="true"]:hover,
.pm-image-button[aria-disabled="true"]:active {
    border-color: #D6D0C4;
    background: #F7F5F0;
    color: #6E6A61;
    cursor: not-allowed;
}

.pm-image-button:focus-visible,
.pm-diagram-options input:focus-visible,
.pm-diagram-frame:focus-visible,
.pm-table-scroll:focus-visible {
    outline: 2px solid #A15C00;
    outline-offset: 2px;
}

/* 다운로드 */
.action-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.download-button {
    flex: 1;
    min-width: 200px;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    background: #FFC107;
    color: #3E2C00;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 150ms ease-out;
}

.download-button:hover {
    background: #FFB300;
}

.upload-button:focus-visible,
.download-button:focus-visible {
    outline: 2px solid #A15C00;
    outline-offset: 2px;
}

/* 알림 */
.notification {
    position: fixed;
    top: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 150ms ease-out, transform 150ms ease-out;
    pointer-events: none;
    z-index: 1000;
}

.notification.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.notification.success {
    border-left: 4px solid #10b981;
}

.notification.error {
    border-left: 4px solid #ef4444;
}

.notification.info {
    border-left: 4px solid #FFC107;
}

.notification.warning {
    border-left: 4px solid #f59e0b;
}

/* 로딩 오버레이 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner {
    text-align: center;
    background: white;
    padding: 2rem 3rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 1rem;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #C77800;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    margin: 0;
    font-size: 1rem;
    color: #475569;
    font-weight: 500;
}

/* 반응형 */
@media (max-width: 768px) {
    .page-title h1 {
        font-size: 2rem;
    }

    .upload-area {
        padding: 2rem 1rem;
    }

    .results-section {
        padding: 1rem;
    }

    .result-card {
        padding: 1rem;
    }

    .pm-name-field {
        max-width: none;
    }

    /* 옆으로 밀어도 어느 경로의 줄인지 알 수 있게 첫 열을 붙여 둔다.
       border-collapse 로는 붙은 칸의 선이 표와 함께 밀려 나가므로 선을 칸마다 따로 긋는다. */
    .result-table {
        border-collapse: separate;
        border-spacing: 0;
        border-top: 1px solid #e5e7eb;
        border-left: 1px solid #e5e7eb;
    }

    .result-table th,
    .result-table td {
        border-width: 0 1px 1px 0;
    }

    .result-table th:first-child,
    .result-table td:first-child {
        position: sticky;
        left: 0;
        z-index: 1;
        /* 이름을 길게 고치면 첫 열이 화면을 다 차지한다 — 줄을 바꿔 숫자 볼 자리를 남긴다.
           anywhere 는 쓰지 않는다: 열 너비를 한 글자까지 줄여도 된다는 뜻이 되어 열이 찌그러진다. */
        min-width: 5.5rem;
        max-width: 9.5rem;
        white-space: normal;
        word-break: keep-all;
        overflow-wrap: break-word;
    }

    .result-table td:first-child {
        background: #fff;
    }

    .download-button {
        min-width: 100%;
    }
}

@media (max-width: 480px) {
    .page-title h1 {
        font-size: 1.5rem;
    }

    .upload-text {
        font-size: 1rem;
    }

    .result-table {
        font-size: 0.8rem;
    }

    .result-table th,
    .result-table td {
        padding: 0.4rem 0.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation-duration: 3s;
    }
}
