/* =========================================================
   Custom Sticker Order – Frontend CSS v2.9.0
   Responsive: mobile-first, breakpoints 480 / 760 / 1024
   ========================================================= */

/* ══════════════════════════════════════════════════════════
   PERUSASETUKSET
   ══════════════════════════════════════════════════════════ */
.cso-wrap {
    max-width: 1200px;
    margin: 0 auto;
    font-family: inherit;
    /* Mobiilissa: yksi sarake, esikatselu alhaalla */
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Lomake ensin mobiilissa – esikatselu sen jälkeen */
#sticker-order-form  { order: 1; }
#cso-preview-panel   { order: 2; }

/* ══════════════════════════════════════════════════════════
   TYPOGRAFIA JA KENTÄT – mobile-first isot touch-alueet
   ══════════════════════════════════════════════════════════ */
#sticker-order-form h2 {
    font-size: 17px;
    border-bottom: 2px solid #111;
    padding-bottom: 6px;
    margin: 20px 0 12px;
}
#sticker-order-form h2:first-child { margin-top: 0; }

.cso-field { margin-bottom: 14px; }

.cso-field label,
#sticker-order-form > label,
.cso-grid label {
    display: block;
    font-weight: 600;
    font-size: 14px;   /* hieman isompi mobiilissa */
    margin-bottom: 6px;
    color: #333;
}

/* Kaikki syötekentät – isot touch-kohteet */
#sticker-order-form input[type="text"],
#sticker-order-form input[type="email"],
#sticker-order-form select,
#sticker-order-form textarea {
    width: 100%;
    padding: 12px 13px;   /* tarkotuksella isompi kuin desktop */
    border: 1.5px solid #ccc;
    border-radius: 8px;
    box-sizing: border-box;
    font-size: 16px;      /* 16px estää iOS:n automaattisen zoomauksen */
    line-height: 1.4;
    transition: border-color .15s;
    background: #fff;
    -webkit-appearance: none;
    appearance: none;
}
#sticker-order-form input:focus,
#sticker-order-form select:focus,
#sticker-order-form textarea:focus {
    outline: none;
    border-color: #333;
    box-shadow: 0 0 0 3px rgba(0,0,0,.08);
}
#sticker-order-form textarea { resize: vertical; min-height: 80px; }

/* Select-nuoli custom */
#sticker-order-form select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ══════════════════════════════════════════════════════════
   GRID-RAKENTEET – mobiilissa aina 1 sarake
   ══════════════════════════════════════════════════════════ */
.cso-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr;   /* mobiili: yksi sarake */
    margin-bottom: 12px;
}

.cso-row {
    display: grid;
    grid-template-columns: 1fr;   /* mobiili: yksi sarake */
    gap: 12px;
    margin-bottom: 12px;
}

.cso-address-fields {
    display: grid;
    grid-template-columns: 1fr;   /* mobiili: yksi sarake */
    gap: 12px;
    margin-bottom: 12px;
}

/* ══════════════════════════════════════════════════════════
   VÄRIPALLOT – isommat touch-kohteet mobiilissa
   ══════════════════════════════════════════════════════════ */
.cso-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}
.cso-swatch {
    display: inline-flex;
    cursor: pointer;
    user-select: none;
    /* Touch-alue kasvaa padding:lla */
    padding: 4px;
    margin: -4px;
    border-radius: 50%;
}
.cso-swatch input[type="radio"] {
    position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0;
}
.cso-dot {
    width: 36px;          /* isompi mobiilissa */
    height: 36px;
    border-radius: 50%;
    border: 2.5px solid #999;
    display: inline-block;
    transition: transform .15s ease, box-shadow .15s ease;
}
.cso-dot:hover { transform: scale(1.1); }
.cso-swatch input:checked + .cso-dot {
    box-shadow: 0 0 0 3px #111;
    transform: scale(1.1);
}

/* ══════════════════════════════════════════════════════════
   VÄRIVAROITUS
   ══════════════════════════════════════════════════════════ */
.cso-warning {
    color: #7a4f00;
    background: #fff8e1;
    border: 1.5px solid #ffc107;
    padding: 12px 14px;
    border-radius: 8px;
    margin: 8px 0 12px;
    font-size: 14px;
}
.cso-warning p { margin: 0 0 10px; }
.cso-warning-accept {
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}
.cso-warning-accept input {
    width: 20px; height: 20px;   /* isompi checkbox mobiilissa */
    margin: 0; flex-shrink: 0;
    cursor: pointer;
}

/* ══════════════════════════════════════════════════════════
   TOIMITUS-RADIONAPIT
   ══════════════════════════════════════════════════════════ */
