/* Root Variables */
:root {
    --primary-color: #0066cc;
    --primary-dark: #0052a3;
    --success-color: #28a745;
    --success-dark: #218838;
    --secondary-color: #6c757d;
    --secondary-dark: #545b62;
    --danger-color: #dc3545;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-light: #999999;
    --border-color: #dddddd;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.12);
    --shadow-lg: 0 8px 16px rgba(0,0,0,0.16);
    --border-radius: 4px;
    --transition: all 0.3s ease;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-light);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Calculator App */
.calculator-app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 0;
    box-shadow: var(--shadow-sm);
}

.app-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.app-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Progress Menu */
.progress-menu {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    padding: 15px 0;
}

.menu-items {
    display: flex;
    justify-content: center;
    gap: 40px;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.menu-item::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 3px;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

.menu-item.active::after {
    width: 100%;
}

.menu-item:hover {
    background: var(--bg-light);
}

.menu-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--text-light);
    color: white;
    font-size: 12px;
    font-weight: 600;
}

.menu-item.active .menu-number {
    background: var(--primary-color);
}

.menu-text {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.menu-item.active .menu-text {
    color: var(--primary-color);
}

/* Main Content */
.app-main {
    flex: 1;
    padding: 30px 0;
}

.content-grid {
    display: grid;
    grid-template-columns: 450px 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

/* Preview Panel */
.preview-panel {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.preview-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-text:hover {
    text-decoration: underline;
}

.preview-area {
    position: relative;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 30px;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-container {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.nameplate-preview {
    background: linear-gradient(135deg, #c0c0c0, #e8e8e8);
    border: 2px solid #999;
    position: relative;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    transition: var(--transition);
    overflow: hidden;
    cursor: crosshair;
}

/* Draggable Text Areas */
.text-area {
    position: absolute;
    min-width: 80px;
    min-height: 30px;
    border: 1px dashed transparent;
    cursor: move;
    padding: 5px;
    transition: border-color 0.2s;
    user-select: none;
}

.text-area:hover {
    border-color: rgba(0, 102, 204, 0.5);
    background: rgba(255, 255, 255, 0.1);
}

.text-area.active {
    border-color: var(--primary-color);
    background: rgba(0, 102, 204, 0.05);
    z-index: 10;
}

.text-area.dragging {
    opacity: 0.7;
    z-index: 100;
}

.text-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 600;
    color: #333;
    font-family: Arial, sans-serif;
    outline: none;
    text-align: center;
    word-wrap: break-word;
    overflow: hidden;
}

.text-content[contenteditable="true"]:focus {
    background: rgba(255, 255, 255, 0.3);
}

/* Resize Handle */
.resize-handle {
    position: absolute;
    bottom: -5px;
    right: -5px;
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: nwse-resize;
    opacity: 0;
    transition: opacity 0.2s;
}

.text-area:hover .resize-handle,
.text-area.active .resize-handle {
    opacity: 1;
}

/* Grid Overlay */
.grid-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    display: none;
}

.grid-overlay.show {
    display: block;
    background-image:
        repeating-linear-gradient(0deg, rgba(0,0,0,0.1) 0, transparent 1px, transparent 20px, rgba(0,0,0,0.1) 21px),
        repeating-linear-gradient(90deg, rgba(0,0,0,0.1) 0, transparent 1px, transparent 20px, rgba(0,0,0,0.1) 21px);
}

/* Dimensions Display */
.dimensions-display {
    position: absolute;
    top: 10px;
    right: 10px;
    left: 10px;
    bottom: 10px;
    pointer-events: none;
}

.dimension-horizontal {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-white);
    padding: 2px 8px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.dimension-vertical {
    position: absolute;
    right: -35px;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-white);
    padding: 2px 8px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.preview-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* Configuration Panel */
.config-panel {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.step-content {
    display: none;
}

.step-content.active {
    display: block;
}

.step-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

/* Layout Mode Selector */
.layout-mode-selector {
    display: flex;
    gap: 10px;
    margin-top: 5px;
}

.mode-btn {
    flex: 1;
    padding: 8px 16px;
    border: 1px solid var(--border-color);
    background: var(--bg-white);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
}

.mode-btn:hover {
    background: var(--bg-light);
}

.mode-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Text Areas List */
.text-areas-list {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-light);
    border-radius: var(--border-radius);
}

.text-areas-list h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.text-area-item {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.text-area-item input {
    flex: 1;
}

.delete-area {
    padding: 5px 10px;
    font-size: 20px;
    color: var(--danger-color);
    background: none;
    border: none;
    cursor: pointer;
}

.delete-area:hover {
    background: rgba(220, 53, 69, 0.1);
    border-radius: var(--border-radius);
}

/* Form Controls */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0,102,204,0.1);
}

select.form-control {
    cursor: pointer;
}

.form-hint {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: var(--text-secondary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.mb-2 {
    margin-bottom: 10px;
}

/* Order Summary */
.order-summary {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 15px;
    margin-bottom: 20px;
}

.order-summary h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    padding: 5px 0;
    font-size: 13px;
}

.summary-label {
    color: var(--text-secondary);
}

.summary-value {
    font-weight: 500;
    color: var(--text-primary);
}

/* Price Table */
.price-breaks {
    margin-top: 20px;
}

.price-breaks h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.price-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.price-table thead {
    background: var(--bg-light);
}

.price-table th,
.price-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.price-table th {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13px;
}

.price-table td {
    font-size: 13px;
    color: var(--text-secondary);
}

.price-table tr.active {
    background: #e3f2fd;
}

.price-table tr.active td {
    color: var(--primary-color);
    font-weight: 500;
}

/* Navigation */
.step-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background: var(--secondary-dark);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: var(--success-dark);
}

.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: white;
}

/* Pricing Bar */
.pricing-bar {
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow-md);
    position: sticky;
    bottom: 20px;
}

.pricing-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pricing-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pricing-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.pricing-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.pricing-item.total .pricing-value {
    font-size: 24px;
    color: var(--success-color);
}

.pricing-actions {
    display: flex;
    gap: 10px;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-body {
    padding: 20px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* Toast */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--success-color);
    color: white;
    padding: 15px 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    animation: slideIn 0.3s ease;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast-icon {
    font-size: 20px;
}

.toast-message {
    font-size: 14px;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 992px) {
    .content-grid {
        grid-template-columns: 1fr;
    }

    .preview-panel {
        order: 2;
    }

    .config-panel {
        order: 1;
    }

    .pricing-content {
        flex-wrap: wrap;
        gap: 15px;
    }
}

@media (max-width: 768px) {
    .menu-items {
        gap: 20px;
    }

    .menu-text {
        display: none;
    }

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

    .pricing-bar {
        position: relative;
        bottom: auto;
    }
}

/* Barcode Styles */
.barcode-element {
    transition: border-color 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    background: white !important;
}

.barcode-element:hover {
    border-color: #0066cc !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.barcode-element canvas {
    display: block;
    image-rendering: crisp-edges;
    image-rendering: pixelated;
    pointer-events: none;
}

.asset-barcode {
    image-rendering: crisp-edges;
    image-rendering: pixelated;
}

/* Asset Layout Styles */
.asset-layout {
    overflow: hidden;
}

.asset-logo-section {
    position: relative;
}

.asset-content-section {
    position: relative;
}

.asset-barcode-section {
    width: calc(100% - 20px);
    margin: 0 10px;
}


/* Template Selector Styles */
.template-selector {
    margin-bottom: 30px;
}

.section-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 15px;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.template-card {
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
    text-align: center;
}

.template-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0,102,204,0.15);
    transform: translateY(-2px);
}

