/**
 * Trade Portal front-end styles.
 *
 * Matches the approved mockup (trade-portal-preview-v2.html)
 * with the Nutural World brand colours and Public Sans font.
 */

:root {
    --tcp-primary: #714007;
    --tcp-primary-dark: #5a3306;
    --tcp-primary-light: #8a5a1e;
    --tcp-secondary: #f9f6f0;
    --tcp-accent: #d4a574;
    --tcp-text: #3a3a3a;
    --tcp-text-light: #7a7a7a;
    --tcp-border: #e0dbd2;
    --tcp-success: #28a745;
    --tcp-warning: #ffc107;
    --tcp-danger: #dc3545;
    --tcp-white: #ffffff;
    --tcp-shadow: 0 2px 4px rgba(0,0,0,0.1);
    --tcp-shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
    --tcp-radius: 8px;
    --tcp-radius-sm: 4px;
}

/* Container */
.tcp-portal-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 10px;
    font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--tcp-text);
}

/* Portal Header */
.tcp-portal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding: 20px 30px;
    background: var(--tcp-white);
    box-shadow: var(--tcp-shadow);
    border-bottom: 2px solid var(--tcp-primary);
    border-radius: var(--tcp-radius);
}

.tcp-portal-welcome h1 {
    color: var(--tcp-primary);
    margin: 0 0 5px 0;
    font-size: 28px;
    font-weight: 600;
}

.tcp-portal-welcome p {
    color: var(--tcp-text-light);
    margin: 0;
    font-size: 14px;
}

.tcp-payment-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 10px;
    vertical-align: middle;
}

.tcp-payment-badge.tcp-payment-proforma {
    background: #e8f5e9;
    color: #2e7d32;
}

.tcp-payment-badge.tcp-payment-net_30 {
    background: #fff3e0;
    color: #e65100;
}

.tcp-portal-actions {
    display: flex;
    gap: 10px;
}

/* Buttons */
.tcp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--tcp-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-family: inherit;
}

.tcp-btn-primary {
    background: var(--tcp-primary);
    color: var(--tcp-white);
}

.tcp-btn-primary:hover {
    background: var(--tcp-primary-dark);
}

.tcp-btn-outline {
    background: transparent;
    color: var(--tcp-primary);
    border: 2px solid var(--tcp-primary);
}

.tcp-btn-outline:hover {
    background: var(--tcp-primary);
    color: var(--tcp-white);
    text-decoration: none;
}

.tcp-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.tcp-btn-full {
    width: 100%;
    margin-top: 15px;
    padding: 14px;
    font-size: 16px;
}

/* Legend */
.tcp-legend {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    font-size: 13px;
}

.tcp-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tcp-legend-color {
    width: 20px;
    height: 20px;
    border-radius: var(--tcp-radius-sm);
    border: 1px solid #999;
}

.tcp-legend-color.available {
    background: #fafafa;
}

.tcp-legend-color.unavailable {
    background: #e0e0e0;
}

/* Tabs */
.tcp-tabs-nav {
    display: flex;
    gap: 5px;
    margin-bottom: 0;
    border-bottom: 2px solid var(--tcp-primary);
    flex-wrap: wrap;
}

.tcp-tab-btn {
    padding: 12px 24px;
    background: var(--tcp-secondary);
    border: none;
    border-radius: var(--tcp-radius) var(--tcp-radius) 0 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--tcp-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.tcp-tab-btn:hover {
    background: var(--tcp-primary-light);
    color: var(--tcp-white);
}

.tcp-tab-btn.active {
    background: var(--tcp-primary);
    color: var(--tcp-white);
}

/* Tab Panels */
.tcp-tab-panel {
    display: none;
    background: var(--tcp-white);
    border: 1px solid var(--tcp-border);
    border-top: none;
    border-radius: 0 0 var(--tcp-radius) var(--tcp-radius);
    padding: 20px;
}

.tcp-tab-panel.active {
    display: block;
}

/* Order Table */
.tcp-order-table-wrapper {
    overflow-x: auto;
}

.tcp-order-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    table-layout: auto;
}

.tcp-order-table th,
.tcp-order-table td {
    padding: 6px 4px;
    text-align: center;
    border: 1px solid var(--tcp-border);
    font-size: 13px;
}

.tcp-order-table thead th {
    background: var(--tcp-primary);
    color: var(--tcp-white);
    font-weight: 600;
}

