/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

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

/* 头部样式 */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.party-stats {
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: none;
}

/* 居中按钮样式 */
.party-global-actions.right-aligned {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e9ecef;
    width: 100%;
    box-sizing: border-box;
}

.party-action-group {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 15px;
}

.party-global-actions.right-aligned .party-action-group {
    margin-left: 0;
    margin-right: 15px;
}

.parties-container {
    margin-bottom: 20px;
}

.party-global-actions {
    border-top: 1px solid #e0e0e0;
    padding-top: 20px;
    margin-top: 20px;
}

.party-action-group {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 6px;
}

.action-party-name {
    flex: 1;
    font-weight: 500;
    color: #333;
    min-width: 120px;
}

.party-action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.edit-btn {
    background-color: #4CAF50;
    color: white;
}

.edit-btn:hover {
    background-color: #45a049;
}

/* 平滑滚动过渡 */
html {
    scroll-behavior: smooth;
}

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

.delete-btn:hover {
    background-color: #d32f2f;
}

.title {
    font-size: 2rem;
    color: #2c3e50;
}

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

.total-seats {
    font-size: 1.2rem;
    font-weight: 600;
    color: #7f8c8d;
}

.save-button {
    padding: 8px 16px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s ease;
    margin-left: 10px;
}

.save-button:hover {
    background-color: #218838;
}

/* 联合政府按钮样式 */
.coalition-button {
    background-color: #17a2b8;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s ease;
    margin-left: 10px;
}

.coalition-button:hover {
    background-color: #138496;
}

/* 存档管理面板样式 */
.save-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.save-panel.active {
    display: flex;
    opacity: 1;
}

.save-panel-content {
    background-color: white;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

.save-panel.active .save-panel-content {
    transform: scale(1) translateY(0);
    opacity: 1;
    transition-delay: 50ms;
}

.save-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.save-panel-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: #333;
}

.close-save-panel {
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    transition: color 0.2s ease;
}

.close-save-panel:hover {
    color: #333;
}

.save-panel-body {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(80vh - 60px);
}

.save-section,
.load-section {
    margin-bottom: 25px;
}

.save-section h4,
.load-section h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #495057;
    font-size: 1rem;
}

.save-name-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 5px;
    font-size: 1rem;
    margin-bottom: 10px;
}

.saved-configs-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.config-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background-color: #f8f9fa;
    border-radius: 5px;
    border: 1px solid #e9ecef;
}

.config-item-name {
    font-weight: 500;
    color: #333;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.config-item-date {
    font-size: 0.8rem;
    color: #6c757d;
    margin-right: 10px;
}

.config-item-actions {
    display: flex;
    gap: 5px;
}

.config-item-btn {
    padding: 4px 10px;
    border: none;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.load-btn {
    background-color: #007bff;
    color: white;
}

.load-btn:hover {
    background-color: #0056b3;
}

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

.delete-btn:hover {
    background-color: #c82333;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .config-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .config-item-actions {
        align-self: flex-end;
    }
}

/* 模态框样式 */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #ddd;
}

.modal-header h3 {
    margin: 0;
    color: #333;
}

.close-coalition-panel {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.close-coalition-panel:hover {
    background-color: #f5f5f5;
    color: #333;
}

.modal-body {
    padding: 20px;
}

/* 联合政府管理面板 */
.coalition-panel {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease-out;
}

.coalition-panel.active {
    display: flex;
    opacity: 1;
}

.coalition-panel-content {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

.coalition-panel.active .coalition-panel-content {
    transform: scale(1) translateY(0);
    opacity: 1;
    transition-delay: 50ms;
}

.coalition-panel-content {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.coalition-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    margin: -20px -20px 20px;
}

.coalition-panel-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: #333;
}

.coalition-creation, .coalition-form,
.existing-coalitions {
    margin-bottom: 25px;
}

.coalition-hint {
    color: #6c757d;
    font-size: 14px;
    margin-bottom: 15px;
}

.coalition-creation h4, .coalition-form h4,
.existing-coalitions h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #495057;
    font-size: 1rem;
}

