* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 600px;
}

.form-wrapper {
    background: white;
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

h1 {
    color: #333;
    margin-bottom: 10px;
    text-align: center;
    font-size: 2em;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
    font-size: 0.95em;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
    font-size: 0.95em;
}

.required {
    color: #e74c3c;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    transition: all 0.3s ease;
    font-family: inherit;
}

input:focus,
select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 40px;
}

.submit-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-top: 10px;
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.submit-btn:active {
    transform: translateY(0);
}

.message {
    margin-top: 20px;
    padding: 15px;
    border-radius: 8px;
    display: none;
    text-align: center;
    font-weight: 500;
}

.message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

.message.info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
    display: block;
}

.message.success a {
    color: #155724;
    text-decoration: underline;
    font-weight: 600;
}

.message.success a:hover {
    color: #0d4214;
}

input[type="file"] {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    transition: all 0.3s ease;
    font-family: inherit;
    background: white;
    cursor: pointer;
}

input[type="file"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.file-hint {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 0.85em;
}

.image-preview {
    margin-top: 15px;
    display: none;
}

.image-preview img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    object-fit: cover;
}

.image-preview.show {
    display: block;
}

/* Visiting Card Styles - Business Card Layout */
.visiting-card-container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    animation: slideDown 0.5s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.visiting-card.business-card {
    background: #ffffff;
    border: 2px solid #2c3e50;
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    width: 3.37in; /* 85.6 mm - Business card width */
    height: 2.125in; /* 53.98 mm - Business card height */
    max-width: 3.37in;
    max-height: 2.125in;
    min-width: 3.37in;
    min-height: 2.125in;
    margin: 0 auto;
    overflow: hidden;
    font-family: 'Arial', 'Helvetica', sans-serif;
    position: relative;
    display: flex;
    flex-direction: column;
    aspect-ratio: 1.58 / 1; /* Maintain business card ratio */
}

/* Header Bar */
.card-header-bar {
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    padding: 6px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #1a252f;
    flex-shrink: 0;
}

.card-title {
    font-size: 0.65em;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.card-id {
    font-size: 0.6em;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.15);
    padding: 3px 8px;
    border-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
}

/* Main Content Area */
.card-main-content {
    display: flex;
    padding: 8px 10px;
    gap: 10px;
    flex: 1;
    background: #ffffff;
    align-items: center;
}

/* Left Section - Photo */
.card-left-section {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-photo-container {
    width: 1.1in;
    height: 1.4in;
    border: 2px solid #2c3e50;
    border-radius: 2px;
    padding: 2px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.1);
    position: relative;
}

.card-photo-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 1px solid #e0e0e0;
    pointer-events: none;
}

.card-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 1px;
    display: block;
}

/* Center Section - Name and Barcode */
.card-center-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 0 8px;
    min-width: 0;
    overflow: hidden;
}

.card-name {
    font-size: 0.8em;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.15;
    word-wrap: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.card-barcode-area {
    text-align: left;
    padding: 3px 0;
}

.barcode-text {
    font-family: 'Courier New', monospace;
    font-size: 0.6em;
    font-weight: 700;
    color: #2c3e50;
    letter-spacing: 2px;
    line-height: 1.1;
}

/* Right Section - QR Code */
.card-right-section {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-qr-container {
    text-align: center;
    padding: 4px;
    background: #ffffff;
    border: 1.5px solid #2c3e50;
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.card-qr-code {
    width: 0.7in;
    height: 0.7in;
    display: block;
    margin: 0 auto 2px;
    background: white;
    padding: 2px;
    max-width: 100%;
    max-height: 100%;
}

.qr-label {
    font-size: 0.45em;
    color: #555;
    margin: 0;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.visiting-card-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    padding: 20px;
    background: transparent;
    flex-wrap: wrap;
}

.save-card-btn,
.close-card-btn {
    padding: 10px 25px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.save-card-btn {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
}

.save-card-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.4);
}

.save-card-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.close-card-btn {
    background: #6c757d;
    color: white;
}

.close-card-btn:hover {
    background: #5a6268;
}

.visiting-card-note {
    text-align: center;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.visiting-card-note p {
    color: #666;
    font-size: 0.85em;
    margin: 0;
}

.share-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
}

.share-link-input {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.9em;
    margin-bottom: 15px;
    background: #f9f9f9;
    cursor: text;
}

.share-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.share-card-btn,
.share-btn-copy,
.share-btn-whatsapp,
.share-btn-facebook {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.share-card-btn {
    background: #17a2b8;
    color: white;
}

.share-card-btn:hover {
    background: #138496;
    transform: translateY(-2px);
}

.share-btn-copy {
    background: #6c757d;
    color: white;
}

.share-btn-copy:hover {
    background: #5a6268;
}

.share-btn-whatsapp {
    background: #25D366;
    color: white;
}

.share-btn-whatsapp:hover {
    background: #20ba5a;
}

.share-btn-facebook {
    background: #1877F2;
    color: white;
}

.share-btn-facebook:hover {
    background: #166fe5;
}

.copy-success-msg {
    text-align: center;
    color: #28a745;
    font-size: 0.9em;
    margin-top: 10px;
    font-weight: 600;
    min-height: 20px;
}

@media print {
    .visiting-card-actions,
    .share-section,
    .visiting-card-note {
        display: none;
    }
    
    .form-wrapper {
        display: none;
    }
    
    body {
        background: white;
        padding: 0;
        margin: 0;
    }
    
    .visiting-card.business-card {
        box-shadow: none;
        border: 2px solid #2c3e50;
        page-break-inside: avoid;
        margin: 0 auto;
        width: 3.37in;
        height: 2.125in;
    }
    
    .card-main-content {
        background: #ffffff;
    }
    
    @page {
        size: 3.37in 2.125in;
        margin: 0;
    }
}

@media (max-width: 600px) {
    .form-wrapper {
        padding: 25px;
    }
    
    h1 {
        font-size: 1.5em;
    }
    
    .visiting-card.business-card {
        width: 100%;
        max-width: 100%;
        height: auto;
        aspect-ratio: 1.58 / 1;
        max-height: none;
    }
    
    .card-photo-container {
        width: 25%;
        height: auto;
        aspect-ratio: 0.786 / 1;
    }
    
    .card-qr-code {
        width: 80%;
        height: auto;
        aspect-ratio: 1 / 1;
    }
    
    .card-name {
        font-size: 0.75em;
    }
    
    .barcode-text {
        font-size: 0.55em;
    }
    
    .card-header-bar {
        padding: 5px 10px;
    }
    
    .card-title {
        font-size: 0.6em;
    }
    
    .card-id {
        font-size: 0.55em;
        padding: 2px 6px;
    }
}

/* QR Scanner Section Styles */
.qr-scanner-section {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#qrReader {
    background: #000;
    min-height: 300px;
}

#toggleScannerBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

#stopScannerBtn:hover {
    background: #c82333;
}

#qrFileInput + label:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.4);
}

#uploadArea {
    transition: all 0.3s ease;
}

#uploadArea:hover {
    border-color: #28a745 !important;
    background: #f0fff4 !important;
}

#scanUploadedBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.4);
}

#scanUploadedBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

#uploadPreview img {
    display: block;
    margin: 0 auto;
}

@media (max-width: 600px) {
    .qr-scanner-section {
        padding: 15px !important;
    }
    
    #qrReader {
        min-height: 250px;
    }
    
    #uploadArea {
        padding: 15px !important;
    }
}
