:root {
    --primary: #4C51BF;
    --primary-light: #E4E9F8;
    --primary-dark: #3C41AB;
    --secondary: #48BB78;
    --danger: #E53E3E;
    --warning: #ED8936;
    --gray-100: #F7FAFC;
    --gray-200: #EDF2F7;
    --gray-300: #E2E8F0;
    --gray-500: #2D3748;
    --gray-700: #4A5568;
    --radius: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: #f5f7fa;
    color: var(--gray-500);
    line-height: 1.6;
    padding: 20px;
    min-height: 100vh;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

@media (max-width: 1100px) {
    .app-container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .app-container {
        gap: 15px;
    }
    
    .panel {
        padding: 15px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .btn-container {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
}

header {
    grid-column: 1 / -1;
    text-align: center;
    margin-bottom: 25px;
    padding: 25px;
    background: white;
    border-radius: var(--radius);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
    border-top: 4px solid var(--primary);
}

h1 {
    color: var(--primary);
    margin-bottom: 10px;
    font-size: clamp(1.8rem, 4vw, 2.2rem);
}

.subtitle {
    color: var(--gray-700);
    font-size: 1.1rem;
    max-width: 600px;
    margin: 0 auto 15px;
}

.stats-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.stat-item {
    background: var(--primary-light);
    color: var(--primary);
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.stat-item i {
    font-size: 1rem;
}

#generateCount {
    font-weight: bold;
    font-size: 1.1rem;
}

.refresh-btn {
    background: var(--secondary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background-color 0.2s;
}

.refresh-btn:hover {
    background: #38A169;
}

.panel {
    background: white;
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 25px;
    height: fit-content;
    position: relative;
}

.panel-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--gray-200);
}

.panel-header i {
    font-size: 1.3rem;
    margin-right: 10px;
    color: var(--primary);
}

.form-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-section {
    background: var(--gray-100);
    border-radius: var(--radius);
    padding: 18px;
    border-left: 4px solid var(--primary);
}

.section-title {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    color: var(--primary);
    font-weight: 600;
}

.section-title i {
    margin-right: 8px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

label {
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--gray-700);
    display: flex;
    align-items: center;
}

label i {
    margin-right: 5px;
    color: var(--primary);
}

input, select, textarea {
    padding: 10px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 1rem;
    background: white;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 2px rgba(76, 81, 191, 0.2);
}

.custom-select {
    position: relative;
    width: 100%;
}

.custom-select select {
    appearance: none;
    width: 100%;
    cursor: pointer;
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%234C51BF' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
}

.array-input {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

@media (max-width: 480px) {
    .array-input {
        grid-template-columns: 1fr;
    }
}

.trigger-info {
    background: var(--gray-100);
    padding: 12px;
    border-radius: 6px;
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--gray-700);
    border-left: 4px solid var(--secondary);
}

.btn-container {
    display: flex;
    justify-content: center;
    margin-top: 25px;
    gap: 15px;
}

.btn {
    background: var(--primary);
    color: white;
    padding: 12px 30px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s;
}

.btn:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--gray-500);
}

.btn-secondary:hover {
    background: var(--gray-700);
}

.btn-success {
    background: var(--secondary);
}

.btn-success:hover {
    background: #38A169;
}

#output {
    background: var(--gray-100);
    padding: 18px;
    border-radius: var(--radius);
    white-space: pre-wrap;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    max-height: 400px;
    overflow: auto;
    margin-top: 15px;
    border: 1px solid var(--gray-300);
    word-break: break-all;
}

.json-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

@media (max-width: 480px) {
    .json-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .copy-btn {
        width: 100%;
        justify-content: center;
    }
}

.copy-btn {
    background: var(--secondary);
    padding: 8px 16px;
    font-size: 0.9rem;
}

.trigger-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    font-size: 0.9rem;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.trigger-table th {
    background: var(--primary);
    color: white;
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
}

.trigger-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--gray-300);
}

.trigger-table tr:nth-child(even) {
    background: var(--gray-100);
}

