/* =========================================================
   RESET
========================================================= */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Arial,
        sans-serif;

    background: #f4f6f8;
    color: #171717;

    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}


/* =========================================================
   COMMON
========================================================= */

.hidden {
    display: none !important;
}


/* =========================================================
   LOADING
========================================================= */

#loading {
    min-height: 100vh;

    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-box {
    text-align: center;
    color: #555;
}

.loading-box p {
    margin-top: 16px;

    font-size: 14px;
}

.loader {
    width: 34px;
    height: 34px;

    margin: auto;

    border: 3px solid #e5e7eb;
    border-top-color: #111;

    border-radius: 50%;

    animation: spin 0.8s linear infinite;
}

@keyframes spin {

    to {
        transform: rotate(360deg);
    }

}


/* =========================================================
   ERROR
========================================================= */

#error {
    min-height: 100vh;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 24px;
}

.error-box {
    width: 100%;
    max-width: 420px;

    padding: 32px;

    text-align: center;

    background: #fff;

    border-radius: 18px;

    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.08);
}

.error-icon {
    width: 46px;
    height: 46px;

    margin: 0 auto 16px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 50%;

    background: #fee2e2;
    color: #dc2626;

    font-weight: 700;
    font-size: 22px;
}

.error-box h2 {
    margin: 0 0 8px;

    font-size: 21px;
}

.error-box p {
    margin: 0 0 20px;

    color: #666;

    font-size: 14px;

    line-height: 1.5;
}

.error-box button {
    border: 0;

    padding: 12px 20px;

    border-radius: 9px;

    background: #111;
    color: #fff;

    font-size: 14px;

    cursor: pointer;

    transition: opacity 0.15s ease;
}

.error-box button:hover {
    opacity: 0.9;
}


/* =========================================================
   INVOICE CONTAINER
========================================================= */

.invoice {
    width: calc(100% - 32px);
    max-width: 760px;

    margin: 32px auto;

    padding: 40px;

    background: #fff;

    border-radius: 18px;

    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.08);
}


/* =========================================================
   SHOP HEADER
========================================================= */

.invoice-header {
    width: 100%;

    display: block;

    text-align: center;
}

.shop-details {
    width: 100%;

    min-width: 0;

    text-align: center;
}

#shopName {
    margin: 0;

    color: #111;

    font-size: 30px;

    line-height: 1.2;

    font-weight: 750;

    letter-spacing: -0.6px;

    text-align: center;

    overflow-wrap: anywhere;
}

.shop-address {
    margin: 8px 0 0;

    color: #555;

    font-size: 14px;

    line-height: 1.5;

    text-align: center;

    overflow-wrap: anywhere;
}

/* -----------------------------------------------------
   SHOP PHONE / EMAIL

   Same visual weight as the address line since they are
   both "contact" info.
----------------------------------------------------- */

.shop-phone,
.shop-email {
    margin: 4px 0 0;

    color: #555;

    font-size: 14px;

    line-height: 1.5;

    text-align: center;

    overflow-wrap: anywhere;
}

/* -----------------------------------------------------
   SHOP GSTIN / FSSAI

   Smaller, muted "compliance" line — shown only when
   the value exists (toggled via .hidden in app.js).
----------------------------------------------------- */

.shop-gstin,
.shop-fssai {
    margin: 5px 0 0;

    color: #777;

    font-size: 12px;

    line-height: 1.4;

    text-align: center;
}

.invoice-badge {
    display: inline-block;

    margin-top: 14px;

    padding: 7px 13px;

    border-radius: 7px;

    background: #f1f3f5;

    color: #333;

    font-size: 11px;

    font-weight: 700;

    letter-spacing: 1px;

    text-align: center;
}


/* =========================================================
   DIVIDER
========================================================= */

.divider {
    width: 100%;

    height: 1px;

    margin: 28px 0;

    background: #e7e7e7;
}


/* =========================================================
   INVOICE META
========================================================= */

.invoice-meta {
    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        minmax(0, 1fr);

    gap: 16px;

    margin-top: 28px;
}

.meta-card {
    min-width: 0;

    padding: 16px;

    border: 1px solid #e9eaec;

    border-radius: 10px;

    background: #fafafa;
}

.meta-label {
    display: block;

    margin-bottom: 7px;

    color: #777;

    font-size: 12px;

    text-transform: uppercase;

    letter-spacing: 0.5px;
}

.meta-card strong {
    display: block;

    color: #222;

    font-size: 15px;

    font-weight: 650;

    line-height: 1.4;

    word-break: break-word;
}


/* =========================================================
   CUSTOMER / ORDER INFORMATION
========================================================= */

.information-grid {
    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        minmax(0, 1fr);

    gap: 18px;

    margin-top: 22px;
}

.info-card {
    min-width: 0;

    padding: 18px;

    border: 1px solid #e9eaec;

    border-radius: 12px;

    background: #fff;
}

