/**
 * Custodi Quotes — Portal Frontend Styles
 * Design system: Custodi brand colours and typography.
 *
 * @package CustodiQuotes
 */

:root {
    --cq-blue: #00C4E8;
    --cq-teal: #0088AA;
    --cq-charcoal: #3A4045;
    --cq-dark: #2B3237;
    --cq-sand: #f4f3f1;
    --cq-border: #EBE9E6;
    --cq-muted: #B8B3AD;
    --cq-text: #3A4045;
    --cq-text-secondary: #6B7780;
    --cq-success: #5BA8A0;
    --cq-alert: #C4846B;
}

/* Portal wrapper */
.cq-portal {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--cq-text);
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px 0;
    background: var(--cq-sand);
    border-radius: 12px;
    padding: 28px;
}

/* Portal header */
.cq-portal-header {
    margin-bottom: 32px;
}

.cq-portal-header h2 {
    font-size: clamp(22px, 3vw, 30px);
    font-weight: 800;
    color: var(--cq-charcoal);
    margin: 0 0 4px 0;
}

.cq-portal-org {
    font-size: 14px;
    color: var(--cq-text-secondary);
    margin: 0;
}

/* Sections */
.cq-section {
    margin-bottom: 40px;
}

.cq-section-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--cq-charcoal);
    margin: 0 0 16px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--cq-border);
}

/* Draft cards */
.cq-draft-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.cq-draft-card {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--cq-border);
    transition: box-shadow 0.2s, transform 0.2s;
}

.cq-draft-card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.cq-draft-card h4 {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 8px 0;
    color: var(--cq-charcoal);
}

.cq-draft-meta {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--cq-text-secondary);
    margin-bottom: 10px;
}

.cq-draft-total {
    font-size: 20px;
    font-weight: 700;
    color: var(--cq-charcoal);
    margin-bottom: 14px;
}

.cq-draft-total small {
    font-size: 12px;
    font-weight: 400;
    color: var(--cq-text-secondary);
}

.cq-draft-actions {
    display: flex;
    gap: 8px;
}

/* Buttons */
.cq-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    line-height: 1.2;
}

.cq-btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.cq-btn-primary {
    background: var(--cq-teal);
    color: white;
}

.cq-btn-primary:hover {
    background: var(--cq-blue);
    transform: translateY(-1px);
    color: white;
    text-decoration: none;
}

.cq-btn-ghost {
    background: transparent;
    color: var(--cq-text-secondary);
    border: 1px solid var(--cq-muted);
}

.cq-btn-ghost:hover {
    border-color: var(--cq-alert);
    color: var(--cq-alert);
}

/* Tables */
.cq-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.cq-table th {
    background: var(--cq-charcoal);
    color: white;
    padding: 10px 14px;
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.cq-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--cq-border);
    font-size: 13px;
}

.cq-table tr:last-child td {
    border-bottom: none;
}

.cq-table a {
    color: var(--cq-teal);
    font-weight: 600;
    text-decoration: none;
}

.cq-table a:hover {
    color: var(--cq-blue);
}

