/* =========================================================
   BRIOCOM SOLUTIONS — CLEAN INVOICE GENERATOR
   ========================================================= */

/* =========================
   ROOT VARIABLES
   ========================= */

:root {
    --red: #dc2626;
    --red-dark: #991b1b;
    --red-light: #ef4444;

    --black: #050505;
    --black-2: #0b0b0b;
    --black-3: #111111;

    --white: #ffffff;
    --white-soft: #f7f7f7;

    --text: #171717;
    --text-soft: #525252;
    --text-muted: #737373;

    --border: #dedede;
    --border-light: #e8e8e8;

    --radius: 10px;
    --radius-lg: 14px;

    --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    --shadow-paper: 0 18px 50px rgba(0, 0, 0, 0.16);

    --container: 900px;
}


/* =========================
   RESET
   ========================= */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    background: #f5f5f5;
    color: var(--text);
    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Arial,
        sans-serif;
    line-height: 1.5;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

img {
    max-width: 100%;
    display: block;
}


/* =========================
   HOME BUTTON
   ========================= */

.invoice-home-btn {
    position: fixed;
    top: 22px;
    left: 22px;
    z-index: 1000;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 42px;
    padding: 0 18px;

    background: var(--black);
    color: var(--white);

    border: 1px solid var(--black);
    border-radius: 8px;

    text-decoration: none;
    font-size: 14px;
    font-weight: 600;

    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.2s ease;
}

.invoice-home-btn:hover {
    background: var(--red);
    border-color: var(--red);
    transform: translateY(-1px);
}


/* =========================
   MAIN PAGE
   ========================= */

.invoice-page {
    width: 100%;
    max-width: var(--container);
    margin: 0 auto;
    padding: 80px 24px 70px;
}


/* =========================
   PAGE HEADER
   ========================= */

.invoice-page-header {
    text-align: center;
    margin-bottom: 38px;
}

.invoice-page-header .eyebrow {
    display: block;
    margin-bottom: 8px;

    color: var(--red);

    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.invoice-page-header h1 {
    margin-bottom: 10px;

    color: var(--black);

    font-size: clamp(30px, 4vw, 46px);
    font-weight: 800;
    line-height: 1.1;
}

.invoice-page-header p {
    max-width: 650px;
    margin: 0 auto;

    color: var(--text-soft);

    font-size: 15px;
}


/* =========================
   FORM SECTION
   ========================= */

.invoice-form-section {
    width: 100%;
}

.invoice-card {
    background: var(--white);

    border: 1px solid var(--border);
    border-radius: var(--radius-lg);

    padding: 34px;

    box-shadow: var(--shadow);
}


/* =========================
   SECTION TITLES
   ========================= */

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;

    margin: 0 0 22px;
    padding-bottom: 12px;

    border-bottom: 2px solid var(--black);
}

.section-title:not(:first-child) {
    margin-top: 38px;
}

.section-title h2 {
    color: var(--black);

    font-size: 18px;
    font-weight: 750;
    line-height: 1.2;
}

.section-title h2::before {
    content: "";
    display: inline-block;

    width: 4px;
    height: 18px;

    margin-right: 9px;

    vertical-align: -3px;

    background: var(--red);
    border-radius: 2px;
}


/* =========================
   FORM GRID
   ========================= */

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.form-group {
    min-width: 0;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    display: block;
    margin-bottom: 7px;

    color: #222;

    font-size: 13px;
    font-weight: 700;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;

    background: var(--white);
    color: var(--text);

    border: 1px solid #cfcfcf;
    border-radius: 7px;

    outline: none;

    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.form-group input,
.form-group select {
    min-height: 44px;
    padding: 0 13px;
}

.form-group textarea {
    min-height: 90px;
    padding: 12px 13px;

    resize: vertical;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #999;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--red);

    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.10);
}


/* =========================
   LOGO UPLOAD
   ========================= */