.trigger-table tr:hover {
    background: var(--primary-light);
}

@media (max-width: 768px) {
    .trigger-table {
        font-size: 0.8rem;
    }
    
    .trigger-table th,
    .trigger-table td {
        padding: 8px 10px;
    }
}

.help-note {
    background: #FFF9DB;
    border-left: 4px solid #FFD43B;
    padding: 12px 18px;
    margin: 15px 0;
    border-radius: 0 6px 6px 0;
    font-size: 0.9rem;
    display: flex;
    align-items: flex-start;
}

.help-note i {
    color: #F59F00;
    margin-right: 10px;
}

.array-controls {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.add-btn, .remove-btn {
    background: var(--gray-300);
    color: var(--gray-700);
    border: none;
    border-radius: 4px;
    padding: 7px 12px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background-color 0.2s;
}

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

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

.input-hint {
    font-size: 0.8rem;
    color: var(--gray-700);
    margin-top: 5px;
    font-style: italic;
}

footer {
    text-align: center;
    margin-top: 40px;
    color: var(--gray-700);
    font-size: 0.9rem;
    padding: 20px;
    grid-column: 1 / -1;
    background: white;
    border-radius: var(--radius);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.panel-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background: var(--primary);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.quick-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.quick-action-btn {
    background: white;
    border: 1px solid var(--gray-300);
    padding: 7px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
}

.quick-action-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--secondary);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1000;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.validation-error {
    border-color: var(--danger) !important;
    box-shadow: 0 0 0 2px rgba(229, 62, 62, 0.2) !important;
}

.error-message {
    color: var(--danger);
    font-size: 0.8rem;
    margin-top: 5px;
}

.form-group.invalid label {
    color: var(--danger);
}

.example-selector {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.example-selector select {
    flex: 1;
}

.example-selector .btn {
    padding: 8px 14px;
    font-size: 0.9rem;
}

@media (max-width: 480px) {
    .example-selector {
        flex-direction: column;
    }
    
    .example-selector select {
        width: 100%;
    }
}

.toggle-advanced {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    margin-top: 10px;
    padding: 10px 0;
    border-top: 1px solid var(--gray-200);
}

.advanced-section {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.advanced-section.show {
    max-height: 1000px;
}

.toggle-icon {
    transition: transform 0.3s ease;
}

.toggle-advanced.active .toggle-icon {
    transform: rotate(180deg);
}

/* 模板库样式 */
.template-library {
    margin-top: 20px;
    padding: 15px;
    background: var(--gray-100);
    border-radius: var(--radius);
    border: 1px solid var(--gray-300);
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 10px;
}

@media (max-width: 768px) {
    .template-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

@media (max-width: 480px) {
    .template-grid {
        grid-template-columns: 1fr;
    }
}

.template-card {
    background: white;
    padding: 15px;
    border-radius: var(--radius);
    box-shadow: 0 2px 5px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid var(--primary);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.template-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.12);
}

.template-card h4 {
    color: var(--primary);
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.template-card p {
    font-size: 0.8rem;
    color: var(--gray-700);
    flex-grow: 1;
}

.template-card .template-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    font-size: 0.75rem;
    color: var(--gray-700);
}

.real-time-preview {
    margin-top: 20px;
    padding: 15px;
    background: var(--gray-100);
    border-radius: var(--radius);
    border: 1px solid var(--gray-300);
}

.preview-content {
    background: white;
    padding: 15px;
    border-radius: var(--radius);
    margin-top: 10px;
    font-size: 0.9rem;
    max-height: 200px;
    overflow-y: auto;
}

.preview-field {
    display: flex;
    margin-bottom: 8px;
}

.preview-label {
    font-weight: bold;
    min-width: 120px;
    color: var(--primary);
}

.preview-value {
    flex: 1;
}

.auto-save-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--secondary);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 1000;
}

.auto-save-indicator.show {
    opacity: 1;
}

.search-box {
    margin-bottom: 15px;
}

.search-box input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
}