.cso-delivery {
    border: 1.5px solid #ddd;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 14px;
}
.cso-delivery legend {
    font-weight: 700;
    padding: 0 4px;
    font-size: 14px;
}
/* Mobiilissa radionapit pinotaan allekkain isompina */
.cso-delivery-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}
.cso-delivery label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    font-size: 15px;
    padding: 10px 12px;
    background: #f8f8f8;
    border: 1.5px solid #e0e0e0;
    border-radius: 7px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.cso-delivery label:has(input:checked) {
    background: #f0f7ff;
    border-color: #0073aa;
}
.cso-delivery input[type="radio"] {
    width: 20px; height: 20px;
    margin: 0; flex-shrink: 0;
    accent-color: #0073aa;
}

/* ══════════════════════════════════════════════════════════
   ASEMOINTI-VALINTA
   ══════════════════════════════════════════════════════════ */
#orientation-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    background: #f8f8f8;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-top: 8px;
}
.cso-radio-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-size: 14px;
    cursor: pointer;
}
.cso-radio-label input[type="radio"] {
    width: 20px; height: 20px;
    margin: 0; flex-shrink: 0;
    accent-color: #0073aa;
}

/* ══════════════════════════════════════════════════════════
   YRITYSTILAAJA
   ══════════════════════════════════════════════════════════ */
.cso-business-toggle label {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 15px;
    padding: 10px 12px;
    background: #f8f8f8;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
}
.cso-business-toggle input[type="checkbox"] {
    width: 20px; height: 20px;
    margin: 0; flex-shrink: 0;
    accent-color: #0073aa;
}
.cso-req { color: #c00; }
#business-fields {
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 14px;
}

/* ══════════════════════════════════════════════════════════
   CHECKBOX-LABELIT (yritys-toggle jne.)
   ══════════════════════════════════════════════════════════ */
.cso-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 15px;
}

/* ══════════════════════════════════════════════════════════
   VIRHEILMOITUKSET
   ══════════════════════════════════════════════════════════ */
.cso-error { color: #b00020; font-size: 13px; margin-top: 4px; }
#cso-form-error {
    color: #b00020;
    background: #fdecea;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 14px;
    margin-top: 10px;
}

/* ══════════════════════════════════════════════════════════
   TEKSTIVAROITUS (rivirajoitus)
   ══════════════════════════════════════════════════════════ */
.cso-text-warning {
    background: #fff8e1;
    border: 1px solid #f0c040;
    border-left: 4px solid #f0a000;
    border-radius: 6px;
    padding: 10px 14px;
    margin: 8px 0 12px;
    font-size: 13px;
    line-height: 1.5;
    color: #5a4000;
}
.cso-text-warning small {
    display: block; margin-top: 4px;
    opacity: .75; font-size: 12px;
}

/* ══════════════════════════════════════════════════════════
   TARRAMÄÄRÄ DISCLAIMER
   ══════════════════════════════════════════════════════════ */
.cso-qty-disclaimer {
    font-size: 12px; color: #666;
    margin: 6px 0 0; line-height: 1.5;
}

/* ══════════════════════════════════════════════════════════
   HINTAYHTEENVETO LOMAKKEESSA
   ══════════════════════════════════════════════════════════ */
#price-summary {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 14px 16px;
    margin: 16px 0 12px;
    font-size: 14px;
    display: none;
}
#price-summary.visible { display: block; }
#price-summary table   { width: 100%; border-collapse: collapse; }
#price-summary td      { padding: 4px 0; }
#price-summary td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
#price-summary .cso-total-row td {
    font-weight: 700;
    border-top: 1px solid #ccc;
    padding-top: 8px;
    font-size: 16px;
}
#price-summary .cso-vat-row { color: #666; font-size: 12px; }

/* ══════════════════════════════════════════════════════════
   LÄHETYSPAINIKE – koko leveyteen, isompi
   ══════════════════════════════════════════════════════════ */
.cso-submit {
    display: block;
    width: 100%;
    background: #111;
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 16px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    transition: background .2s;
    margin-top: 6px;
    /* Isompi touch-kohde */
    min-height: 54px;
}
.cso-submit:hover:not(:disabled) { background: #333; }
.cso-submit:disabled { opacity: .6; cursor: not-allowed; }

/* ══════════════════════════════════════════════════════════
   HR
   ══════════════════════════════════════════════════════════ */
#sticker-order-form hr {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 22px 0;
}

/* ══════════════════════════════════════════════════════════
   ONNISTUMISVIESTI
   ══════════════════════════════════════════════════════════ */
