@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&display=swap');

body {
    font-family: 'Noto Sans SC', sans-serif;
    line-height: 1.7;
    background-color: #f7f9fc; /* A lighter, more modern blue-ish gray */
    color: #333;
    margin: 0;
    padding: 20px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 800px;
    margin: 20px auto;
    background: #ffffff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 30, 80, 0.1);
}

h1, h2 {
    color: #2c3e50;
    text-align: center;
    margin-bottom: 25px;
}

h1 {
    font-weight: 700;
}

h2 {
    font-weight: 500;
    border-bottom: 1px solid #eef2f7;
    padding-bottom: 15px;
    margin-top: 40px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #5a6e82;
}

.form-group input,
.item input {
    width: 100%;
    padding: 12px;
    border: 1px solid #dcdfe6;
    border-radius: 6px;
    box-sizing: border-box; /* Important */
    transition: all 0.3s ease;
    background-color: #fdfdff;
}

.form-group input:focus,
.item input:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.component-category {
    margin-bottom: 25px;
    padding: 20px;
    border: none;
    border-radius: 8px;
    background-color: #f8f9fa;
    transition: box-shadow 0.3s ease;
}

.component-category:hover {
    box-shadow: 0 4px 16px rgba(0, 30, 80, 0.06);
}

.category-title {
    margin-top: 0;
    margin-bottom: 20px;
    color: #4a90e2;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 10px;
    font-weight: 500;
}

.item {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
    align-items: center;
}

.item:last-child {
    margin-bottom: 0;
}

.item .item-name {
    flex: 4;
}

.item .item-quantity, .item .item-price {
    flex: 1;
}

.item .item-total-label {
    align-self: center;
    font-weight: 500;
    color: #7f8c9b;
}
.item .item-total {
    flex: 1;
    align-self: center;
    font-weight: 700;
    color: #2c3e50;
    min-width: 50px;
}

.grand-total-container {
    margin-top: 30px;
    margin-right: 0;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    text-align: right;
    font-size: 1.25em;
    font-weight: 700;
    color: #2c3e50;
}

.grand-total-container label {
    margin-right: 15px;
    color: #4a90e2;
    font-weight: 500;
}

#grand-total-input {
    padding: 10px;
    border: 1px solid #dcdfe6;
    border-radius: 6px;
    width: 180px;
    font-size: 1em;
    font-weight: 700;
    text-align: right;
    background-color: #fff;
}

#grand-total-input:focus {
    outline: none;
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}


button {
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    margin-top: 10px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

#generate-btn {
    background: linear-gradient(45deg, #4a90e2, #007bff);
    display: block;
    width: 100%;
    font-size: 18px;
}

#print-btn {
    background: linear-gradient(45deg, #6c757d, #5a6268);
    margin-left: 10px;
}

#add-item-btn {
    background-color: #28a745;
    background-image: linear-gradient(45deg, #28a745, #218838);
}

.remove-item-btn {
    background: none;
    border: 1px solid #dc3545;
    color: #dc3545;
    padding: 6px 10px;
    font-size: 14px;
}

.remove-item-btn:hover {
    background-color: #dc3545;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.2);
}

hr {
    margin-top: 30px;
    margin-bottom: 30px;
    border: 0;
    border-top: 1px solid #eef2f7;
}

.hidden {
    display: none;
}

/* --- Styles for Generated Output --- */
/* (These styles remain unchanged) */

#output-container {
    margin-top: 30px;
    padding: 30px;
    border: 1px solid #a4c8e9;
    background: #fff;
    border-radius: 8px;
}
#invoice {
    width: 100%;
    max-width: 800px;
    margin: auto;
    position: relative; /* Required for z-index stacking context */
}

#invoice::before {
    content: "";
    background-image: url("data:image/svg+xml,%3csvg width='180' height='120' xmlns='http://www.w3.org/2000/svg'%3e%3ctext x='50%25' y='50%25' dominant-baseline='middle' text-anchor='middle' transform='rotate(-30, 90, 60)' style='font-size:22px;font-weight:bold;fill:rgba(74,144,226,0.08);'%3eCloudstar%3c/text%3e%3c/svg%3e");
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2; /* Watermark layer */
    pointer-events: none;
}

#invoice > * {
    position: relative;
    z-index: 1; /* Content layer (default) */
}

#invoice .header {
    text-align: center;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-bottom: 2px solid #4a90e2;
    padding-bottom: 15px;
}

#invoice .header h1 {
    margin: 0;
    color: #2c3e50;
    font-size: 24px;
    margin-top: 10px;
}

.logo {
    max-width: 180px;
    height: auto;
}

#invoice .info {
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

#invoice .info p {
    margin: 0;
    flex: 1; /* Distribute space evenly */
    min-width: 240px; /* Adjust for better wrapping */
}

#output-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    /* The table itself is part of the content layer */
}

#output-table th, #output-table td {
    border: 1px solid #ddd;
    padding: 12px;
    text-align: left;
}

#output-table th {
    background-color: #4a90e2; /* Restore solid color */
    color: white; /* Restore text color */
}

#output-table tfoot td {
    font-weight: bold;
    background-color: #f0f8ff; /* Restore fill color */
}

#invoice .footer {
    margin-top: 40px;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#invoice .footer p {
    margin: 10px 0;
}

#invoice .seal-container {
    position: absolute;
    top: -120px;
    right: 30px;
    text-align: center;
    z-index: 3; /* Seal layer, on top of watermark */
}

.seal-image {
    width: 150px; /* Increased size */
    height: 150px; /* Increased size */
    opacity: 0.75;
}

@media print {
    body {
        background-color: #fff;
        padding: 0;
        margin: 0;
    }
    .container, #generate-btn, #print-btn, #add-item-btn, .remove-item-btn, #info-form, h2, hr, .grand-total-container {
        display: none;
    }

    /* Force printing of background colors and images */
    #invoice, #output-table th, #output-table tfoot td {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    #output-container {
        display: block;
        border: none;
        box-shadow: none;
        margin: 0;
        padding: 0;
    }
    #invoice {
        width: 100%;
        max-width: 100%;
        box-shadow: none;
    }

    .seal-image {
        opacity: 0.75; /* Keep opacity for printing */
    }
} 