/**
 * Invoice Analyzer Styles
 * Business-forward landing page for invoice upload and product matching
 *
 * @version 1.1.0
 */

/* ==========================================================================
   Container & Layout
   ========================================================================== */

.pis-invoice-analyzer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    color: #333;
}

.pis-invoice-analyzer-container * {
    box-sizing: border-box;
}

/* ==========================================================================
   Hero Section - Clean Business Style
   ========================================================================== */

.pis-invoice-hero {
    text-align: center;
    padding: 50px 30px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    margin-bottom: 30px;
    border: 1px solid #e0e0e0;
}

.pis-invoice-hero h1 {
    font-size: 32px;
    font-weight: 700;
    margin: 0 0 12px 0;
    line-height: 1.2;
    color: #333;
}

.pis-invoice-hero p {
    font-size: 17px;
    color: #555;
    margin: 0;
    max-width: 550px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.5;
}

/* ==========================================================================
   Upload Section
   ========================================================================== */

.pis-invoice-upload-section {
    background: #fff;
    border-radius: 10px;
    padding: 35px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid #e0e0e0;
    margin-bottom: 30px;
}

.pis-invoice-upload-section h3 {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0 0 20px 0;
}

.pis-invoice-dropzone {
    border: 2px dashed #ccc;
    border-radius: 10px;
    padding: 45px 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
}

.pis-invoice-dropzone:hover {
    border-color: #39b54a;
    background: #f0f8f0;
}

.pis-invoice-dropzone.drag-over {
    border-color: #39b54a;
    background: #e8f5e9;
    transform: scale(1.01);
}

.pis-dropzone-content svg {
    color: #999;
    margin-bottom: 14px;
}

.pis-dropzone-content h3 {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0 0 8px 0;
}

.pis-dropzone-content p {
    color: #666;
    margin: 0 0 8px 0;
    font-size: 15px;
}

.pis-dropzone-content small {
    color: #999;
    font-size: 13px;
}

/* File List */
.pis-invoice-file-list {
    margin-top: 20px;
}

.pis-invoice-file-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #f5f5f5;
    border-radius: 8px;
    margin-bottom: 8px;
    gap: 12px;
}

.pis-file-icon {
    width: 32px;
    height: 32px;
    background: #39b54a;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.pis-file-name {
    flex: 1;
    font-weight: 500;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pis-file-size {
    color: #999;
    font-size: 13px;
}

.pis-file-status.uploading {
    color: #39b54a;
    font-size: 13px;
}

.pis-file-remove {
    background: none;
    border: none;
    color: #999;
    font-size: 20px;
    cursor: pointer;
    padding: 0 8px;
    line-height: 1;
    transition: color 0.2s;
}

.pis-file-remove:hover {
    color: #f44336;
}

/* Submit Button */
.pis-invoice-submit-btn {
    display: block;
    width: 100%;
    max-width: 280px;
    margin: 25px auto 0;
    padding: 14px 28px;
    background: #39b54a;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.pis-invoice-submit-btn:hover:not(:disabled) {
    background: #2d9b3c;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(57, 181, 74, 0.3);
}

.pis-invoice-submit-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* ==========================================================================
   Results Section
   ========================================================================== */

.pis-invoice-results-section {
    background: #fff;
    border-radius: 10px;
    padding: 30px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid #e0e0e0;
}

/* Loading State */
.pis-invoice-loading {
    text-align: center;
    padding: 60px 20px;
}

.pis-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e5e7eb;
    border-top-color: #39b54a;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.pis-invoice-loading h3 {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0 0 10px 0;
}

.pis-loading-status {
    color: #666;
    margin: 0 0 20px 0;
}

.pis-progress-bar {
    width: 100%;
    max-width: 400px;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    margin: 0 auto;
    overflow: hidden;
}

.pis-progress-fill {
    height: 100%;
    background: #39b54a;
    border-radius: 4px;
    width: 0;
    transition: width 0.3s ease;
}

/* Results Header */
.pis-results-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid #39b54a;
}

.pis-results-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.pis-results-summary {
    color: #666;
    font-size: 14px;
}

.pis-results-summary span {
    margin-right: 8px;
}