.cso-success-msg {
    background: #e8f5e9;
    border: 1px solid #a5d6a7;
    border-radius: 10px;
    padding: 24px;
    color: #1b5e20;
    font-weight: 600;
    font-size: 16px;
    text-align: center;
    line-height: 1.5;
}

/* ══════════════════════════════════════════════════════════
   TARRAKORTIT (lisätyt tarrat)
   ══════════════════════════════════════════════════════════ */
#cso-sticker-list { margin-bottom: 20px; }

.cso-sticker-card {
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 10px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,.07);
}
.cso-card-header {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 15px;
    margin-bottom: 5px;
    flex-wrap: wrap;
}
.cso-card-price {
    margin-left: auto;
    font-weight: 700;
    color: #1a6b2a;
    white-space: nowrap;
}
.cso-card-meta {
    font-size: 12px;
    color: #666;
    margin-bottom: 10px;
    line-height: 1.6;
    /* Mobiilissa pystysuuntaan */
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.cso-card-actions {
    display: flex;
    gap: 10px;
}
/* Isommat toimintopainikkeet mobiilissa */
.cso-btn-edit-card,
.cso-btn-remove-card {
    flex: 1;
    text-align: center;
    padding: 8px !important;
    font-size: 13px !important;
}
.cso-btn-remove-card {
    color: #b00 !important;
    border-color: #b00 !important;
}

/* ══════════════════════════════════════════════════════════
   LISÄÄ TARRA -PALKKI
   ══════════════════════════════════════════════════════════ */
.cso-add-sticker-bar {
    display: flex;
    flex-direction: column;   /* mobiilissa pino */
    gap: 10px;
    margin: 18px 0 4px;
    padding: 16px;
    background: #f0f7ff;
    border: 1.5px dashed #7ab0d4;
    border-radius: 10px;
}
.cso-btn-add {
    background: #0073aa !important;
    color: #fff !important;
    border-color: #005f8d !important;
    font-size: 15px !important;
    padding: 12px 16px !important;
    width: 100% !important;
    text-align: center !important;
    min-height: 48px !important;
    border-radius: 7px !important;
}
.cso-btn-add:hover  { background: #005f8d !important; }
.cso-btn-add:disabled { opacity: .6; }
.cso-btn-cancel {
    font-size: 13px !important;
    width: 100% !important;
    text-align: center !important;
    padding: 10px !important;
}
#cso-sticker-count-msg {
    font-size: 13px;
    color: #555;
    text-align: center;
}

/* ══════════════════════════════════════════════════════════
   FONTTIVALINTA
   ══════════════════════════════════════════════════════════ */
#font { width: 100%; max-width: 100%; display: block; }

/* ══════════════════════════════════════════════════════════
   ESIKATSELU – mobiilissa kompaktimpi vaakasuuntainen strip
   ══════════════════════════════════════════════════════════ */
#cso-preview-panel {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,.07);
}

/* Mobiilissa: esikatselu + hinta vierekkäin */
#preview-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border-bottom: 1px solid #eee;
}
#preview-container h3 {
    display: none;   /* piilotetaan mobiilissa – tila kortilla */
}

#preview-canvas {
    width: 110px;
    height: 110px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: repeating-conic-gradient(#ebebeb 0% 25%, #f8f8f8 0% 50%)
                0 0 / 12px 12px;
    border-radius: 6px;
    overflow: hidden;
    outline: 1px solid #e0e0e0;
}

.cso-preview-info {
    flex: 1;
    min-width: 0;
}
.cso-preview-size-label {
    font-size: 12px;
    color: #555;
    font-style: italic;
    line-height: 1.4;
    margin: 0 0 4px;
}
.cso-preview-notice {
    font-size: 11px;
    color: #999;
    line-height: 1.4;
    margin: 0;
}

#cso-price-panel {
    padding: 12px 14px;
}
#summary-detail { font-size: 13px; line-height: 1.7; }
#summary-detail table { width: 100%; border-collapse: collapse; }
#summary-detail td { padding: 2px 0; }
#summary-detail td:last-child {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
#summary-detail .cso-total-row td {
    font-weight: 700;
    border-top: 1px solid #ddd;
    padding-top: 6px;
    font-size: 15px;
}
#summary-detail .cso-vat-row { color: #666; font-size: 12px; }

/* ══════════════════════════════════════════════════════════
   POSTIMERKKIESIKATSELU
   ══════════════════════════════════════════════════════════ */