.logo-upload-group {
    position: relative;
}

.input-help {
    display: block;
    margin-top: 6px;

    color: var(--text-muted);
    font-size: 12px;
}

.logo-upload-preview {
    display: flex;
    align-items: center;
    justify-content: center;

    min-height: 100px;
    margin-top: 12px;
    padding: 12px;

    background: #fafafa;

    border: 1px dashed #cfcfcf;
    border-radius: 8px;

    color: #888;
    font-size: 13px;

    text-align: center;
}

.logo-upload-preview img {
    max-width: 180px;
    max-height: 90px;
    object-fit: contain;
}

.remove-logo-btn {
    margin-top: 10px;
}


/* =========================
   ITEMS HEADING
   ========================= */

.items-heading {
    align-items: center;
}

.add-item-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-height: 38px;
    padding: 0 14px;

    background: var(--red);
    color: var(--white);

    border: 1px solid var(--red);
    border-radius: 7px;

    font-size: 13px;
    font-weight: 700;

    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.2s ease;
}

.add-item-btn:hover {
    background: var(--red-dark);
    border-color: var(--red-dark);
    transform: translateY(-1px);
}


/* =========================
   ITEMS TABLE
   ========================= */

.items-table-wrapper {
    width: 100%;
    overflow-x: auto;

    border: 1px solid var(--border);
    border-radius: 8px;
}

.items-table {
    width: 100%;
    min-width: 700px;

    border-collapse: collapse;

    background: var(--white);
}

.items-table thead {
    background: var(--black);
}

.items-table th {
    padding: 12px 13px;

    color: var(--white);

    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-align: left;
    text-transform: uppercase;
}

.items-table td {
    padding: 10px;

    border-top: 1px solid var(--border-light);

    vertical-align: middle;
}

.items-table input {
    width: 100%;
    min-height: 38px;

    padding: 0 9px;

    border: 1px solid #d3d3d3;
    border-radius: 6px;

    outline: none;

    font-size: 13px;
}

.items-table input:focus {
    border-color: var(--red);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
}

.items-table td:nth-child(2),
.items-table td:nth-child(3),
.items-table td:nth-child(4) {
    text-align: right;
}

.items-table th:nth-child(2),
.items-table th:nth-child(3),
.items-table th:nth-child(4) {
    text-align: right;
}

.items-table th:last-child,
.items-table td:last-child {
    text-align: center;
}


/* =========================
   TOTALS
   ========================= */

.totals-section {
    display: flex;
    justify-content: flex-end;

    margin-top: 25px;
}

.totals-box {
    width: min(100%, 380px);

    border: 1px solid var(--border);
    border-radius: 8px;

    overflow: hidden;

    background: #fafafa;
}

.total-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;

    min-height: 48px;
    padding: 8px 15px;

    border-bottom: 1px solid var(--border-light);

    font-size: 13px;
}

.total-row:last-child {
    border-bottom: 0;
}

.total-row span {
    color: #444;
    font-weight: 600;
}

.total-row strong {
    color: var(--black);
    font-weight: 750;
}

.total-row input {
    width: 100px;
    min-height: 36px;

    padding: 0 9px;

    border: 1px solid #ccc;
    border-radius: 6px;

    background: var(--white);

    text-align: right;
    outline: none;
}

.total-row input:focus {
    border-color: var(--red);
}

.total-row.grand-total {
    min-height: 58px;

    background: var(--black);
}

.total-row.grand-total span {
    color: var(--white);

    font-size: 14px;
    font-weight: 800;
}

.total-row.grand-total strong {
    color: var(--white);

    font-size: 18px;
}


/* =========================
   PREVIEW SECTION
   ========================= */

.preview-section {
    width: 100%;
    margin-top: 45px;
}

.preview-section-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;

    margin-bottom: 18px;
}