.pis-bulk-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.pis-btn-select-all {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    color: #333;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.pis-btn-select-all:hover {
    background: #f5f5f5;
    border-color: #39b54a;
}

.pis-btn-add-selected {
    padding: 10px 20px;
    background: #39b54a;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.pis-btn-add-selected:hover:not(:disabled) {
    background: #2d9b3c;
}

.pis-btn-add-selected:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* ==========================================================================
   Results Table
   ========================================================================== */

.pis-table-wrapper {
    overflow-x: auto;
}

.pis-invoice-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.pis-invoice-table th {
    background: #f8f9fa;
    padding: 14px 12px;
    font-weight: 600;
    text-align: left;
    color: #333;
    border-bottom: 2px solid #ddd;
    white-space: nowrap;
}

.pis-invoice-table td {
    padding: 14px 12px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
    color: #333;
}

.pis-invoice-table tbody tr:hover {
    background: #fafafa;
}

.pis-invoice-table tbody tr.pis-added-to-cart {
    background: #e8f5e9;
}

/* Column Widths */
.pis-col-checkbox {
    width: 40px;
    text-align: center;
}

.pis-col-divider {
    width: 40px;
    text-align: center;
    color: #ccc;
}

.pis-arrow {
    font-size: 18px;
    color: #999;
}

.pis-col-invoice-item,
.pis-col-match-product {
    min-width: 180px;
}

.pis-col-invoice-price,
.pis-col-match-price {
    min-width: 90px;
    text-align: right;
}

.pis-col-savings {
    min-width: 100px;
    text-align: right;
}

.pis-col-quantity {
    width: 80px;
    text-align: center;
}

.pis-col-action {
    width: 120px;
    text-align: center;
}

/* Row States */
.pis-invoice-row.no-match {
    background: #fef3f2;
}

.pis-invoice-row.no-match:hover {
    background: #fee2e2;
}

/* Item Details */
.pis-item-name {
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
}

.pis-item-sku {
    font-size: 12px;
    color: #777;
}

/* Match Details */
.pis-match-name {
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
}

.pis-match-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pis-match-sku {
    font-size: 12px;
    color: #777;
}

.pis-no-match {
    color: #999;
    font-style: italic;
}

/* Match Confidence Badge */
.pis-match-confidence {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pis-match-confidence.high {
    background: #d4edda;
    color: #155724;
}

.pis-match-confidence.medium {
    background: #fff3cd;
    color: #856404;
}

.pis-match-confidence.low {
    background: #f8d7da;
    color: #721c24;
}

/* Savings Display */
.pis-savings-amount {
    font-weight: 600;
    display: block;
}

.pis-savings-percent {
    font-size: 12px;
    color: #777;
}

.pis-savings-high .pis-savings-amount {
    color: #155724;
}

.pis-savings-medium .pis-savings-amount {
    color: #856404;
}

.pis-savings-low .pis-savings-amount {
    color: #777;
}

/* Quantity Input */
.pis-qty-input {
    width: 60px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    text-align: center;
    font-size: 14px;
    color: #333;
}

.pis-qty-input:focus {
    outline: none;
    border-color: #39b54a;
    box-shadow: 0 0 0 3px rgba(57, 181, 74, 0.1);
}

/* Add to Cart Button */
.pis-btn-add-single {
    padding: 8px 16px;
    background: #39b54a;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.pis-btn-add-single:hover:not(:disabled) {
    background: #2d9b3c;
}

.pis-btn-add-single:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.pis-btn-add-single.added {
    background: #28a745;
}

.pis-btn-add-single.error {
    background: #dc3545;
}

/* Checkbox */
.pis-item-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #39b54a;
}

/* ==========================================================================
   Results Footer
   ========================================================================== */

.pis-results-footer {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #eee;
    text-align: right;
}

.pis-total-savings {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: #e8f5e9;
    padding: 16px 24px;
    border-radius: 8px;
    border: 1px solid #c8e6c9;
}

.pis-savings-label {
    font-weight: 500;
    color: #2d7a3e;
}

.pis-savings-value {
    font-size: 24px;
    font-weight: 700;
    color: #39b54a;
}

/* ==========================================================================
   Cart Summary
   ========================================================================== */