/* Status badges */
.cq-status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.cq-status-draft     { background: #EBE9E6; color: #6B7780; }
.cq-status-submitted { background: #e0f7fc; color: #0088AA; }
.cq-status-review    { background: #fceee8; color: #C4846B; }
.cq-status-quoted    { background: #e0f7fc; color: #0088AA; }
.cq-status-accepted  { background: #e8f5f3; color: #5BA8A0; }
.cq-status-declined  { background: #fceee8; color: #C4846B; }
.cq-status-expired   { background: #EBE9E6; color: #B8B3AD; }

/* Notices */
.cq-portal-notice {
    padding: 20px 24px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.cq-notice-info {
    background: var(--cq-sand);
    color: var(--cq-text);
}

.cq-notice-warning {
    background: #fceee8;
    color: var(--cq-alert);
}

.cq-notice-muted {
    font-size: 13px;
    color: var(--cq-muted);
    font-style: italic;
}

.cq-new-quote-action {
    margin-top: 16px;
}

/* Responsive */
@media (max-width: 768px) {
    .cq-draft-grid {
        grid-template-columns: 1fr;
    }

    .cq-table {
        font-size: 12px;
    }

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

/* ============================================
   PHASE 2 ADDITIONS
   ============================================ */

/* Portal Nav */
.cq-portal-nav { display: flex; gap: 4px; margin-bottom: 28px; border-bottom: 2px solid var(--cq-border); padding-bottom: 0; }
.cq-nav-item { padding: 10px 18px; font-size: 13px; font-weight: 600; color: var(--cq-text-secondary); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; }
.cq-nav-item:hover { color: var(--cq-teal); }
.cq-nav-active { color: var(--cq-teal); border-bottom-color: var(--cq-blue); }

/* Section header with button */
.cq-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.cq-section-header .cq-section-title { margin: 0; padding: 0; border: 0; }

/* Portal header */
.cq-portal-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; }
.cq-header-actions { display: flex; gap: 8px; }

/* Discount badge */
.cq-discount-badge { display: inline-block; background: #e8f5f3; color: var(--cq-success); padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; margin-left: 8px; }

/* Links */
.cq-link { font-size: 13px; color: var(--cq-teal); text-decoration: none; font-weight: 600; }
.cq-link:hover { color: var(--cq-blue); }
.cq-back-link { font-size: 13px; color: var(--cq-text-secondary); text-decoration: none; display: block; margin-bottom: 8px; }
.cq-back-link:hover { color: var(--cq-teal); }

/* Login box */
.cq-login-box { text-align: center; padding: 60px 40px; background: white; border-radius: 12px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); max-width: 480px; margin: 40px auto; border: 1px solid var(--cq-border); }
.cq-login-box h2 { font-size: 24px; font-weight: 800; color: var(--cq-charcoal); margin-bottom: 10px; }
.cq-login-box p { color: var(--cq-text-secondary); font-size: 14px; margin-bottom: 20px; }
.cq-login-register { margin-top: 20px; font-size: 13px; }
.cq-login-register a { color: var(--cq-teal); font-weight: 600; }

/* Quote selector bar */
.cq-quote-selector { display: flex; align-items: center; gap: 12px; background: white; padding: 14px 20px; border-radius: 8px; margin-bottom: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); border: 1px solid var(--cq-border); }
.cq-quote-selector label { font-size: 13px; font-weight: 600; color: var(--cq-text-secondary); white-space: nowrap; }

/* Forms */
.cq-select { padding: 8px 12px; border: 1px solid var(--cq-border); border-radius: 6px; font-family: inherit; font-size: 13px; color: var(--cq-text); background: white; min-width: 140px; }
.cq-input { padding: 8px 12px; border: 1px solid var(--cq-border); border-radius: 6px; font-family: inherit; font-size: 13px; color: var(--cq-text); width: 100%; }
.cq-input:focus, .cq-select:focus { outline: none; border-color: var(--cq-blue); box-shadow: 0 0 0 3px rgba(0,196,232,0.15); }
.cq-input-error { border-color: var(--cq-alert) !important; box-shadow: 0 0 0 3px rgba(196,132,107,0.15) !important; }
.cq-textarea { padding: 12px; border: 1px solid var(--cq-border); border-radius: 6px; font-family: inherit; font-size: 13px; color: var(--cq-text); width: 100%; min-height: 80px; resize: vertical; }

/* Filters */
.cq-filters { margin-bottom: 24px; }
.cq-filter-row { display: flex; gap: 12px; flex-wrap: wrap; }
.cq-filter-group { flex: 1; min-width: 150px; }
.cq-filter-group .cq-input { width: 100%; }

/* Product grid */
.cq-product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.cq-product-card { background: white; border-radius: 10px; overflow: hidden; box-shadow: 0 2px 12px rgba(0,0,0,0.06); border: 1px solid var(--cq-border); display: flex; flex-direction: column; transition: box-shadow 0.2s, transform 0.2s; }
.cq-product-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.1); transform: translateY(-2px); }
.cq-card-added { border-color: var(--cq-success); box-shadow: 0 0 0 2px var(--cq-success); }

.cq-product-image { position: relative; background: #fafafa; padding: 10px; text-align: center; }
.cq-product-image img { max-height: 160px; width: auto; object-fit: contain; }
.cq-product-badge { position: absolute; top: 10px; right: 10px; padding: 4px 10px; border-radius: 4px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.cq-badge-rfq { background: var(--cq-alert); color: white; }

.cq-product-info { padding: 16px; flex: 1; }
.cq-product-brand { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--cq-teal); }
.cq-product-name { font-size: 15px; font-weight: 700; color: var(--cq-charcoal); margin: 4px 0 6px 0; }
.cq-product-desc { font-size: 12px; color: var(--cq-text-secondary); line-height: 1.5; margin: 0 0 10px 0; }

.cq-product-pricing { display: flex; align-items: baseline; gap: 6px; }
.cq-product-rrp { font-size: 13px; color: var(--cq-muted); text-decoration: line-through; }
.cq-product-price { font-size: 18px; font-weight: 700; color: var(--cq-charcoal); }
.cq-product-price-suffix { font-size: 11px; color: var(--cq-text-secondary); }
.cq-product-poa { font-size: 13px; color: var(--cq-alert); font-weight: 600; font-style: italic; }

.cq-product-actions { padding: 12px 16px; border-top: 1px solid var(--cq-border); background: #fafafa; }
.cq-qty-row { display: flex; align-items: center; gap: 8px; }
.cq-qty-label { font-size: 12px; font-weight: 600; color: var(--cq-text-secondary); }
.cq-qty-input { width: 60px; padding: 6px 8px; border: 1px solid var(--cq-border); border-radius: 4px; font-size: 13px; text-align: center; }

.cq-config-form, .cq-custom-form { display: flex; flex-direction: column; gap: 8px; }
.cq-config-field { display: flex; flex-direction: column; gap: 3px; }
.cq-config-field label { font-size: 11px; font-weight: 600; color: var(--cq-text-secondary); }

/* Builder table extras */
.cq-builder-table .cq-col-product { min-width: 200px; }
.cq-builder-table .cq-col-type { width: 80px; }
.cq-builder-table .cq-col-qty { width: 70px; }
.cq-builder-table .cq-col-price { width: 100px; }
.cq-builder-table .cq-col-discount { width: 80px; }
.cq-builder-table .cq-col-total { width: 100px; }
.cq-builder-table .cq-col-actions { width: 40px; text-align: center; }

.cq-item-sku { display: block; font-size: 11px; color: var(--cq-muted); }
.cq-item-config { margin-top: 4px; }
.cq-config-tag { display: inline-block; background: #e0f7fc; color: var(--cq-teal); padding: 2px 8px; border-radius: 3px; font-size: 11px; margin: 2px 4px 2px 0; }
.cq-item-notes { font-size: 11px; color: var(--cq-text-secondary); font-style: italic; margin-top: 4px; }
.cq-tbc { color: var(--cq-alert); font-style: italic; font-weight: 600; }
.cq-discount-text { color: var(--cq-success); font-weight: 600; }

.cq-type-badge { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 10px; font-weight: 600; }
.cq-type-standard { background: #e8f5f3; color: var(--cq-success); }
.cq-type-configurable { background: #fceee8; color: var(--cq-alert); }
.cq-type-custom { background: #e0f7fc; color: var(--cq-teal); }

.cq-remove-item { background: none; border: none; color: var(--cq-muted); font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 4px; transition: all 0.2s; }
.cq-remove-item:hover { color: var(--cq-alert); background: #fceee8; }

/* Totals */
.cq-totals-label { text-align: right; font-weight: 600; }
.cq-totals-value { font-weight: 600; }
.cq-totals-discount .cq-totals-label, .cq-totals-discount .cq-totals-value { color: var(--cq-success); }
.cq-totals-grand .cq-totals-label, .cq-totals-grand .cq-totals-value { font-size: 16px; font-weight: 800; }

/* Editable title */
.cq-editable-title { outline: none; border-bottom: 2px dashed var(--cq-border); padding-bottom: 2px; cursor: text; }
.cq-editable-title:focus { border-bottom-color: var(--cq-blue); }

/* Notes box */
.cq-notes-box { background: white; border-radius: 10px; padding: 20px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); margin-bottom: 20px; }
.cq-notes-box h4 { font-size: 15px; font-weight: 700; margin: 0 0 10px 0; }
.cq-notes-box h4 small { font-weight: 400; color: var(--cq-muted); }
.cq-notes-readonly { background: var(--cq-sand); }
.cq-autosave-status { font-size: 11px; color: var(--cq-success); display: block; margin-top: 6px; min-height: 16px; }

/* Submit bar */
.cq-submit-bar { display: flex; justify-content: space-between; align-items: center; background: white; border-radius: 10px; padding: 20px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
.cq-submit-info p { font-size: 13px; color: var(--cq-text-secondary); margin: 0; }
.cq-btn-lg { padding: 14px 32px; font-size: 15px; }

/* Accept/decline bar */
.cq-accept-decline { display: flex; gap: 12px; margin-top: 16px; }

/* Timeline */
.cq-timeline { margin-bottom: 30px; padding-left: 20px; border-left: 2px solid var(--cq-border); }
.cq-timeline-item { position: relative; padding: 0 0 20px 20px; }
.cq-timeline-dot { position: absolute; left: -27px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--cq-border); }
.cq-timeline-dot.cq-status-submitted { background: var(--cq-blue); }
.cq-timeline-dot.cq-status-review { background: var(--cq-alert); }
.cq-timeline-dot.cq-status-quoted { background: var(--cq-teal); }
.cq-timeline-dot.cq-status-accepted { background: var(--cq-success); }
.cq-timeline-dot.cq-status-declined { background: var(--cq-alert); }
.cq-timeline-status { font-size: 13px; font-weight: 700; color: var(--cq-charcoal); }
.cq-timeline-date { font-size: 11px; color: var(--cq-muted); margin-left: 8px; }
.cq-timeline-note { font-size: 12px; color: var(--cq-text-secondary); margin: 4px 0 0 0; font-style: italic; }

/* Empty state */
.cq-empty-state { text-align: center; padding: 40px; background: white; border-radius: 10px; box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
.cq-empty-state h3 { margin: 0 0 8px 0; color: var(--cq-charcoal); }
.cq-empty-state p { color: var(--cq-text-secondary); margin: 0 0 16px 0; }

/* Toast notifications */
.cq-toast { position: fixed; top: 20px; right: 20px; z-index: 99999; max-width: 400px; padding: 14px 20px; border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.15); transform: translateX(120%); transition: transform 0.3s ease; }
.cq-toast-visible { transform: translateX(0); }
.cq-toast p { margin: 0; font-size: 13px; font-weight: 600; }
.cq-notice-success { background: #e8f5f3; color: var(--cq-success); border: 1px solid var(--cq-success); }

/* Responsive */
@media (max-width: 768px) {
    .cq-portal-nav { overflow-x: auto; white-space: nowrap; }
    .cq-portal-header { flex-direction: column; gap: 12px; }
    .cq-quote-selector { flex-direction: column; align-items: stretch; }
    .cq-filter-row { flex-direction: column; }
    .cq-product-grid { grid-template-columns: 1fr; }
    .cq-submit-bar { flex-direction: column; gap: 12px; text-align: center; }
    .cq-accept-decline { flex-direction: column; }
}
