/* Custom styles for halagen - Bootstrap 5 compatible */

/* Remove global reset - Bootstrap handles this */
body {
    background-color: #f8f9fa;
    padding-top: 25px;
}

/* Container adjustments for Bootstrap */
.container-fluid {
    min-width: calc(var(--label-width, 40mm) * 2 + 200px + 120px);
    width: max-content;
    position: relative;
}

/* Header logo styling - preserve existing */
.header-logo {
    position: absolute;
    top: -70px;
    left: -30px;
    z-index: 1000;
    width: auto;
    height: auto;
}

.header-logo .logo {
    height: 150px;
    width: auto;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1)) drop-shadow(0 1px 2px rgba(0,0,0,0.15));
}

/* WYSIWYG Preview Interactions - preserve existing */
.clickable-icon {
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 4px;
    position: relative;
}

.clickable-icon:hover {
    background-color: rgba(0, 123, 255, 0.1);
    box-shadow: 0 0 0 1px rgba(0, 123, 255, 0.3);
}

.clickable-icon:hover::after {
    content: "Click to change";
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 1px 3px;
    border-radius: 2px;
    font-size: 4px;
    top: -8px;
    left: 50%;
    transform: translateX(-50%) scale(0.5);
    white-space: nowrap;
    pointer-events: none;
    z-index: 10;
}

.editable-text {
    cursor: text;
    min-width: 20px;
    min-height: 1em;
    border-radius: 2px;
    transition: all 0.2s ease;
    padding: 1px 2px;
    text-align: left !important;
    direction: ltr !important;
}

.editable-text:hover {
    background-color: rgba(0, 123, 255, 0.05);
    outline: 1px solid rgba(0, 123, 255, 0.2);
}

.editable-text:focus {
    background-color: rgba(0, 123, 255, 0.05);
    outline: 2px solid rgba(0, 123, 255, 0.4);
}

/* Tab content styling - preserve existing layout */
.tab-content {
    display: block;
    padding: 20px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 0 0 8px 8px;
    position: relative;
    z-index: 0;
}

#batch-tab {
    display: block;
    padding: 20px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 0 0 8px 8px;
    position: relative;
    z-index: 0;
}

/* Label preview styles - preserve existing */
.label {
    display: flex;
    align-items: center;
    background: white;
    border: 1px solid #ddd;
    border-radius: 2px;
    padding: 2px;
    height: 12mm;
    width: 40mm;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transform: scale(2);
    margin: 30px;
}