.card-title {
    margin-bottom: 14px;

    color: #777;

    font-size: 12px;

    font-weight: 700;

    text-transform: uppercase;

    letter-spacing: 0.6px;
}

.customer-name {
    color: #171717;

    font-size: 16px;

    font-weight: 650;

    line-height: 1.4;

    overflow-wrap: anywhere;
}

.customer-phone {
    margin-top: 6px;

    color: #666;

    font-size: 13px;

    line-height: 1.4;

    overflow-wrap: anywhere;
}

.info-row {
    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 16px;

    padding: 6px 0;
}

.info-row span {
    min-width: 0;

    color: #777;

    font-size: 13px;
}

.info-row strong {
    min-width: 0;

    color: #222;

    font-size: 13px;

    font-weight: 650;

    text-align: right;

    text-transform: capitalize;

    overflow-wrap: anywhere;
}


/* =========================================================
   ITEMS SECTION
========================================================= */

.items-section {
    width: 100%;

    margin-top: 32px;
}


/* =========================================================
   ITEMS LIST
========================================================= */

.items-list {
    width: 100%;
}


/* =========================================================
   SINGLE ITEM
=========================================================

   This is the important part.

   Layout:

   Herbal                              ₹100.00
   1 × ₹100.00

   --------------------------------------------

   Blu cofee                           ₹150.00
   1 × ₹150.00

   NOTE: app.js must emit these exact class names
   (item-row / item-details / item-name / item-quantity /
   item-amount) or this grid layout never applies.

========================================================= */

.item-row {
    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        150px;

    align-items: start;

    width: 100%;

    min-height: 68px;

    padding: 17px 0 16px;

    border-bottom: 1px solid #eeeeee;
}


/* =========================================================
   ITEM DETAILS
========================================================= */

.item-details {
    min-width: 0;

    padding-right: 24px;
}

.item-name {
    display: block;

    margin: 0;

    color: #111;

    font-size: 15px;

    font-weight: 700;

    line-height: 1.45;

    overflow-wrap: anywhere;

    word-break: break-word;
}


/* =========================================================
   ITEM QUANTITY + RATE
========================================================= */

.item-quantity {
    display: block;

    margin-top: 5px;

    color: #777;

    font-size: 13px;

    font-weight: 400;

    line-height: 1.4;

    white-space: normal;
}


/* =========================================================
   ITEM AMOUNT
========================================================= */

.item-amount {
    min-width: 0;

    color: #111;

    font-size: 15px;

    font-weight: 650;

    line-height: 1.45;

    text-align: right;

    white-space: nowrap;
}


/* =========================================================
   EMPTY ITEM STATE
========================================================= */

.item-empty {
    padding: 20px 0;

    color: #777;

    font-size: 14px;

    text-align: center;

    border-bottom: 1px solid #eeeeee;
}


/* =========================================================
   TOTALS
========================================================= */

.totals-section {
    width: 100%;

    max-width: 360px;

    margin-left: auto;

    margin-top: 26px;
}

.amount-row {
    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 20px;

    padding: 7px 0;

    color: #555;

    font-size: 14px;
}

.amount-row span {
    min-width: 0;
}

.amount-row strong {
    color: #222;

    font-weight: 550;

    white-space: nowrap;

    text-align: right;
}

.total-row {
    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 20px;

    margin-top: 12px;

    padding-top: 17px;

    border-top: 2px solid #222;

    font-size: 20px;
}

.total-row span {
    color: #171717;

    font-weight: 650;
}

.total-row strong {
    color: #111;

    font-weight: 750;

    white-space: nowrap;

    text-align: right;
}


/* =========================================================
   PAYMENT STATUS
========================================================= */

.payment-status {
    width: 100%;

    margin-top: 28px;

    padding: 14px;

    border-radius: 10px;

    background: #e9f8ef;

    color: #168044;

    text-align: center;

    font-size: 14px;

    font-weight: 750;

    letter-spacing: 0.5px;

    text-transform: uppercase;
}


/* =========================================================
   PAYMENT STATUS COLORS
========================================================= */

.payment-status.paid,
.payment-status.completed {
    background: #e9f8ef;

    color: #168044;
}

.payment-status.pending {
    background: #fff7ed;

    color: #c2410c;
}

.payment-status.unpaid {
    background: #fef2f2;

    color: #dc2626;
}

.payment-status.failed {
    background: #fef2f2;

    color: #dc2626;
}


/* =========================================================
   FOOTER
========================================================= */

.invoice-footer {
    width: 100%;

    margin-top: 30px;

    padding-top: 24px;

    border-top: 1px solid #eeeeee;

    text-align: center;
}

.thank-you {
    margin: 0;

    color: #222;

    font-size: 14px;

    font-weight: 550;

    line-height: 1.5;
}

.powered-by {
    margin: 7px 0 0;

    color: #888;

    font-size: 12px;

    line-height: 1.4;
}


/* =========================================================
   PRINT BUTTON
========================================================= */