.empty-state {
    text-align: center;
    padding: 30px;
    color: var(--gray-700);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 15px;
    color: var(--gray-300);
}

.template-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.template-filter {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.template-filter-btn {
    background: white;
    border: 1px solid var(--gray-300);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.template-filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* 事件详情显示样式 */
.event-details {
    margin-top: 25px;
    padding: 20px;
    background: var(--gray-100);
    border-radius: var(--radius);
    border: 1px solid var(--gray-300);
}

.event-details h3 {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    color: var(--primary);
}

.event-details h3 i {
    margin-right: 10px;
}

.detail-item {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--gray-200);
}

.detail-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.detail-label {
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 5px;
}

.detail-value {
    color: var(--gray-700);
}

.detail-list {
    list-style-type: none;
    padding-left: 0;
}

.detail-list li {
    padding: 3px 0;
}

.detail-list li:before {
    content: "•";
    color: var(--primary);
    margin-right: 8px;
}

.detail-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--gray-300);
}

.detail-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.detail-section-title {
    font-size: 1.1rem;
    color: var(--primary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.detail-section-title i {
    margin-right: 8px;
}

.trigger-description {
    background: white;
    padding: 15px;
    border-radius: var(--radius);
    border-left: 4px solid var(--primary);
    margin-top: 10px;
}

.file-upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 20px;
}

.file-upload-area:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.file-upload-area i {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 15px;
}

.file-upload-area p {
    margin-bottom: 15px;
}

.file-info {
    background: var(--gray-100);
    padding: 15px;
    border-radius: var(--radius);
    margin-top: 15px;
    display: none;
}

.file-info.show {
    display: block;
}

.file-info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.file-name {
    font-weight: bold;
    color: var(--primary);
}

.file-size {
    color: var(--gray-700);
    font-size: 0.9rem;
}

.event-count {
    background: var(--primary);
    color: white;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
}

.events-list {
    margin-top: 20px;
    max-height: 300px;
    overflow-y: auto;
}

.event-item {
    background: white;
    padding: 15px;
    border-radius: var(--radius);
    margin-bottom: 10px;
    cursor: pointer;
    border-left: 4px solid var(--primary);
    transition: all 0.2s;
}

.event-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.event-item.active {
    border-left-color: var(--secondary);
    background: var(--primary-light);
}

.event-id {
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 5px;
}

.event-trigger {
    font-size: 0.9rem;
    color: var(--gray-700);
}

.no-events {
    text-align: center;
    padding: 30px;
    color: var(--gray-700);
}

.no-events i {
    font-size: 3rem;
    margin-bottom: 15px;
    color: var(--gray-300);
}

/* 弹窗样式 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    animation: modalAppear 0.3s ease-out;
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    background: var(--primary);
    color: white;
    padding: 20px;
    border-radius: var(--radius) var(--radius) 0 0;
    display: flex;
    align-items: center;
    gap: 15px;
}

.modal-header i {
    font-size: 1.8rem;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
}

.modal-body {
    padding: 25px;
}

.modal-message h3 {
    color: var(--primary);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-light);
}

.modal-message p {
    margin-bottom: 12px;
    line-height: 1.6;
}

.modal-message ul,
.modal-message ol {
    margin: 15px 0;
    padding-left: 25px;
}

.modal-message li {
    margin-bottom: 8px;
    line-height: 1.5;
}

.warning-text {
    background: #FFF9DB;
    border-left: 4px solid #FFD43B;
    padding: 15px;
    border-radius: 0 6px 6px 0;
    margin-top: 20px;
    color: #8A6D3B;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.warning-text i {
    color: #F59F00;
    margin-top: 2px;
}

.modal-footer {
    padding: 20px;
    background: var(--gray-100);
    border-radius: 0 0 var(--radius) var(--radius);
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    border-top: 1px solid var(--gray-300);
}

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .modal-body {
        padding: 20px;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer .btn {
        width: 100%;
        justify-content: center;
    }
}