/*=========== CUSTOM STYLES ===========*/

/* ID Card Container */
.id-card-container {
    aspect-ratio: var(--aspect-ratio, 1 / 1.6);
    width: 100%;
    max-width: 320px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.02);
    overflow: hidden;
    transition: all 0.3s ease;
    position: relative;
    border: 1px solid #e5e7eb;
}

.id-card-container.landscape {
    aspect-ratio: 1.6 / 1;
    max-width: 400px;
}

.id-card-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.05s ease;
    position: relative;
}

/* Sticky Preview Section */
.sticky-preview {
    position: sticky;
    top: 20px;
    z-index: 10;
}

/*=========== PRINT LAYOUT STYLES ===========*/
.print-layout-container {
    background: #f8fafc;
    border-radius: 12px;
    padding: 20px;
    border: 2px dashed #94a3b8;
    position: relative;
    min-height: 500px;
}

.print-grid {
    display: grid;
    gap: 5mm;
    padding: 10mm;
    background: white;
    border-radius: 8px;
    min-height: auto;
    width: 100%;
    box-sizing: border-box;
}

/* FIXED: Cards align to top */
.print-grid.align-top {
    align-content: start;
}

.print-card {
    aspect-ratio: 85.6 / 54;
    width: 100%;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.print-card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.print-card-number {
    position: absolute;
    top: 2px;
    left: 2px;
    background: rgba(37, 99, 235, 0.8);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
    z-index: 5;
}

.print-placeholder {
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 12px;
    border: 2px dashed #cbd5e1;
}

.paper-size-indicator {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #2563eb;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    z-index: 10;
}

/*=========== 4x6 PHOTO PAPER LAYOUT ===========*/
.photo-paper-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 5mm;
    padding: 5mm;
    background: white;
    border-radius: 8px;
    min-height: 152mm;
    width: 100%;
    box-sizing: border-box;
}

.photo-paper-card {
    aspect-ratio: 85.6 / 54;
    width: 100%;
    max-width: 130mm;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.photo-paper-card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.photo-paper-label {
    position: absolute;
    top: 5px;
    left: 5px;
    background: rgba(37, 99, 235, 0.9);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    z-index: 5;
}

/*=========== PRINT MEDIA QUERIES ===========*/
@media print {
    @page {
        size: A4 portrait;
        margin: 0 !important;
    }

    body {
        margin: 0;
        padding: 0;
        background: white;
    }

    .no-print {
        display: none !important;
    }

    .print-only {
        display: block !important;
    }

    .print-grid,
    .photo-paper-layout {
        box-shadow: none;
        page-break-after: avoid;
        page-break-inside: avoid;
        break-inside: avoid;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .print-card,
    .photo-paper-card {
        page-break-inside: avoid;
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .print-card-number,
    .photo-paper-label {
        display: none;
    }
}

/*=========== POSITION OVERLAY ===========*/
.position-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    border: 2px dashed rgba(37, 99, 235, 0.5);
    z-index: 5;
    display: none;
}

.id-card-container:hover .position-overlay {
    display: block;
}

.position-indicator {
    position: absolute;
    background: rgba(37, 99, 235, 0.2);
    z-index: 4;
    pointer-events: none;
}

.indicator-horizontal {
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #2563eb, transparent);
}

.indicator-vertical {
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(180deg, transparent, #2563eb, transparent);
}

/*=========== UPLOAD PLACEHOLDER ===========*/
.upload-placeholder {
    aspect-ratio: var(--aspect-ratio, 1 / 1.6);
    width: 100%;
    max-width: 320px;
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 2px dashed #9ca3af;
    transition: all 0.3s ease;
}

.upload-placeholder.landscape {
    aspect-ratio: 1.6 / 1;
    max-width: 400px;
}

.upload-placeholder:hover {
    border-color: #2563eb;
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
}

.upload-placeholder i {
    font-size: 3rem;
    color: #6b7280;
    margin-bottom: 1rem;
}

.upload-placeholder:hover i {
    color: #2563eb;
}

/*=========== BUTTON STYLES ===========*/
.tool-btn {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: white;
    border: 1px solid #e5e7eb;
    color: #374151;
}

.tool-btn:hover {
    background: #f3f4f6;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.tool-btn:active {
    transform: translateY(0);
}

.tool-btn.active {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}

.tool-btn.active:hover {
    background: #1d4ed8;
}

.download-btn {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    border: none;
}

.download-btn:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
}

.print-layout-btn {
    background: linear-gradient(135deg, #059669, #047857);
    color: white;
    border: none;
}

.print-layout-btn:hover {
    background: linear-gradient(135deg, #047857, #065f46);
}

.photo-paper-btn {
    background: linear-gradient(135deg, #9333ea, #7e22ce);
    color: white;
    border: none;
}

.photo-paper-btn:hover {
    background: linear-gradient(135deg, #7e22ce, #6b21a8);
}

/*=========== POSITION CONTROLS ===========*/
.pos-control-btn {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: white;
    border: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.2rem;
    color: #4b5563;
}

.pos-control-btn:hover {
    background: #f3f4f6;
    transform: scale(1.05);
    border-color: #2563eb;
    color: #2563eb;
}

.pos-control-btn:active {
    transform: scale(0.95);
}

.pos-control-panel {
    background: #f9fafb;
    border-radius: 12px;
    padding: 15px;
    margin-top: 10px;
}

.pos-value {
    background: white;
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

.position-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    margin-bottom: 10px;
}

/*=========== RESPONSIVE ===========*/
@media (max-width: 768px) {

    .id-card-container,
    .id-card-container.landscape {
        max-width: 280px;
    }

    .upload-placeholder,
    .upload-placeholder.landscape {
        max-width: 280px;
    }
}

/*=========== LOADING SPINNER ===========*/
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #2563eb;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/*=========== TOAST NOTIFICATION ===========*/
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #10b981;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 9999;
}

.toast.show {
    transform: translateX(0);
}

/*=========== DIMENSION OVERLAY ===========*/
.dimension-overlay {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(37, 99, 235, 0.9);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 10px;
    z-index: 10;
}

/*=========== COLOR PICKER ===========*/
.color-picker {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

/*=========== CUSTOM SLIDER ===========*/
.custom-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(90deg, #2563eb, #9333ea);
    outline: none;
    -webkit-appearance: none;
}

.custom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #2563eb;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
    transition: all 0.2s ease;
}

.custom-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/*=========== PRINT CONTROL PANEL ===========*/
.print-control-panel {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
}

.paper-size-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    border: 1px solid #cbd5e1;
    background: white;
}

.paper-size-btn.active {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}

/*=========== HOME BUTTON ===========*/
.home-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.home-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(37, 99, 235, 0.4);
}