:root {
    --primary-color: #4a6fa5;
    --secondary-color: #6b8cbc;
    --accent-color: #ff6b6b;
    --success-color: #2ecc71;
    --warning-color: #f39c12;
    --text-color: #333;
    --text-light: #777;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --sidebar-bg: #2c3e50;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.15);
    --transition: all 0.3s ease;
    --border-radius: 10px;
}

[data-theme="dark"] {
    --primary-color: #5a7bb5;
    --secondary-color: #7b9ccc;
    --accent-color: #ff7b7b;
    --text-color: #f0f0f0;
    --text-light: #aaa;
    --bg-color: #1a1a2e;
    --card-bg: #16213e;
    --sidebar-bg: #0f3460;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: var(--transition);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Animated Background */
.animated-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.1;
    animation: float 15s infinite linear;
}

.shape-1 {
    width: 300px;
    height: 300px;
    background: var(--primary-color);
    top: 10%;
    left: 5%;
    animation-delay: 0s;
}

.shape-2 {
    width: 200px;
    height: 200px;
    background: var(--accent-color);
    top: 60%;
    right: 10%;
    animation-delay: 3s;
}

.shape-3 {
    width: 150px;
    height: 150px;
    background: var(--secondary-color);
    bottom: 10%;
    left: 15%;
    animation-delay: 6s;
}

.shape-4 {
    width: 250px;
    height: 250px;
    background: var(--success-color);
    top: 20%;
    right: 20%;
    animation-delay: 9s;
}

.shape-5 {
    width: 180px;
    height: 180px;
    background: var(--warning-color);
    bottom: 20%;
    right: 5%;
    animation-delay: 12s;
}

@keyframes float {
    0% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(180deg); }
    100% { transform: translateY(0) rotate(360deg); }
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 30px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
}

.logo i {
    font-size: 28px;
}

.header-controls {
    display: flex;
    gap: 10px;
}

.theme-toggle, .help-btn {
    background: var(--card-bg);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: var(--transition);
    color: var(--text-color);
}

.theme-toggle:hover, .help-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

/* Dashboard Layout */
.dashboard {
    display: grid;
    grid-template-columns: 250px 1fr 350px;
    gap: 30px;
    height: calc(100vh - 120px);
}

/* Sidebar */
.sidebar {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    overflow-y: auto;
}

.sidebar-section {
    margin-bottom: 30px;
}

.sidebar-section h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tool-item, .export-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.tool-item:hover, .export-item:hover {
    background: rgba(74, 111, 165, 0.1);
}

.tool-item.active, .export-item.active {
    background: var(--primary-color);
    color: white;
}

.tool-item i, .export-item i {
    width: 20px;
    text-align: center;
}

/* Main Content */
.main-content {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    overflow-y: auto;
}

.panel {
    display: none;
}

.panel.active {
    display: block;
}

.panel-title {
    font-size: 20px;
    margin-bottom: 25px;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Form Styles */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-color);
}

input, select, textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: var(--card-bg);
    color: var(--text-color);
    transition: var(--transition);
    font-family: 'Poppins', sans-serif;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.2);
}

/* Template Grid */
.template-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
}

