/* Print-specific styles with exact dimensions */
@page {
    size: A4;
    margin: 0;
}

@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

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

    body {
        margin: 0;
        padding: 0;
    }

    .label-page {
        page-break-after: always;
        page-break-inside: avoid;
    }

    .label-page:last-child {
        page-break-after: auto;
    }

    .label {
        page-break-inside: avoid;
    }
}

/* Screen styles */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    margin: 0;
    padding: 0;
    background: #f5f5f5;
    color: #333;
}

header {
    background: #2c3e50;
    color: white;
    padding: 2rem;
    text-align: center;
}

header h1 {
    margin: 0 0 0.5rem 0;
    font-size: 2.5rem;
}

header p {
    margin: 0;
    font-size: 1.1rem;
    opacity: 0.9;
}

.controls {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.control-section {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.control-section h2 {
    margin: 0 0 1rem 0;
    color: #2c3e50;
    font-size: 1.3rem;
}

.control-section h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    color: #555;
}

select, input[type="file"], input[type="number"] {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

select:focus, input[type="file"]:focus, input[type="number"]:focus, textarea:focus {
    outline: none;
    border-color: #3498db;
}

/* Settings grid layout */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.setting-group {
    display: flex;
    flex-direction: column;
}

.setting-group label {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.3rem;
    color: #555;
}

.setting-group small {
    font-size: 0.8rem;
    color: #777;
    margin-top: 0.25rem;
}

.settings-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

/* Label form */
.label-input-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid #e0e0e0;
}

.label-form {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr 1fr;
    gap: 0.5rem;
    margin-bottom: 1rem;
    align-items: end;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
    color: #555;
}

.swap-button-group {
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.btn-swap {
    background: #9b59b6;
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    margin-bottom: 8px;
}

.btn-swap:hover {
    background: #8e44ad;
    transform: rotate(180deg);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.size-preview {
    justify-content: flex-end;
}

.size-display {
    background: white;
    border: 2px solid #3498db;
    border-radius: 4px;
    padding: 0.75rem;
    text-align: center;
    font-weight: 600;
    color: #3498db;
    margin-top: auto;
}

.label-preview-section {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: white;
    border-radius: 6px;
    border: 2px dashed #ddd;
}

.label-preview-section label {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    color: #555;
}

.label-preview {
    border: 1px solid #ccc;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.3s;
    max-width: 500px;
    max-height: 500px;
}

.label-preview-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
    color: #333;
    overflow: hidden;
    word-wrap: break-word;
}

/* Labels list */
.labels-list-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid #e0e0e0;
}

.labels-list {
    margin-top: 1rem;
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: #999;
    font-style: italic;
}

.label-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    border: 1px solid #e0e0e0;
}

.label-item-content {
    flex: 1;
}

.label-item-text {
    font-weight: 600;
    margin-bottom: 0.25rem;
    white-space: pre-wrap;
}

.label-item-size {
    font-size: 0.85rem;
    color: #666;
}

.label-item-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: 1rem;
}

.btn-edit {
    background: #3498db;
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.3s;
}

.btn-edit:hover {
    background: #2980b9;
}

.btn-remove {
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.3s;
}

.btn-remove:hover {
    background: #c0392b;
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.data-input-options {
    display: none; /* Removed in new version */
}

.input-method {
    display: none; /* Removed in new version */
}

textarea {
    width: 100%;
    min-height: 100px;
    padding: 0.75rem;
    border: 2px solid #ddd;
    border-radius: 4px;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.9rem;
    resize: vertical;
}

.btn-primary, .btn-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.info-box {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 4px;
    font-size: 0.9rem;
    display: none;
}

.info-box.success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    display: block;
}

.info-box.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    display: block;
}

.info-box.info {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
    display: block;
}

.info-box.warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    display: block;
}

/* Instruction boxes */
.instruction-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    padding: 0.5rem 0;
    transition: all 0.3s ease;
}

.instruction-header:hover {
    transform: translateX(5px);
}

.instruction-header:hover h2 {
    color: #3498db;
}

.toggle-icon {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
    color: #3498db;
}

.toggle-icon.rotated {
    transform: rotate(-180deg);
}

.instruction-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease-in-out, opacity 0.5s ease-in-out;
    opacity: 0;
}

.instruction-content.open {
    max-height: 2000px;
    opacity: 1;
    margin-top: 1rem;
}

/* Carousel - shows 3 cards at once */
.carousel-container {
    position: relative;
    width: 100%;
    padding: 2rem 80px;
}

.carousel-wrapper {
    overflow: hidden;
    width: 100%;
}

