/* PDF 表單系統樣式 */

/* ========== 容器 ========== */
.pdf-forms-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.8rem;
    margin: 0.5rem 0;
}

.page-header .subtitle {
    color: #666;
    margin: 0;
}

.back-link {
    color: #4A90D9;
    text-decoration: none;
    font-size: 0.9rem;
}

.back-link:hover {
    text-decoration: underline;
}

.header-actions {
    margin-top: 1rem;
}

/* ========== 群組卡片 ========== */
.groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.group-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.5rem;
    background: #fff;
    border-radius: 12px;
    border-left: 4px solid #4A90D9;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
}

.group-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.group-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.group-info h3 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
}

.group-description {
    color: #666;
    font-size: 0.9rem;
    margin: 0 0 0.5rem;
}

.template-count {
    font-size: 0.8rem;
    color: #999;
}

/* ========== 模板卡片 ========== */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.template-card {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s;
}

.template-card:hover {
    border-color: #4A90D9;
}

.template-icon {
    font-size: 2rem;
}

.template-info h3 {
    margin: 0 0 0.25rem;
    font-size: 1rem;
}

.template-meta {
    display: flex;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: #666;
    margin: 0;
}

.document-id {
    font-family: monospace;
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 4px;
}

.version {
    color: #4A90D9;
}

/* ========== 模板列表 (群組內) ========== */
.templates-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.template-list-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.template-order {
    width: 32px;
    height: 32px;
    background: #4A90D9;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.template-list-item .template-info {
    flex: 1;
}

.template-list-item .template-info h3 {
    margin: 0;
}

.template-list-item .template-info h3 a {
    color: #333;
    text-decoration: none;
}

.template-list-item .template-info h3 a:hover {
    color: #4A90D9;
}

.template-note {
    color: #666;
    font-size: 0.9rem;
    margin: 0.25rem 0 0;
}

.template-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.required-badge {
    background: #dc3545;
    color: #fff;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 12px;
}

/* ========== 工作流程圖 ========== */
.workflow-section {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
}

.workflow-diagram {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem 0;
}

.workflow-step {
    background: #fff;
    padding: 1rem;
    border-radius: 8px;
    border: 2px solid #4A90D9;
    text-align: center;
    min-width: 150px;
}

.step-number {
    width: 28px;
    height: 28px;
    background: #4A90D9;
    color: #fff;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.step-content h4 {
    margin: 0 0 0.25rem;
    font-size: 0.95rem;
}

.step-note {
    font-size: 0.8rem;
    color: #666;
    margin: 0 0 0.5rem;
}

.workflow-arrow {
    font-size: 1.5rem;
    color: #4A90D9;
}