.label-icon {
    width: 8mm;
    height: 8mm;
    margin: 2mm;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.label-icon .icon {
    width: 100%;
    height: 100%;
    fill: #333;
}

.label-text {
    flex: 1;
    padding: 1mm;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.main-text {
    font-size: 12px;
    font-weight: bold;
    color: #000;
    line-height: 1.2;
    margin-bottom: 1px;
    display: flex;
    gap: 2px;
    width: 100%;
    align-items: center;
    justify-content: flex-start;
}

.sub-text {
    font-size: 8px;
    color: #666;
    line-height: 1.2;
    display: flex;
    gap: 2px;
    width: 100%;
    align-items: center;
    justify-content: flex-start;
}

/* Dynamic label heights - preserve existing */
.label[data-height="9"] {
    height: 9mm;
}

.label[data-height="12"] {
    height: 12mm;
}

.label[data-height="18"] {
    height: 18mm;
}

.label[data-height="24"] {
    height: 24mm;
}

.label[data-height="9"] .label-icon {
    width: 6mm;
    height: 6mm;
}

.label[data-height="9"] .main-text {
    font-size: 6px;
}

.label[data-height="9"] .sub-text {
    font-size: 4px;
}

.label[data-height="18"] .label-icon {
    width: 14mm;
    height: 14mm;
}

.label[data-height="18"] .main-text {
    font-size: 12px;
}

.label[data-height="18"] .sub-text {
    font-size: 8px;
}

.label[data-height="24"] .label-icon {
    width: 18mm;
    height: 18mm;
}

.label[data-height="24"] .main-text {
    font-size: 14px;
}

.label[data-height="24"] .sub-text {
    font-size: 10px;
}

/* WYSIWYG Editor Layout - preserve existing */
.wysiwyg-editor {
    margin-bottom: 20px;
}

.width-control {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.dimensional-line {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dimensional-line.horizontal {
    flex-direction: row;
}

.dimensional-line.vertical {
    flex-direction: column;
    height: 120px;
    justify-content: center;
}

.dimension-arrow {
    font-size: 14px;
    color: #666;
    font-weight: bold;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    user-select: none;
}

.dimension-arrow:hover {
    background-color: #e9ecef;
    color: #495057;
}

.dimension-arrow:active {
    background-color: #dee2e6;
    transform: scale(0.95);
}

.dimension-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.dimension-control .input-group {
    width: 95px !important;
}

/* Hide number input arrows */
.dimension-control input[type="number"]::-webkit-outer-spin-button,
.dimension-control input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.dimension-control input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

.dimension-control.vertical {
    writing-mode: vertical-lr;
    text-orientation: mixed;
}

.dimension-control.vertical .input-group {
    writing-mode: horizontal-tb;
    text-orientation: upright;
    width: 95px !important;
}


.preview-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    position: relative;
    min-height: 120px;
    width: 100%;
    min-width: calc(var(--label-width, 40mm) * 2 + 160px);
    overflow: visible;
}

.height-control {
    display: flex;
    align-items: center;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(calc(-100% - var(--label-width, 40mm) - 40px), -50%);
    z-index: 10;
}

.preview-area {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.preview-area #header-label-preview {
    transform: scale(2);
    margin: 30px;
}

.column-controls-right {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: flex-start;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(calc(var(--label-width, 40mm) + 40px), -50%);
    z-index: 10;
}

.main-text-control,
.sub-text-control {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
}

.main-text-control label,
.sub-text-control label {
    font-size: 11px;
    color: #666;
    font-weight: 600;
    margin: 0;
}

.column-buttons-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.column-btn-small {
    width: 20px;
    height: 20px;
    border: 1px solid #dee2e6;
    background: white;
    color: #6c757d;
    font-size: 12px;
    font-weight: bold;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    margin: 0;
}

.column-btn-small:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    color: #495057;
}

.column-btn-small:active {
    background: #dee2e6;
    transform: scale(0.95);
}

.column-controls-right .column-count {
    font-size: 12px;
    font-weight: 600;
    color: #495057;
    min-width: 15px;
    text-align: center;
}

/* Text column styling */
.main-text-column {
    flex: 1;
    text-align: left;
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
    line-height: inherit;
    padding-right: 4px;
    white-space: nowrap;
    overflow: hidden;
    min-width: 0;
    direction: ltr;
    text-overflow: clip;
    text-align: left !important;
    scroll-behavior: auto;
}

.main-text-column::-webkit-scrollbar {
    display: none;
}

.sub-text-column {
    flex: 1;
    text-align: left;
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
    line-height: inherit;
    padding-right: 4px;
    white-space: nowrap;
    overflow: hidden;
    min-width: 0;
    direction: ltr;
    text-overflow: clip;
    text-align: left !important;
    scroll-behavior: auto;
}

.sub-text-column::-webkit-scrollbar {
    display: none;
}

/* Validation result styling */
.validation-result {
    margin-top: 20px;
    padding: 15px;
    border-radius: 4px;
    display: none;
}

.validation-result.success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.validation-result.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.validation-result.warning {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
}

/* CodeMirror YAML Editor Styling */
.CodeMirror {
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-family: 'Fira Code', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.4;
    background: white;
    transition: border-color 0.3s;
}

.CodeMirror-focused {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.CodeMirror-gutters {
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
}

.CodeMirror-linenumber {
    color: #6c757d;
    font-size: 12px;
}

.CodeMirror-cursor {
    border-left: 2px solid #3498db;
}

/* YAML Syntax Highlighting */
.cm-comment {
    color: #6c757d;
    font-style: italic;
}

.cm-string {
    color: #28a745;
}

.cm-number {
    color: #dc3545;
}

.cm-keyword {
    color: #6f42c1;
    font-weight: bold;
}

.cm-atom {
    color: #fd7e14;
}

.cm-def {
    color: #007bff;
    font-weight: bold;
}

.cm-variable {
    color: #495057;
}

.cm-punctuation {
    color: #6c757d;
}

/* Hide original textarea when CodeMirror is active */
#yaml-input {
    display: none;
}

/* Icon Picker Styles - preserve existing */
.icon-picker {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 90vw;
}

.icon-picker-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.icon-picker-overlay.active {
    opacity: 1;
    visibility: visible;
}

.icon-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.icon-picker-header h3 {
    margin: 0;
    font-size: 18px;
    color: #495057;
}

.icon-picker-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.icon-picker-close:hover {
    background: #e9ecef;
    color: #495057;
}

.icon-picker-search {
    padding: 12px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    gap: 8px;
    align-items: center;
}

.icon-picker-search input[type="text"] {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-size: 14px;
    margin: 0;
}

.icon-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 4px;
    padding: 8px;
    max-height: 400px;
    overflow-y: auto;
}

.icon-picker-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 4px;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    background: #f8f9fa;
    text-align: center;
    position: relative;
}

