/* 卡密验证系统 - 样式文件 */

/* ==================== 全局样式 ==================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --primary-dark: #5568d3;
    --secondary-color: #764ba2;
    --success-color: #48bb78;
    --error-color: #f56565;
    --warning-color: #ed8936;
    --info-color: #4299e1;
    --text-color: #2d3748;
    --text-light: #718096;
    --border-color: #e2e8f0;
    --bg-light: #f7fafc;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.2);
}

body {
    font-family: 'Microsoft YaHei', 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    min-height: 100vh;
    color: var(--text-color);
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
}

button,
.btn,
input,
select,
textarea,
a {
    touch-action: manipulation;
}

/* ==================== 容器 ==================== */

.container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ==================== 卡片 ==================== */

.card {
    background: white;
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.card-header {
    padding: 30px;
    text-align: center;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
}

.card-header h1 {
    font-size: 28px;
    margin-bottom: 10px;
}

.card-header h2 {
    font-size: 20px;
    margin: 0;
}

.subtitle {
    font-size: 14px;
    opacity: 0.9;
    margin: 0;
}

.card-body {
    padding: 30px;
}

.card-footer {
    padding: 20px;
    text-align: center;
    background: var(--bg-light);
    border-top: 1px solid var(--border-color);
}

/* ==================== 表单 ==================== */

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    font-size: 16px;
    transition: all 0.3s;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-control:disabled {
    background: var(--bg-light);
    cursor: not-allowed;
}

.form-text {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: var(--text-light);
}

.form-inline {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.form-inline .form-group {
    flex: 1;
    min-width: 150px;
    margin-bottom: 0;
}

/* ==================== 按钮 ==================== */

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

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

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--text-light);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: var(--text-color);
}

.btn-danger {
    background: var(--error-color);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #e53e3e;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 14px;
}

.btn-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* ==================== 加载动画 ==================== */

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ==================== 结果显示 ==================== */

.result {
    padding: 20px;
    border-radius: 5px;
    margin-top: 20px;
    text-align: center;
}

.result-success {
    background: #c6f6d5;
    color: #22543d;
    border: 2px solid var(--success-color);
}

.result-error {
    background: #fed7d7;
    color: #742a2a;
    border: 2px solid var(--error-color);
}

.result-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.result-message {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
}

.result-details {
    font-size: 14px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.result-details p {
    margin: 5px 0;
}

/* ==================== 提示框 ==================== */

.alert {
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 15px;
}

.alert-success {
    background: #c6f6d5;
    color: #22543d;
    border: 1px solid var(--success-color);
}

.alert-error {
    background: #fed7d7;
    color: #742a2a;
    border: 1px solid var(--error-color);
}

.alert-info {
    background: #bee3f8;
    color: #2c5282;
    border: 1px solid var(--info-color);
}

/* ==================== 链接 ==================== */

.link {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s;
}

.link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.separator {
    margin: 0 10px;
    color: var(--text-light);
}

/* ==================== 管理后台 ==================== */

.admin-header {
    background: white;
    padding: 20px 30px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.admin-header h1 {
    margin: 0;
    color: var(--text-color);
}

/* 统计卡片 */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 10px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-value {
    font-size: 36px;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.stat-label {
    font-size: 14px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* 工具栏 */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 15px;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    gap: 10px;
    flex: 1;
    min-width: 300px;
}

.search-box .form-control {
    flex: 1;
}

.actions {
    display: flex;
    gap: 10px;
}

/* 表格 */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.table th,
.table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background: var(--bg-light);
    font-weight: 600;
    color: var(--text-color);
}

.table tr:hover {
    background: var(--bg-light);
}

.table code {
    background: var(--bg-light);
    padding: 4px 8px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.key-code {
    word-break: break-all;
}

/* 状态标签 */
.status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-unused {
    background: #c6f6d5;
    color: #22543d;
}

.status-used {
    background: #fed7d7;
    color: #742a2a;
}

.status-expired {
    background: #feebc8;
    color: #7c2d12;
}

/* 生成结果 */
.generated-keys {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.keys-list {
    max-height: 300px;
    overflow-y: auto;
    margin: 10px 0;
    padding: 10px;
    background: white;
    border-radius: 5px;
}

.key-item {
    padding: 8px;
    margin: 5px 0;
    background: var(--bg-light);
    border-radius: 3px;
}

.key-item code {
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}

.pagination button {
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.pagination button:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

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

/* 文本工具类 */
.text-center {
    text-align: center;
}

.text-error {
    color: var(--error-color);
}

/* ==================== 响应式设计 ==================== */

@media (max-width: 768px) {
    .container {
        padding: 14px;
        align-items: flex-start;
    }

    .card {
        max-width: 100%;
        border-radius: 12px;
    }

    .card-body {
        padding: 20px 16px;
    }

    .card-footer {
        padding: 14px;
    }

    .card-header h1 {
        font-size: 24px;
    }
    
    .admin-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .stats-container {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .search-box {
        min-width: 100%;
    }
    
    .form-inline {
        flex-direction: column;
    }
    
    .form-inline .form-group {
        width: 100%;
    }
    
    .table {
        font-size: 14px;
    }
    
    .table th,
    .table td {
        padding: 8px;
    }

    .btn {
        min-height: 42px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 10px;
    }

    .card-header {
        padding: 20px 14px;
    }

    .card-header h1 {
        font-size: 22px;
    }

    .card-header h2 {
        font-size: 18px;
    }

    .form-control {
        font-size: 16px;
        padding: 11px 12px;
    }

    .btn {
        width: 100%;
        font-size: 15px;
        padding: 12px 16px;
    }

    .stats-container {
        grid-template-columns: 1fr;
    }
    
    .stat-value {
        font-size: 28px;
    }
}
