/* dashboard.css - 组件 & 布局样式 */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
fieldset { border: none; padding: 0; margin: 0; min-width: 0; }
fieldset[disabled] .input,
fieldset[disabled] .select,
fieldset[disabled] .textarea {
    background: var(--muted); opacity: 1;
    cursor: default; resize: none;
}
fieldset[disabled] input[type="checkbox"] { opacity: 0.6; }

body {
    font-family: var(--font-sans);
    background: var(--background);
    color: var(--foreground);
    font-size: 0.875rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* === Shell === */
.dashboard-shell { display: flex; min-height: 100vh; }
.dashboard-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.dashboard-content { flex: 1; padding: 1.5rem; }

/* === Sidebar === */
.sidebar {
    width: 16rem; background: var(--sidebar); border-right: 1px solid var(--sidebar-border);
    display: flex; flex-direction: column; padding: 1rem 0.75rem; gap: 0.25rem;
}
.sidebar-logo { padding: 0.5rem 0.75rem; font-size: 1.125rem; font-weight: 700; margin-bottom: 1rem; color: var(--sidebar-foreground); }
.sidebar-group-label { padding: 0.5rem 0.75rem; font-size: 0.75rem; font-weight: 500; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: 0.05em; }
.sidebar-item {
    display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md); color: var(--sidebar-foreground); text-decoration: none;
    font-size: 0.875rem; transition: background 0.15s, color 0.15s; border: none; background: none; cursor: pointer; width: 100%;
}
.sidebar-item:hover { background: var(--sidebar-accent); color: var(--sidebar-accent-foreground); }
.sidebar-item.active { background: var(--sidebar-accent); color: var(--sidebar-accent-foreground); font-weight: 500; }
.sidebar-item svg { width: 1rem; height: 1rem; flex-shrink: 0; }
.sidebar-spacer { flex: 1; }
.sidebar-logout-btn { color: var(--muted-foreground); }

/* === Header === */
.header {
    height: 3.5rem; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; padding: 0 1.5rem; background: var(--background);
}
.header-title { font-size: 1rem; font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 0.5rem; }

/* === Button === */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.5rem 1rem; border-radius: var(--radius-md); font-size: 0.875rem; font-weight: 500;
    line-height: 1.25rem; cursor: pointer; border: 1px solid transparent;
    transition: background 0.15s, color 0.15s, border-color 0.15s; text-decoration: none; white-space: nowrap;
    font-family: var(--font-sans);
}
.btn svg { width: 1rem; height: 1rem; }
.btn-primary { background: var(--primary); color: var(--primary-foreground); }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.btn-secondary:hover { filter: brightness(0.96); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--foreground); }
.btn-outline:hover { background: var(--accent); }
.btn-ghost { background: transparent; color: var(--foreground); border: none; }
.btn-ghost:hover { background: var(--accent); }
.btn-destructive { background: var(--destructive); color: var(--destructive-foreground); }
.btn-destructive:hover { opacity: 0.9; }
.btn-sm { padding: 0.25rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.625rem 1.5rem; font-size: 1rem; }
.btn-icon { padding: 0.5rem; }

/* === Card === */
.card { background: var(--card); color: var(--card-foreground); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-header { padding: 1.5rem 1.5rem 0; }
.card-header.border-b { padding-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.card-title { font-size: 1.125rem; font-weight: 600; line-height: 1; }
.card-description { font-size: 0.875rem; color: var(--muted-foreground); margin-top: 0.375rem; }
.card-content { padding: 1.5rem; }
.card-content-flush { padding: 0; }
.card-footer { padding: 0 1.5rem 1.5rem; display: flex; align-items: center; gap: 0.5rem; }

/* === Table === */
.table-wrapper { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th { text-align: left; padding: 0.75rem 1rem; font-weight: 500; color: var(--muted-foreground); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:hover td { background: var(--muted); }

/* === Form === */
.form-group { display: flex; flex-direction: column; gap: 0.375rem; }
.label { font-size: 0.875rem; font-weight: 500; color: var(--foreground); }
.input, .select, .textarea {
    width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--input); border-radius: var(--radius-md);
    font-size: 0.875rem; font-family: var(--font-sans); background: var(--background); color: var(--foreground);
    outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--ring); box-shadow: 0 0 0 2px rgba(163,163,163,0.2); }
.input::placeholder { color: var(--muted-foreground); }
.textarea { min-height: 5rem; resize: vertical; }

/* === Badge === */
.badge { display: inline-flex; align-items: center; padding: 0.125rem 0.625rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 500; line-height: 1.25rem; }
.badge-default { background: var(--primary); color: var(--primary-foreground); }
.badge-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.badge-outline { background: transparent; border: 1px solid var(--border); color: var(--foreground); }
.badge-destructive { background: var(--destructive); color: var(--destructive-foreground); }
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef9c3; color: #854d0e; }

/* === Alert === */
.alert { padding: 0.75rem 1rem; border-radius: var(--radius-md); border: 1px solid var(--border); font-size: 0.875rem; display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

/* === Breadcrumb === */
.breadcrumb { display: flex; align-items: center; gap: 0.375rem; font-size: 0.875rem; color: var(--muted-foreground); margin-bottom: 1rem; }
.breadcrumb a { color: var(--muted-foreground); text-decoration: none; }
.breadcrumb a:hover { color: var(--foreground); }
.breadcrumb-separator { color: var(--muted-foreground); }
.breadcrumb-separator svg { width: 0.875rem; height: 0.875rem; }
.breadcrumb-current { color: var(--foreground); font-weight: 500; }

/* === Pagination === */
.pagination { display: flex; align-items: center; justify-content: center; gap: 0.25rem; margin-top: 1.5rem; }
.pagination-item { display: inline-flex; align-items: center; justify-content: center; min-width: 2rem; height: 2rem; padding: 0 0.5rem; border-radius: var(--radius-md); font-size: 0.875rem; text-decoration: none; color: var(--foreground); transition: background 0.15s; }
.pagination-item:hover { background: var(--accent); }
.pagination-item.active { background: var(--primary); color: var(--primary-foreground); }
.pagination-item.disabled { opacity: 0.5; pointer-events: none; }

/* === Utilities === */
.text-muted { color: var(--muted-foreground); }
.text-sm { font-size: 0.8125rem; }
.text-lg { font-size: 1.125rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; gap: 0.5rem; }
.search-input { max-width: 16rem; }

/* === Login === */
.login-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--muted); }
.login-card { width: 100%; max-width: 24rem; }

/* === Badge Group (推荐位/语言 tag 容器) === */
.badge-group { display: inline-flex; flex-wrap: wrap; gap: 0.25rem; align-items: center; }

/* === Action Group (操作列按钮容器) === */
.action-group { display: inline-flex; align-items: center; gap: 0.125rem; }

/* === Table Cover Image === */
.table-cover { width: 48px; height: 64px; object-fit: cover; border-radius: var(--radius-sm); display: block; }

/* === Drawer (侧边抽屉) === */
.drawer-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 40;
    opacity: 0; pointer-events: none; transition: opacity 0.3s ease;
}
.drawer-overlay.active { opacity: 1; pointer-events: auto; }

