/* ============================================================
   客户生日提醒系统 - 现代 UI 主题
   ============================================================ */

/* === CSS 变量 === */
:root {
    --app-primary: #4f6ef7;
    --app-primary-dark: #3b54d4;
    --app-primary-light: #eef1ff;
    --app-secondary: #7c5ce7;
    --app-gradient: linear-gradient(135deg, #4f6ef7 0%, #7c5ce7 100%);
    --app-success: #10b981;
    --app-warning: #f59e0b;
    --app-danger: #ef4444;
    --app-info: #3b82f6;
    --app-bg: #f3f4f6;
    --app-card-bg: #ffffff;
    --app-text: #1f2937;
    --app-text-muted: #6b7280;
    --app-border: #e5e7eb;
    --app-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --app-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
    --app-shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
    --app-radius: 14px;
    --app-radius-lg: 18px;
    --app-radius-sm: 10px;
    --app-transition: 0.2s ease;
}

/* === 全局 === */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
    background: var(--app-bg);
    color: var(--app-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === 整体布局（左侧边栏 + 主区域） === */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* === 左侧边栏 === */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 250px;
    background: linear-gradient(180deg, #182238 0%, #232f4e 100%);
    color: #aab4cc;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform 0.25s ease;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.08);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    color: #fff;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transition: background var(--app-transition);
}

.sidebar-brand:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.04);
}

.sidebar-brand .brand-icon {
    width: 38px;
    height: 38px;
    background: var(--app-gradient);
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #fff;
    box-shadow: 0 4px 12px rgba(79, 110, 247, 0.45);
    flex-shrink: 0;
}

.sidebar-brand .brand-name {
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 12px 20px;
}

.sidebar-nav::-webkit-scrollbar {
    width: 5px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.nav-group-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #5c6b8c;
    padding: 16px 10px 6px;
    user-select: none;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: 10px;
    color: #aab4cc;
    font-size: 0.88rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s ease;
    position: relative;
}

.nav-item i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.nav-item.active {
    background: var(--app-gradient);
    color: #fff;
    box-shadow: 0 4px 12px rgba(79, 110, 247, 0.35);
}

.sidebar-user {
    padding: 14px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-user .user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--app-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 600;
    flex-shrink: 0;
    box-shadow: 0 3px 8px rgba(79, 110, 247, 0.4);
}

.sidebar-user .user-meta {
    min-width: 0;
    flex: 1;
}

.sidebar-user .user-name {
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user .logout-link {
    color: #8b98b8;
    font-size: 0.75rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color 0.15s;
}

.sidebar-user .logout-link:hover {
    color: #f87171;
}

/* 移动端遮罩 */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1035;
}

