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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Microsoft YaHei', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    overflow: hidden;
}

.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo i {
    font-size: 1.5rem;
    color: #4f46e5;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1f2937;
}

.header-actions {
    display: flex;
    gap: 1rem;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-primary {
    background: #4f46e5;
    color: white;
}

.btn-primary:hover {
    background: #4338ca;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    padding: 1.5rem;
}

.sidebar-section {
    margin-bottom: 2rem;
}

.sidebar-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.template-categories {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.template-category {
    border: 1px solid #e0e0e0;
    border-radius: 0.5rem;
    overflow: hidden;
}

.category-header {
    background: #f8f9fa;
    padding: 0.75rem 1rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    transition: background 0.2s;
}

.category-header:hover {
    background: #e9ecef;
}

.category-header h4 {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
}

.category-toggle {
    font-size: 0.75rem;
    color: #6b7280;
    transition: transform 0.2s;
}

.category-header.collapsed .category-toggle {
    transform: rotate(-90deg);
}

.category-content {
    padding: 0.75rem;
    display: block;
}

.category-content.collapsed {
    display: none;
}

.template-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

.template-item {
    aspect-ratio: 3.5/2;
    background: #ffffff;
    border: 2px solid transparent;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.template-item:hover {
    border-color: #4f46e5;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.template-item.selected {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.template-item canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.template-item .template-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    text-align: center;
    backdrop-filter: blur(4px);
}

/* Background Controls */
.background-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.bg-colors label,
.bg-image label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.5rem;
}

.color-picker {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.color-option {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.375rem;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    border-color: #4f46e5;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2);
}

/* Avatar Controls */
.avatar-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.avatar-upload label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.5rem;
}

.upload-avatar-btn {
    width: 100%;
    padding: 0.75rem;
    border: 2px dashed #d1d5db;
    background: #fff;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: #6b7280;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.upload-avatar-btn:hover {
    border-color: #4f46e5;
    color: #4f46e5;
    background: #f8faff;
}

.avatar-preview {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    background: #f9fafb;
}

.avatar-preview img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e5e7eb;
}

.remove-avatar-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 1.5rem;
    height: 1.5rem;
    border: none;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.remove-avatar-btn:hover {
    background: #dc2626;
    transform: scale(1.1);
}

/* Canvas Area */
.canvas-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f9fafb;
    padding: 2rem;
}

.canvas-container {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    border-radius: 0.5rem;
    overflow: hidden;
}

#businessCard {
    display: block;
    background: white;
}

/* Text Panel */
.text-panel {
    width: 320px;
    background: #fff;
    border-left: 1px solid #e0e0e0;
    overflow-y: auto;
    padding: 1.5rem;
}

.text-panel-section {
    margin-bottom: 2rem;
}

.text-panel-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    margin-bottom: 1rem;
}

.text-fields {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.text-field {
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
    background: #fafafa;
    transition: all 0.2s;
}

.text-field:hover {
    border-color: #d1d5db;
    background: #ffffff;
}

.text-field-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.text-field label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
}

.text-field-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.field-control-btn {
    width: 1.5rem;
    height: 1.5rem;
    border: 1px solid #d1d5db;
    background: #fff;
    border-radius: 0.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: #6b7280;
    transition: all 0.2s;
}

.field-control-btn:hover {
    background: #f3f4f6;
    border-color: #4f46e5;
    color: #4f46e5;
}

.text-field input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-family: inherit;
    transition: all 0.2s;
    margin-bottom: 0.75rem;
}

.text-field input:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.text-field-advanced {
    display: none;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e5e7eb;
}

.text-field-advanced.expanded {
    display: grid;
}

.advanced-control {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.advanced-control label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
}

.advanced-control input,
.advanced-control select {
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
    font-size: 0.75rem;
}

.advanced-control input:focus,
.advanced-control select:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.1);
}

.advanced-control-full {
    grid-column: 1 / -1;
}

/* Background opacity control */
.bg-opacity-control {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.bg-opacity-control label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.opacity-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e5e7eb;
    outline: none;
    -webkit-appearance: none;
}

.opacity-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4f46e5;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.opacity-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4f46e5;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Style Controls */
.style-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.style-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.style-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
}

.style-group select,
.style-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.style-group select:focus,
.style-group input:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Color inputs */
input[type="color"] {
    height: 40px;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 1200px) {
    .sidebar, .text-panel {
        width: 260px;
    }
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
    }

    .sidebar, .text-panel {
        width: 100%;
        max-height: 200px;
    }

    .canvas-area {
        padding: 1rem;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Loading state */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6b7280;
    font-size: 0.875rem;
}

/* Success message */
.success-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #10b981;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

/* Export Dropdown */
.export-dropdown {
    position: relative;
    display: inline-block;
}

.export-options {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: none;
    min-width: 200px;
    margin-top: 0.5rem;
}

.export-options.show {
    display: block;
}

.export-option {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #374151;
}

.export-option:hover {
    background-color: #f8f9fa;
}

.export-option:first-child {
    border-radius: 0.5rem 0.5rem 0 0;
}

.export-option:last-child {
    border-radius: 0 0 0.5rem 0.5rem;
}

.export-option i {
    color: #6b7280;
    width: 16px;
    text-align: center;
}

/* Print Modal */
.print-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.print-modal.show {
    display: flex;
}

.print-modal-content {
    background: white;
    border-radius: 0.5rem;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.print-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
}

.print-modal-header h3 {
    margin: 0;
    color: #1f2937;
    font-size: 1.25rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: all 0.2s;
}

.close-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.print-modal-body {
    padding: 1.5rem;
}

.print-setting {
    margin-bottom: 1.5rem;
}

.print-setting label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

.print-setting select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background: white;
}

.print-setting select:focus {
    outline: none;
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.print-preview {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 0.375rem;
    border: 1px solid #e0e0e0;
}

.print-preview canvas {
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
}

.print-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid #e0e0e0;
}

.print-modal-footer .btn {
    min-width: 100px;
}