.preview-eyebrow {
    display: block;
    margin-bottom: 5px;

    color: var(--red);

    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.preview-section-header h2 {
    margin-bottom: 4px;

    color: var(--black);

    font-size: 24px;
    font-weight: 800;
}

.preview-section-header p {
    color: var(--text-soft);
    font-size: 14px;
}


/* =========================
   PREVIEW STATUS
   ========================= */

.preview-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;

    padding: 7px 11px;

    background: #f0fdf4;
    color: #166534;

    border: 1px solid #bbf7d0;
    border-radius: 999px;

    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.08em;
}

.preview-status::before {
    content: "";

    width: 7px;
    height: 7px;

    background: #22c55e;
    border-radius: 50%;
}


/* =========================
   PREVIEW CARD
   ========================= */

.preview-card {
    position: relative;

    padding: 35px;

    background:
        radial-gradient(
            circle at top center,
            rgba(220, 38, 38, 0.08),
            transparent 40%
        ),
        #111111;

    border: 1px solid #262626;
    border-radius: 18px;

    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.02),
        0 15px 40px rgba(0, 0, 0, 0.12);

    overflow: auto;
}

.preview-label {
    margin-bottom: 18px;

    color: #8f8f8f;

    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    text-align: center;
}


/* =========================================================
   INVOICE PAPER — KEEP THIS STYLE AS THE MAIN PREVIEW
   ========================================================= */

.invoice-preview {
    position: relative;

    width: 794px;
    min-height: 1123px;
    max-width: 100%;

    margin: 0 auto;
    padding: 60px;

    background: #ffffff;
    color: #111111;

    border: 1px solid #dddddd;

    box-shadow: 0 18px 45px rgba(0, 0, 0, 0.22);

    overflow: hidden;

    font-family:
        Arial,
        Helvetica,
        sans-serif;

    font-size: 13px;
    line-height: 1.5;
}

.invoice-preview::before {
    content: "";

    position: absolute;
    top: 0;
    left: 0;

    width: 100%;
    height: 6px;

    background: #dc2626;
}


/* =========================
   PREVIEW HEADER
   ========================= */

.preview-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 50px;

    padding-bottom: 25px;

    border-bottom: 1px solid #d9d9d9;
}

.preview-business {
    flex: 1;
    min-width: 0;
}

.preview-business h2 {
    margin-bottom: 7px;

    color: #111111;

    font-size: 26px;
    font-weight: 800;
    line-height: 1.15;
}

.preview-business p {
    margin: 2px 0;

    color: #666666;

    font-size: 11px;
    line-height: 1.5;
}

.preview-logo-container {
    width: 160px;
    min-height: 70px;

    margin-bottom: 12px;

    display: flex;
    align-items: flex-start;
}

.preview-logo {
    display: block;

    max-width: 160px;
    max-height: 75px;

    object-fit: contain;
}

.preview-meta {
    min-width: 190px;

    text-align: right;
}

.preview-invoice-title {
    margin-bottom: 8px;

    color: #dc2626;

    font-size: 34px;
    font-weight: 900;
    line-height: 1;
    letter-spacing: -0.02em;
}

.preview-meta p {
    margin: 3px 0;

    color: #666666;

    font-size: 11px;
}

.preview-meta strong {
    color: #111111;
}


/* =========================
   CUSTOMER SECTION
   ========================= */

.preview-customer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 50px;

    padding: 28px 0;

    border-bottom: 1px solid #d9d9d9;
}

