/* style.css - KeygenMaster Web 版 现代化暗色主题 v2 */
:root {
    /* 主色调 */
    --bg: #0f1117;
    --bg-soft: #151824;
    --sidebar: #161a26;
    --card: #1a1f2e;
    --card-hover: #212736;
    --border: #2a3040;
    --border-light: #333b4f;

    /* 文字 */
    --text: #e8eaf0;
    --text-secondary: #9aa3b8;
    --text-muted: #67708a;

    /* 强调色 */
    --primary: #5b8def;
    --primary-hover: #4a7ae0;
    --primary-soft: rgba(91, 141, 239, 0.12);
    --success: #34c98e;
    --success-hover: #2bb37e;
    --success-soft: rgba(52, 201, 142, 0.12);
    --danger: #ef5350;
    --danger-hover: #e0443f;
    --danger-soft: rgba(239, 83, 80, 0.12);
    --warning: #ffa726;
    --warning-soft: rgba(255, 167, 38, 0.12);

    --mono: 'Cascadia Code', 'Consolas', 'JetBrains Mono', monospace;
    --radius: 12px;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
    --transition: all 0.2s ease;
}

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

html, body { height: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', '微软雅黑', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 14px;
}

/* ===================== 侧边栏布局 ===================== */
.layout {
    display: grid;
    grid-template-columns: 230px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

.brand-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), #8a6df0);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 12px rgba(91, 141, 239, 0.3);
}

.brand-text h1 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.brand-text p {
    font-size: 11px;
    color: var(--text-muted);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    font-size: 14px;
}

.nav-item:hover {
    background: var(--bg-soft);
    color: var(--text);
}

.nav-item.active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}

.nav-item .nav-icon { font-size: 18px; width: 22px; text-align: center; }

.sidebar-user {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin-top: 16px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    margin-bottom: 8px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--success), var(--primary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #fff;
    font-weight: 700;
}

.logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border-radius: 10px;
    background: var(--danger-soft);
    color: var(--danger);
    text-decoration: none;
    transition: var(--transition);
    font-size: 13px;
    font-weight: 500;
}

.logout-btn:hover {
    background: var(--danger);
    color: #fff;
}

/* ===================== 主内容区 ===================== */
.main {
    padding: 32px 40px;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.main-title {
    font-size: 24px;
    font-weight: 700;
}

.main-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 4px;
}

/* ===================== 卡片 ===================== */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===================== 表单 ===================== */
.form-group { margin-bottom: 20px; }

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

.form-input, .form-select {
    width: 100%;
    padding: 11px 14px;
    background: var(--bg-soft);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    transition: var(--transition);
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.form-input.mono { font-family: var(--mono); font-size: 13px; }
.form-input::placeholder { color: var(--text-muted); }

.required { color: var(--danger); }

/* ===================== 选择器（产品下拉） ===================== */
.product-select-wrap {
    position: relative;
}

.product-select {
    width: 100%;
    padding: 13px 16px;
    background: var(--bg-soft);
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-size: 14px;
    transition: var(--transition);
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.product-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
    outline: none;
}

.select-arrow {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-muted);
}

/* ===================== 按钮 ===================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

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

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 14px rgba(91, 141, 239, 0.3);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-1px); }

.btn-success {
    background: var(--success);
    color: #fff;
    box-shadow: 0 4px 14px rgba(52, 201, 142, 0.25);
}
.btn-success:hover { background: var(--success-hover); transform: translateY(-1px); }

.btn-danger {
    background: var(--danger-soft);
    color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
}
.btn-outline:hover { background: var(--bg-soft); border-color: var(--text-muted); color: var(--text); }

.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }

.btn-generate {
    background: linear-gradient(135deg, var(--primary), #8a6df0);
    color: #fff;
    width: 100%;
    font-size: 15px;
    font-weight: 600;
    padding: 14px;
    box-shadow: 0 6px 20px rgba(91, 141, 239, 0.35);
    margin-top: 8px;
}
.btn-generate:hover:not(:disabled) { box-shadow: 0 8px 26px rgba(91, 141, 239, 0.5); transform: translateY(-1px); }

/* ===================== 登录页 ===================== */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: radial-gradient(ellipse at top, #1a2030 0%, var(--bg) 60%);
}

