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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
    color: #2c3e50;
    margin-bottom: 10px;
}

header p {
    color: #7f8c8d;
}

.main-content {
    display: grid;
    gap: 20px;
}

section {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    min-width: 0;
}

section h2 {
    color: #2c3e50;
    margin-bottom: 15px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 5px;
}

/* 字段配置样式 */
.field-item {
    display: grid;
    grid-template-columns: 1fr 2fr auto;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.field-name, .field-pattern {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.field-pattern {
    font-family: 'Courier New', monospace;
}

.remove-field {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.remove-field:hover {
    background: #c0392b;
}

#addField {
    background: #27ae60;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 10px;
}

#addField:hover {
    background: #229954;
}

/* 可折叠内容样式 */
.collapsible-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.collapsible-header:hover {
    color: #3498db;
}

.collapse-icon {
    transition: transform 0.3s ease;
    font-size: 14px;
}

.collapsible-content {
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.collapsible-content.collapsed {
    max-height: 0;
}

.collapsible-content:not(.collapsed) {
    max-height: none;
}

/* KeePass模式说明样式 */
.pattern-examples {
    display: grid;
    gap: 20px;
    padding-top: 15px;
}

.pattern-category h3 {
    color: #34495e;
    margin-bottom: 10px;
    font-size: 16px;
}

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

.pattern-grid span {
    background: #f8f9fa;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    border-left: 3px solid #3498db;
}

.pattern-examples-list {
    display: grid;
    gap: 8px;
}

.pattern-examples-list div {
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 13px;
    border-left: 3px solid #27ae60;
}

code {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #e74c3c;
    font-weight: bold;
}

/* 弹窗样式 */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 8px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.modal-header h2 {
    margin: 0;
    color: #2c3e50;
}

.close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #000;
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

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

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* 字典管理样式 */
.dictionary-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #dee2e6;
}

.dictionary-stats-summary {
    color: #6c757d;
    font-size: 14px;
}

#addDictionary {
    background: #9b59b6;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
}

#addDictionary:hover {
    background: #8e44ad;
}

.dictionary-item {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 15px;
    padding: 15px;
}

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

.dictionary-title {
    font-weight: 600;
    color: #2c3e50;
    font-size: 16px;
}

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

.dict-btn {
    padding: 4px 8px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}

.edit-btn {
    background: #3498db;
    color: white;
}

.edit-btn:hover {
    background: #2980b9;
}

.save-btn {
    background: #27ae60;
    color: white;
}

.save-btn:hover {
    background: #229954;
}

.delete-btn-dict {
    background: #e74c3c;
    color: white;
}

.delete-btn-dict:hover {
    background: #c0392b;
}

.dictionary-content-area {
    margin-top: 10px;
}

.dictionary-textarea {
    width: 100%;
    min-height: 120px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    resize: vertical;
}

.dictionary-display {
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 10px;
    min-height: 120px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    white-space: pre-line;
    color: #495057;
}

.dictionary-stats {
    font-size: 12px;
    color: #6c757d;
    margin-top: 5px;
}

/* 生成控制样式 */
.generate-section {
    text-align: center;
}

.generate-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
    align-items: center;
}

.batch-generate {
    display: flex;
    align-items: center;
    gap: 10px;
}

.batch-generate label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.batch-generate input[type="number"] {
    width: 60px;
    padding: 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.settings {
    display: flex;
    justify-content: flex-end;
}

.settings label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

#generateEntry, #clearAll, #exportTxt, #exportCsv, #manageDictionaries {
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

#generateEntry {
    background: #3498db;
    color: white;
}

#generateEntry:hover {
    background: #2980b9;
}

#clearAll {
    background: #e74c3c;
    color: white;
}

#clearAll:hover {
    background: #c0392b;
}

#exportTxt, #exportCsv {
    background: #27ae60;
    color: white;
}

#exportTxt:hover, #exportCsv:hover {
    background: #229954;
}

#manageDictionaries {
    background: #9b59b6;
    color: white;
}

#manageDictionaries:hover {
    background: #8e44ad;
}

/* 表格样式 */
.table-container {
    overflow-x: auto;
    margin-top: 15px;
    max-width: 100%;
}

table {
    min-width: 100%;
    border-collapse: collapse;
    background: white;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
}

th:last-child, td:last-child {
    text-align: right;
    width: 80px;
}

tr:hover {
    background: #f8f9fa;
}

.copyable-cell {
    cursor: pointer;
    transition: background-color 0.2s ease;
    position: relative;
    white-space: pre;
}

.copyable-cell:hover {
    background: #e3f2fd !important;
}

.copyable-cell:active {
    background: #bbdefb !important;
}

.editable-cell {
    position: relative;
}

.editable-cell:hover::after {
    content: "单击复制，双击编辑 (Enter保存/Esc取消)";
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
}

.cell-edit-input {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    background: #fff3cd !important;
    border: 2px solid #ffc107 !important;
    border-radius: 3px;
    padding: 4px !important;
    margin: -2px;
}

.copy-feedback {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #27ae60;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    animation: copyFeedbackShow 0.2s ease-out;
}

@keyframes copyFeedbackShow {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.delete-btn {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.delete-btn:hover {
    background: #c0392b;
}

.no-entries {
    text-align: center;
    color: #7f8c8d;
    font-style: italic;
    margin-top: 20px;
    display: none;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .field-item {
        grid-template-columns: 1fr;
        gap: 5px;
    }

    .pattern-grid {
        grid-template-columns: 1fr;
    }

    .generate-controls {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .action-buttons {
        flex-direction: column;
        align-items: center;
    }

    .container {
        padding: 10px;
    }
}
