/**
 * WP PocketBase Forms - Frontend Styles
 * Responsive card layout, form styles
 * Version: 1.0.0
 */

/* ===== 容器 ===== */
.pb-forms-app {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #333;
    box-sizing: border-box;
}

.pb-forms-app *,
.pb-forms-app *::before,
.pb-forms-app *::after {
    box-sizing: border-box;
}

/* ===== 头部 ===== */
.pb-forms-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #2271b1;
}

.pb-forms-title {
    margin: 0 0 6px;
    font-size: 1.5em;
    font-weight: 700;
    color: #1d2327;
    line-height: 1.3;
}

.pb-forms-subtitle {
    margin: 0;
    font-size: 0.9em;
    color: #646970;
}

/* ===== 工具栏 ===== */
.pb-forms-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

/* ===== 按钮 ===== */
.pb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 18px;
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    background: #f0f0f1;
    color: #2c3338;
    white-space: nowrap;
}

.pb-btn:hover {
    opacity: 0.9;
}

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

.pb-btn-primary {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

.pb-btn-primary:hover {
    background: #135e96;
    border-color: #135e96;
    color: #fff;
}

.pb-btn-secondary {
    background: #f0f0f1;
    color: #2c3338;
    border-color: #c3c4c7;
}

.pb-btn-secondary:hover {
    background: #e0e0e1;
    color: #1d2327;
}

.pb-btn-danger {
    background: #d63638;
    color: #fff;
    border-color: #d63638;
}

.pb-btn-danger:hover {
    background: #b32d2e;
    border-color: #b32d2e;
    color: #fff;
}

.pb-btn-sm {
    padding: 5px 12px;
    font-size: 12px;
}

/* ===== 消息提示 ===== */
.pb-forms-message {
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.5;
}

.pb-forms-message.pb-msg-success {
    background: #edf7ed;
    border-left: 4px solid #00a32a;
    color: #1a7a1a;
}

.pb-forms-message.pb-msg-error {
    background: #fde8e8;
    border-left: 4px solid #d63638;
    color: #b32d2e;
}

.pb-forms-message.pb-msg-info {
    background: #e8f0fe;
    border-left: 4px solid #2271b1;
    color: #135e96;
}

/* ===== 加载状态 ===== */
.pb-forms-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 30px;
    color: #646970;
    font-size: 14px;
}

.pb-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid #c3c4c7;
    border-top-color: #2271b1;
    border-radius: 50%;
    animation: pb-spin 0.8s linear infinite;
}

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

/* ===== 筛选栏 ===== */
.pb-forms-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding: 12px 14px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}

.pb-filter-search-wrap {
    flex: 1 1 220px;
    min-width: 160px;
}

.pb-filter-input {
    width: 100%;
    padding: 7px 12px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.5;
    color: #1d2327;
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.pb-filter-input:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

.pb-filter-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pb-filter-select {
    padding: 6px 10px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 13px;
    color: #1d2327;
    background: #fff;
    cursor: pointer;
    max-width: 200px;
}

.pb-filter-select:focus {
    outline: none;
    border-color: #2271b1;
}

.pb-filter-count {
    font-size: 12px;
    color: #646970;
    white-space: nowrap;
    margin-left: auto;
}

/* ===== 批量操作栏 ===== */
.pb-forms-batch-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding: 10px 14px;
    background: #fff7f7;
    border: 1px solid #ffcdc7;
    border-radius: 6px;
}

.pb-batch-count {
    font-size: 14px;
    font-weight: 600;
    color: #b32d2e;
    margin-right: auto;
}

/* ===== 列表视图 - 数据表格 ===== */
.pb-table-wrap {
    margin-bottom: 20px;
}

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

.pb-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    line-height: 1.5;
}

.pb-data-table thead th {
    background: #f0f0f1;
    color: #1d2327;
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid #c3c4c7;
    vertical-align: middle;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}

.pb-data-table tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f1;
    vertical-align: middle;
    color: #1d2327;
}

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

.pb-data-table tbody tr:hover {
    background: #f9fbff;
}

.pb-data-table tbody tr.pb-table-empty td {
    text-align: center;
    padding: 30px 12px;
    color: #646970;
}

/* 复选框列 */
.pb-col-check {
    width: 40px;
    text-align: center;
    white-space: nowrap;
}

.pb-data-table input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    vertical-align: middle;
}

