* {
    box-sizing: border-box;
}

input:focus {
    outline: 2px solid #B70E13;
    outline-offset: -1px;
    border-color: #B70E13;
}

select:focus {
    outline: 2px solid #B70E13;
    outline-offset: -1px;
    border-color: #B70E13;
}

/* Container styles */
.container {
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
    background-color: #fff;
    padding: 20px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    text-align: left;
    border-style: dotted;
    border-color: #b70e13;
    border-radius: 10px;
    box-sizing: border-box;
}

/* Top container with card settings */
.top-container {
    width: 100%;
    margin-bottom: 15px;
}

.card-settings {
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.settings-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    align-items: center;
}

.card-select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 10px;
}

/* Order section - separate from sidebars */
.order-section {
    margin-top: 20px;
    clear: both;
}

/* Order options section */
.order-options {
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 5px;
    margin-top: 10px;
    margin-bottom: 20px;
}

.order-option {
    margin-bottom: 10px;
}

.order-option label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    font-size: 0.9rem;
    cursor: pointer;
}

/* Quantity selector */
.quantity-select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 10px;
}

/* Envelope option */
.envelope-option {
    margin-top: 10px;
}

.envelope-option label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 0.9rem;
    cursor: pointer;
}

/* Price display */
.price-display {
    margin-top: 15px;
    padding: 10px;
    background-color: #fff;
    border-radius: 5px;
    border: 1px dashed #ddd;
}

.price-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.price-total {
    font-weight: bold;
    border-top: 1px solid #ddd;
    padding-top: 5px;
    margin-top: 5px;
    margin-bottom: 15px;
}

/* Purchase button container */
.purchase-button-container {
    text-align: center;
    margin-top: 20px;
}

.purchase-button {
    padding: 12px 24px;
    background-color: #B70E13;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Kaleko205Round', Arial, sans-serif;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.2s;
    min-width: 200px;
}

.purchase-button:hover {
    background-color: #960b0f;
}

.price-value {
    font-weight: bold;
    color: #B70E13;
}

/* Main container */
.main-container {
    display: flex;
    width: 100%;
    justify-content: center;
}

/* Canvas container */
.canvas-container {
    width: 100%;
    max-width: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    border-style: solid;
    border-color: #000000;
    border-radius: 5px;
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    transition: padding-top 0.3s ease;
}

/* Canvas proportions for different orientations and sizes */
.canvas-wrapper.portrait {
    padding-top: 200%; /* 10x20 ratio (2:1) */
}

.canvas-wrapper.portrait.small {
    padding-top: 150%; /* 10x15 ratio (3:2) */
}

.canvas-wrapper.landscape {
    padding-top: 50%; /* 20x10 ratio (1:2) */
}

.canvas-wrapper.landscape.small {
    padding-top: 66.67%; /* 15x10 ratio (2:3) */
}

#mainCanvas,
#symbolCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 5px;
    object-fit: contain;
}

/* Bottom container and buttons */
.bottom-container {
    width: 100%;
    margin-top: 15px;
    position: relative;
}

#mainButtons {
    background-color: transparent;
    padding: 0;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.bottom-content {
    background-color: #f9f9f9;
    border-radius: 5px;
    padding: 15px;
    position: relative;
    transition: all 0.3s ease;
}

