@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@400;500;600&display=swap');

:root {
	--bs-body-font-family: 'Rubik', sans-serif;
	--bs-body-bg: #f8f9fa;
	--bs-primary-rgb: 13, 110, 253; /* Standard Bootstrap Blue for consistency */
	--card-shadow: 0 4px 12px rgba(0,0,0, .08);
	--card-border-radius: .5rem;
}

html, body {
	height: 100%;
}

body {
	background: linear-gradient(180deg, #ffffff 0%, #eef2f5 300px);
}

#summaryBar {
	background-color: #212529 !important;
	color: #ffffff !important;
	border-bottom: 1px solid #dee2e6;
	box-shadow: var(--card-shadow);
	transition: box-shadow .2s ease;
	z-index: 1000;
}

.card {
	border: none;
	border-radius: var(--card-border-radius);
	box-shadow: var(--card-shadow);
}

.form-control, .form-select {
	border-radius: .375rem;
}

.btn {
	border-radius: .375rem;
	font-weight: 500;
}

#layoutCanvas {
	background: var(--bs-body-bg);
}

.list-enter {
	animation: listEnter .2s ease-out;
}
@keyframes listEnter {
	from { transform: translateY(6px); opacity: 0; }
	to { transform: translateY(0); opacity: 1; }
}

.blink {
	animation: blinkHighlight 1s ease-in-out;
}
@keyframes blinkHighlight {
	0% { box-shadow: 0 0 0 0 rgba(13,110,253,.4); }
	50% { box-shadow: 0 0 0 6px rgba(13,110,253,.0); }
	100% { box-shadow: 0 0 0 0 rgba(13,110,253,.0); }
}

#itemsList .item-row {
	display: grid;
	grid-template-columns: 1fr auto;
	gap: .5rem;
	align-items: center;
}
#itemsList .dims {
	font-weight: 500;
}
#itemsList .meta {
	color: #6c757d;
	font-size: .9rem;
}

@media (min-width: 768px) {
	#itemsList .item-row {
		grid-template-columns: 2fr 1fr auto;
	}
}

/* Print styles for better output quality */
@media print {
	* {
		-webkit-print-color-adjust: exact !important;
		print-color-adjust: exact !important;
		color-adjust: exact !important;
	}
	
	body {
		background: white !important;
	}
	
	.card {
		page-break-inside: avoid;
		break-inside: avoid;
	}
	
	#summaryBar {
		position: static !important;
		page-break-after: avoid;
		break-after: avoid;
	}
	
	canvas, img {
		page-break-inside: avoid !important;
		break-inside: avoid !important;
		image-rendering: -webkit-optimize-contrast;
		image-rendering: crisp-edges;
	}
	
	button {
		display: none !important;
	}
}

/* Screen A4 preview styles */
#printPreview .preview-pages { }
#printPreview .preview-pages .page {
    background: #fff;
    padding: 10mm;
    margin: 0 auto 12px auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #dee2e6;
    width: 281mm; /* A4 landscape usable width with margins aligned to print */
}
#printPreview .rolls-table { width: 100%; border-collapse: separate; border-spacing: 6px 8px; table-layout: fixed; }
#printPreview .rolls-table td.col { padding: 4px; vertical-align: top; }
#printPreview .col-header { text-align: center; color: #0a58ca; font-weight: 700; font-size: 13px; margin-bottom: 6px; border-bottom: 2px solid #0a58ca; padding-bottom: 3px; white-space: nowrap; }
#printPreview .col-img { width: 100%; height: 100%; display: block; border: 2px solid #333; object-fit: contain; }
#printPreview .col-footer { font-size: 11px; color: #000; font-weight: 600; margin-top: 4px; text-align: center; line-height: 1.4; }

/* Layout preview in 3 columns inside canvasContainer */
#canvasContainer {
    position: relative;
}

#layoutPreview {
    padding: 1rem;
    min-height: 100%;
}

.layout-preview-wrapper {
    width: 100%;
    height: 100%;
}

.layout-preview-container {
    width: 100%;
    padding: 1rem;
}

.layout-preview-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: nowrap;
    justify-content: flex-start;
}

