/**
 * 关怀弹窗系统 - 管理后台样式 (Dark Theme)
 */

:root {
    /* Color Palette - Dark Cyber/Modern */
    --bg-body: #0f172a;
    --bg-surface: #1e293b;
    --bg-surface-hover: #334155;
    --bg-input: #0f172a;
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --primary-color: #8b5cf6;
    --primary-hover: #7c3aed;
    --primary-gradient: linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%);
    
    --secondary-bg: #334155;
    --secondary-text: #e2e8f0;
    
    --danger-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    
    --border-color: #334155;
    --border-focus: #8b5cf6;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.16);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.15);
    --shadow-glow: 0 0 15px rgba(139, 92, 246, 0.3);
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* 通用样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-body); 
}

::-webkit-scrollbar-thumb {
    background: var(--bg-surface-hover); 
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted); 
}

/* 按钮样式 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    letter-spacing: 0.025em;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 20px rgba(139, 92, 246, 0.5);
    filter: brightness(1.1);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--secondary-bg);
    color: var(--secondary-text);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-surface-hover);
    border-color: var(--text-muted);
}

.btn-large {
    width: 100%;
    padding: 14px;
    font-size: 16px;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 6px 12px;
    font-size: 12px;
}

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

/* 模态框 (Modal) */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow: hidden; /* 防止overlay本身滚动 */
}

.modal-overlay.active {
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    overflow-y: auto; /* 允许在overlay内滚动，但不会影响body */
    overscroll-behavior: contain; /* 防止滚动传播到body */
}

.modal-content {
    background: var(--bg-surface);
    width: 90%;
    max-width: 600px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--bg-surface-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(85vh - 120px); /* 减去header和padding的高度 */
    /* 优化滚动体验 */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain; /* 防止滚动传播到父元素 */
}

/* 自定义滚动条样式 */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: var(--bg-input);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* 悬浮消息 Toast */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 400px;
    animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.toast.hide {
    opacity: 0;
    transform: translateX(100%);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-content {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.success .toast-icon {
    color: var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

.toast.error .toast-icon {
    color: var(--danger-color);
}

.toast.info {
    border-left: 4px solid #60a5fa;
}

.toast.info .toast-icon {
    color: #60a5fa;
}

/* 登录页面样式 */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: radial-gradient(circle at top right, #1e1b4b, #0f172a);
}

.login-box {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg), 0 0 0 1px var(--border-color);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    position: relative;
    overflow: hidden;
}

/* 顶部装饰条 */
.login-box::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--primary-gradient);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.heart-icon {
    font-size: 48px;
    margin-bottom: 16px;
    display: inline-block;
    filter: drop-shadow(0 0 10px rgba(239, 68, 68, 0.5));
    animation: heartBeat 1.5s infinite;
}

@keyframes heartBeat {
    0% { transform: scale(1); }
    14% { transform: scale(1.1); }
    28% { transform: scale(1); }
    42% { transform: scale(1.1); }
    70% { transform: scale(1); }
}

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary); /* Fallback color */
    margin-bottom: 8px;
    background: var(--primary-gradient);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-form .form-group {
    margin-bottom: 24px;
}

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

.login-form input[type="text"],
.login-form input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.login-form input[type="text"]:focus,
.login-form input[type="password"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    margin-right: 10px;
    accent-color: var(--primary-color);
    width: 16px;
    height: 16px;
}

.checkbox-label span {
    color: var(--text-secondary);
    font-size: 14px;
}

.error-message {
    margin-top: 16px;
    padding: 12px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-md);
    font-size: 14px;
    text-align: center;
}

/* 管理面板样式 */
.dashboard {
    min-height: 100vh;
    background: var(--bg-body);
}

.dashboard-header {
    background: var(--bg-surface);
    padding: 16px 32px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background: rgba(30, 41, 59, 0.9);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-left .heart-icon {
    font-size: 28px;
    margin-bottom: 0;
}

.header-left h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.5px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-name {
    font-size: 14px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-name::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--success-color);
    border-radius: 50%;
    box-shadow: 0 0 5px var(--success-color);
}

.dashboard-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 20px;
}

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

.stat-card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary-color);
}

.stat-icon {
    font-size: 40px;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
}

.stat-info {
    flex: 1;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

/* 通用卡片 */
.section {
    margin-bottom: 40px;
}

.section h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-left: 12px;
    border-left: 4px solid var(--primary-color);
}

.card {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.section-description {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
    background: rgba(51, 65, 85, 0.5);
    padding: 12px;
    border-radius: var(--radius-md);
    border-left: 3px solid var(--text-muted);
}

/* 表单组 */
.form-group {
    margin-bottom: 24px;
}

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

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.form-group input[type="text"]:focus,
.form-group input[type="number"]:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

.color-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px;
}

/* 消息列表 */
.message-list {
    margin-bottom: 24px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 8px;
}

.message-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.message-item:hover {
    background: var(--bg-surface-hover);
    transform: translateX(4px);
}

.message-text {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
    margin-right: 16px;
}

.message-actions {
    display: flex;
    gap: 8px;
}

.message-edit-input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-body);
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-primary);
    outline: none;
    margin-right: 12px;
}

.btn-edit {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.2);
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

.btn-edit:hover {
    background: #3b82f6;
    color: white;
}

.btn-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.2);
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

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

/* 历史记录表格 */
.history-table-container {
    overflow-x: auto;
    margin-bottom: 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

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

.history-table thead {
    background: var(--bg-surface-hover);
}

.history-table th {
    padding: 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-color);
}

.history-table td {
    padding: 16px;
    font-size: 14px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.history-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.history-table tr:last-child td {
    border-bottom: none;
}

.color-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.type-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.type-badge.custom {
    background: rgba(236, 72, 153, 0.15);
    color: #f472b6;
    border: 1px solid rgba(236, 72, 153, 0.3);
}

/* 截图区域 */
.screenshot-info {
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--text-secondary);
    background: var(--bg-surface-hover);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    display: inline-block;
}

.screenshot-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.screenshot-item {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
}

.screenshot-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.screenshot-item img {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    display: block;
    cursor: zoom-in;
    transition: filter 0.3s;
}

.screenshot-item:hover img {
    filter: brightness(1.1);
}

.screenshot-item-time {
    padding: 10px;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-surface-hover);
    text-align: center;
    border-top: 1px solid var(--border-color);
}

/* 图片查看器（全屏） */
.image-viewer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    cursor: zoom-out;
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
    overflow: hidden; /* 防止滚动 */
    overscroll-behavior: contain; /* 防止滚动传播 */
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.image-viewer.active {
    display: flex;
}

.image-viewer img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
    border-radius: 4px;
    cursor: zoom-out;
}

/* 底部 */
.dashboard-footer {
    text-align: center;
    padding: 32px;
    color: var(--text-muted);
    font-size: 12px;
    border-top: 1px solid var(--border-color);
    margin-top: 40px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        gap: 16px;
        padding: 16px;
    }
    
    .stats-section {
        grid-template-columns: 1fr;
    }

    .screenshot-gallery {
        grid-template-columns: 1fr;
    }
    
    #toast-container {
        left: 20px;
        right: 20px;
        top: 20px;
    }
    
    .toast {
        min-width: auto;
        width: 100%;
    }
    
    .card {
        padding: 20px;
    }
    
    .message-item {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .message-actions {
        justify-content: flex-end;
    }
}

/* 旋转动画（用于加载状态） */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* 防止body在模态框打开时滚动 */
body.modal-open {
    overflow: hidden !important;
}