.preview-section-title {
    margin-bottom: 7px;

    color: #dc2626;

    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.preview-customer p {
    margin: 2px 0;

    color: #666666;

    font-size: 11px;
    line-height: 1.5;
}

.preview-customer strong {
    color: #111111;
}


/* =========================
   PREVIEW ITEMS
   ========================= */

.preview-items {
    width: 100%;

    margin-top: 30px;

    border-collapse: collapse;
    table-layout: fixed;

    font-size: 11px;
}

.preview-items thead {
    background: #111111;
}

.preview-items th {
    padding: 10px 9px;

    color: #ffffff;

    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-align: left;
    text-transform: uppercase;
}

.preview-items td {
    padding: 10px 9px;

    color: #555555;

    border-bottom: 1px solid #e1e1e1;

    font-size: 11px;
    vertical-align: top;
}

.preview-items th:nth-child(1),
.preview-items td:nth-child(1) {
    width: 46%;
}

.preview-items th:nth-child(2),
.preview-items td:nth-child(2) {
    width: 14%;

    text-align: right;
}

.preview-items th:nth-child(3),
.preview-items td:nth-child(3) {
    width: 20%;

    text-align: right;
}

.preview-items th:nth-child(4),
.preview-items td:nth-child(4) {
    width: 20%;

    text-align: right;
}

.preview-items td strong {
    color: #111111;
    font-weight: 700;
}


/* =========================
   PREVIEW TOTALS
   ========================= */

.preview-totals {
    width: 290px;
    max-width: 100%;

    margin: 24px 0 0 auto;
}

.preview-total-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;

    padding: 6px 0;

    color: #555555;

    font-size: 11px;
}

.preview-total-row strong {
    color: #111111;
}

.preview-total-row:last-child {
    margin-top: 8px;
    padding-top: 10px;

    border-top: 2px solid #111111;

    color: #111111;

    font-size: 15px;
    font-weight: 800;
}

.preview-total-row:last-child strong {
    color: #dc2626;

    font-size: 18px;
}


/* =========================
   PREVIEW NOTES
   ========================= */

.preview-notes {
    margin-top: 45px;
    padding-top: 20px;

    border-top: 1px solid #dddddd;
}

.preview-notes-title {
    margin-bottom: 6px;

    color: #111111;

    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.preview-notes p {
    color: #666666;

    font-size: 10px;
    line-height: 1.6;
}


/* =========================
   ACTION BUTTONS
   ========================= */

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;

    margin-top: 22px;
}

.action-buttons button {
    min-height: 44px;

    padding: 0 18px;

    border-radius: 7px;

    font-size: 13px;
    font-weight: 700;

    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease;
}

.action-buttons button:hover {
    transform: translateY(-1px);
}


/* Primary */

.primary-btn {
    background: var(--red);
    color: var(--white);

    border: 1px solid var(--red);
}

.primary-btn:hover {
    background: var(--red-dark);
    border-color: var(--red-dark);
}


/* PDF */

.pdf-btn {
    background: var(--black);
    color: var(--white);

    border: 1px solid var(--black);
}

.pdf-btn:hover {
    background: #262626;
    border-color: #262626;
}


/* Secondary */

.secondary-btn {
    background: var(--white);
    color: #222222;

    border: 1px solid #cfcfcf;
}

.secondary-btn:hover {
    background: #f3f3f3;
    border-color: #aaa;
}


/* Danger */

.danger-btn {
    background: #fff;
    color: var(--red);

    border: 1px solid #efb2b2;
}

.danger-btn:hover {
    background: #fef2f2;
    border-color: var(--red);
}


/* =========================
   RESPONSIVE PREVIEW
   ========================= */

@media (max-width: 900px) {

    .invoice-page {
        padding: 75px 18px 50px;
    }

    .invoice-card {
        padding: 25px;
    }

    .preview-card {
        padding: 25px;
    }

    .invoice-preview {
        padding: 45px;
    }

    .preview-header {
        gap: 30px;
    }
}


@media (max-width: 800px) {

    .preview-card {
        padding: 20px;
    }

    .invoice-preview {
        width: 100%;
        min-height: auto;
        padding: 40px;
    }

    .form-grid {
        gap: 16px;
    }
}