.tcp-order-table .tcp-subheader th,
.tcp-order-table .tcp-variant-header-row th {
    background: var(--tcp-primary-light);
    font-size: 11px;
    padding: 4px 3px;
    color: var(--tcp-white);
}

.tcp-order-table .tcp-col-product {
    text-align: left;
    min-width: 140px;
}

.tcp-order-table .tcp-product-name {
    text-align: left;
    font-weight: 500;
}

.tcp-order-table .tcp-price {
    color: var(--tcp-text-light);
    white-space: nowrap;
    font-size: 12px;
}

.tcp-order-table .tcp-qty-cell.filled .tcp-qty-input {
    background: #c8e6b3; /* medium light green: marks the input itself when a valid qty is entered */
}

.tcp-order-table .tcp-qty-cell {
    background: #fafafa;
}

/* Quantity Input */
.tcp-qty-input {
    width: 42px;
    padding: 4px 2px;
    border: 1px solid var(--tcp-border);
    border-radius: var(--tcp-radius-sm);
    text-align: center;
    font-size: 13px;
    font-family: inherit;
    -moz-appearance: textfield;
}

.tcp-qty-input::-webkit-outer-spin-button,
.tcp-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.tcp-qty-input:focus {
    outline: none;
    border-color: var(--tcp-primary);
    background: var(--tcp-white);
}

.tcp-qty-input:disabled {
    background: #e0e0e0;
    cursor: not-allowed;
    color: #999;
}

.tcp-qty-input.error {
    border-color: var(--tcp-danger);
    background: #fff5f5;
}

/* Unavailable cells: greyed out to match the disabled-input convention */
.tcp-qty-cell.unavailable {
    background: #e0e0e0;
}

.tcp-qty-cell.unavailable .tcp-qty-input {
    background: #e0e0e0;
    border-color: #e0a800;
}

/* Totals */
.tcp-row-total,
.tcp-category-total {
    font-weight: 600;
    color: var(--tcp-primary);
    white-space: nowrap;
}

.tcp-category-total-row {
    background: var(--tcp-secondary);
}

.tcp-total-label {
    text-align: right;
    font-weight: 600;
}

/* Order Summary */
.tcp-order-summary {
    margin-top: 30px;
}

.tcp-summary-card {
    background: var(--tcp-white);
    border: 2px solid var(--tcp-primary);
    border-radius: var(--tcp-radius);
    padding: 25px;
    max-width: 500px;
    margin-left: auto;
}

.tcp-summary-card h3 {
    color: var(--tcp-primary);
    margin-top: 0;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--tcp-border);
    font-weight: 600;
}

.tcp-summary-items {
    max-height: 250px;
    overflow-y: auto;
    margin-bottom: 15px;
    font-size: 13px;
}

.tcp-summary-items table {
    width: 100%;
    border-collapse: collapse;
}

.tcp-summary-items th {
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid var(--tcp-border);
    font-weight: 600;
    font-size: 12px;
    color: var(--tcp-text-light);
}

.tcp-summary-items td {
    padding: 6px 8px;
    border-bottom: 1px solid #f0ebe0;
}

.tcp-summary-items td:last-child {
    text-align: right;
    font-weight: 500;
}

.tcp-summary-empty {
    color: var(--tcp-text-light);
    font-size: 13px;
    text-align: center;
    padding: 20px;
}

/* Summary Totals */
.tcp-summary-totals {
    border-top: 1px solid var(--tcp-border);
    padding-top: 15px;
}

.tcp-summary-line {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 14px;
}

.tcp-summary-line--info {
    font-size: 12px;
    color: var(--tcp-success);
    font-style: italic;
}

.tcp-summary-line--total {
    font-weight: 700;
    font-size: 18px;
    color: var(--tcp-primary);
    padding-top: 10px;
    border-top: 2px solid var(--tcp-primary);
    margin-top: 5px;
}

/* Min order warning */
.tcp-min-order-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: var(--tcp-radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    color: #856404;
    margin-top: 10px;
}

/* Order notes */
.tcp-order-summary textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--tcp-border);
    border-radius: var(--tcp-radius-sm);
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
}

.tcp-order-summary textarea:focus {
    outline: none;
    border-color: var(--tcp-primary);
}

.tcp-order-summary label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--tcp-text);
}

/* Notice */
.tcp-notice {
    background: var(--tcp-secondary);
    border: 1px solid var(--tcp-border);
    border-radius: var(--tcp-radius);
    padding: 30px;
    text-align: center;
    color: var(--tcp-text-light);
}

