/* ============================================
   Business Card Designer - Frontend v6.0
   ============================================ */

   .bcd-container {
    display: flex;
    gap: 30px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    direction: rtl;
    flex-wrap: wrap;
}

/* ---- Template Selector ---- */
.template-selector {
    width: 100%;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
}

.template-selector h4 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.template-list {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.template-item {
    width: 150px;
    height: 100px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 3px solid transparent;
    transition: transform 0.2s, border-color 0.2s;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
    position: relative;
    overflow: hidden;
}

.template-item:hover {
    transform: scale(1.05);
}

.template-item.active {
    border-color: #3498db;
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.3);
}

.template-item small {
    font-size: 10px;
    opacity: 0.8;
    margin-top: 5px;
}

/* ---- Controls ---- */
.bcd-controls {
    flex: 1;
    background: #f8f9fa;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    max-height: 95vh;
    overflow-y: auto;
    min-width: 350px;
}

.bcd-controls h3 {
    color: #2c3e50;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid #3498db;
}

.bcd-info {
    color: #7f8c8d;
    font-size: 13px;
    margin-bottom: 20px;
    padding: 10px;
    background: #e8f4f8;
    border-radius: 8px;
    border-right: 3px solid #3498db;
}

.bcd-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.bcd-field-group {
    margin-bottom: 12px;
}

.bcd-field-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    color: #555;
    font-size: 0.9em;
}

.bcd-field-group input,
.bcd-field-group textarea,
.bcd-field-group select {
    width: 100%;
    padding: 8px 10px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
}

.bcd-preview-thumb {
    width: 70px;
    height: 70px;
    border: 2px dashed #ccc;
    border-radius: 6px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #fff;
}

.bcd-preview-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
}

.bcd-btn-primary, .bcd-btn-secondary {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: transform 0.2s;
}

.bcd-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.bcd-btn-secondary {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
    margin-top: 10px;
}

.bcd-btn-small {
    padding: 6px 12px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
}

/* ---- Preview ---- */
.bcd-preview-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: sticky;
    top: 20px;
    height: fit-content;
}

.bcd-card-wrapper {
    perspective: 1000px;
    position: relative;
    padding: 20px;
    background: #e0e0e0;
    border-radius: 20px;
}

.business-card {
    width: 400px;
    height: 250px;
    position: relative;
    border-radius: 0;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    background: white;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.card-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    background-size: cover;
    background-position: center;
}

/* Elements */
.card-element {
    position: absolute;
    z-index: 10;
    overflow: hidden;
}

.card-element img {
    width: 100%;
    height: 100%;
    display: block;
}

#card-photo-container img {
    object-fit: cover;
}

#card-sig-container img {
    object-fit: contain;
    filter: invert(1);
}

#card-extra-container img {
    object-fit: contain;
}

/* Text Fields */
.card-field {
    position: absolute;
    z-index: 10;
    padding: 2px;
    white-space: nowrap;
}

.field-value {
    font-weight: 700;
    font-size: 14px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
    display: inline-block;
}

.card-watermark {
    position: absolute;
    bottom: 8px;
    right: 10px;
    font-size: 9px;
    opacity: 0.6;
    z-index: 100;
    color: white;
    background: rgba(0,0,0,0.5);
    padding: 2px 8px;
    border-radius: 10px;
    pointer-events: none;
}

/* Hidden elements */
.card-element.hidden,
.card-field.hidden {
    display: none !important;
}

/* Download Modal */
.bcd-download-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.bcd-download-modal.active {
    display: flex;
}

.bcd-download-modal img {
    max-width: 90%;
    max-height: 80%;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal-buttons {
    margin-top: 20px;
    display: flex;
    gap: 15px;
}

.modal-buttons button {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    font-family: inherit;
}

.btn-download {
    background: #27ae60;
    color: white;
}

.btn-close {
    background: #e74c3c;
    color: white;
}

/* Responsive */
@media (max-width: 900px) {
    .bcd-container {
        flex-direction: column;
    }
    .bcd-controls {
        max-height: none;
        min-width: auto;
    }
}