.party-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 5px;
    border: 1px solid #e9ecef;
    margin-bottom: 15px;
}

.party-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.party-checkbox-item:hover {
    background-color: #e9ecef;
}

.party-checkbox-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid #dee2e6;
}

#coalition-leader {
    width: 100%;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 5px;
    font-size: 1rem;
    margin-bottom: 15px;
}

#create-coalition-btn {
    padding: 8px 16px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s ease;
}

#create-coalition-btn:hover:not(:disabled) {
    background-color: #218838;
}

#create-coalition-btn:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
}

.coalitions-list {
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.no-coalitions {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 30px 0;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px dashed #ddd;
}

.coalition-item {
    background-color: #f8f9fa;
    border-radius: 5px;
    padding: 15px;
    border-left: 4px solid #28a745;
}

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

.coalition-name {
    font-weight: bold;
    color: #2c3e50;
}

.coalition-total-seats {
    color: #6c757d;
    font-size: 0.8rem;
}

.coalition-leader {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-weight: 500;
    color: #34495e;
}

.coalition-leader-color {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid #dee2e6;
}

.coalition-parties {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.coalition-party {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px;
    background-color: white;
    border-radius: 12px;
    font-size: 0.8rem;
    border: 1px solid #dee2e6;
}

.coalition-party-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid #dee2e6;
}

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

.coalition-action-btn {
    padding: 4px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.coalition-action-btn.dissolve-btn {
    background-color: #dc3545;
    color: white;
}

.coalition-action-btn.dissolve-btn:hover {
    background-color: #c82333;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .party-checkboxes {
        grid-template-columns: 1fr;
    }
    
    .coalition-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
    
    .coalition-parties {
        justify-content: center;
    }
    
    .coalition-actions {
        align-self: center;
    }
}

/* 主要内容样式 */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.visualization-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #fff;
    border-radius: 10px;
    padding: 40px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

#seats-canvas {
    max-width: 100%;
    height: auto;
}

.party-overview {
    background-color: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.party-overview h2 {
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 1.5rem;
}

.party-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.party-stat-item {
    display: flex;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 5px;
    transition: transform 0.2s ease, background-color 0.2s ease;
    position: relative;
}

.party-stat-item:hover {
    transform: translateY(-2px);
    background-color: #e9ecef;
}

.party-color-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #e0e0e0;
    flex-shrink: 0;
    margin-right: 10px;
}

.party-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.party-name {
    font-weight: 600;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.party-seat-count {
    font-size: 0.9rem;
    color: #7f8c8d;
}

/* 政党操作按钮样式 */
.party-actions {
    display: flex;
    gap: 5px;
    margin-left: 10px;
    align-self: center;
}

.party-action-btn {
    padding: 4px 10px;
    border: none;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.edit-btn {
    background-color: #007bff;
    color: white;
}

.edit-btn:hover {
    background-color: #0056b3;
}

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

.delete-btn:hover {
    background-color: #c82333;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .party-stat-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .party-color-indicator {
        margin-right: 0;
        margin-bottom: 8px;
    }
    
    .party-actions {
        margin-left: 0;
        margin-top: 8px;
        align-self: flex-start;
    }
}

/* 控制面板样式 */
.control-panel {
    background-color: #fff;
    border-radius: 10px;
    padding: 20px;
    margin-top: 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}



/* 滑块控制样式 */
.capacity-control {
    margin: 15px 0;
}

.capacity-control label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.slider:hover {
    opacity: 1;
}

.slider::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4CAF50;
    cursor: pointer;
    border: none;
}

.control-panel h2 {
    margin-bottom: 20px;
    color: #2c3e50;
    font-size: 1.5rem;
}

.form-group {
    margin-bottom: 15px;
}

.description-control {
    display: flex;
    gap: 10px;
    align-items: center;
}

.description-control input {
    flex: 1;
}

.small-button {
    padding: 8px 12px;
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background-color 0.2s ease;
}