.cso-preview-stamp {
    background-image:
        radial-gradient(circle at 50% 0%,   transparent 5px, #aaa 5px, #aaa 6px, transparent 6px),
        radial-gradient(circle at 50% 100%, transparent 5px, #aaa 5px, #aaa 6px, transparent 6px),
        radial-gradient(circle at 0%  50%,  transparent 5px, #aaa 5px, #aaa 6px, transparent 6px),
        radial-gradient(circle at 100% 50%, transparent 5px, #aaa 5px, #aaa 6px, transparent 6px);
    background-size: 12px 100%, 12px 100%, 100% 12px, 100% 12px;
    background-position: top, bottom, left, right;
    background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
    box-shadow: inset 0 0 0 2px #ddd, 0 2px 6px rgba(0,0,0,.12);
    border-radius: 2px;
    padding: 8px !important;
}

/* ══════════════════════════════════════════════════════════
   HONEYPOT
   ══════════════════════════════════════════════════════════ */
.cso-hp-wrap {
    position: absolute; left: -9999px;
    width: 1px; height: 1px;
    overflow: hidden; opacity: 0;
}

/* ══════════════════════════════════════════════════════════
   TABLET (≥ 600px) – kaksi saraketta kentille
   ══════════════════════════════════════════════════════════ */
@media (min-width: 600px) {
    .cso-grid           { grid-template-columns: repeat(2, 1fr); }
    .cso-row            { grid-template-columns: repeat(2, 1fr); }
    .cso-address-fields { grid-template-columns: 2fr 1fr 1fr; }

    .cso-add-sticker-bar {
        flex-direction: row;
        align-items: center;
    }
    .cso-btn-add    { width: auto !important; }
    .cso-btn-cancel { width: auto !important; }

    .cso-card-meta {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0;
    }

    .cso-delivery-options { flex-direction: row; gap: 12px; }
    .cso-delivery label   { flex: 1; }

    #orientation-group { flex-direction: row; gap: 16px; }
}

/* ══════════════════════════════════════════════════════════
   DESKTOP (≥ 820px) – sivupalkkilayout
   ══════════════════════════════════════════════════════════ */
@media (min-width: 820px) {
    .cso-wrap {
        display: grid;
        grid-template-columns: 1fr 300px;
        grid-template-areas: "form preview";
        gap: 28px;
        align-items: start;
        flex-direction: unset;
    }
    #sticker-order-form { order: unset; grid-area: form; }
    #cso-preview-panel  {
        order: unset;
        grid-area: preview;
        position: sticky;
        top: 20px;
        background: none;
        border: none;
        box-shadow: none;
        border-radius: 0;
        overflow: visible;
    }

    /* Desktop-esikatselu: pystysuuntainen */
    #preview-container {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 14px;
        border: 1px solid #ddd;
        border-radius: 10px;
        box-shadow: 0 2px 10px rgba(0,0,0,.06);
        background: #fff;
        margin-bottom: 12px;
    }
    #preview-container h3 {
        display: block;
        margin: 0 0 10px;
        font-size: 15px;
        font-weight: 700;
        color: #333;
    }
    .cso-preview-info { display: none; }   /* desktop käyttää erillistä label-elementtiä */

    #preview-canvas {
        width: 270px;
        height: 270px;
        margin: 0 auto 6px;
    }
    .cso-preview-size-label {
        display: block;
        text-align: center;
        min-height: 2.8em;
        font-size: 11px;
        color: #888;
        margin: 0 0 6px;
    }
    .cso-preview-notice {
        display: block;
        font-size: 11px;
        color: #888;
        margin: 4px 0 0;
    }

    #cso-price-panel {
        background: #fff;
        border: 1px solid #ddd;
        padding: 14px;
        border-radius: 10px;
        box-shadow: 0 2px 10px rgba(0,0,0,.06);
    }

    /* Desktop: väripallot normaalikokoiset */
    .cso-dot { width: 30px; height: 30px; }

    /* Desktop: kentät pienemmällä paddingilla */
    #sticker-order-form input[type="text"],
    #sticker-order-form input[type="email"],
    #sticker-order-form select,
    #sticker-order-form textarea {
        padding: 9px 11px;
        font-size: 14px;
    }

    .cso-submit { padding: 14px; font-size: 15px; min-height: unset; }

    .cso-card-meta { flex-direction: row; }

    .cso-btn-edit-card,
    .cso-btn-remove-card { flex: unset; }
}

/* ══════════════════════════════════════════════════════════
   LEVEÄ DESKTOP (≥ 1024px)
   ══════════════════════════════════════════════════════════ */
@media (min-width: 1024px) {
    .cso-wrap { grid-template-columns: 1fr 320px; }
}
