* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f4f6f8;
    color: #222;
}

.container {
    max-width: 700px;
    margin: 40px auto;
    padding: 20px;
}


/* HEADINGS */

h1 {
    text-align: center;
    margin-bottom: 8px;
}

h2 {
    margin-top: 0;
    margin-bottom: 20px;
}

.subtitle {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
}


/* CARDS */

.card {
    background: white;
    padding: 25px;
    margin-bottom: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}


/* FORM */

label {
    display: block;
    margin-top: 15px;
    margin-bottom: 6px;
    font-weight: bold;
}

input,
textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 7px;
    font-size: 16px;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    user-select: none;
}

.checkbox-label input {
    width: auto;
}


/* BUTTONS */

button {
    width: 100%;
    margin-top: 20px;
    padding: 14px;
    border: none;
    border-radius: 7px;
    background: #222;
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
}

button:hover {
    background: #444;
}

#australiaQuoteGuide a,
.info-section>p a {
    color: #7657d9;
}

#australiaQuoteGuide a:hover,
.info-section>p a:hover {
    color: #7657d9;
}

.secondary-button {
    background: #7657d9;
}

.secondary-button:hover {
    background: #6346c2;
}


/* QUOTE NUMBER + DATE */

.quote-meta {
    margin-bottom: 20px;
}

.meta-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.meta-row strong {
    min-width: 80px;
}

.edit-button {
    width: 28px;
    height: 28px;
    margin: 0;
    padding: 0;
    background: #f1f3f5;
    color: #555;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-weight: normal;
}

.edit-button:hover {
    background: #e5e7eb;
    color: #222;
}

/* COUNTRY SELECTOR */

.country-selector {
    width: 100%;
    max-width: 280px;
    margin: -10px auto 30px;
    text-align: center;
}

.country-selector>label {
    display: block;
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 600;
    color: #444;
}

.native-country-select {
    display: none !important;
}

.custom-country-selector {
    position: relative;
    width: 100%;
    text-align: left;
}

.country-selector-button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 46px;
    margin: 0;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #fff;
    color: #222;
    font-family: inherit;
    font-size: 15px;
    font-weight: normal;
    text-align: left;
}

.country-selector-button:hover {
    background: #f9fafb;
}

.country-selector-button:focus-visible {
    outline: 2px solid #7657d9;
    outline-offset: 2px;
}

.country-selector-button img,
.country-option img {
    width: 28px;
    height: 19px;
    object-fit: cover;
    border: 1px solid #eee;
    border-radius: 2px;
    flex-shrink: 0;
}

.country-selector-arrow {
    width: 8px;
    height: 8px;
    margin-left: auto;
    border-right: 2px solid #666;
    border-bottom: 2px solid #666;
    transform: rotate(45deg) translateY(-2px);
}

.country-selector-options {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    z-index: 100;
    padding: 5px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.country-selector-options[hidden] {
    display: none;
}

.country-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    margin: 0;
    padding: 11px 9px;
    border: none;
    border-radius: 5px;
    background: #fff;
    color: #222;
    font-family: inherit;
    font-size: 14px;
    font-weight: normal;
    text-align: left;
    cursor: pointer;
}

.country-option:hover,
.country-option[aria-selected="true"] {
    background: #f1effb;
}

.country-option:focus-visible {
    outline: 2px solid #7657d9;
    outline-offset: -2px;
}

#australiaQuoteGuide[hidden] {
    display: none;
}

/* EDIT WINDOWS */

.edit-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.edit-window {
    width: 100%;
    max-width: 400px;
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.edit-window h3 {
    margin-top: 0;
    margin-bottom: 18px;
}

.edit-window input {
    width: 100%;
}

.edit-window-buttons {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.edit-window-buttons button {
    margin-top: 0;
}

.cancel-edit {
    background: #f1f3f5;
    color: #333;
}

.cancel-edit:hover {
    background: #e2e5e8;
}

.save-edit {
    background: #7657d9;
}

.save-edit:hover {
    background: #6346c2;
}


/* QUOTE ITEMS */

.quote-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 80px 100px minmax(120px, 150px) 40px;
    gap: 10px;
    align-items: end;
    margin-bottom: 15px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    min-width: 0;
}

.quote-item .item-field {
    min-width: 0;
}

.quote-item input {
    min-width: 0;
    width: 100%;
}

.quote-item input {
    margin: 0;
}

.item-field {
    display: flex;
    flex-direction: column;
}

.item-field label {
    margin-top: 0;
    margin-bottom: 6px;
    font-size: 13px;
    color: #666;
}

.help-label {
    display: flex;
    align-items: center;
    gap: 5px;
}

.help-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border: 1px solid #999;
    border-radius: 50%;
    color: #666;
    font-size: 10px;
    font-weight: bold;
    line-height: 1;
    cursor: help;
}