.login-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 44px 40px;
    width: 100%;
    max-width: 410px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.login-logo .brand-icon {
    width: 68px;
    height: 68px;
    border-radius: 18px;
    font-size: 34px;
    box-shadow: 0 8px 24px rgba(91, 141, 239, 0.4);
}

.login-title {
    text-align: center;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
}

.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 32px;
}

/* ===================== Toast 通知 ===================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    min-width: 280px;
    max-width: 360px;
    padding: 14px 18px;
    border-radius: 12px;
    background: var(--card);
    border: 1px solid var(--border-light);
    color: var(--text);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    animation: toast-in 0.3s ease;
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-info { border-left: 4px solid var(--primary); }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast-out { animation: toast-out 0.3s ease forwards; }
@keyframes toast-out {
    to { opacity: 0; transform: translateX(30px); }
}

/* Flash 消息映射到 toast 风格 */
.flash { display: none; }

/* ===================== 快捷键 ===================== */
.days-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.days-input {
    width: 130px;
    flex-shrink: 0;
    font-family: var(--mono);
}

.days-quick { display: flex; gap: 6px; }

.quick-btn {
    padding: 9px 14px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.quick-btn:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary);
}

/* ===================== 结果框 ===================== */
.result-box {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    position: relative;
}

.result-area {
    width: 100%;
    min-height: 110px;
    background: transparent;
    border: none;
    color: var(--text);
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.6;
    resize: vertical;
    word-break: break-all;
    outline: none;
}

.result-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
    gap: 8px;
}

.result-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 14px 16px;
    background: var(--success-soft);
    border: 1px solid var(--success);
    border-radius: 10px;
    margin-top: 16px;
    color: var(--success);
    font-size: 13px;
}

.result-meta .spinner {
    border: 2px solid var(--success);
    border-top-color: transparent;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    animation: spin 0.8s linear infinite;
}

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

/* ===================== 生成区交互状态 ===================== */
.generate-section { transition: opacity 0.3s; }
.generate-section.loading { opacity: 0.6; pointer-events: none; }

/* ===================== 数据表格 ===================== */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
}

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

.data-table th, .data-table td {
    padding: 14px 18px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    font-size: 13.5px;
}

.data-table th {
    background: var(--bg-soft);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.15s; }
.data-table tbody tr:hover { background: var(--card-hover); }

.mono { font-family: var(--mono); font-size: 12.5px; }

.actions-cell { display: flex; gap: 8px; align-items: center; }

/* ===================== 空状态 ===================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }

/* ===================== 信息卡片 ===================== */
.info-card {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 16px;
}

.info-card h3 {
    font-size: 14px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-card p, .info-card li {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    line-height: 1.7;
}

.info-card ol { padding-left: 20px; }

code {
    background: var(--bg);
    padding: 2px 7px;
    border-radius: 5px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--primary);
    border: 1px solid var(--border);
}

/* ===================== 徽章 ===================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 12.5px;
    color: var(--text-secondary);
}

.badge-days {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-soft);
}

.badge-id {
    color: var(--text-muted);
    font-family: var(--mono);
}

.product-meta { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }

/* ===================== 页面头部通用 ===================== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.form-actions { display: flex; gap: 12px; margin-top: 8px; }

/* ===================== 错误页 ===================== */
.error-page { text-align: center; padding: 80px 20px; }
.error-icon { font-size: 64px; margin-bottom: 20px; }
.error-page h1 { font-size: 20px; margin-bottom: 24px; color: var(--text-secondary); }

/* ===================== 响应式 ===================== */
@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar {
        position: static;
        height: auto;
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        padding: 16px;
        gap: 8px;
    }
    .sidebar-brand { border: none; padding: 0; margin: 0; }
    .sidebar-nav { flex-direction: row; flex-wrap: wrap; flex: 1; }
    .sidebar-user { border: none; padding: 0; margin: 0; }
    .user-info { display: none; }
    .main { padding: 20px; }
    .days-row { flex-direction: column; align-items: stretch; }
    .days-input { width: 100%; }
    .days-quick { justify-content: space-between; }
    .quick-btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}