/**
 * 共享 UI 组件
 */

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--grgl-bg-muted);
    min-height: 100vh;
    font-family: var(--grgl-font);
    color: var(--grgl-text);
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.01em;
}

.app-main-content {
    padding: 24px;
}

.container-fluid.page-shell {
    width: 100% !important;
    max-width: var(--grgl-content-max);
    min-height: calc(100vh - 48px);
    padding: 0;
    margin: 0 auto !important;
}

/* 卡片 */
.grgl-card,
.card.grgl-card {
    border: 1px solid var(--grgl-border-light);
    border-radius: var(--grgl-radius);
    box-shadow: var(--grgl-shadow-sm);
    background: var(--grgl-bg);
    /* 与 theme.css 一致：勿 hidden，否则表格横向滑动被裁切 */
    overflow: visible;
}

.grgl-card .card-header,
.card.grgl-card > .card-header {
    background: var(--grgl-bg) !important;
    border: none !important;
    border-bottom: 1px solid var(--grgl-border-light) !important;
    padding: 18px 24px;
    font-weight: 600;
    color: var(--grgl-text) !important;
    letter-spacing: -0.02em;
}

.grgl-card .card-body {
    padding: 24px;
}

/* 账户页 */
.account-card {
    max-width: 640px;
    margin: 0 auto;
}

.account-card-wide {
    max-width: 720px;
}

/* 页面标题 */
.dashboard-header {
    margin-bottom: 24px;
    padding: 20px 28px;
    background: var(--grgl-bg-glass);
    border-radius: var(--grgl-radius-lg);
    box-shadow: var(--grgl-shadow-sm);
    border: 1px solid var(--grgl-border-light);
    backdrop-filter: blur(16px);
}

.dashboard-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 6px;
    letter-spacing: -0.025em;
    background: var(--grgl-gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.dashboard-subtitle {
    margin: 0;
    color: var(--grgl-text-secondary);
    font-size: 0.95rem;
}

/* 统一页面内容区 — 与荣誉汇总同宽 */
.grgl-page-content,
.honor-summary-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    padding: 0 0 32px;
    margin: 0;
}

.honor-summary-container::before {
    content: "";
    position: fixed;
    inset: 0;
    background: var(--grgl-gradient-page);
    pointer-events: none;
    z-index: -1;
}

/* 表格 */
.grgl-table-wrap {
    border: 1px solid var(--grgl-table-border);
    border-radius: var(--grgl-radius);
    background: var(--grgl-table-bg);
    box-shadow: var(--grgl-shadow-sm);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.grgl-table-wrap .table {
    margin-bottom: 0;
    --bs-table-bg: var(--grgl-table-bg);
    --bs-table-hover-bg: var(--grgl-table-row-hover);
    --bs-table-border-color: var(--grgl-table-border);
}

.grgl-table-wrap .table th {
    background: var(--grgl-table-header-bg);
    text-align: center;
    font-size: 0.8125rem;
    padding: 13px 12px;
    white-space: nowrap;
    font-weight: 600;
    border: none;
    border-bottom: 1px solid rgba(22, 119, 255, 0.12);
    color: var(--grgl-table-header-text);
}

.grgl-table-wrap .table td {
    text-align: center;
    vertical-align: middle;
    font-size: 0.8125rem;
    padding: 13px 12px;
    border: none;
    border-bottom: 1px solid var(--grgl-table-border);
    background: var(--grgl-table-bg);
    color: var(--grgl-text);
}

.grgl-table-wrap .table tbody tr:last-child td {
    border-bottom: none;
}

.grgl-table-wrap .table tbody tr:hover > * {
    background: var(--grgl-table-row-hover) !important;
}

/* 筛选区 — 详见 filters.css */
.filter-section:not(.grgl-filter) {
    background: var(--grgl-bg);
    border-radius: var(--grgl-radius);
    padding: 24px 28px;
    box-shadow: var(--grgl-shadow-sm);
    margin-bottom: 24px;
    border: 1px solid var(--grgl-border-light);
}

/* 按钮 */
.btn {
    padding: 6px 14px !important;
    font-size: 0.8125rem !important;
    border-radius: var(--grgl-radius-sm) !important;
    font-weight: 500 !important;
    transition: transform 0.15s, box-shadow 0.15s !important;
}

.btn-primary {
    background: var(--grgl-primary) !important;
    border: none !important;
    color: #fff !important;
    box-shadow: 0 2px 6px rgba(0, 122, 255, 0.25) !important;
}

.btn-primary:hover {
    background: var(--grgl-primary-hover) !important;
    transform: translateY(-1px);
}

.btn-outline-secondary {
    background: #6c757d !important;
    color: #fff !important;
    border: none !important;
}

.app-shell .export-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--grgl-radius-sm);
    background: var(--grgl-bg);
    border: 1px solid var(--grgl-border);
    color: var(--grgl-text);
    text-decoration: none;
    font-size: 0.875rem;
    box-shadow: var(--grgl-shadow-sm);
    transition: all 0.2s;
}

.app-shell .export-btn:hover {
    border-color: var(--grgl-primary);
    color: var(--grgl-primary);
    transform: translateY(-1px);
}

