/* Global styles */
* {
    box-sizing: border-box;
}

/* Focus states for input elements */
input:focus {
    outline: 2px solid #B70E13;
    outline-offset: -1px;
    border-color: #B70E13;
}

/* Focus states for select elements */
select:focus {
    outline: 2px solid #B70E13;
    outline-offset: -1px;
    border-color: #B70E13;
}

/* Error messages */
.error-message {
    color: #B70E13;
    font-size: 0.8em;
    display: none;
    margin-top: 5px;
}

.error-message.show {
    display: block;
}

input.error {
    border-color: #B70E13;
}

/* Container styles */
.container, .purchase-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 poster settings */
.top-container {
    width: 100%;
    margin-bottom: 15px;
}

.poster-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;
}

.poster-select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 10px;
}

#passepartout {
    width: 100%;
    margin-top: 5px;
}

#passepartoutValue {
    display: inline-block;
    min-width: 40px;
    text-align: right;
    font-size: 14px;
    color: #666;
}

/* 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-wrapper.portrait {
    padding-top: 140%; /* Default portrait ratio */
}

.canvas-wrapper.landscape {
    padding-top: 71.42857143%; /* 10:7 ratio for landscape */
}

.canvas-wrapper.square {
    padding-top: 100%; /* 1:1 ratio for square */
}

#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;
}

/* Button styles */
.edit-buttons {
    display: flex;
    flex-wrap: wrap;
    width: 100%;
    gap: 10px;
    justify-content: center;
    align-items: center;
}

.edit-buttons button, #payWithKlarna {
    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, #payWithKlarna: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 {
    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; /* justera efter behov */
    width: 17px; /* justera efter behov */
}

.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;
    text-align: center;
}

.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;
}

/* Shadow toggle styling */
.shadow-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 15px;
    margin-bottom: 20px;
}

.shadow-toggle input[type="checkbox"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 20px; /* justera efter behov */
  height: 20px;
  border: 1px solid #B70E13;
  border-radius: 4px;
  cursor: pointer;
}

/* Styla checkboxen när den är markerad */
.shadow-toggle input[type="checkbox"]:checked {
  background-color: #B70E13; /* Den önskade färgen */
  border-color: #B70E13;
}

.shadow-toggle label {
    display: inline;
    font-size: 14px;
    color: #666;
    cursor: pointer;
    margin: 0;
}

/* 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;
}

/* Toast styling */
.toast {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    background-color: #f4f4f4;
    color: black;
    padding: 15px;
    border-radius: 0 0 10px 10px;
    z-index: 1000;
    text-align: center;
    min-width: 300px;
    max-width: 80%;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    display: none;
}

.toast.error {
    background-color: #f44336;
    color: white;
}

.toast-ok-btn {
    margin-top: 10px;
    padding: 5px 10px;
    background-color: #B70E13;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.toast-ok-btn:hover {
    background-color: #960b0f;
}

/* Purchase page specific styles */
.poster-image {
    max-width: 300px;
    max-height: 300px;
    width: auto;
    height: auto;
    border: 5px solid #ffffff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.poster-image.white { border: 5px solid #f3f3f3; }
.poster-image.black { border: 5px solid black; }
.poster-image.gold { border: 5px solid gold; }
.poster-image.silver { border: 5px solid #888888; }
.poster-image.wood { border: 5px solid #c88c3c; }

.poster-image.no-border {
    border: none !important;
    box-shadow: none !important;
}

.show {
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 5px;
    margin: 20px 0;
}

/* Customer Form */
.customer-form {
    max-width: 500px;
    margin: 0 auto;
}

.form-section {
    max-width: 500px;
    margin: 20px auto;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 10px;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    margin-bottom: 3px;
    font-weight: bold;
}

.form-group input {
    width: 100%;
    padding: 6px;
    font-size: 0.9rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Frame Options */
.frame-options {
    max-width: 500px;
    margin: 20px auto;
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 5px;
}

.frame-selector label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 0.9rem;
    cursor: pointer;
}

/* Radio buttons styling */
input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid #B70E13;
    border-radius: 50%;
    margin: 0;
    cursor: pointer;
    position: relative;
}

input[type="radio"]:checked {
    background-color: #B70E13;
}

input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
}

/* Delivery Options */
.delivery-options {
    max-width: 500px;
    margin: 20px auto;
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 5px;
}

.delivery-option {
    margin-bottom: 10px;
}

.delivery-option label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 0.9rem;
    cursor: pointer;
}

/* Order Summary */
.order-summary {
    max-width: 500px;
    margin: 20px auto;
    background-color: #f9f9f9;
    padding: 15px;
    border-radius: 5px;
    text-align: center;
}

.summary-content {
    margin-bottom: 20px;
}

.summary-content p {
    margin: 5px 0;
    padding: 5px 0;
    text-align: center;
}

.summary-content p .price {
    display: inline;
    margin-left: 5px;
}

.price {
    font-weight: bold;
    color: #B70E13;
}

.total {
    font-size: 1.2em;
    border-top: 2px solid #ddd;
    padding-top: 10px;
    margin-top: 10px;
    text-align: center;
}

/* Test order button */
.test-order-button {
    background-color: #ffc107;
    color: #000;
    border: none;
    padding: 8px;
    border-radius: 5px;
    margin-right: 10px;
    cursor: pointer;
}

.test-order-button:hover {
    background-color: #ffca28;
}

.test-order-button:disabled {
    background-color: #ffecb3;
    cursor: not-allowed;
}

/* 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); }
}

/* Klarna Checkout Container */
#klarnaCheckoutContainer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0,0,0,0.8);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 40px 0;
}

#klarnaCheckoutContainer.show {
    display: flex;
}

#klarnaCheckoutIframe {
    width: 80%;
    max-width: 800px;
    height: 90vh;
    max-height: 900px;
    background: #fff;
    border: none;
}

#closeCheckout {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 10px 15px;
    background: #B70E13;
    color: #fff;
    border: none;
    cursor: pointer;
    z-index: 2100;
}

/* Utilities */
.hidden {
    display: none !important;
}

/* Responsive styles */
@media (max-width: 768px) {
    .edit-buttons button {
        flex: 0 1 calc(50% - 10px);
    }
    
    .settings-group {
        grid-template-columns: 1fr;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    #klarnaCheckoutIframe {
        width: 95%;
        height: 100vh;
    }
}

@media (max-width: 600px) {
    body {
        padding: 0;
    }

    .container, .purchase-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;
    }
    
    .poster-image {
        max-width: 100%;
    }
}