.small-button:hover {
    background-color: #5a6268;
}

#description-length {
    font-size: 0.8rem;
    color: #6c757d;
    text-align: right;
    margin-top: 2px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #555;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.control-button {
    padding: 10px 20px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s ease;
    margin-top: 10px;
    width: 100%;
}

.control-button:hover {
    background-color: #0056b3;
}

.control-button.secondary {
    background-color: #6c757d;
}

.control-button.secondary:hover {
    background-color: #5a6268;
}

/* 编辑确认区域样式 */
.edit-info {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
    border-left: 4px solid #007bff;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.edit-info small {
    color: #6c757d;
    font-weight: 500;
}

.edit-info .control-button {
    margin-top: 5px;
    width: 100%;
}

/* 模态框样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: #fff;
    padding: 30px;
    border-radius: 10px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
    color: #7f8c8d;
    transition: color 0.3s ease;
}

.close-modal:hover {
    color: #2c3e50;
}

.modal-content h2 {
    margin-bottom: 15px;
    color: #2c3e50;
    font-size: 1.8rem;
}

.modal-content p {
    margin-bottom: 10px;
    line-height: 1.6;
    color: #555;
}

/* 响应式设计 - 平板和小屏设备 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .title {
        font-size: 1.5rem;
    }
    
    .header-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .total-seats {
        font-size: 1rem;
    }
    
    .save-button,
    .coalition-button {
        margin-left: 0;
        width: 100%;
    }
    
    .visualization-container {
        padding: 20px 15px;
    }
    
    .party-stats {
        grid-template-columns: 1fr;
    }
    
    .control-button {
        width: 100%;
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    .control-button:last-child {
        margin-bottom: 0;
    }
    
    .party-overview h2,
    .control-panel h2 {
        font-size: 1.3rem;
    }
}

/* 手机端适配 - 小屏幕手机 */
@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    
    .title {
        font-size: 1.3rem;
    }
    
    .visualization-container {
        padding: 15px 10px;
    }
    
    .party-overview,
    .control-panel {
        padding: 15px;
    }
    
    .form-group input,
    .form-group textarea {
        padding: 8px;
        font-size: 0.9rem;
    }
    
    .modal-content {
        padding: 20px 15px;
        margin: 10px;
        width: calc(100% - 20px);
    }
    
    .modal-content h2 {
        font-size: 1.5rem;
    }
    
    .save-panel-content,
    .coalition-panel-content {
        width: 95%;
        margin: 5px;
        max-height: 90vh;
    }
    
    .save-panel-body,
    .modal-body {
        padding: 15px;
    }
    
    .party-global-actions.right-aligned {
        padding: 10px 0;
        gap: 5px;
    }
    
    .party-action-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
        width: 100%;
    }
    
    .action-party-name {
        font-size: 0.9rem;
    }
    
    .party-action-btn {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
    
    .capacity-control label {
        font-size: 0.9rem;
    }
    
    .slider {
        height: 5px;
    }
    
    .slider::-webkit-slider-thumb,
    .slider::-moz-range-thumb {
        width: 16px;
        height: 16px;
    }
    
    .party-stat-item {
        padding: 12px;
    }
    
    .party-name {
        font-size: 0.9rem;
    }
    
    .party-seat-count {
        font-size: 0.8rem;
    }
    
    .coalition-panel-header,
    .save-panel-header {
        padding: 12px 15px;
        margin: -15px -15px 15px;
    }
    
    .coalition-panel-header h3,
    .save-panel-header h3 {
        font-size: 1.1rem;
    }
    
    .close-coalition-panel {
        width: 25px;
        height: 25px;
        font-size: 20px;
    }
    
    .party-checkboxes {
        gap: 8px;
        max-height: 180px;
    }
    
    .coalition-parties {
        justify-content: flex-start;
    }
    
    .coalition-party {
        font-size: 0.75rem;
        padding: 3px 6px;
    }
}

/* 工具提示样式 */
.tooltip {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.9rem;
    pointer-events: none;
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
    white-space: nowrap;
}