/* === 顶栏 === */
.app-topbar {
    height: 60px;
    background: #fff;
    border-bottom: 1px solid var(--app-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    gap: 12px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.sidebar-toggle {
    display: none;
    border: none;
    background: transparent;
    font-size: 1.4rem;
    color: var(--app-text);
    padding: 4px 8px;
    border-radius: 8px;
    line-height: 1;
    transition: background 0.15s;
}

.sidebar-toggle:hover {
    background: #f1f3f5;
}

.topbar-page {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--app-text);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-page i {
    color: var(--app-primary);
    font-size: 1.05rem;
}

.topbar-clock {
    font-size: 0.82rem;
    color: var(--app-text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    background: #f8f9fa;
    padding: 6px 12px;
    border-radius: 8px;
    white-space: nowrap;
}

.topbar-clock i {
    color: var(--app-primary);
}

/* === 主内容区域 === */
.app-main {
    flex: 1;
    min-width: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    margin-left: 250px;
}

.app-content {
    flex: 1;
    padding: 24px;
}

/* 页面内容容器内边距由 app-content 统一控制，避免双重留白 */
.app-content > .container-fluid {
    padding: 0 !important;
}

/* === 页脚 === */
.app-footer {
    margin-top: auto;
    background: #fff;
    border-top: 1px solid var(--app-border);
    padding: 14px 24px;
    font-size: 0.82rem;
    color: var(--app-text-muted);
}

.footer-brand {
    color: var(--app-primary);
    font-weight: 600;
}

.footer-tagline {
    color: #9ca3af;
}

/* === 卡片 === */
.card {
    border: 1px solid var(--app-border);
    background: var(--app-card-bg);
    border-radius: var(--app-radius);
    box-shadow: var(--app-shadow-sm);
    transition: box-shadow var(--app-transition);
}

.card:hover {
    box-shadow: var(--app-shadow);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--app-border);
    border-radius: var(--app-radius) var(--app-radius) 0 0 !important;
}

.card-footer {
    background: #fafbfc;
    border-top: 1px solid var(--app-border);
    border-radius: 0 0 var(--app-radius) var(--app-radius) !important;
}

/* === 统计卡片 === */
.stat-card {
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    background: #fff;
    padding: 20px;
    transition: all var(--app-transition);
    height: 100%;
}

.stat-card:hover {
    box-shadow: var(--app-shadow-lg);
    transform: translateY(-2px);
}

.stat-icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}

.stat-icon-wrap.primary {
    background: #eef1ff;
    color: var(--app-primary);
}

.stat-icon-wrap.success {
    background: #ecfdf5;
    color: var(--app-success);
}

.stat-icon-wrap.warning {
    background: #fffbeb;
    color: var(--app-warning);
}

.stat-icon-wrap.danger {
    background: #fef2f2;
    color: var(--app-danger);
}

.stat-icon-wrap.info {
    background: #eff6ff;
    color: var(--app-info);
}

.stat-icon-wrap.purple {
    background: #f5f3ff;
    color: var(--app-secondary);
}

.stat-label {
    font-size: 0.8rem;
    color: var(--app-text-muted);
    margin-bottom: 2px;
}

.stat-value {
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--app-text);
    line-height: 1.2;
}

/* === 页面标题 === */
.page-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--app-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-title i {
    color: var(--app-primary);
    font-size: 1.3rem;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 12px;
}

/* === 表格 === */
.table {
    margin-bottom: 0;
    font-size: 0.88rem;
}

.table > thead {
    background: #f9fafb;
}

.table > thead > tr > th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--app-text-muted);
    border-bottom: 2px solid var(--app-border);
    padding: 12px 14px;
    white-space: nowrap;
}

.table > tbody > tr > td {
    padding: 12px 14px;
    vertical-align: middle;
    border-bottom: 1px solid var(--app-border);
}

.table-hover > tbody > tr:hover {
    background-color: var(--app-primary-light);
}

/* === 按钮 === */
.btn {
    font-weight: 500;
    font-size: 0.85rem;
    padding: 7px 18px;
    border-radius: 8px;
    transition: all var(--app-transition);
}

.btn-primary {
    background: var(--app-gradient);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #3b54d4 0%, #6344d4 100%);
    box-shadow: 0 4px 12px rgba(79, 110, 247, 0.35);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--app-success);
    border-color: var(--app-success);
}

.btn-success:hover {
    background: #059669;
    border-color: #059669;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-warning {
    background: var(--app-warning);
    border-color: var(--app-warning);
    color: #fff;
}

.btn-warning:hover {
    background: #d97706;
    border-color: #d97706;
    color: #fff;
}

.btn-danger {
    background: var(--app-danger);
    border-color: var(--app-danger);
}

.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
}

.btn-outline-primary {
    color: var(--app-primary);
    border-color: var(--app-primary);
}

.btn-outline-primary:hover {
    background: var(--app-primary);
    color: #fff;
}

.btn-sm {
    font-size: 0.8rem;
    padding: 5px 14px;
}

.rounded-pill {
    border-radius: 50px !important;
}

/* === 表单 === */
.form-control, .form-select {
    border: 1.5px solid var(--app-border);
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 0.88rem;
    transition: all var(--app-transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.12);
}

.form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--app-text-muted);
    margin-bottom: 5px;
}

.input-group-text {
    background: #f9fafb;
    border: 1.5px solid var(--app-border);
    border-right: none;
    border-radius: 8px 0 0 8px;
    color: var(--app-text-muted);
}

.input-group .form-control {
    border-left: none;
    border-radius: 0 8px 8px 0;
}

/* === 徽章 === */
.badge {
    font-weight: 600;
    font-size: 0.75rem;
    padding: 4px 10px;
}