.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    margin: 4px 8px 4px 0;
    border-radius: 999px;
    background: var(--grgl-bg-muted);
    font-size: 0.8125rem;
    color: var(--grgl-text);
}

/* 进度条（动态宽度仍用 inline style） */
.storage-progress,
.grgl-progress {
    height: 6px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 999px;
    overflow: hidden;
}

.storage-progress .progress-bar:not(.bg-danger),
.grgl-progress .progress-bar:not(.bg-danger) {
    background: var(--grgl-gradient-brand);
}

/* 提示 */
.alert {
    border: none;
    border-radius: var(--grgl-radius-sm);
    box-shadow: var(--grgl-shadow-sm);
    position: relative;
    padding-right: 3rem;
}

/* Bootstrap 4 兼容：可关闭提示框 */
.grgl-alert-close,
.app-shell .alert .close {
    position: absolute;
    top: 50%;
    right: 0.75rem;
    transform: translateY(-50%);
    float: none;
    width: 1.75rem;
    height: 1.75rem;
    margin: 0;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    opacity: 0.55;
    font-size: 1.35rem;
    font-weight: 400;
    line-height: 1;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}

.grgl-alert-close:hover,
.app-shell .alert .close:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.06);
    color: inherit;
    text-decoration: none;
}

.grgl-alert-close span,
.app-shell .alert .close span {
    line-height: 1;
}

/* 右上角 Toast 通知（胶囊样式） */
.grgl-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1080;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    width: auto;
    max-width: min(420px, calc(100vw - 40px));
    pointer-events: none;
}

.grgl-toast {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    max-width: 100%;
    min-height: 44px;
    padding: 8px 12px 8px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow:
        0 10px 30px rgba(15, 23, 42, 0.1),
        0 2px 8px rgba(15, 23, 42, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(15, 23, 42, 0.08);
    opacity: 0;
    transform: translateX(20px) scale(0.96);
    transition: opacity 0.24s ease, transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
    pointer-events: auto;
    overflow: hidden;
}

.grgl-toast.is-visible {
    opacity: 1;
    transform: translateX(0) scale(1);
}

.grgl-toast.is-leaving {
    opacity: 0;
    transform: translateX(20px) scale(0.96);
}

.grgl-toast-icon {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    font-size: 0.8125rem;
    color: #fff;
    box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.08);
}

.grgl-toast-icon svg {
    width: 14px;
    height: 14px;
    display: block;
    fill: currentColor;
    color: #fff;
}

.grgl-toast-body {
    flex: 1 1 auto;
    min-width: 0;
    padding-right: 2px;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.45;
    color: var(--grgl-text);
    word-break: break-word;
}

.grgl-toast-close {
    flex: 0 0 auto;
    width: 1.375rem;
    height: 1.375rem;
    margin: 0 0 0 2px;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.06);
    color: var(--grgl-text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.grgl-toast-close:hover {
    background: rgba(15, 23, 42, 0.12);
    color: var(--grgl-text);
    transform: scale(1.05);
}

.grgl-toast-close span {
    line-height: 1;
    margin-top: -1px;
}

.grgl-toast-progress {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 4px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    opacity: 0.35;
    transform-origin: left center;
    animation-name: grgl-toast-progress;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
}

@keyframes grgl-toast-progress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

.grgl-toast-success {
    border-color: rgba(82, 196, 26, 0.22);
    background: linear-gradient(135deg, rgba(246, 255, 237, 0.98) 0%, rgba(255, 255, 255, 0.96) 100%);
    color: #389e0d;
}

.grgl-toast-success .grgl-toast-icon {
    background: linear-gradient(135deg, #73d13d 0%, #52c41a 100%);
}

.grgl-toast-error {
    border-color: rgba(255, 77, 79, 0.22);
    background: linear-gradient(135deg, rgba(255, 241, 240, 0.98) 0%, rgba(255, 255, 255, 0.96) 100%);
    color: #cf1322;
}

.grgl-toast-error .grgl-toast-icon {
    background: linear-gradient(135deg, #ff7875 0%, #ff4d4f 100%);
}

.grgl-toast-warning {
    border-color: rgba(250, 173, 20, 0.22);
    background: linear-gradient(135deg, rgba(255, 251, 230, 0.98) 0%, rgba(255, 255, 255, 0.96) 100%);
    color: #d48806;
}

.grgl-toast-warning .grgl-toast-icon {
    background: linear-gradient(135deg, #ffc53d 0%, #faad14 100%);
}

.grgl-toast-info {
    border-color: rgba(22, 119, 255, 0.22);
    background: linear-gradient(135deg, rgba(230, 244, 255, 0.98) 0%, rgba(255, 255, 255, 0.96) 100%);
    color: #0958d9;
}

.grgl-toast-info .grgl-toast-icon {
    background: linear-gradient(135deg, #4096ff 0%, #1677ff 100%);
}

@media (max-width: 575.98px) {
    .grgl-toast-container {
        top: 12px;
        right: 12px;
        left: 12px;
        max-width: none;
        align-items: stretch;
    }

    .grgl-toast {
        width: 100%;
    }
}

.page-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}