.print-button {
    width: 100%;

    margin-top: 24px;

    padding: 14px 20px;

    border: 0;

    border-radius: 10px;

    background: #111;

    color: #fff;

    font-size: 15px;

    font-weight: 600;

    cursor: pointer;

    transition:
        transform 0.15s ease,
        opacity 0.15s ease;
}

.print-button:hover {
    opacity: 0.9;
}

.print-button:active {
    transform: scale(0.99);
}


/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 600px) {

    body {
        background: #fff;
    }


    /* -----------------------------------------------------
       INVOICE
    ----------------------------------------------------- */

    .invoice {
        width: 100%;

        margin: 0;

        padding: 28px 20px;

        border-radius: 0;

        box-shadow: none;
    }


    /* -----------------------------------------------------
       HEADER
    ----------------------------------------------------- */

    .invoice-header {
        display: block;

        text-align: center;
    }

    .shop-details {
        text-align: center;
    }

    #shopName {
        font-size: 28px;

        line-height: 1.2;

        text-align: center;
    }

    .shop-address {
        font-size: 14px;

        text-align: center;
    }

    .shop-phone,
    .shop-email {
        font-size: 13px;

        text-align: center;
    }

    .shop-gstin,
    .shop-fssai {
        font-size: 12px;

        text-align: center;
    }

    .invoice-badge {
        display: inline-block;

        margin-top: 14px;
    }


    /* -----------------------------------------------------
       META
    ----------------------------------------------------- */

    .invoice-meta {
        grid-template-columns:
            minmax(0, 1fr)
            minmax(0, 1fr);

        gap: 10px;
    }

    .meta-card {
        padding: 13px;
    }

    .meta-label {
        font-size: 10px;
    }

    .meta-card strong {
        font-size: 13px;
    }


    /* -----------------------------------------------------
       CUSTOMER / ORDER
    ----------------------------------------------------- */

    .information-grid {
        grid-template-columns: 1fr;

        gap: 12px;
    }

    .info-card {
        padding: 16px;
    }


    /* -----------------------------------------------------
       ITEMS
    ----------------------------------------------------- */

    .items-section {
        margin-top: 28px;
    }

    .item-row {
        grid-template-columns:
            minmax(0, 1fr)
            110px;

        min-height: 64px;

        padding: 16px 0 15px;
    }

    .item-details {
        padding-right: 14px;
    }

    .item-name {
        font-size: 15px;

        line-height: 1.45;
    }

    .item-quantity {
        margin-top: 5px;

        font-size: 13px;
    }

    .item-amount {
        font-size: 15px;

        line-height: 1.45;
    }


    /* -----------------------------------------------------
       TOTALS
    ----------------------------------------------------- */

    .totals-section {
        max-width: none;

        margin-top: 22px;
    }

    .amount-row {
        font-size: 14px;
    }

    .total-row {
        font-size: 19px;
    }


    /* -----------------------------------------------------
       PAYMENT
    ----------------------------------------------------- */

    .payment-status {
        margin-top: 24px;

        padding: 13px;

        font-size: 13px;
    }


    /* -----------------------------------------------------
       FOOTER
    ----------------------------------------------------- */

    .invoice-footer {
        margin-top: 26px;

        padding-top: 22px;
    }


    /* -----------------------------------------------------
       PRINT BUTTON
    ----------------------------------------------------- */

    .print-button {
        margin-top: 22px;

        padding: 14px 18px;
    }

}


/* =========================================================
   SMALL PHONES
========================================================= */

@media (max-width: 380px) {

    .invoice {
        padding: 24px 16px;
    }


    /* -----------------------------------------------------
       HEADER
    ----------------------------------------------------- */

    #shopName {
        font-size: 25px;
    }

    .shop-address {
        font-size: 13px;
    }

    .shop-phone,
    .shop-email {
        font-size: 12px;
    }


    /* -----------------------------------------------------
       META
    ----------------------------------------------------- */

    .invoice-meta {
        grid-template-columns: 1fr;
    }


    /* -----------------------------------------------------
       ITEMS
    ----------------------------------------------------- */

    .item-row {
        grid-template-columns:
            minmax(0, 1fr)
            90px;

        padding: 14px 0;
    }

    .item-details {
        padding-right: 10px;
    }

    .item-name {
        font-size: 14px;
    }

    .item-quantity {
        font-size: 12px;
    }

    .item-amount {
        font-size: 14px;
    }


    /* -----------------------------------------------------
       TOTAL
    ----------------------------------------------------- */

    .total-row {
        font-size: 18px;
    }

}


/* =========================================================
   PRINT
========================================================= */

@media print {

    body {
        background: #fff;
    }

    .invoice {
        width: 100%;

        max-width: none;

        margin: 0;

        padding: 20px;

        border-radius: 0;

        box-shadow: none;
    }

    .print-button {
        display: none !important;
    }

    #loading,
    #error {
        display: none !important;
    }

    .item-row {
        break-inside: avoid;

        page-break-inside: avoid;
    }

}