/* =========================
   全局容器
========================= */
.cdkey-wrapper {
    max-width: 1400px;
    margin: 20px auto;
    padding: 0 20px;
}

/* 标题 */
.cdkey-title {
    font-size: 24px;
    margin-bottom: 20px;
    font-weight: bold;
    color: #333;
}

/* 卡片容器 - 覆盖 app.css 中的 flex 样式 */
.cdkey-card {
    display: block !important;
    background: #fff !important;
    padding: 20px !important;
    border-radius: 8px !important;
    margin-bottom: 20px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
    border: none !important;
    align-items: unset !important;
    justify-content: unset !important;
    color: unset !important;
    font-size: unset !important;
    white-space: unset !important;
    text-align: unset !important;
}

/* =========================
   搜索框
========================= */
.cdkey-search input {
    width: 100%;
    padding: 10px 15px;
    border-radius: 6px;
    border: 1px solid #ddd;
    font-size: 14px;
    box-sizing: border-box;
}

.cdkey-search input:focus {
    border-color: #3498db;
    outline: none;
}

/* =========================
   新增表单布局
========================= */
#cdkey-create-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

#cdkey-create-form input[type="text"],
#cdkey-create-form input[type="number"],
#cdkey-create-form input[type="datetime-local"],
#cdkey-create-form select {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    height: 36px;
    box-sizing: border-box;
}

#cdkey-create-form input[name="item_data"] {
    flex: 1;
    min-width: 250px;
}

#cdkey-create-form input[name="max_use"] {
    width: 70px;
}

#cdkey-create-form button[type="submit"] {
    background: #27ae60;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    height: 36px;
}

#cdkey-create-form button[type="submit"]:hover {
    background: #219150;
}

/* =========================
   批量删除按钮
========================= */
#bulk-delete-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}

#bulk-delete-btn:hover {
    background: #c0392b;
}

/* =========================
   表格容器
========================= */
.cdkey-table-wrapper {
    width: 100%;
    overflow-x: auto;
    margin-top: 15px;
}

.cdkey-table {
    width: 100%;
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
    table-layout: auto;
}

/* 表头 */
.cdkey-table th {
    background: #2c3e50;
    color: #fff;
    padding: 12px 8px;
    text-align: center;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
}

/* 单元格 */
.cdkey-table td {
    padding: 10px 8px;
    text-align: center;
    word-break: break-word;
    font-size: 13px;
    border-bottom: 1px solid #eee;
}

/* hover */
.cdkey-table tbody tr:hover {
    background: #f8f9fa;
}

/* 物品描述 */
.cdkey-item-desc {
    color: #666;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-align: left;
}

/* 状态颜色 */
.ok {
    color: #27ae60;
    font-weight: bold;
}

.used {
    color: #e74c3c;
    font-weight: bold;
}

/* 按钮通用样式 */
.cdkey-wrapper button:not(#bulk-delete-btn):not([type="submit"]) {
    padding: 4px 10px;
    border: none;
    background: #3498db;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.cdkey-wrapper button:not(#bulk-delete-btn):not([type="submit"]):hover {
    background: #2980b9;
}

.delete-btn {
    background: #e74c3c !important;
}

.delete-btn:hover {
    background: #c0392b !important;
}

/* checkbox */
.cdkey-table input[type="checkbox"] {
    transform: scale(1.2);
    cursor: pointer;
}

/* 分页控件 */
.pagination-top {
    margin-bottom: 15px;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

#pagination-controls-top {
    display: flex;
    align-items: center;
    gap: 8px;
}

#pagination-controls-top button {
    padding: 5px 12px;
    background: #eee;
    color: #333;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

#pagination-controls-top button:hover {
    background: #ddd;
}

#page-numbers-top button {
    margin: 0 2px;
}

.page-jump {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
    font-size: 13px;
    color: #666;
}

.page-jump input {
    width: 60px;
    padding: 4px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    text-align: center;
}

.page-jump input:focus {
    border-color: #3498db;
    outline: none;
}

.page-jump button {
    padding: 4px 12px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.page-jump button:hover {
    background: #2980b9;
}

/* 分页信息 */
#pagination-info {
    font-size: 14px;
    color: #666;
    white-space: nowrap;
}

/* 顶部操作栏 */
.table-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 15px !important;
    width: 100%;
    flex-direction: row !important;
}

.table-header #bulk-delete-btn {
    flex-shrink: 0;
}

.table-header #pagination-info {
    flex-shrink: 0;
    white-space: nowrap;
}

/* 移动端适配 */
@media (max-width: 768px) {
    .cdkey-wrapper {
        padding: 10px;
    }
    
    #cdkey-create-form {
        flex-direction: column;
    }
    
    #cdkey-create-form input,
    #cdkey-create-form select {
        width: 100% !important;
    }
    
    .cdkey-table thead {
        display: none;
    }
    
    .cdkey-table tr {
        display: block;
        margin-bottom: 14px;
        background: #fff;
        border-radius: 8px;
        padding: 12px;
        box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    }
    
    .cdkey-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border: none;
        font-size: 13px;
    }
    
    .cdkey-table td::before {
        content: attr(data-label);
        font-weight: bold;
        color: #888;
        margin-right: 10px;
    }
    
    .cdkey-table td:first-child {
        justify-content: flex-end;
    }
    
    .cdkey-item-desc {
        -webkit-line-clamp: 3;
    }
}
