/* ============================================================
 * Altium 原理图查看器
 * ============================================================ */

/* ---------------- 页面头部（与其它工具页保持一致） ---------------- */

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    margin-bottom: 20px;
}

.back-btn {
    display: inline-flex;
    align-items: center;
    padding: 6px 18px;
    background-color: #f5f5f5;
    color: #666;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    height: 36px;
    box-sizing: border-box;
}

.back-btn:hover {
    background-color: #e8e8e8;
    color: #333;
    transform: translateY(-1px);
}

.header .header-actions {
    position: static;
    transform: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.favorite-button {
    display: inline-flex;
    align-items: center;
    padding: 6px 18px;
    background-color: #f5f5f5;
    color: #666;
    text-decoration: none;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    height: 36px;
    box-sizing: border-box;
    cursor: pointer;
    font-family: inherit;
}

.favorite-button:hover {
    background-color: #e8e8e8;
    color: #333;
    transform: translateY(-1px);
}

.favorite-button.favorited {
    background-color: #fff8e1;
    color: #f9a825;
}

.favorite-button.favorited:hover {
    background-color: #fff3cd;
    color: #e65100;
}

/* ---------------- 布局 ---------------- */

.sdv-layout {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 16px;
    margin: 18px 0 40px;
    align-items: start;
}

.sdv-panel {
    background: #ffffff;
    border: 1px solid #e8ebef;
    border-radius: 14px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.04);
    box-sizing: border-box;
}

.sdv-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.sdv-panel-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
}

.sdv-panel-badge {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 999px;
    background: #f3f4f6;
    color: #9ca3af;
    font-weight: 500;
    white-space: nowrap;
}

.sdv-panel-badge.is-active {
    background: #eef9f0;
    color: #2f9e50;
}

/* ---------------- 上传区 ---------------- */

.sdv-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 34px 18px;
    border: 1.5px dashed #d6dbe1;
    border-radius: 12px;
    background: #fbfcfd;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.18s ease, background 0.18s ease;
    outline: none;
}

.sdv-dropzone:hover,
.sdv-dropzone:focus-visible {
    border-color: #9ed6ab;
    background: #f8fdf9;
}

.sdv-dropzone.is-dragover {
    border-color: #4CAF50;
    background: #eef9f0;
}

.sdv-dropzone-icon {
    width: 42px;
    height: 42px;
    color: #b8c0c9;
    margin-bottom: 4px;
}

.sdv-dropzone-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.sdv-dropzone-hint {
    margin: 0;
    font-size: 12px;
    color: #9ca3af;
    line-height: 1.5;
}

.sdv-dropzone-btn {
    margin-top: 10px;
}

/* ---------------- 信息 ---------------- */

.sdv-meta {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    margin-top: 14px;
}

.sdv-meta-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    background: #fafbfc;
    border-radius: 8px;
    min-width: 0;
}

.sdv-meta-label {
    font-size: 12px;
    color: #9ca3af;
    flex: none;
}

.sdv-meta-value {
    font-size: 13px;
    color: #1f2937;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.sdv-preview-actions {
    margin-top: 2px;
}

.sdv-link-btn {
    border: none;
    background: none;
    color: #4CAF50;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0;
    font-family: inherit;
}

.sdv-link-btn:hover {
    color: #2f9e50;
    text-decoration: underline;
}

.sdv-tip {
    margin: 14px 0 0;
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.65;
    color: #8a8f98;
    background: #fafbfc;
    border-radius: 8px;
}

.sdv-tip strong {
    color: #6b7280;
    font-weight: 600;
}

/* ---------------- 工具栏 ---------------- */

.sdv-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.sdv-tool-btn {
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #ffffff;
    color: #4b5563;
    font-size: 15px;
    line-height: 1;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.16s ease;
}

.sdv-tool-btn:hover:not(:disabled) {
    border-color: #4CAF50;
    color: #2f9e50;
    background: #f8fdf9;
}

.sdv-tool-btn:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.sdv-tool-text {
    font-size: 12px;
    font-weight: 500;
    padding: 0 10px;
}

.sdv-zoom-value {
    min-width: 46px;
    text-align: center;
    font-size: 12px;
    color: #6b7280;
    font-variant-numeric: tabular-nums;
}

/* ---------------- 画布区 ---------------- */

.sdv-stage {
    position: relative;
    height: 70vh;
    min-height: 460px;
    overflow: auto;
    background: #f4f6f8;
    border-radius: 10px;
    border: 1px solid #eef1f4;
    cursor: default;
}