.carousel-track {
    display: flex;
    gap: 1.5rem;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.carousel-item {
    min-width: calc((100% - 3rem) / 3);
    flex-shrink: 0;
}

.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #3498db, #2ecc71);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 2rem;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.carousel-btn:hover {
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.6);
}

.carousel-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.carousel-btn.prev {
    left: 15px;
}

.carousel-btn.next {
    right: 15px;
}

.carousel-indicators {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 1.5rem;
}

.indicator {
    width: 30px;
    height: 4px;
    background: #ddd;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.indicator.active {
    background: linear-gradient(90deg, #3498db, #2ecc71);
    width: 50px;
}

/* Responsive adjustments */
@media (max-width: 1400px) {
    .carousel-item {
        min-width: calc((100% - 3rem) / 3);
    }
}

@media (max-width: 1024px) {
    .carousel-item {
        min-width: calc((100% - 1.5rem) / 2);
    }
    
    .carousel-container {
        padding: 2rem 60px;
    }
}

@media (max-width: 768px) {
    .carousel-item {
        min-width: 100%;
    }
    
    .carousel-container {
        padding: 2rem 50px;
    }
    
    .carousel-btn {
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }
}

.instruction-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.instruction-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, #3498db, #2ecc71);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.instruction-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

.instruction-card:hover::before {
    transform: scaleX(1);
}

.warning-card::before {
    background: linear-gradient(90deg, #f39c12, #e67e22);
}

.tips-card::before {
    background: linear-gradient(90deg, #9b59b6, #8e44ad);
}

.error-card::before {
    background: linear-gradient(90deg, #e74c3c, #c0392b);
}

.card-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    display: inline-block;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.instruction-card h3 {
    margin: 0 0 1rem 0;
    color: #2c3e50;
    font-size: 1.2rem;
    font-weight: 600;
}

.instruction-card ol {
    margin: 0;
    padding-left: 0;
    list-style: none;
    counter-reset: step-counter;
}

.instruction-card ol li {
    counter-increment: step-counter;
    margin: 0.75rem 0;
    padding-left: 2.5rem;
    position: relative;
    line-height: 1.5;
}

.instruction-card ol li::before {
    content: counter(step-counter);
    position: absolute;
    left: 0;
    top: 0;
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #3498db, #2ecc71);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.85rem;
    box-shadow: 0 2px 6px rgba(52, 152, 219, 0.3);
}

/* Print settings */
.print-settings {
    background: rgba(255, 243, 205, 0.3);
    border-radius: 8px;
    padding: 1rem;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px dashed rgba(133, 100, 4, 0.2);
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-label {
    font-weight: 500;
    color: #856404;
}

.setting-value {
    font-weight: bold;
    color: #e67e22;
    background: white;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

/* Tips */
.tip-item,
.trouble-item {
    display: flex;
    gap: 1rem;
    margin: 1rem 0;
    padding: 0.75rem;
    background: white;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.tip-item:hover,
.trouble-item:hover {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.05), rgba(46, 204, 113, 0.05));
    transform: translateX(5px);
}

.tip-icon,
.trouble-icon {
    font-size: 1.8rem;
    flex-shrink: 0;
}

.tip-item strong,
.trouble-item strong {
    display: block;
    color: #2c3e50;
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
}

.tip-item p,
.trouble-item p {
    margin: 0;
    color: #7f8c8d;
    font-size: 0.85rem;
    line-height: 1.4;
}

/* Responsive */
@media (max-width: 1200px) {
    .instruction-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .instruction-grid {
        grid-template-columns: 1fr;
    }
}

/* Label container - shows preview on screen */
.label-container {
    margin: 2rem auto;
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    max-width: fit-content;
}

/* Label page styling - exact A4 dimensions in mm */
.label-page {
    width: 210mm;
    height: 297mm;
    position: relative;
    background: white;
    margin: 0 auto 2rem auto;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

/* Individual label styling */
.label {
    position: absolute;
    overflow: hidden;
    border: 0.5px solid #e0e0e0; /* Visual guide, can be removed for print */
    box-sizing: border-box;
}

/* Label content elements */
.label-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 2mm;
    font-size: 9pt;
    line-height: 1.2;
}

.label-line {
    margin: 0;
    padding: 0;
    width: 100%;
}

.label-text {
    margin: 0;
    padding: 0;
    max-width: 100%;
}

.label-size-info {
    margin-top: 4px;
    font-size: 9pt;
    color: #666;
    font-weight: 400;
    opacity: 0.85;
}

/* Responsive design for smaller screens */
@media screen and (max-width: 768px) {
    .controls {
        padding: 0 1rem;
    }

    header h1 {
        font-size: 2rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .label-page {
        transform: scale(0.5);
        transform-origin: top center;
        margin-bottom: -148.5mm;
    }
}