/* Toast notification */
.tcp-toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--tcp-primary);
    color: var(--tcp-white);
    padding: 15px 25px;
    border-radius: var(--tcp-radius);
    box-shadow: var(--tcp-shadow-lg);
    font-size: 14px;
    font-weight: 500;
    z-index: 9999;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.tcp-toast.show {
    opacity: 1;
    transform: translateY(0);
}

.tcp-toast.error {
    background: var(--tcp-danger);
}

/* Responsive */
@media (max-width: 768px) {
    .tcp-portal-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
        padding: 15px 20px;
    }

    .tcp-portal-welcome h1 {
        font-size: 22px;
    }

    .tcp-tab-btn {
        padding: 10px 16px;
        font-size: 14px;
    }

    .tcp-summary-card {
        max-width: 100%;
        margin-left: 0;
    }

    .tcp-btn-full {
        padding: 16px;
    }
}


/* Checkout confirmation modal */
.tcp-modal[hidden] { display: none; }

.tcp-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.tcp-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    animation: tcp-fade-in 0.15s ease;
}
.tcp-modal-dialog {
    position: relative;
    background: var(--tcp-white);
    border-radius: var(--tcp-radius);
    box-shadow: var(--tcp-shadow-lg);
    max-width: 460px;
    width: 100%;
    padding: 28px 28px 24px;
    animation: tcp-pop-in 0.18s ease;
}
.tcp-modal-title {
    margin: 0 0 12px;
    font-size: 20px;
    font-weight: 600;
    color: var(--tcp-text);
}
.tcp-modal-body {
    margin: 0 0 22px;
    font-size: 15px;
    line-height: 1.5;
    color: var(--tcp-text);
}
.tcp-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.tcp-modal-actions .tcp-btn { min-width: 130px; }

@keyframes tcp-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes tcp-pop-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 768px) {
    .tcp-modal-dialog { padding: 22px 20px 20px; }
    .tcp-modal-actions { flex-direction: column-reverse; }
    .tcp-modal-actions .tcp-btn { width: 100%; min-width: 0; }
}

/* ============================================================
   Account Details Panel
   ============================================================ */

.tcp-account-panel {
    background: #fff;
    border: 1px solid #e0dbd2;
    border-radius: 6px;
    margin-bottom: 28px;
    overflow: hidden;
}

.tcp-account-panel-inner {
    padding: 28px 32px;
}

.tcp-account-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #714007;
}

.tcp-account-panel-header h2 {
    margin: 0;
    color: #714007;
    font-size: 20px;
}

.tcp-account-panel-close {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: #7a7a7a;
    padding: 0 4px;
}

.tcp-account-panel-close:hover {
    color: #714007;
}

.tcp-account-section-title {
    font-size: 15px;
    font-weight: 600;
    color: #714007;
    margin: 24px 0 14px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e0dbd2;
}

.tcp-account-section-title:first-child {
    margin-top: 0;
}

.tcp-account-row {
    display: flex;
    gap: 20px;
    margin-bottom: 14px;
}

.tcp-account-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.tcp-account-field--wide {
    flex: 2;
}

.tcp-account-field label {
    font-size: 13px;
    font-weight: 600;
    color: #3a3a3a;
}

.tcp-account-field label .required {
    color: #b32d2e;
}

.tcp-account-field small {
    font-size: 12px;
    color: #7a7a7a;
    font-weight: normal;
}

.tcp-account-field input[type="text"],
.tcp-account-field input[type="tel"],
.tcp-account-field input[type="email"] {
    padding: 8px 10px;
    border: 1px solid #d0c8be;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.tcp-account-field input:focus {
    outline: none;
    border-color: #714007;
    box-shadow: 0 0 0 2px rgba(113,64,7,0.12);
}

.tcp-account-field input:disabled {
    background: #f5f5f5;
    color: #7a7a7a;
    cursor: not-allowed;
}

.tcp-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    font-weight: normal !important;
}

.tcp-checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #714007;
}

.tcp-account-actions {
    display: flex;
    gap: 12px;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid #e0dbd2;
}

/* Active state for Account Details toggle button */
#tcp-account-details-toggle.active {
    background: #714007;
    color: #fff;
    border-color: #714007;
}

@media (max-width: 600px) {
    .tcp-account-row {
        flex-direction: column;
        gap: 14px;
    }

    .tcp-account-panel-inner {
        padding: 20px 16px;
    }
}
