/* ═══════════════════════════════════════════════════════
   BASE
═══════════════════════════════════════════════════════ */

html, body
{
    overflow-x: hidden;
}

body
{
    background-color: #f5ead5;  /* warm wheat / parchment */
    font-family: Arial, sans-serif;
    color: #3d2b1a;
    margin: 0;
    padding: 0;
    /* Eliminate 300ms tap delay on mobile */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* ═══════════════════════════════════════════════════════
   TOP BAR
═══════════════════════════════════════════════════════ */

.top-bar
{
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;

    background-color: #6b4226;
    color: white;

    padding: 10px 18px;
    /* Respect iPhone notch / Dynamic Island */
    padding-left: max(18px, env(safe-area-inset-left));
    padding-right: max(18px, env(safe-area-inset-right));
    padding-top: max(10px, env(safe-area-inset-top));
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);

    position: sticky;
    top: 0;
    z-index: 10;
}

.top-bar-brand
{
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-icon
{
    font-size: 22px;
    line-height: 1;
}

.brand-name
{
    font-size: 18px;
    font-weight: bold;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.top-bar-nav
{
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

/* Nav buttons sit on the brown header — override base button styles */
.top-bar-nav button
{
    background-color: rgba(255,255,255,0.15);
    color: white;
    border-color: rgba(255,255,255,0.4);
    border-radius: 5px;
    padding: 4px 10px;
    font-size: 13px;
    margin: 0; /* cancel out base margin-top/bottom */
}

.top-bar-nav button:hover:enabled
{
    background-color: rgba(255,255,255,0.28);
}




/* ═══════════════════════════════════════════════════════
   MAIN CONTENT WRAPPER
═══════════════════════════════════════════════════════ */

.main-content
{
    max-width: 960px;
    margin: 0 auto;
    padding: 18px 16px 40px;
}


/* ═══════════════════════════════════════════════════════
   CONTROL STRIP  (items-per-row slider)
═══════════════════════════════════════════════════════ */

.control-strip
{
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.control-strip label
{
    font-weight: bold;
    white-space: nowrap;
}

.control-strip input[type="range"]
{
    flex: 1;
    min-width: 120px;
    max-width: 260px;
    vertical-align: middle;
}

.items-badge
{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    background-color: #e8972e;
    color: white;
    font-weight: bold;
    border-radius: 14px;
    font-size: 14px;
}


/* ═══════════════════════════════════════════════════════
   PANEL  (card container)
═══════════════════════════════════════════════════════ */

.panel
{
    background-color: #fffef5;
    border: 2px solid #e0c98a;
    border-radius: 8px;
    padding: 14px 16px 12px;
    margin-bottom: 12px;
    box-shadow: 0 1px 4px rgba(107,66,38,0.10);
}

.panel-header
{
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    border-bottom: 1px solid #e0c98a;
    padding-bottom: 8px;
}

.panel-title
{
    font-size: 16px;
    font-weight: bold;
    color: #6b4226;
}

.panel-hint
{
    font-size: 12px;
    color: #8a6a50;
}

/* Price result panel — slightly different accent */
.price-result-panel
{
    border-color: #b8d98a;
    background-color: #f8fff0;
}

.price-result-panel .panel-title
{
    color: #3d6b26;
}


/* ═══════════════════════════════════════════════════════
   ITEM FORM ROW
═══════════════════════════════════════════════════════ */

.item-form-row
{
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin-bottom: 10px;
}

.field-group
{
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.field-group label
{
    font-size: 12px;
    font-weight: bold;
    color: #6b4226;
    white-space: nowrap;
}

.field-group--actions
{
    flex-direction: row;
    align-items: flex-end;
    gap: 6px;
    padding-bottom: 0;
}


/* ═══════════════════════════════════════════════════════
   BUTTON ROWS
═══════════════════════════════════════════════════════ */

.btn-row
{
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}


/* ═══════════════════════════════════════════════════════
   HINT TEXT
═══════════════════════════════════════════════════════ */

.hint-text
{
    font-size: 12px;
    color: #8a6a50;
    font-style: italic;
    margin: 4px 0 6px;
}


/* ═══════════════════════════════════════════════════════
   PREVIEW WRAPPER  (frames the screenshot card)
═══════════════════════════════════════════════════════ */

.preview-wrapper
{
    margin-top: 18px;
    padding-top: 18px;
    border-top: 2px dashed #d4b896;
    text-align: center;  /* centres the inline-block screenshotRegion */
    overflow-x: auto;
}


/* ═══════════════════════════════════════════════════════
   BASE FORM ELEMENTS
═══════════════════════════════════════════════════════ */

button
{
    color: #3d2b1a;
    border-color: #b8956a;
    background-color: #f5f0e8;
    border-radius: 5px;

    padding: 4px 10px;

    transition: color 0.15s, background-color 0.15s, border-color 0.15s;

    margin-top: 2px;
    margin-bottom: 2px;

    /* Eliminate 300ms tap delay on interactive elements */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
}

button:disabled
{
    color: rgba(61,43,26,0.3);
    background-color: rgba(239,239,239,0.4);
    border-color: rgba(184,149,106,0.3);
}

button:active
{
    transform: scale(0.97);
}

button:hover:enabled
{
    cursor: pointer;
    background-color: #ede4d0;
}

/* Keep spacing between adjacent sibling buttons (legacy support) */
button + button
{
    margin-left: 0; /* gap handles spacing in flex containers; reset here */
}

button, input, textarea, select
{
    border-style: solid;
}

input, textarea
{
    transition: background-color 0.3s;
}

:is(input, textarea):focus
{
    background-color: #ff05;
}

/* Only affect text-type inputs; not sliders, radios, checkboxes */
button, input[type="text"], textarea, select
{
    border-radius: 5px;
    border-width: 2px;
}


/* ═══════════════════════════════════════════════════════
   BUTTON VARIANTS
═══════════════════════════════════════════════════════ */

.btn-primary
{
    background-color: #e8972e;
    color: white;
    border-color: #c67a18;
    font-weight: bold;
}

.btn-primary:hover:enabled
{
    background-color: #d08520;
}

.btn-danger
{
    background-color: #f5f0e8;
    color: #c0392b;
    border-color: #c0392b;
}

.btn-danger:hover:enabled
{
    background-color: #fde8e6;
}

.btn-danger:disabled
{
    color: rgba(192,57,43,0.3);
    border-color: rgba(192,57,43,0.3);
}

.btn-action
{
    background-color: #5a9640;
    color: white;
    border-color: #407a2a;
    font-weight: bold;
}

.btn-action:hover:enabled
{
    background-color: #4a8030;
}


/* ═══════════════════════════════════════════════════════
   SELECTED / INVALID STATES
═══════════════════════════════════════════════════════ */

.selected:not(:disabled), .invalid
{
    border-style: solid;
    border-color: red;
    outline: none;
}


/* ═══════════════════════════════════════════════════════
   ITEM TABLE  (inside screenshot region)
═══════════════════════════════════════════════════════ */

td
{
    border: 3px solid;
    border-color: #0002;
    transition: border-color 0.2s;

    animation: grow 0.3s;
}

@keyframes grow
{
    from
    {
        transform: scale(0.8);
        opacity: 0.8;
        border-radius: 50px;
    }
    to
    {
        transform: scale(1);
        opacity: 1;
    }
}

td:hover
{
    border-color: #ffd600;
    cursor: pointer;
}

td.selected:hover
{
    border-color: purple;
}

#itemTable
{
    margin: 0 auto;
}


/* ═══════════════════════════════════════════════════════
   ITEM CELLS  (inside screenshot region)
═══════════════════════════════════════════════════════ */

.itemCell
{
    position: relative;
}

.itemImage
{
    width: 100px;
    height: 100px;
    object-fit: contain;

    --itemImageOutlineColor: rgb(0, 0, 0, 0.5);
    filter: drop-shadow(0 0 2px var(--itemImageOutlineColor));
    transition: filter 0.2s;
}

.itemImage:hover
{
    --itemImageOutlineColor: rgb(255, 165, 0, 0.8);
}

.label
{
    position: absolute;
    font-weight: bold;
    color: white;

    --labelOutlineColor: 0, 0, 0;
    filter:
        drop-shadow(0 0 1px rgb(var(--labelOutlineColor), 0.8))
        drop-shadow(0 0 1px rgb(var(--labelOutlineColor), 0.8))
        drop-shadow(0 0 5px rgb(var(--labelOutlineColor), 0.8));
    transition: filter 0.2s;
}

.label:hover
{
    --labelOutlineColor: 255, 165, 0;
}

.customLabel
{
    --labelOutlineColor: 255, 0, 0;
}

.quantityLabel
{
    top: 5px;
    right: 5px;
    font-size: 50px;
    transition: opacity 0.2s;
}

.customQuantityLabel
{
    top: 53px;
    left: 5px;
    font-size: 25px;
    --labelOutlineColor: 255, 0, 0;
    animation: fadeIn 0.2s forwards;
}

.priceLabel
{
    transform: translate(0%, -100%);
    top: 2px;
    left: 2px;
    font-size: 30px;
    transition: opacity 0.2s;
}

.customPriceLabel
{
    transform: translate(0%, -100%);
    top: 2px;
    right: 2px;
    font-size: 25px;
    animation: fadeIn 0.2s forwards;
}

.coin
{
    position: relative;
    top: 2px;
    width: 28px;
    height: 28px;
}


/* ═══════════════════════════════════════════════════════
   SCREENSHOT REGION  (the actual card output)
   Explicit background so it stays #fff8b8 regardless of
   body/wrapper background (needed by html-to-image too)
═══════════════════════════════════════════════════════ */

#screenshotRegion
{
    background-color: #fff8b8;

    display: inline-block;  /* wraps tightly around children */
    transform-origin: top left;
}

#bottomText
{
    text-align: center;
    font-size: 50px;
    font-weight: bold;
    margin-top: 10px;
    margin-bottom: 0px;
    white-space: pre;
}

#bottomText:hover
{
    cursor: pointer;
}

#screenshotPriceHolder, .watermark
{
    font-size: 16px;
    font-weight: bold;
    margin: 10px;
    margin-top: 2px;
}

#screenshotPriceHolder
{
    float: left;
    animation: fadeIn 0.2s forwards;
}

.watermark
{
    text-align: right;
}


/* ═══════════════════════════════════════════════════════
   OVERLAYS
═══════════════════════════════════════════════════════ */

.overlay:not(#changelogOverlay)
{
    text-align: center;
}

.overlayBackground
{
    position: fixed;
    top: 0%;
    left: 0%;
    width: 100%;
    height: 100%;
    background-color: #000a;
}

.overlayBox
{
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50.00005%, -50%);

    min-width: 20%;
    max-width: 90%;
    max-height: 90%;
    overflow-y: auto;

    background-color: #fffbec;
    border-style: solid;
    border-color: #b8956a;
    border-width: 3px;
    border-radius: 8px;
}

.overlayInner
{
    margin: 10px;
}

.overlayHideButton
{
    position: sticky;
    top: 0;
    left: calc(100%);
    transform: translate(-50%, 50%);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    padding: 0;
    font-size: 14px;
    font-weight: bold;
    background-color: #6b4226;
    color: white;
    border-color: #6b4226;
}

.overlayHideButton:hover:enabled
{
    background-color: #8b5a36;
}

.overlayHideButton:active
{
    transform: translate(-50%, 50%) scale(0.97);
}

#abbreviationMappingTableArea
{
    max-height: 400px;
    overflow-y: auto;
    display: inline-block;
}

/* Failed copy overlay — wider to show the image properly */
#failedCopyOverlay .overlayBox
{
    width: 80%;
}

#failedCopyOverlayImageHolder
{
    max-width: 100%;
}




/* ═══════════════════════════════════════════════════════
   FUZZY MATCH DROPDOWN
═══════════════════════════════════════════════════════ */

.fuzzyMatchesHolder
{
    position: absolute;
    width: 100%;
    z-index: 1;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.fuzzyMatchesHolder:not(:empty)
{
    animation: fadeIn 0.2s forwards;
}

.fuzzyMatchesHolder:empty
{
    display: none;
}

.fuzzyMatchesHolder button
{
    width: 100%;
    height: 100%;
    background-color: #5a5a5a;
    border-style: solid;
    border-width: 1px;
    border-color: #404040;
    border-radius: 0;
    color: white;
    margin: 0;
    padding-left: 1em;
}

.fuzzyMatchesHolder div
{
    position: relative;
}

.fuzzyMatchesHolder p
{
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 2px;
    padding: 0;
    margin: 0;
    font-size: 10pt;
    font-weight: bold;
    color: lime;
}


/* ═══════════════════════════════════════════════════════
   NOTIFICATIONS
═══════════════════════════════════════════════════════ */

.notification
{
    position: fixed;
    left: 50%;
    top: 0;
    border-style: solid;
    border-width: 2px;
    border-radius: 5px;
    padding: 10px;
    animation: slideFade 5s forwards;
}

.notificationSuccess
{
    background-color: #d1ffbd;
    border-color: #2e990055;
}

.notificationFail
{
    background-color: #ffc8c8;
    border-color: #db2f2355;
}


/* ═══════════════════════════════════════════════════════
   LOADING WHEEL
═══════════════════════════════════════════════════════ */

.loading:not([hidden])
{
    display: inline-block;
    vertical-align: middle;
    margin-left: 4px;
    margin-right: 4px;
    width: 12px;
    height: 12px;
    border-style: solid;
    border-width: 3px;
    border-radius: 100%;
    border-color: #e8972e #e8972e #e8972e transparent;
    animation: spin 2.5s linear infinite;
}


/* ═══════════════════════════════════════════════════════
   TOTAL PRICE MESSAGE
═══════════════════════════════════════════════════════ */

#totalSelectedPriceMessageHolder
{
    font-weight: bold;
    transition: color 0.2s;
}


/* ═══════════════════════════════════════════════════════
   FADE / ANIMATION RULES
═══════════════════════════════════════════════════════ */

.overlay, #totalSelectedPriceArea :not(img, :empty), #priceCalculationModeSelectionInfo
{
    animation: fadeIn 0.3s forwards;
}

@keyframes fadeIn
{
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slideFade
{
    from, to
    {
        opacity: 0;
        transform: translate(-50%, -100%);
    }
    20%, 80%
    {
        opacity: 1;
        transform: translate(-50%, 10%);
    }
}

@keyframes spin
{
    from  { transform: rotate(0deg); }
    50%   { transform: rotate(360deg) scale(0.8); border-color: #f5c980 #f5c980 #f5c980 transparent; }
    to    { transform: rotate(720deg); }
}


/* ═══════════════════════════════════════════════════════
   MOBILE  (≤ 600 px)
═══════════════════════════════════════════════════════ */

@media (max-width: 600px)
{
    /* ── Top bar ── */
    .top-bar
    {
        padding: 8px 12px;
        gap: 6px;
    }

    .brand-name { font-size: 15px; }
    .brand-icon  { font-size: 18px; }

    .top-bar-nav
    {
        width: 100%;
        justify-content: flex-start;
    }

    .top-bar-nav button
    {
        flex: 1 1 auto;          /* buttons share available width */
        text-align: center;
        padding: 7px 8px;        /* bigger tap target */
        font-size: 13px;
    }

    /* ── Main content ── */
    .main-content
    {
        padding: 12px 10px 32px;
    }

    /* ── Panel ── */
    .panel
    {
        padding: 12px 10px 10px;
    }

    /* ── Item form row — stack fields full-width ── */
    .item-form-row
    {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .field-group
    {
        width: 100%;
    }

    .field-group input[type="text"]
    {
        width: 100% !important;  /* override inline widths */
        box-sizing: border-box;
        min-height: 40px;        /* comfortable tap target */
        font-size: 16px;         /* prevent iOS zoom-on-focus */
    }

    .field-group--actions
    {
        flex-direction: row;
        gap: 8px;
    }

    .field-group--actions button
    {
        flex: 1;
        min-height: 40px;
        font-size: 15px;
    }

    /* ── Button rows ── */
    .btn-row
    {
        gap: 8px;
    }

    .btn-row button
    {
        flex: 1 1 auto;
        min-height: 40px;        /* bigger tap target */
        font-size: 14px;
        padding: 6px 8px;
    }

    /* ── Control strip (slider row) ── */
    .control-strip input[type="range"]
    {
        max-width: 100%;
        flex: 1;
    }

    /* ── Overlays ── */
    .overlayBox
    {
        width: 94% !important;
        max-width: 94%;
        max-height: 88%;
    }

    .overlayInner
    {
        margin: 8px;
    }

    /* Make settings inputs full-width inside overlay */
    .overlayInner input[type="text"],
    .overlayInner select,
    .overlayInner textarea
    {
        width: 90% !important;
        box-sizing: border-box;
        font-size: 16px;
    }

    .overlayInner input[type="text"][style*="width: 12em"],
    .overlayInner input[type="text"][style*="width: 8em"],
    .overlayInner input[type="text"][style*="width: 3em"],
    .overlayInner select[style*="width: 12em"]
    {
        width: 100% !important;
    }

    /* Abbreviation table scrollable */
    #abbreviationMappingTableArea
    {
        max-height: 30vh;
        width: 100%;
    }

    #abbreviationMappingTable
    {
        width: 100%;
    }

    /* ── Preview / screenshot region ── */
    .preview-wrapper
    {
        margin-top: 12px;
        padding-top: 12px;
        /* Allow horizontal scroll so the card at 0.6× scale is still reachable */
        overflow-x: auto;
        overflow-y: hidden;
        /* Use flex so the card centres and the scrollable area sizes correctly */
        display: flex;
        justify-content: flex-start;
        padding-bottom: 12px;
    }

    /* Keep transform-origin at top left (set inline by JS) so scroll works naturally */
    #screenshotRegion
    {
        flex-shrink: 0;   /* don't let flex squash the card further */
    }

    /* ── Hint text ── */
    .hint-text
    {
        font-size: 11px;
    }

    /* ── Notifications ── */
    .notification
    {
        font-size: 13px;
        padding: 8px 12px;
        max-width: 90%;
    }
}


/* ═══════════════════════════════════════════════════════
   MOBILE  (≤ 400 px — very small phones)
═══════════════════════════════════════════════════════ */

@media (max-width: 400px)
{
    .brand-name { font-size: 13px; }

    .top-bar-nav button
    {
        padding: 6px 6px;
        font-size: 12px;
    }

    .btn-row button,
    .field-group--actions button
    {
        font-size: 13px;
        padding: 6px 6px;
    }

    .panel-title { font-size: 14px; }
}