.drawer-panel {
    position: fixed; top: 0; right: 0; bottom: 0; width: 50%;
    background: var(--background); border-left: 1px solid var(--border);
    z-index: 50; display: flex; flex-direction: column;
    transform: translateX(100%); transition: transform 0.3s ease;
    box-shadow: -4px 0 24px rgba(0,0,0,0.1);
}
.drawer-panel.active { transform: translateX(0); }

.drawer-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.drawer-title { font-size: 1.125rem; font-weight: 600; }

.drawer-body { flex: 1; overflow: auto; }

.drawer-iframe {
    width: 100%; height: 100%; border: none; display: block;
}

/* === Responsive === */
@media (max-width: 1024px) {
    .sidebar { display: none; }
    .grid-stats { grid-template-columns: repeat(2, 1fr); }
    .drawer-panel { width: 80%; }
}

/* === Cover Preview === */
.cover-preview {
    width: 100px; height: 140px; object-fit: cover;
    border-radius: var(--radius-md); border: 1px solid var(--border);
    background: var(--muted);
}
.cover-empty {
    display: flex; align-items: center; justify-content: center;
    color: var(--muted-foreground); font-size: 0.75rem;
}
.lang-cover-wrap {
    position: relative; flex-shrink: 0;
}
.lang-badge {
    position: absolute; top: 4px; left: 4px; z-index: 1;
    background: var(--primary); color: var(--primary-foreground);
    font-size: 0.625rem; font-weight: 700; text-transform: uppercase;
    padding: 1px 6px; border-radius: var(--radius-sm);
    line-height: 1.4;
}
.input-sm { font-size: 0.8125rem; padding: 0.375rem 0.5rem; }

/* === Cover Upload Overlay === */
.lang-cover-wrap { cursor: pointer; }
.lang-cover-wrap::after {
    content: ''; position: absolute; inset: 0;
    background: rgba(0,0,0,0.45); border-radius: var(--radius-md);
    opacity: 0; transition: opacity 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.lang-cover-wrap:hover::after { opacity: 1; }
.lang-cover-wrap .cover-overlay {
    position: absolute; inset: 0; z-index: 2;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: #fff; font-size: 0.6875rem; font-weight: 500;
    opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
.lang-cover-wrap:hover .cover-overlay { opacity: 1; }

/* === Action Buttons with Text === */
.action-btn {
    display: inline-flex; align-items: center; gap: 0.25rem;
    padding: 0.25rem 0.5rem; border-radius: var(--radius-sm);
    font-size: 0.75rem; font-weight: 500; cursor: pointer;
    border: none; background: none; color: var(--muted-foreground);
    transition: background 0.15s, color 0.15s;
    text-decoration: none; white-space: nowrap;
}
.action-btn:hover { background: var(--muted); color: var(--foreground); }
.action-btn svg { width: 14px; height: 14px; }
.action-btn--danger:hover { background: #fef2f2; color: var(--destructive); }
@media (max-width: 640px) {
    .dashboard-content { padding: 1rem; }
    .grid-stats { grid-template-columns: 1fr; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .search-input { max-width: 100%; }
    .drawer-panel { width: 100%; }
}

/* === Toast === */
.toast {
    position: fixed;
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-width: 300px;
    animation: slideDown 0.3s ease-out;
}
.toast-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.toast-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.toast-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.toast-info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

.toast-content { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; font-size: 0.875rem; }
.toast-close { background: transparent; border: none; font-size: 1.25rem; line-height: 1; cursor: pointer; opacity: 0.5; color: inherit; padding: 0; }
.toast-close:hover { opacity: 1; }

@keyframes slideDown {
    from { transform: translate(-50%, -100%); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

/* === Confirm Modal === */
.confirm-modal-mask {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10000;
    display: flex; align-items: center; justify-content: center;
    animation: fadeIn 0.15s ease-out;
}
.confirm-modal-panel {
    background: var(--background);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 420px; width: 90%;
    padding: 1.5rem;
}
.confirm-modal-msg {
    font-size: 0.95rem;
    color: var(--foreground);
    margin-bottom: 1.25rem;
    white-space: pre-wrap;
    line-height: 1.5;
}
.confirm-modal-actions {
    display: flex; justify-content: flex-end; gap: 0.5rem;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