.help-tooltip {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    width: 220px;
    padding: 8px 10px;
    background: #222;
    color: #fff;
    border-radius: 6px;
    font-size: 12px;
    font-weight: normal;
    line-height: 1.4;
    text-align: left;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 100;
}

.help-tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: #222 transparent transparent transparent;
}

.help-icon:hover .help-tooltip,
.help-icon:focus .help-tooltip {
    visibility: visible;
    opacity: 1;
}

.remove-item {
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    background: #ffa0a0;
    color: #070707;
    border: 1px solid #ddd;
    border-radius: 7px;
    font-size: 16px;
    font-weight: normal;
}

.remove-item:hover {
    background: #e5e7eb;
    color: #222;
}


/* QUOTE PREVIEW */

.result {
    border: 2px solid #222;
}

.quote-header {
    text-align: left;
}

.quote-header h2 {
    text-align: left;
    margin-bottom: 20px;
    font-size: 32px;
    letter-spacing: 1px;
}

.quote-meta-preview {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "title title"
        "number date";
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #ddd;
}

.quote-meta-preview h2 {
    grid-area: title;
    margin-bottom: 20px;
}

.quote-meta-preview p:nth-of-type(1) {
    grid-area: number;
}

.quote-meta-preview p:nth-of-type(2) {
    grid-area: date;
    text-align: right;
}

.quote-meta-preview p {
    margin: 0;
    color: #555;
}

.quote-meta-preview strong {
    color: #222;
}

.quote-header p {
    margin: 6px 0;
}

#previewDocumentTitle {
    overflow-wrap: anywhere;
    word-break: normal;
    max-width: 100%;
}


/* BUSINESS DETAILS */

.business-preview {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    margin-top: 25px;
}

.business-preview strong {
    font-size: 20px;
    margin-bottom: 6px;
}

.business-preview span {
    color: #666;
    font-size: 14px;
    white-space: pre-line;
}

.business-preview span:empty {
    display: none;
}

#previewBusinessName,
#previewBusinessEmail,
#previewBusinessPhone,
#previewBusinessAddress,
#previewABN {
    display: block;
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: normal;
}


/* CUSTOMER */

.customer-preview {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.customer-preview h3,
.notes-preview h3 {
    margin: 0 0 12px;
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #666;
}

.customer-preview p {
    margin: 5px 0;
    color: #555;
}

.customer-preview p:first-of-type {
    font-size: 17px;
    font-weight: bold;
    color: #222;
}

.customer-preview p:empty {
    display: none;
}

#previewCustomerName,
#previewCustomerEmail,
#previewCustomerPhone,
#previewCustomerAddress {
    overflow-wrap: anywhere;
    word-break: normal;
    max-width: 100%;
}


/* ITEMS PREVIEW */

.items-preview {
    margin-top: 35px;
}

.items-header,
.preview-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 20px;
    padding: 14px 0;
    border-bottom: 1px solid #eee;
}

.items-header {
    border-bottom: 2px solid #222;
    font-weight: bold;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #555;
}

.preview-item span {
    color: #555;
    line-height: 1.4;
}

.preview-item strong {
    font-size: 15px;
    color: #222;
}

.items-header span:last-child,
.preview-item strong {
    text-align: right;
}

#previewQuoteNotes,
.preview-item>span {
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: normal;
}

.preview-item>strong {
    flex-shrink: 0;
}


/* TOTALS */

.totals {
    margin-top: 20px;
}

.totals p {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 20px;
    margin: 0;
    padding: 2px 0;
}

.totals p strong {
    text-align: right;
    font-weight: bold;
}

.totals .grand-total {
    border: none;
    margin-top: 2px;
    padding-top: 2px;
    font-size: 20px;
    font-weight: bold;
}