.sdv-stage.is-panning {
    cursor: grabbing;
    user-select: none;
}

.sdv-stage.is-panning .sdv-canvas-wrap {
    pointer-events: none;
}

.sdv-canvas-wrap {
    position: relative;
    width: 0;
    height: 0;
}

.sdv-canvas-wrap canvas {
    display: block;
}

.sdv-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #b0b7c0;
    text-align: center;
    padding: 20px;
    pointer-events: none;
}

.sdv-empty[hidden] {
    display: none;
}

.sdv-empty svg {
    width: 52px;
    height: 52px;
    opacity: 0.8;
}

.sdv-empty p {
    margin: 0;
    font-size: 13px;
    line-height: 1.6;
    max-width: 320px;
}

/* ---------------- 按钮 ---------------- */

.sdv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: 10px;
    border: 1.5px solid transparent;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.18s ease;
    white-space: nowrap;
}

.sdv-btn-primary {
    background: #4CAF50;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.24);
}

.sdv-btn-primary:hover:not(:disabled) {
    background: #43a047;
    box-shadow: 0 4px 14px rgba(76, 175, 80, 0.3);
}

.sdv-btn-primary:disabled {
    background: #d7dbdf;
    box-shadow: none;
    cursor: not-allowed;
}

.sdv-btn-ghost {
    background: #ffffff;
    border-color: #e5e7eb;
    color: #4b5563;
}

.sdv-btn-ghost:hover {
    border-color: #4CAF50;
    color: #2f9e50;
    background: #f8fdf9;
}

.sdv-btn-sm {
    padding: 6px 14px;
    font-size: 13px;
    border-radius: 8px;
}

/* ---------------- 提示条 ---------------- */

.sdv-toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translate(-50%, -12px);
    padding: 11px 22px;
    border-radius: 10px;
    background: #374151;
    color: #ffffff;
    font-size: 14px;
    line-height: 1.4;
    z-index: 99999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.24s ease, transform 0.24s ease;
    max-width: 82vw;
    text-align: center;
}

.sdv-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.sdv-toast.is-error {
    background: #dc2626;
}

.sdv-toast.is-success {
    background: #16a34a;
}

/* ---------------- 响应式 ---------------- */

@media (max-width: 1024px) {
    .sdv-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .sdv-stage {
        height: 60vh;
    }
}

@media (max-width: 640px) {
    .sdv-panel {
        padding: 12px;
        border-radius: 12px;
    }

    .sdv-stage {
        height: 52vh;
        min-height: 320px;
    }

    .sdv-toolbar {
        width: 100%;
    }

    .sdv-tool-btn,
    .sdv-btn-sm {
        flex: 0 0 auto;
    }
}

/* ---------------- 元件清单 ---------------- */

.sdv-bom-panel {
    margin-bottom: 40px;
}

.sdv-bom-scroll {
    max-height: 420px;
    overflow: auto;
    border: 1px solid #eef1f4;
    border-radius: 10px;
}

.sdv-bom-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.sdv-bom-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #fafbfc;
    color: #6b7280;
    font-weight: 600;
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid #eef1f4;
    white-space: nowrap;
}

.sdv-bom-table tbody td {
    padding: 9px 12px;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
    vertical-align: top;
    line-height: 1.5;
}

.sdv-bom-table tbody tr:last-child td {
    border-bottom: none;
}

.sdv-bom-table tbody tr:hover td {
    background: #fafbfc;
}

.sdv-bom-table tbody td:first-child {
    font-weight: 600;
    white-space: nowrap;
    color: #1f2937;
}

.sdv-bom-table tbody td:nth-child(2) {
    white-space: nowrap;
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 12px;
}

@media (max-width: 640px) {
    .sdv-bom-table thead th,
    .sdv-bom-table tbody td {
        padding: 8px;
        font-size: 12px;
    }

    .sdv-bom-table tbody td:nth-child(2) {
        white-space: normal;
    }
}

/* ---------------- 全屏 ---------------- */

.sdv-viewer-panel:fullscreen {
    width: 100vw;
    height: 100vh;
    padding: 14px;
    border: none;
    border-radius: 0;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.sdv-viewer-panel:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    padding: 14px;
    border: none;
    border-radius: 0;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.sdv-viewer-panel:fullscreen .sdv-stage,
.sdv-viewer-panel:-webkit-full-screen .sdv-stage {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
}

.sdv-viewer-panel:fullscreen .sdv-panel-head,
.sdv-viewer-panel:-webkit-full-screen .sdv-panel-head {
    flex: 0 0 auto;
}