/* ========== 快速連結 ========== */
.quick-links {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.quick-link {
    padding: 0.75rem 1.5rem;
    background: #f5f5f5;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    transition: background 0.2s;
}

.quick-link:hover {
    background: #e8e8e8;
}

/* ========== 填寫表單頁面 ========== */
.fill-form-layout {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 2rem;
}

.pdf-preview-panel,
.form-panel {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
}

.panel-header {
    padding: 1rem;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h3 {
    margin: 0;
    font-size: 1rem;
}

.page-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-nav button {
    padding: 0.25rem 0.5rem;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
}

.page-nav button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pdf-container {
    padding: 1rem;
    text-align: center;
    position: relative;
    min-height: 500px;
}

.pdf-container canvas {
    max-width: 100%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.pdf-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #666;
}

/* ========== 表單欄位 ========== */
.pdf-fill-form {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group .required {
    color: #dc3545;
}

.form-group input[type="text"],
.form-group input[type="date"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #4A90D9;
    box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.1);
}

.checkbox-label,
.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* ========== 按鈕 ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}

.btn-primary {
    background: #4A90D9;
    color: #fff;
}

.btn-primary:hover {
    background: #3a7bc8;
}

.btn-secondary {
    background: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background: #e8e8e8;
}

.btn-danger {
    background: #dc3545;
    color: #fff;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ========== 模板編輯器 ========== */
.template-editor-page .editor-layout {
    display: grid;
    grid-template-columns: 220px 1fr 280px;
    gap: 1.5rem;
    min-height: 70vh;
}

.tools-panel,
.actions-panel {
    background: #fff;
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.tools-panel h3,
.actions-panel h3 {
    font-size: 0.95rem;
    margin: 0 0 1rem;
    color: #666;
}

.field-tools {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.tool-btn {
    padding: 0.5rem;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    text-align: center;
    transition: all 0.2s;
}

.tool-btn:hover {
    background: #f5f5f5;
    border-color: #4A90D9;
}

.editor-main {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
}

.editor-toolbar {
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.zoom-controls button {
    width: 28px;
    height: 28px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
}

.editor-canvas-container {
    padding: 1rem;
    overflow: auto;
    background: #e8e8e8;
    min-height: 500px;
}

.field-properties .form-group {
    margin-bottom: 0.75rem;
}

.field-properties label {
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.field-properties input,
.field-properties textarea,
.field-properties select {
    padding: 0.4rem;
    font-size: 0.85rem;
}

.field-list {
    max-height: 200px;
    overflow-y: auto;
}

.field-list-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: #f5f5f5;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
}

.field-list-item:hover {
    background: #e8e8e8;
}

.field-icon {
    font-size: 1rem;
}

.field-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.field-page {
    color: #999;
    font-size: 0.75rem;
}

.version-info {
    background: #f5f5f5;
    padding: 0.75rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.version-info p {
    margin: 0.25rem 0;
    font-size: 0.9rem;
}

.version-history {
    max-height: 200px;
    overflow-y: auto;
}

.version-item {
    padding: 0.75rem;
    background: #f5f5f5;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.version-item.active {
    border-left: 3px solid #4A90D9;
}

.version-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
}

.version-num {
    font-weight: bold;
}

.version-date {
    color: #666;
}

.version-log {
    font-size: 0.85rem;
    margin: 0.25rem 0;
    color: #333;
}

.version-author {
    font-size: 0.75rem;
    color: #999;
    margin: 0;
}

/* ========== 驗證頁面 ========== */
.verify-page .verify-container {
    max-width: 600px;
    margin: 0 auto;
}

.verify-input-section {
    background: #fff;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 2rem;
}

.verify-input-section input {
    font-size: 1.1rem;
    padding: 0.75rem;
}

.scan-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e0e0e0;
    text-align: center;
}

.scan-section p {
    color: #666;
    margin-bottom: 1rem;
}

#scannerContainer {
    margin-top: 1rem;
}

#scanner {
    width: 100%;
    max-width: 400px;
    border-radius: 8px;
}

.verify-result {
    background: #fff;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    text-align: center;
}

.verify-success,
.verify-failed,
.verify-error {
    padding: 1rem;
}

.result-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.verify-success h2 {
    color: #28a745;
}

.verify-failed h2 {
    color: #dc3545;
}

.result-details {
    text-align: left;
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 1.5rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e0e0e0;
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-row .label {
    color: #666;
}

.detail-row .value {
    font-weight: 500;
}

.warning {
    color: #856404;
    background: #fff3cd;
    padding: 0.75rem;
    border-radius: 6px;
    margin-top: 1rem;
}

/* ========== 管理頁面 ========== */
.admin-page .admin-menu {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.admin-menu-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s, box-shadow 0.2s;
}

.admin-menu-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.admin-menu-item .icon {
    font-size: 2.5rem;
}

.admin-menu-item .info h3 {
    margin: 0 0 0.25rem;
}

.admin-menu-item .info p {
    margin: 0;
    color: #666;
    font-size: 0.9rem;
}

/* ========== 資料表格 ========== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.data-table th,
.data-table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.data-table th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 0.9rem;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tr.inactive {
    opacity: 0.6;
}

.data-table .actions {
    white-space: nowrap;
}

.data-table .actions .btn {
    margin-right: 0.25rem;
}

.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

.status-active {
    color: #28a745;
}

.status-inactive {
    color: #dc3545;
}

/* ========== Tab ========== */
.admin-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #e0e0e0;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 1rem;
    color: #666;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.tab-btn.active {
    color: #4A90D9;
    border-bottom-color: #4A90D9;
}

.tab-content {
    display: none;
}

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

/* ========== Modal ========== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #fff;
    padding: 2rem;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content.modal-lg {
    max-width: 700px;
}

.modal-content h3 {
    margin: 0 0 1.5rem;
}

/* ========== 空狀態 ========== */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: #666;
}

.empty-state p {
    margin-bottom: 1rem;
}

/* ========== 提示文字 ========== */
.hint {
    font-size: 0.85rem;
    color: #666;
    margin: 0.25rem 0 0;
}

/* ========== 響應式 ========== */
@media (max-width: 1024px) {
    .template-editor-page .editor-layout {
        grid-template-columns: 1fr;
    }
    
    .tools-panel,
    .actions-panel {
        order: 1;
    }
    
    .editor-main {
        order: 0;
    }
}

@media (max-width: 768px) {
    .fill-form-layout {
        grid-template-columns: 1fr;
    }
    
    .pdf-preview-panel {
        display: none;
    }
    
    .groups-grid {
        grid-template-columns: 1fr;
    }
    
    .workflow-diagram {
        flex-direction: column;
    }
    
    .workflow-arrow {
        transform: rotate(90deg);
    }
}

/* ========== 上傳區域 ========== */
.file-upload-area {
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    position: relative;
    cursor: pointer;
    transition: border-color 0.2s;
}

.file-upload-area:hover,
.file-upload-area.dragover {
    border-color: #4A90D9;
}

.file-upload-area input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.upload-placeholder .icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.5rem;
}

.upload-placeholder p {
    color: #666;
    margin: 0;
}

.upload-preview {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: center;
}

.file-icon {
    font-size: 2rem;
}

.file-name {
    font-weight: 500;
}

/* ========== 表單區域 ========== */
.form-section {
    background: #fff;
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.form-section h3 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* ========== 版本資訊標頭 ========== */
.template-meta-header {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.template-meta-header .document-id {
    background: #f5f5f5;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-family: monospace;
}

.template-meta-header .version {
    color: #4A90D9;
    font-weight: 500;
}

.template-meta-header .date {
    color: #666;
}

/* ========== 排序列表 ========== */
.sortable-list {
    min-height: 100px;
}

.sortable-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: #f5f5f5;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.drag-handle {
    cursor: grab;
    color: #999;
}

.sortable-item .template-name {
    flex: 1;
    font-weight: 500;
}

.sortable-item .template-note {
    color: #666;
    font-size: 0.85rem;
}

/* ========== 群組圖示預覽 ========== */
.group-icon-preview {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    font-size: 1.2rem;
}

/* ========== 成員列表 ========== */
.member-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e0e0e0;
}

.member-item:last-child {
    border-bottom: none;
}

/* ========== 角色選擇 ========== */
.role-select {
    padding: 0.375rem 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

/* ========== 簽名區域 ========== */
.signature-field {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 0.5rem;
}

.signature-canvas {
    width: 100%;
    height: 100px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    cursor: crosshair;
}

.clear-signature {
    margin-top: 0.5rem;
}

.admin-form {
    max-width: 800px;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: #666;
}