/* Edit buttons styles */
.edit-buttons {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

.edit-buttons button {
    flex: 0 1 calc(25% - 10px);
    min-width: 120px;
    padding: 8px;
    background-color: #B70E13;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Kaleko205Round', Arial, sans-serif;
    font-size: 14px;
    white-space: nowrap;
    transition: background-color 0.2s;
    margin: 5px;
}

.edit-buttons button:hover {
    background-color: #960b0f;
}

/* Control sections */
.bottom-content h2 {
    font-size: clamp(1rem, 3.5vw, 1.5rem);
    margin: 0 0 15px 0;
}

.bottom-content label {
    display: block;
    margin-bottom: 5px;
    font-size: clamp(0.9rem, 3vw, 1rem);
}

.bottom-content input,
.bottom-content select,
.bottom-content textarea {
    width: 100%;
    margin-bottom: 10px;
    padding: 8px;
    font-size: clamp(0.9rem, 3vw, 1rem);
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Button controls grid */
.button-controls {
    gap: 8px;
    margin-top: 0px;
    justify-content: center;
    justify-self: center;
    max-width: 100%;
}

.button-group {
    gap: 8px;
    justify-content: center;
}

.button-group button {
    margin-top: 5px;
    padding: 5px;
    background-color: #B70E13;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: clamp(0.8rem, 2.5vw, 1rem);
    min-height: 35px;
    min-width: 35px;
    transition: background-color 0.2s;
    font-weight: 500;
}

button img {
    vertical-align: middle;
    height: 17px;
    width: 17px;
}

.button-single {
    margin-top: 5px;
    padding: 4px;
    background-color: #B70E13;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Kaleko205Round', Arial, sans-serif;
    font-size: 14px;
    height: 35px;
    width: 150px;
    transition: background-color 0.2s;
    font-weight: 500;
}

.button-group button:hover,
.button-single:hover {
    background-color: #960b0f;
}

/* Image controls */
.file-upload-container {
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
}

.file-upload-container input[type="file"] {
    display: none;
}

/* Range inputs (sliders) */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    margin: 10px 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #B70E13;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #B70E13;
    cursor: pointer;
    border: none;
}

/* Color picker styling */
input[type="color"] {
    -webkit-appearance: none;
    padding: 0;
    width: 100%;
    height: 40px;
    cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 4px;
}

/* Symbol grid styling */
.symbol-grid-container {
    margin-top: 10px;
    height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 8px;
    background-color: #fff;
}

.symbol-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 8px;
}

.symbol-item {
    aspect-ratio: 1;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 4px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.symbol-item:hover {
    border-color: #B70E13;
}

.symbol-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Toast styling */
.toast {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%) translateY(-100%);
    background-color: #f4f4f4;
    color: black;
    padding: 46px 24px;
    border-style: dotted;
    border-color: #B70E13;
    border-radius: 0 0 10px 10px;
    z-index: 1000;
    transition: transform 0.3s ease-out;
    text-align: center;
    min-width: 300px;
    max-width: 80%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast.error {
    background-color: #f4f4f4;
}

/* Text area styling for the right/bottom white area */
.text-area-preview {
    background-color: white;
    position: absolute;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    overflow: hidden;
    box-sizing: border-box;
    font-family: Arial, sans-serif;
}

.text-area-preview.right {
    top: 0;
    right: 0;
    height: 100%;
}

.text-area-preview.bottom {
    left: 0;
    bottom: 0;
    width: 100%;
}

/* Info message styling */
.info-message {
    color: #777;
    font-size: 0.85em;
    display: block;
    margin-top: 5px;
}

/* White field controls */
.white-field-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.field-control-btn {
    padding: 8px 15px;
    background-color: #B70E13;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-family: 'Kaleko205Round', Arial, sans-serif;
    font-size: 14px;
    transition: background-color 0.2s;
}

.field-control-btn:hover {
    background-color: #960b0f;
}

.field-size-display {
    font-size: 16px;
    font-weight: bold;
    min-width: 60px;
    text-align: center;
}

/* Checkbox styling */
input[type="checkbox"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid #B70E13;
    border-radius: 3px;
    margin: 0;
    cursor: pointer;
    position: relative;
    vertical-align: middle;
}

input[type="checkbox"]:checked {
    background-color: #B70E13;
}

input[type="checkbox"]:checked:after {
    content: '';
    position: absolute;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    top: 1px;
    left: 5px;
    transform: rotate(45deg);
}

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 3000;
    justify-content: center;
    align-items: center;
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #B70E13;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .edit-buttons button {
        flex: 0 1 calc(50% - 10px);
    }
    
    .settings-group {
        grid-template-columns: 1fr;
    }
    
    .symbol-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    }
}

@media (max-width: 600px) {
    body {
        padding: 0;
    }

    .container {
        padding: 10px;
        margin: 0;
        border-radius: 0;
        width: 100%;
        max-width: none;
    }
    
    .bottom-content {
        padding: 10px;
    }

    .edit-buttons button {
        flex: 0 1 150px;
        max-width: none;
    }
    
    .symbol-grid {
        grid-template-columns: repeat(auto-fill, minmax(45px, 1fr));
    }
}