.totals .grand-total span,
.totals .grand-total strong {
    font-weight: bold;
}


/* NOTES */

.notes-preview {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.notes-preview h3 {
    margin: 0 0 12px;
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #666;
}

.notes-preview p {
    margin: 0;
    white-space: pre-line;
    line-height: 1.5;
}

/* QUOTE ACTIONS */

.quote-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 40px;
}

.quote-actions .print-button,
.quote-actions .pdf-button {
    flex: 1;
}

.quote-actions .new-quote-button {
    flex-basis: 100%;
}

.quote-actions button {
    margin-top: 0;
}

.pdf-button {
    background: #222;
}

.pdf-button:hover {
    background: #444;
}

.new-quote-button {
    background: #7657d9;
}

.new-quote-button:hover {
    background: #6346c2;
}

.tax-section {
    margin-top: 15px;
}

.tax-section input[type="number"] {
    width: 100%;
    max-width: 150px;
    position: relative;
    z-index: 2;
}

.tax-section>label:not(.checkbox-label) {
    position: relative;
    z-index: 0;
    width: fit-content;
}

/* PRINT */

@page {
    size: A4;
    margin: 0;
}

@media print {

    html,
    body {
        margin: 0;
        padding: 0;
        background: white;
    }

    .container {
        max-width: none;
        margin: 0;
        padding: 0;
    }

    .site-header,
    .info-section,
    .site-footer,
    .quote-actions {
        display: none !important;
    }

    .container>h1,
    .container>.subtitle,
    .container>.card:not(.result) {
        display: none !important;
    }

    .result {
        display: block !important;
        width: 100%;
        margin: 0;
        padding: 20mm;
        border: none;
        box-shadow: none;
        border-radius: 0;
    }

    .business-preview span,
    .customer-preview h3,
    .notes-preview h3 {
        color: #222;
    }

    .quote-item,
    .quote-totals,
    .quote-notes {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .quote-header {
        break-after: avoid;
        page-break-after: avoid;
    }
}

/* INFORMATION SECTION */

.info-section {
    margin: 40px 0 20px;
    padding: 30px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
}

.info-section h2 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 24px;
    color: #222;
}

.info-section h3 {
    margin-top: 25px;
    margin-bottom: 10px;
    font-size: 18px;
    color: #333;
}

.info-section p {
    margin: 0 0 15px;
    line-height: 1.6;
    color: #555;
}

.info-section ol {
    margin: 0 0 15px;
    padding-left: 25px;
    color: #555;
    line-height: 1.8;
}

/* RESPONSIVE QUOTE ITEMS */

@media (min-width: 601px) and (max-width: 850px) {
    .quote-item {
        grid-template-columns: minmax(0, 1fr) 80px 100px 40px;
    }

    .quote-item .item-description-field {
        grid-column: 1 / -1;
    }

    .quote-item .item-price-field {
        grid-column: 1 / 4;
    }

    .quote-item .remove-item {
        grid-column: 4;
        grid-row: auto;
        width: 40px;
    }
}

/* Smaller mobile screens */
@media (max-width: 600px) {
    .quote-item {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 10px;
    }

    .quote-item .item-description-field,
    .quote-item .item-price-field {
        grid-column: 1 / -1;
    }

    .quote-item .item-quantity-field,
    .quote-item .item-unit-field {
        grid-column: auto;
    }

    .quote-item .remove-item {
        grid-column: 1 / -1;
        grid-row: auto;
        width: 100%;
    }

    .country-selector {
        max-width: 100%;
    }

    .info-section {
        padding: 20px;
    }

    .quote-meta-preview {
        column-gap: 12px;
    }

    .quote-header h2 {
        font-size: 26px;
    }
}

/* ACCESSIBILITY: KEYBOARD FOCUS */

:where(button,
    input,
    textarea,
    select,
    a,
    [tabindex]:not([tabindex="-1"])):focus-visible {
    outline: 3px solid #7657d9;
    outline-offset: 3px;
}

button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
textarea:focus:not(:focus-visible),
select:focus:not(:focus-visible) {
    outline: none;
}

.help-icon:focus-visible {
    outline: 3px solid #7657d9;
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* HIDE PRINT BUTTON ON TABLETS AND MOBILE */

@media (max-width: 850px) {
    .quote-actions .print-button {
        display: none;
    }
}