@media (max-width: 700px) {

    .invoice-page-header h1 {
        font-size: 32px;
    }

    .invoice-card {
        padding: 20px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-group.full-width {
        grid-column: auto;
    }

    .section-title {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    .items-heading {
        flex-direction: row;
        align-items: center;
    }

    .preview-section-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .action-buttons {
        display: grid;
        grid-template-columns: 1fr;
    }

    .action-buttons button {
        width: 100%;
    }
}


@media (max-width: 600px) {

    .invoice-home-btn {
        top: 14px;
        left: 14px;

        min-height: 38px;
        padding: 0 13px;

        font-size: 12px;
    }

    .invoice-page {
        padding: 68px 12px 40px;
    }

    .invoice-page-header {
        margin-bottom: 28px;
    }

    .invoice-page-header h1 {
        font-size: 28px;
    }

    .invoice-page-header p {
        font-size: 13px;
    }

    .invoice-card {
        padding: 16px;
        border-radius: 10px;
    }

    .preview-card {
        padding: 15px;
        border-radius: 12px;
    }

    .invoice-preview {
        padding: 28px;
    }

    .preview-header {
        flex-direction: column;
        gap: 25px;
    }

    .preview-meta {
        width: 100%;
        text-align: left;
    }

    .preview-invoice-title {
        font-size: 28px;
    }

    .preview-business h2 {
        font-size: 22px;
    }

    .preview-customer {
        grid-template-columns: 1fr;
        gap: 22px;
    }

    .preview-items {
        font-size: 10px;
    }

    .preview-items th {
        padding: 8px 6px;
        font-size: 8px;
    }

    .preview-items td {
        padding: 8px 6px;
        font-size: 10px;
    }

    .preview-totals {
        width: 100%;
    }
}


@media (max-width: 420px) {

    .invoice-page {
        padding-left: 8px;
        padding-right: 8px;
    }

    .invoice-card {
        padding: 13px;
    }

    .preview-card {
        padding: 10px;
    }

    .invoice-preview {
        padding: 22px 18px;
    }

    .preview-logo-container {
        width: 130px;
    }

    .preview-logo {
        max-width: 130px;
    }

    .preview-invoice-title {
        font-size: 25px;
    }

    .preview-items th,
    .preview-items td {
        padding-left: 5px;
        padding-right: 5px;
    }
}


/* =========================
   LIGHT PREVIEW SUPPORT
   ========================= */

.preview-card.light-mode {
    background: #f1f1f1;
}


/* =========================
   PRINT
   ========================= */

@media print {

    @page {
        size: Letter;
        margin: 0;
    }

    html,
    body {
        width: 100%;
        min-height: 100%;

        background: #ffffff !important;
    }

    body {
        margin: 0;
        padding: 0;
    }

    .invoice-home-btn,
    .invoice-page-header,
    .invoice-form-section,
    .preview-section-header,
    .preview-label,
    .preview-status,
    .action-buttons {
        display: none !important;
    }

    .invoice-page {
        width: 100%;
        max-width: none;

        margin: 0;
        padding: 0;
    }

    .preview-section {
        display: block;

        width: 100%;
        margin: 0;
        padding: 0;
    }

    .preview-card {
        display: block;

        width: 100%;
        margin: 0;
        padding: 0;

        background: #ffffff !important;

        border: 0;
        border-radius: 0;

        box-shadow: none;

        overflow: visible;
    }

    .invoice-preview {
        width: 794px;
        min-height: 1123px;

        margin: 0;
        padding: 60px;

        background: #ffffff !important;

        border: 0;
        box-shadow: none;

        overflow: visible;
    }

    .invoice-preview::before {
        display: block;
    }
}


/* =========================
   PRINT SAFETY
   ========================= */

@media print {

    .invoice-preview,
    .invoice-preview * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .preview-items thead {
        background: #111111 !important;
    }

    .preview-items th {
        color: #ffffff !important;
    }

    .preview-invoice-title,
    .preview-section-title,
    .preview-total-row:last-child strong {
        color: #dc2626 !important;
    }
}