.icon-picker-item:hover {
    background: #e9ecef;
    border-color: #3498db;
}

.icon-picker-item.selected {
    background: #e3f2fd;
    border-color: #3498db;
}

.icon-picker-item img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    margin-bottom: 3px;
}

.icon-picker-item span {
    font-size: 9px;
    color: #495057;
    line-height: 1.1;
    word-break: break-word;
}

.icon-picker-category {
    grid-column: 1 / -1;
    font-size: 12px;
    font-weight: 600;
    color: #6c757d;
    margin-top: 8px;
    margin-bottom: 4px;
    padding-bottom: 4px;
    border-bottom: 1px solid #e9ecef;
}

.icon-picker-category:first-child {
    margin-top: 0;
}

.upload-icon-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.3s;
    margin-bottom: 8px;
}

.upload-icon-btn:hover {
    background: #218838;
}

.custom-icon-category {
    background: #e8f5e8;
    border: 1px solid #28a745;
    border-radius: 4px;
    padding: 4px 8px;
    color: #155724;
    font-weight: bold;
}

.delete-icon-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
    padding: 0;
}

.icon-picker-item:hover .delete-icon-btn {
    display: flex;
}

.delete-icon-btn:hover {
    background: #c82333;
}

/* Footer Styles */
footer {
    margin-top: 20px;
}

.attribution {
    text-align: center;
    font-size: 12px;
    color: #666;
}

.attribution a {
    color: #0d6efd;
    text-decoration: none;
}

.attribution a:hover {
    text-decoration: underline;
}

/* Custom DPI preset button styling to match Bootstrap */
.dpi-presets .btn {
    font-size: 10px;
    padding: 2px 8px;
}

/* Make download button group match height of settings column */
.export-section .btn-group {
    height: 100%;
}

.export-section .btn-group .btn {
    height: 100%;
}


/* Consistent alignment and font styling for export controls */
.form-check.form-switch .form-check-label {
    font-size: 13px;
    margin: 0;
    padding-left: 0 !important;
}

.form-check.form-switch {
    padding-left: 0 !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container-fluid {
        padding: 10px;
    }
    
    .preview-container {
        padding: 20px;
        min-height: 150px;
    }
    
    .tab-content {
        padding: 15px;
    }
}