.layout-preview-col {
    flex: 0 0 calc(33.333% - 0.67rem);
    min-width: 0;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0.75rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

.layout-preview-col-header {
    text-align: center;
    color: #0a58ca;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #0a58ca;
    white-space: nowrap;
}

.layout-preview-col-image {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    margin-bottom: 0.5rem;
    min-height: 150px;
    overflow: visible;
}

.layout-preview-img {
    width: 100%;
    height: auto;
    border: 2px solid #333;
    border-radius: 0.25rem;
    object-fit: contain;
    display: block;
}

.layout-preview-col-footer {
    font-size: 12px;
    color: #000;
    font-weight: 600;
    text-align: center;
    line-height: 1.5;
    padding-top: 0.5rem;
    border-top: 1px solid #dee2e6;
    white-space: nowrap;
}

/* Мобильная адаптация */
@media (max-width: 991px) {
    #canvasContainer {
        height: auto !important;
        min-height: 400px;
        max-height: 600px;
    }
    
    #layoutPreview {
        padding: 0.5rem;
    }
    
    .layout-preview-container {
        padding: 0.5rem;
    }
    
    .layout-preview-row {
        flex-wrap: wrap;
        gap: 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    .layout-preview-col {
        flex: 0 0 100%;
        max-width: 100%;
        padding: 0.5rem;
    }
    
    .layout-preview-col-header {
        font-size: 13px;
        margin-bottom: 0.4rem;
        padding-bottom: 0.4rem;
    }
    
    .layout-preview-col-image {
        min-height: 120px;
        margin-bottom: 0.4rem;
    }
    
    .layout-preview-col-footer {
        font-size: 11px;
        padding-top: 0.4rem;
    }
}

@media (max-width: 576px) {
    #canvasContainer {
        height: auto !important;
        min-height: 300px;
        max-height: 500px;
    }
    
    #layoutPreview {
        padding: 0.25rem;
    }
    
    .layout-preview-container {
        padding: 0.25rem;
    }
    
    .layout-preview-row {
        gap: 0.5rem;
        margin-bottom: 0.5rem;
    }
    
    .layout-preview-col {
        padding: 0.4rem;
    }
    
    .layout-preview-col-header {
        font-size: 12px;
        margin-bottom: 0.3rem;
        padding-bottom: 0.3rem;
    }
    
    .layout-preview-col-image {
        min-height: 100px;
        margin-bottom: 0.3rem;
    }
    
    .layout-preview-col-footer {
        font-size: 10px;
        padding-top: 0.3rem;
        line-height: 1.4;
    }
    
    .layout-preview-img {
        border-width: 1px;
    }
}

/* Checkbox grid for quantity modal */
.qty-checkboxes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 0.375rem;
}

.qty-checkbox-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border: 2px solid #dee2e6;
    border-radius: 0.375rem;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.qty-checkbox-item:hover {
    border-color: #0d6efd;
    transform: translateY(-2px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.qty-checkbox-item.checked {
    background: #0d6efd;
    border-color: #0d6efd;
    color: white;
}

.qty-checkbox-item input[type="checkbox"] {
    display: none;
}

.qty-checkbox-label {
    font-weight: 600;
    font-size: 0.9rem;
    text-align: center;
}

/* Mobile header improvements */
#summaryBar {
	transition: all 0.3s ease;
	display: block !important;
	visibility: visible !important;
}

#summaryBar .container {
	max-width: 100%;
}

/* Mobile menu button */
#summaryBar .btn-outline-light {
	border-color: rgba(255,255,255,0.5) !important;
	color: #ffffff !important;
	background-color: rgba(255,255,255,0.05) !important;
}

#summaryBar .btn-outline-light:hover,
#summaryBar .btn-outline-light:focus {
	background-color: rgba(255,255,255,0.15) !important;
	border-color: rgba(255,255,255,0.7) !important;
	color: #ffffff !important;
}

/* Three dots button */
#summaryBar button[data-bs-toggle="collapse"] {
	min-width: 40px;
	min-height: 36px;
	font-size: 1.2rem;
}

#summaryBar button[data-bs-toggle="collapse"] i {
	font-size: 1.3rem;
}

@media (max-width: 991px) {
    #summaryBar .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    #summaryBar .badge {
    	font-size: 0.75rem;
    	padding: 0.35rem 0.5rem;
    	font-weight: 500;
    }
    
    #summaryBar .badge.bg-secondary {
    	background-color: #6c757d !important;
    }
    
    #summaryBar .badge.bg-info {
    	background-color: #0dcaf0 !important;
    	color: #000 !important;
    }
    
    #summaryBar .badge.bg-warning {
    	background-color: #ffc107 !important;
    	color: #000 !important;
    }
    
    #mobileMenu {
        margin-top: 0.75rem;
        padding-bottom: 0.5rem;
    }
    
    #mobileMenu .btn-group {
        width: 100%;
    }
    
    #mobileMenu .btn-group .btn {
        flex: 1;
    }
    
    /* Ensure mobile layout is visible */
    .d-lg-none {
    	display: block !important;
    }
    
    /* Hide desktop layout on mobile */
    .d-none.d-lg-flex {
    	display: none !important;
    }
}

/* Item row with quantity badge */
#itemsList .qty-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    background: #e9ecef;
    transition: all 0.2s ease;
}

#itemsList .qty-badge:hover {
    background: #0d6efd;
    color: white;
}

#itemsList .qty-badge i {
    font-size: 0.8rem;
}