.pis-cart-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 20px;
    background: #e8f5e9;
    border: 1px solid #c8e6c9;
    border-radius: 8px;
    margin-top: 20px;
}

.pis-cart-message {
    font-weight: 600;
    color: #2d7a3e;
    font-size: 16px;
}

.pis-cart-actions {
    display: flex;
    gap: 12px;
}

.pis-btn-view-cart,
.pis-btn-checkout {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
}

.pis-btn-view-cart {
    background: white;
    color: #333;
    border: 1px solid #ddd;
}

.pis-btn-view-cart:hover {
    background: #f5f5f5;
    border-color: #39b54a;
    color: #333;
}

.pis-btn-checkout {
    background: #39b54a;
    color: white;
    border: none;
}

.pis-btn-checkout:hover {
    background: #2d9b3c;
    color: white;
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.pis-invoice-empty {
    text-align: center;
    padding: 60px 20px;
}

.pis-invoice-empty h3 {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0 0 12px 0;
}

.pis-invoice-empty p {
    color: #666;
    max-width: 400px;
    margin: 0 auto;
}

/* ==========================================================================
   Toast Messages
   ========================================================================== */

.pis-toast-message {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 16px 24px;
    border-radius: 8px;
    font-weight: 500;
    z-index: 10000;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 400px;
}

.pis-toast-message.show {
    transform: translateY(0);
    opacity: 1;
}

.pis-toast-success {
    background: #39b54a;
    color: white;
}

.pis-toast-error {
    background: #dc3545;
    color: white;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 1024px) {
    .pis-invoice-hero {
        padding: 40px 20px;
    }

    .pis-invoice-hero h1 {
        font-size: 26px;
    }

    .pis-invoice-upload-section {
        padding: 25px 20px;
    }

    .pis-results-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .pis-bulk-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 768px) {
    .pis-invoice-analyzer-container {
        padding: 10px;
    }

    .pis-invoice-hero {
        padding: 30px 15px;
        border-radius: 10px;
    }

    .pis-invoice-hero h1 {
        font-size: 22px;
    }

    .pis-invoice-hero p {
        font-size: 15px;
    }

    .pis-invoice-dropzone {
        padding: 30px 20px;
    }

    .pis-dropzone-content h3 {
        font-size: 16px;
    }

    .pis-invoice-table {
        font-size: 13px;
    }

    .pis-invoice-table th,
    .pis-invoice-table td {
        padding: 10px 8px;
    }

    .pis-col-divider {
        display: none;
    }

    .pis-cart-summary {
        flex-direction: column;
        text-align: center;
    }

    .pis-cart-actions {
        width: 100%;
        flex-direction: column;
    }

    .pis-btn-view-cart,
    .pis-btn-checkout {
        width: 100%;
        text-align: center;
    }

    .pis-results-footer {
        text-align: center;
    }

    .pis-total-savings {
        flex-direction: column;
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .pis-bulk-actions {
        flex-direction: column;
        width: 100%;
    }

    .pis-btn-select-all,
    .pis-btn-add-selected {
        width: 100%;
        justify-content: center;
    }

    /* Stack table on very small screens */
    .pis-invoice-table thead {
        display: none;
    }

    .pis-invoice-table,
    .pis-invoice-table tbody,
    .pis-invoice-table tr,
    .pis-invoice-table td {
        display: block;
        width: 100%;
    }

    .pis-invoice-table tr {
        margin-bottom: 16px;
        padding: 16px;
        background: #f9fafb;
        border-radius: 8px;
        border: 1px solid #eee;
    }

    .pis-invoice-table tr.no-match {
        background: #fef3f2;
        border-color: #fecaca;
    }

    .pis-invoice-table td {
        padding: 8px 0;
        border: none;
        text-align: left !important;
    }

    .pis-invoice-table td:before {
        content: attr(data-label);
        font-weight: 600;
        color: #666;
        display: block;
        margin-bottom: 4px;
        font-size: 12px;
        text-transform: uppercase;
    }

    .pis-col-checkbox {
        position: absolute;
        top: 16px;
        right: 16px;
    }

    .pis-col-action {
        margin-top: 12px;
    }

    .pis-btn-add-single {
        width: 100%;
    }
}