.template-card.active {
    border-color: var(--primary-color);
    background: linear-gradient(to bottom, #f0f7ff, white);
    box-shadow: 0 4px 12px rgba(0,102,204,0.2);
}

.template-preview {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.mini-nameplate {
    width: 90px;
    height: 40px;
    border: 1px solid #999;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    background: linear-gradient(135deg, #c0c0c0, #e8e8e8);
    color: #333;
}

.mini-nameplate.dark {
    background: #1a1a1a;
    color: white;
}

.mini-nameplate.danger {
    background: #dc3545;
    color: white;
}

.mini-nameplate.custom {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.mini-asset-tag {
    width: 90px;
    height: 35px;
    border-radius: 4px;
    display: flex;
    overflow: hidden;
    border: 1px solid #005ca9;
}

/* New Layout Styles for 8 Templates */
.mini-layout {
    width: 90px;
    height: 40px;
    border: 1px solid #999;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: bold;
    color: white;
    position: relative;
    overflow: hidden;
}

.mini-layout.red-bg {
    background: #dc3545;
}

.mini-layout.split-bg {
    background: white;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.mini-layout .top-section {
    flex: 1.2;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #dc3545;
    color: white;
}

.mini-layout .bottom-section {
    flex: 0.8;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
}

.mini-layout .icon-box {
    width: 20px;
    height: 20px;
    border: 2px solid white;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 5px;
    font-size: 12px;
}

.mini-layout .icon-box.large {
    width: 24px;
    height: 24px;
}

.mini-layout .text-right {
    flex: 1;
    text-align: center;
}

.mini-layout.two-line {
    flex-direction: column;
    gap: 2px;
}

.mini-layout .text-middle {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 8px;
}

.mini-layout .text-middle small {
    font-size: 6px;
    opacity: 0.9;
}

.mini-layout .number-box {
    background: white;
    color: #333;
    padding: 2px 4px;
    border-radius: 2px;
    font-size: 10px;
    margin-right: 5px;
}

.mini-layout .mini-barcode {
    font-family: 'Courier', monospace;
    font-size: 10px;
    letter-spacing: 1px;
    color: #333;
}

.mini-layout .top-section.with-icon {
    padding: 0 5px;
    justify-content: flex-start;
}

.mini-layout .text-lines {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    font-size: 7px;
    gap: 1px;
}

.asset-left {
    width: 30%;
    background: #e8e8e8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    color: #005ca9;
}

.asset-right {
    width: 70%;
    background: #005ca9;
    color: white;
    padding: 2px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.asset-text {
    font-size: 5px;
    display: block;
}

.asset-company {
    font-size: 8px;
    font-weight: bold;
    display: block;
}

.asset-barcode {
    background: white;
    color: black;
    font-size: 8px;
    padding: 1px;
    margin-top: 2px;
    border-radius: 1px;
    text-align: center;
    letter-spacing: -1px;
}

.template-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Dynamic field sections */
.field-section {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-light);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.field-section h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--text-primary);
}