/* === Alert === */
.alert {
    border: none;
    border-radius: var(--app-radius);
    font-size: 0.9rem;
}

.alert-danger {
    background: #fef2f2;
    color: #991b1b;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
}

.alert-info {
    background: #eff6ff;
    color: #1e40af;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
}

/* === 分页 === */
.pagination .page-link {
    border: 1.5px solid var(--app-border);
    color: var(--app-text-muted);
    font-weight: 500;
    font-size: 0.85rem;
    border-radius: 8px;
    margin: 0 2px;
    padding: 6px 14px;
    transition: all var(--app-transition);
}

.pagination .page-link:hover {
    background: var(--app-primary-light);
    color: var(--app-primary);
    border-color: var(--app-primary);
}

.pagination .page-item.active .page-link {
    background: var(--app-gradient);
    border-color: transparent;
    color: #fff;
}

/* === 进度条 === */
.progress {
    background: #f3f4f6;
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar {
    border-radius: 10px;
    background: var(--app-gradient);
}

/* === 上传区域 === */
.upload-zone {
    border: 2px dashed var(--app-border);
    border-radius: var(--app-radius);
    cursor: pointer;
    transition: all var(--app-transition);
    background: #fafbfc;
    padding: 40px 20px;
    text-align: center;
}

.upload-zone:hover {
    border-color: var(--app-primary);
    background: var(--app-primary-light);
}

/* === 面包屑 === */
.breadcrumb {
    background: transparent;
    padding: 0;
    font-size: 0.85rem;
}

.breadcrumb-item a {
    color: var(--app-primary);
    text-decoration: none;
}

/* === 动画 === */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

.animate-fade-in {
    animation: fadeInUp 0.4s ease-out;
}

.card.animate-fade-in:nth-child(1) { animation-delay: 0s; }
.card.animate-fade-in:nth-child(2) { animation-delay: 0.05s; }
.card.animate-fade-in:nth-child(3) { animation-delay: 0.1s; }
.card.animate-fade-in:nth-child(4) { animation-delay: 0.15s; }
.card.animate-fade-in:nth-child(5) { animation-delay: 0.2s; }

/* === 快捷操作栏 === */
.quick-actions {
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: var(--app-radius);
    padding: 14px 20px;
}

.quick-actions .section-label {
    font-size: 0.82rem;
    color: var(--app-text-muted);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* === 图表容器 === */
.chart-container {
    position: relative;
    width: 100%;
}

/* === 导航菜单子项提示 === */
.nav-pills .nav-link {
    color: var(--app-text-muted);
    border-radius: 8px;
    padding: 8px 16px;
    font-weight: 500;
    transition: all var(--app-transition);
}

.nav-pills .nav-link:hover {
    background: var(--app-primary-light);
    color: var(--app-primary);
}

.nav-pills .nav-link.active {
    background: var(--app-gradient);
    color: #fff;
}

/* === 空状态 === */
.empty-state {
    text-align: center;
    padding: 48px 20px;
}

.empty-state i {
    font-size: 3rem;
    color: #d1d5db;
    display: block;
    margin-bottom: 12px;
}

.empty-state p {
    color: var(--app-text-muted);
    font-size: 0.95rem;
    margin-bottom: 16px;
}

/* === Toast 通知 === */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

/* === 模态框 === */
.modal-content {
    border: none;
    border-radius: var(--app-radius-lg);
    box-shadow: var(--app-shadow-lg);
}

.modal-header {
    border-bottom: 1px solid var(--app-border);
    background: #fafbfc;
    border-radius: var(--app-radius-lg) var(--app-radius-lg) 0 0;
}

/* === 响应式 === */
@media (max-width: 992px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-sidebar.open {
        transform: translateX(0);
    }

    .sidebar-backdrop.show {
        display: block;
    }

    .app-main {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: block;
    }

    .stat-value {
        font-size: 1.35rem;
    }
}

@media (max-width: 768px) {
    .app-content {
        padding: 18px 14px;
    }

    .page-title {
        font-size: 1.15rem;
    }

    .table {
        font-size: 0.82rem;
    }

    .table > thead > tr > th,
    .table > tbody > tr > td {
        padding: 8px 10px;
    }

    .card-body {
        padding: 14px;
    }

    .btn {
        font-size: 0.8rem;
        padding: 6px 14px;
    }

    .upload-zone {
        padding: 24px 14px;
    }
}

@media (max-width: 576px) {
    .app-topbar {
        padding: 0 12px;
    }

    .topbar-clock {
        padding: 5px 9px;
        font-size: 0.76rem;
    }

    .app-content {
        padding: 16px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .stat-card {
        padding: 14px;
    }

    .stat-icon-wrap {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
    }

    .stat-value {
        font-size: 1.2rem;
    }
}

/* === 打印时隐藏导航 === */
@media print {
    .app-sidebar, .app-topbar, .app-footer, .btn, .quick-actions {
        display: none !important;
    }

    .app-main {
        margin-left: 0;
    }
}

/* ============================================================
   邮件模板可视化编辑器样式
   ============================================================ */

/* --- 区块库左侧面板 --- */
.block-list { }

.block-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
    color: #495057;
    transition: all 0.2s ease;
    text-align: left;
}

.block-item:hover {
    background: #eef0ff;
    border-color: #b8c2ff;
    color: #4f6ef7;
    transform: translateX(3px);
}

.block-item:active {
    transform: scale(0.97);
}

.block-icon {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(79,110,247,0.1);
    border-radius: 8px;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* --- 画布区块卡片 --- */
.canvas-block {
    background: #fff;
    border: 2px solid #e9ecef;
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.canvas-block:hover {
    border-color: #b8c2ff;
    box-shadow: 0 4px 16px rgba(79,110,247,0.1);
}

.canvas-block.selected {
    border-color: #4f6ef7;
    box-shadow: 0 0 0 3px rgba(79,110,247,0.15), 0 6px 20px rgba(79,110,247,0.1);
}

.canvas-block.drag-over {
    border-color: #4f6ef7;
    border-style: dashed;
    background: #f8f9ff;
}

.block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #fafbfc;
    border-bottom: 1px solid #f0f0f0;
}

.block-type-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #868e96;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.block-actions {
    display: flex;
    gap: 2px;
}

.block-btn {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: 6px;
    color: #adb5bd;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.75rem;
}

.block-btn:hover {
    background: #e9ecef;
    color: #495057;
}

.block-btn-danger:hover {
    background: #fee2e2;
    color: #dc3545;
}

.block-body {
    padding: 12px 16px;
    min-height: 20px;
}

.block-body [contenteditable="true"] {
    outline: none;
    border-radius: 4px;
    padding: 2px 4px;
    transition: background 0.15s;
    min-height: 1em;
}

.block-body [contenteditable="true"]:focus {
    background: rgba(79,110,247,0.06);
    box-shadow: 0 0 0 2px rgba(79,110,247,0.15);
}

/* Hero 预览 */
.hero-preview {
    border-radius: 14px !important;
}

/* --- 属性面板 --- */
#propsContent {
    max-height: 55vh;
    overflow-y: auto;
}

#propsContent .form-label {
    margin-top: 10px;
}

#propsContent .form-label:first-child {
    margin-top: 0;
}

#propsContent select,
#propsContent input {
    margin-bottom: 6px;
}

/* --- 吸顶侧边栏 --- */
.sticky-sidebar {
    position: sticky;
    top: 85px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

/* --- 模板卡片预览 --- */
.template-card {
    transition: all 0.25s ease;
}

.template-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.1) !important;
}

.template-card .template-preview-mini {
    font-size: 12px;
    line-height: 1.4;
}

/* --- 编辑器空状态 --- */
.border-dashed {
    border-style: dashed !important;
}

/* --- 编辑器响应式 --- */
@media (max-width: 992px) {
    #blockLibrary {
        order: 1;
    }
    #blockCanvas {
        order: 2;
    }
    #blockProps {
        order: 3;
    }
    .sticky-sidebar {
        position: static;
        max-height: none;
    }
    .block-list {
        flex-direction: row;
        flex-wrap: wrap;
    }
    .block-item {
        width: auto;
        flex: 0 0 auto;
        padding: 8px 14px;
    }
}