/* 单元格 */
.pb-cell {
    word-break: break-word;
    max-width: 280px;
}

.pb-cell-date {
    white-space: nowrap;
    color: #646970;
    font-size: 12px;
}

.pb-cell a {
    color: #2271b1;
    text-decoration: none;
}

.pb-cell a:hover {
    text-decoration: underline;
}

.pb-value-empty {
    color: #c3c4c7;
}

.pb-value-bool-true {
    color: #00a32a;
    font-weight: 600;
}

.pb-value-bool-false {
    color: #646970;
}

/* 操作列 */
.pb-col-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

.pb-col-actions .pb-btn {
    margin-left: 4px;
}

/* 空状态 */
.pb-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #646970;
    background: #f9f9f9;
    border: 1px dashed #dcdcde;
    border-radius: 6px;
}

.pb-empty-state p {
    margin: 0;
    font-size: 14px;
}

/* ===== 表单视图 ===== */
.pb-form-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.pb-form-card-title {
    margin: 0 0 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f1;
    font-size: 1.2em;
    color: #1d2327;
}

.pb-form-field {
    margin-bottom: 16px;
}

.pb-field-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #1d2327;
}

.pb-required {
    color: #d63638;
}

.pb-field-control {
    width: 100%;
}

.pb-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.5;
    color: #1d2327;
    background: #fff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.pb-input:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

.pb-input:invalid {
    border-color: #d63638;
}

textarea.pb-input {
    resize: vertical;
    min-height: 80px;
}

.pb-checkbox-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.pb-checkbox-wrap input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.pb-locked-value {
    display: inline-block;
    padding: 8px 12px;
    background: #f0f0f1;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    font-size: 14px;
    color: #646970;
}

.pb-form-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #f0f0f1;
}

/* ===== 未登录提示 ===== */
.pb-forms-login-required .pb-forms-message-box {
    text-align: center;
    padding: 40px 20px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
}

.pb-forms-login-required .pb-forms-message-box p {
    margin: 10px 0;
    font-size: 14px;
}

/* ===== 响应式 ===== */
@media screen and (max-width: 782px) {
    .pb-forms-app {
        padding: 15px 0;
    }

    .pb-forms-title {
        font-size: 1.3em;
    }

    .pb-forms-toolbar {
        flex-direction: column;
    }

    .pb-forms-toolbar .pb-btn {
        width: 100%;
    }

    .pb-forms-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .pb-filter-fields {
        flex-direction: column;
    }

    .pb-filter-select {
        max-width: 100%;
    }

    .pb-filter-count {
        margin-left: 0;
        text-align: right;
    }

    .pb-forms-batch-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .pb-batch-count {
        margin-right: 0;
        text-align: center;
    }

    /* 表格在小屏改为卡片式行 */
    .pb-data-table thead {
        display: none;
    }

    .pb-data-table,
    .pb-data-table tbody,
    .pb-data-table tr,
    .pb-data-table td {
        display: block;
        width: 100%;
    }

    .pb-data-table tbody tr {
        border: 1px solid #e0e0e0;
        border-radius: 6px;
        margin-bottom: 10px;
        padding: 6px 0;
    }

    .pb-data-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 8px 12px;
        border-bottom: 1px solid #f0f0f1;
        text-align: right;
    }

    .pb-data-table tbody td::before {
        content: attr(data-label);
        font-size: 11px;
        font-weight: 600;
        color: #646970;
        text-transform: uppercase;
        text-align: left;
    }

    .pb-data-table tbody td.pb-col-check {
        justify-content: center;
        border-bottom: 2px solid #e0e0e0;
    }

    .pb-data-table tbody td.pb-col-check::before {
        display: none;
    }

    .pb-data-table tbody td.pb-col-actions {
        justify-content: flex-end;
    }

    .pb-cell {
        max-width: 60%;
    }

    .pb-form-actions {
        flex-direction: column;
    }

    .pb-form-actions .pb-btn {
        width: 100%;
    }

    .pb-form-card {
        padding: 16px;
    }

    .pb-btn {
        padding: 10px 18px;
        font-size: 15px;
    }
}

@media screen and (max-width: 480px) {
    .pb-forms-app {
        padding: 10px 0;
    }

    .pb-forms-title {
        font-size: 1.15em;
    }

    .pb-forms-subtitle {
        font-size: 0.85em;
    }

    .pb-cell {
        max-width: none;
    }
}