.template-item {
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.template-item:hover {
    transform: translateY(-5px);
}

.template-item.active .template-preview {
    border-color: var(--primary-color);
    box-shadow: 0 5px 15px rgba(74, 111, 165, 0.3);
}

.template-preview {
    width: 100%;
    height: 80px;
    border: 2px solid #ddd;
    border-radius: 8px;
    margin-bottom: 8px;
    transition: var(--transition);
}

.template-item span {
    font-size: 12px;
    color: var(--text-color);
}

/* Color Palette */
.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.color-option {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.active {
    border-color: var(--text-color);
}

/* Alignment Options */
.alignment-options {
    display: flex;
    gap: 10px;
}

.align-btn {
    background: var(--card-bg);
    border: 1px solid #ddd;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-color);
}

.align-btn.active, .align-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Upload Area */
.upload-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.upload-area {
    border: 2px dashed #ddd;
    border-radius: var(--border-radius);
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(74, 111, 165, 0.05);
}

.upload-area i {
    font-size: 40px;
    color: var(--text-light);
    margin-bottom: 15px;
}

.upload-area h3 {
    margin-bottom: 10px;
    color: var(--text-color);
}

.upload-area p {
    color: var(--text-light);
    font-size: 14px;
}

.upload-area input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Background Options */
.bg-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.bg-option {
    text-align: center;
    cursor: pointer;
}

.bg-option.active .bg-preview {
    border-color: var(--primary-color);
}

.bg-preview {
    width: 100%;
    height: 60px;
    border: 2px solid #ddd;
    border-radius: 8px;
    margin-bottom: 8px;
    transition: var(--transition);
}

.bg-option span {
    font-size: 12px;
    color: var(--text-color);
}

/* Preview Panel */
.preview-panel {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
    overflow-y: auto;
}

.card-preview-container {
    margin-bottom: 30px;
}

.card-preview {
    width: 100%;
    height: 220px;
    position: relative;
    perspective: 1000px;
    margin-bottom: 20px;
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    transition: transform 0.6s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: white;
}

.card-back {
    transform: rotateY(180deg);
    background: #f8f9fa;
}

.card-preview.flipped .card-front {
    transform: rotateY(180deg);
}

.card-preview.flipped .card-back {
    transform: rotateY(0);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.card-logo {
    max-width: 80px;
    max-height: 40px;
}

.card-badge {
    background: var(--primary-color);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
}

.card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.card-name {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 5px;
    color: #333;
}

.card-title {
    font-size: 14px;
    color: #666;
    margin-bottom: 15px;
}

.card-contact {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    margin-bottom: 5px;
    color: #555;
}

.card-contact i {
    color: var(--primary-color);
    width: 12px;
}

.card-footer {
    border-top: 1px solid #eee;
    padding-top: 10px;
}

.card-company {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.card-social {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.card-social i {
    color: var(--primary-color);
    font-size: 16px;
}

.qr-code {
    text-align: center;
    margin-top: 10px;
}

#qrCodePlaceholder {
    width: 70px;
    height: 70px;
    background: #eee;
    margin: 0 auto 5px;
    border-radius: 5px;
}

.qr-code p {
    font-size: 10px;
    color: #777;
}

.card-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.control-btn {
    background: var(--card-bg);
    border: 1px solid #ddd;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    color: var(--text-color);
}

.control-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Export Section */
.export-section {
    margin-bottom: 30px;
}

.export-section h3 {
    margin-bottom: 15px;
    color: var(--text-color);
}

.layout-options {
    display: flex;
    gap: 10px;
}

.layout-option {
    padding: 8px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
}

.layout-option.active, .layout-option:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.export-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 20px;
}

.export-btn {
    padding: 12px 15px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
    color: white;
}

.export-btn.pdf {
    background: #e74c3c;
}

.export-btn.word {
    background: #2c5ea7;
}

.export-btn.png, .export-btn.jpeg {
    background: #27ae60;
}

.export-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

/* AI Suggestions */
.ai-suggestions {
    background: rgba(74, 111, 165, 0.1);
    border-radius: var(--border-radius);
    padding: 20px;
}

.ai-suggestions h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.suggestion {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    background: var(--card-bg);
    border-radius: 8px;
    margin-bottom: 10px;
    transition: var(--transition);
    cursor: pointer;
}

.suggestion:hover {
    transform: translateX(5px);
}

.suggestion i {
    color: var(--accent-color);
    margin-top: 2px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    background: var(--card-bg);
    padding: 30px;
    border-radius: var(--border-radius);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-content h3 {
    margin-bottom: 10px;
    color: var(--text-color);
}

.loading-content p {
    color: var(--text-light);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .dashboard {
        grid-template-columns: 220px 1fr;
    }
    
    .preview-panel {
        grid-column: 1 / -1;
        margin-top: 30px;
    }
    
    .template-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 992px) {
    .dashboard {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .sidebar {
        display: none;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .template-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .upload-section {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .dashboard {
        gap: 20px;
    }
    
    .template-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .bg-options {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .export-buttons {
        grid-template-columns: 1fr;
    }
    
    .card-controls {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .template-grid {
        grid-template-columns: 1fr;
    }
    
    .card-preview {
        height: 200px;
    }
    
    .card-name {
        font-size: 16px;
    }
    
    .card-title {
        font-size: 12px;
    }
    
    .card-contact {
        font-size: 10px;
    }
}