﻿/* 所有CSS样式都放在这里 */
:root {
    --primary: #4361ee;
    --secondary: #3f37c9;
    --success: #4cc9f0;
    --light: #f8f9fa;
    --dark: #212529;
    --danger: #e63946;
}

body {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    font-family: 'Microsoft YaHei', sans-serif;
    font-size: 14px;
    line-height: 1.4;
    padding: 0;
    margin: 0;
}

.app-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    margin: 0.5rem;
    height: calc(100vh - 1rem);
    display: flex;
    flex-direction: column;
}

.app-header {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 12px 12px 0 0;
}

.app-header h1 {
    font-size: 1.5rem;
    margin: 0;
}

.app-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.template-list {
    background: var(--light);
    padding: 1rem;
    border-right: 1px solid #dee2e6;
    width: 15%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.template-edit {
    padding: 1.5rem;
    width: 85%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.template-edit-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-toolbar {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-bottom: none;
    padding: 0.4rem;
}

.template-content {
    min-height: 180px;
    border: 1px solid #dee2e6;
    padding: 0.8rem;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    width: 100%;
    flex: 1;
}

.replace-fields {
    background: #f8f9fa;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.preview-area {
    background: white;
    border-radius: 6px;
    padding: 1rem;
    border: 1px solid #dee2e6;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.preview-content {
    background: #f9f9f9;
    border-radius: 4px;
    padding: 0.8rem;
    flex: 1;
    overflow-y: auto;
    white-space: pre-wrap;
    line-height: 1.5;
    border: 1px dashed #adb5bd;
    font-size: 14px;
    min-height: 0;
}

.btn {
    font-size: 14px;
    padding: 0.4rem 0.8rem;
    min-width: auto;
    white-space: nowrap;
}

.btn-sm {
    font-size: 12px;
    padding: 0.3rem 0.6rem;
}

.btn-primary {
    background: var(--primary);
    border: none;
}

.btn-success {
    background: var(--success);
    border: none;
}

.notification {
    position: fixed;
    top: 15px;
    right: 15px;
    padding: 0.8rem 1.2rem;
    border-radius: 6px;
    color: white;
    font-weight: 600;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 12px;
}

.notification.show {
    opacity: 1;
}

.notification.success {
    background: var(--success);
}

.notification.error {
    background: var(--danger);
}

.new-template-indicator {
    background: linear-gradient(45deg, #ff6b6b, #ffd93d);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-weight: bold;
    margin-bottom: 0.8rem;
    text-align: center;
    animation: pulse 2s infinite;
    font-size: 12px;
}

@keyframes pulse {
    0% { opacity: 0.8; }
    50% { opacity: 1; }
    100% { opacity: 0.8; }
}

.search-box {
    margin-bottom: 0.8rem;
}

.search-box input {
    font-size: 12px;
    padding: 0.4rem 0.8rem;
}

.template-actions {
    margin-top: auto;
    background: var(--light);
    padding: 0.8rem 0;
    border-top: 1px solid #dee2e6;
}

h3 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
}

h5 {
    font-size: 1rem;
    margin-bottom: 0.8rem;
}

.form-label {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 0.3rem;
}

.form-control {
    font-size: 12px;
    padding: 0.4rem 0.8rem;
    height: 38px;
    box-sizing: border-box;
}

.badge {
    font-size: 10px;
    padding: 0.25rem 0.5rem;
}

.keyword-highlight {
    background-color: #fff3cd;
    padding: 1px 3px;
    border-radius: 2px;
    font-weight: 600;
}

.preview-actions {
    display: flex;
    gap: 0.5rem;
}

.category-buttons {
    display: flex;
    gap: 0.3rem;
    margin-bottom: 1rem;
}

.category-btn {
    flex: 1;
    text-align: center;
    padding: 0.6rem 0.4rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.2s;
}

.category-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.category-btn.massage.active {
    background: var(--primary);
}

.category-btn.edge.active {
    background: #ffc107;
}

.category-btn.large.active {
    background: var(--danger);
}

.template-grid {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    flex: 1;
    overflow-y: auto;
    max-height: none;
    padding: 0.2rem 0;
    align-content: start;
}

.template-card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 0.6rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 50px;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    margin: 0;
}

.template-card:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.template-card.active {
    border-color: var(--primary);
    background: rgba(67, 97, 238, 0.08);
}

.template-number {
    background: var(--primary);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    flex-shrink: 0;
}

.template-title {
    flex: 1;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.template-edit-top-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.template-edit-top-actions .btn {
    flex: 1;
    font-size: 14px;
    padding: 0.4rem 0.6rem;
}

.btn-save-new {
    background: #20c997;
    border: none;
    color: white;
}

.name-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.name-input-col, .notes-name-col, .name-preview-col {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.name-preview-content {
    background: #f9f9f9;
    border-radius: 4px;
    padding: 0.4rem 0.8rem;
    height: 38px;
    border: 1px solid #dee2e6;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    white-space: pre-wrap;
    line-height: 1.4;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
}

.content-row {
    display: flex;
    gap: 1rem;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.content-input-col, .notes-input-col, .content-preview-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.content-input-col .form-label,
.notes-input-col .form-label,
.content-preview-col .form-label {
    margin-bottom: 0.5rem;
}

.content-input-col .editor-container,
.notes-input-col .notes-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.content-input-col textarea,
.notes-input-col textarea {
    flex: 1;
    resize: none;
    min-height: 0;
}

.content-preview-col .preview-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.content-preview-col .preview-content {
    flex: 1;
    min-height: 0;
}

.notes-container textarea {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 0.8rem;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    width: 100%;
    flex: 1;
}

.ad-maker-modal .modal-dialog {
    max-width: 80%;
    width: 1000px;
    height: 95vh;
    margin: 2.5vh auto;
}

.ad-maker-modal .modal-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.ad-maker-modal .modal-header {
    flex-shrink: 0;
}

.ad-maker-modal .modal-body {
    flex: 1;
    overflow: hidden;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.ad-maker-modal .modal-footer {
    flex-shrink: 0;
}

.ad-maker-container {
    display: flex;
    height: 100%;
    gap: 20px;
}

.ad-preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ad-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    margin-bottom: 20px;
    border: 1px solid #dee2e6;
}

.ad-card-header {
    padding: 15px 20px;
    background: #f9f9f9;
    border-bottom: 1px solid #eee;
    font-weight: bold;
}

.ad-card-body {
    padding: 20px;
}

.ad-display-preview {
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 25px;
    background: white;
    flex: 1;
    overflow-y: auto;
    width: 100%;
    min-height: 400px;
    max-height: none;
    box-sizing: border-box;
}

.ad-title-preview {
    font-size: 22px;
    margin-bottom: 20px;
    color: #de2600;
    word-wrap: break-word;
    line-height: 1.4;
}

.ad-images-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    margin-bottom: 25px;
    justify-content: flex-start;
}

.ad-image-preview {
    width: 140px;
    height: 180px;
    object-fit: contain;
    border-radius: 6px;
    flex: 0 0 auto;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
}

.ad-content-preview {
    line-height: 1.7;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    font-size: 15px;
    margin-top: 20px;
}

.ad-screenshot-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 20px;
    width: auto;
    align-self: flex-start;
}

.ad-preview-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.ad-preview-actions .btn {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    padding: 8px 16px;
}

.category-modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.category-modal-btn {
    padding: 20px;
    border: 2px solid #dee2e6;
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 120px;
}

.category-modal-btn.active {
    border-color: var(--primary);
    background: rgba(67, 97, 238, 0.1);
}

.category-modal-btn.massage.active {
    border-color: var(--primary);
}

.category-modal-btn.edge.active {
    border-color: #ffc107;
}

.category-modal-btn.large.active {
    border-color: var(--danger);
}

.category-icon {
    font-size: 24px;
    margin-bottom: 10px;
}

.ad-display-preview {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.ad-display-preview * {
    border-top: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
}

.ad-display-preview::-webkit-scrollbar {
    width: 6px;
}

.ad-display-preview::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.ad-display-preview::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.image-management-group {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.image-count-display {
    flex: 1;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 0.4rem 0.8rem;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    box-sizing: border-box;
    min-width: 120px;
}

.image-count-display .count-number {
    font-weight: bold;
    color: var(--primary);
    margin: 0 3px;
}

.btn-delete-images {
    background: var(--danger);
    border: none;
    color: white;
    height: 38px;
    min-width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-delete-images:hover {
    background: #c82333;
}

.btn-delete-images:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.replace-fields .row.g-2 {
    align-items: flex-end;
}

.address-col {
    flex: 1.5;
}

.phone-col,
.hours-col,
.upload-col,
.watermark-col,
.delete-col,
.count-col {
    flex: 1;
}

/* 字符计数样式 */
.name-input-col .form-label .badge {
    margin-left: 5px;
    font-size: 9px;
    padding: 0.2rem 0.4rem;
}

.form-text.text-end {
    font-size: 11px;
    color: #6c757d;
    margin-top: 3px;
}

/* 字符计数颜色状态 */
#nameCharCount.bg-secondary {
    background-color: #6c757d !important;
}

#nameCharCount.bg-warning {
    background-color: #ffc107 !important;
    color: #000 !important;
}

#nameCharCount.bg-danger {
    background-color: #dc3545 !important;
}

/* 无效状态 */
.form-control.is-invalid {
    border-color: #dc3545;
}

.form-control.is-invalid:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

/* 水印合成工具样式 */
.watermark-modal .modal-dialog {
    max-width: 95%;
    width: 1200px;
}

.watermark-modal .modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

.watermark-container .section-title {
    font-size: 0.9rem;
    margin-bottom: 1rem;
    color: var(--primary);
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 0.5rem;
}

.upload-area {
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    text-align: center;
    background-color: #f8f9fa;
    transition: all 0.3s;
    cursor: pointer;
}

.upload-area:hover {
    background-color: #e9ecef;
    border-color: var(--primary);
}

.upload-icon {
    margin-bottom: 10px;
}

.upload-text {
    margin-bottom: 5px;
    font-size: 0.8rem;
    color: #6c757d;
}

.position-visual {
    width: 100%;
    height: 120px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    position: relative;
    overflow: hidden;
}

.position-marker {
    width: 20px;
    height: 20px;
    background-color: rgba(67, 97, 238, 0.7);
    border-radius: 50%;
    position: absolute;
    cursor: move;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transform: translate(-50%, -50%);
}

.position-coordinates {
    text-align: center;
    margin-top: 8px;
    font-size: 0.75rem;
    color: #6c757d;
}

/* 新的水印预览布局 */
.watermark-preview-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 100%;
}

.watermark-preview-top {
    display: flex;
    gap: 1rem;
    height: 620px; /* 水印预览 + 效果预览的总高度 */
}

.watermark-preview-bottom {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 120px;
}

/* 水印预览列包含按钮 */
.watermark-logo-preview-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.watermark-logo-preview-col .preview-container {
    flex: 1;
    min-height: 180px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background-color: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    overflow: hidden;
}

/* 效果预览列 */
.effect-preview-col {
    flex: 2;
    display: flex;
    flex-direction: column;
}

.effect-preview-col .preview-container {
    flex: 1;
    min-height: 580px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background-color: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    overflow: hidden;
}

/* 按钮列竖向排列 */
.watermark-actions-col {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-top: auto;
}

.watermark-actions-col .btn {
    height: 50px;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.watermark-actions-col .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* 图片列表样式 */
.thumbnail-section {
    margin-top: 1rem;
}

.thumbnail-container {
    min-height: 100px;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 12px;
    align-items: center;
    border: 1px solid #dee2e6 !important;
    border-radius: 6px;
    background-color: #f8f9fa;
}

.thumbnail {
    width: 50px;
    height: 50px;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border 0.2s;
    flex-shrink: 0;
}

.thumbnail.active {
    border-color: var(--primary);
}

.thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.watermark-status {
    padding: 8px;
    border-radius: 4px;
    text-align: center;
    display: none;
    font-size: 0.8rem;
}

.watermark-status.success {
    background: #d4edda;
    color: #155724;
    display: block;
}

.watermark-status.error {
    background: #f8d7da;
    color: #721c24;
    display: block;
}

.watermark-status.info {
    background: #cce7ff;
    color: #004085;
    display: block;
}

.watermark-upload-section,
.watermark-preview-section {
    height: 100%;
}

.control-group {
    margin-bottom: 1rem;
}

.control-group .form-label {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.control-group .form-range {
    height: 6px;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .watermark-preview-top {
        flex-direction: column;
        height: auto;
    }
    
    .watermark-logo-preview-col .preview-container {
        min-height: 150px;
    }
    
    .effect-preview-col .preview-container {
        min-height: 300px;
    }
    
    .watermark-actions-col {
        flex-direction: row;
        margin-top: 1rem;
    }
    
    .watermark-actions-col .btn {
        flex: 1;
        height: 44px;
        font-size: 14px;
    }
}

@media (max-width: 1400px) {
    .ad-maker-modal .modal-dialog {
        max-width: 85%;
        width: 900px;
    }
}

@media (max-width: 1200px) {
    .ad-maker-modal .modal-dialog {
        max-width: 90%;
        width: 800px;
    }
    
    .watermark-modal .modal-dialog {
        max-width: 98%;
        width: 98%;
    }
}

@media (max-width: 768px) {
    .ad-maker-modal .modal-dialog {
        max-width: 95%;
        width: 95%;
    }
    
    .ad-image-preview {
        width: 100px;
        height: 140px;
    }
    
    .ad-images-preview {
        gap: 20px;
    }
    
    .ad-preview-actions {
        flex-direction: column;
    }
    
    .watermark-modal .modal-dialog {
        max-width: 100%;
        width: 100%;
        margin: 10px;
    }
    
    .watermark-container .row {
        flex-direction: column;
    }
}