/* ---------------------------------
   Summary
--------------------------------- */

.crm-summary-card {
    border: 1px solid #ddd;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 22px;
    background: #fff;
}

.crm-summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.crm-quote-number {
    font-size: 18px;
}

.crm-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}


/* ---------------------------------
   Status
--------------------------------- */

.crm-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 82px;
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.crm-status-issued {
    background: #dbeafe;
    color: #1e40af;
}

.crm-status-sent {
    background: #e0f2fe;
    color: #075985;
}

.crm-status-accepted {
    background: #dcfce7;
    color: #166534;
}

.crm-status-rejected {
    background: #fee2e2;
    color: #991b1b;
}

.crm-status-expired {
    background: #f3f4f6;
    color: #6b7280;
}


/* ---------------------------------
   Actions
--------------------------------- */

.crm-action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.btn-danger {
    border: 0;
    border-radius: 10px;
    padding: 12px 16px;
    background: #b91c1c;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
}

.crm-document-row {
    margin-bottom: 28px;
}

.crm-document-row .btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 46px;
    text-decoration: none;
}


/* ---------------------------------
   Activity Timeline
--------------------------------- */

.crm-section {
    margin-top: 20px;
}

.crm-activity-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.crm-activity-item {
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 15px;
    background: #fff;
}

.crm-activity-top {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 8px;
}

.crm-activity-outcome,
.crm-activity-subject,
.crm-activity-notes,
.crm-follow-up {
    margin-top: 7px;
}

.crm-activity-user {
    margin-top: 10px;
    color: #666;
    font-size: 13px;
}


/* ---------------------------------
   Back
--------------------------------- */

.crm-back-row {
    margin-top: 30px;
}

.crm-back-row .btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    text-decoration: none;
}

.crm-menu-back {
    margin-top: 24px;
}


/* ---------------------------------
   Modals
--------------------------------- */

.crm-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 9999;
}

.crm-modal-card {
    width: 100%;
    max-width: 560px;
    background: #fff;
    border-radius: 12px;
    padding: 22px;
    box-sizing: border-box;
}

.crm-modal-card input,
.crm-modal-card textarea {
    width: 100%;
    box-sizing: border-box;
}

.crm-modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 20px;
}


/* ---------------------------------
   Follow-up Actions
--------------------------------- */

.crm-followup-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.crm-followup-complete,
.crm-followup-cancel {
    border: 0;
    border-radius: 8px;
    padding: 7px 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.crm-followup-complete {
    background: #dcfce7;
    color: #166534;
}

.crm-followup-cancel {
    background: #fee2e2;
    color: #991b1b;
}

.crm-followup-open {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 8px;
    padding: 7px 10px;
    background: #e5e7eb;
    color: #374151;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.crm-followup-open:hover {
    text-decoration: none;
}


/* =========================================
   FOLLOW-UP TABLE - DESKTOP
========================================= */

.crm-mobile-document,
.crm-mobile-status,
.crm-mobile-quote-number,
.crm-mobile-quote-status {
    display: none;
}

.crm-followup-actions-row td {
    padding: 8px 6px 14px;
    border-top: 0;
}

.crm-followup-actions-row .crm-followup-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
}


/* =========================================
   QUOTE OPPORTUNITY ACTION ROW - DESKTOP
========================================= */

.crm-quote-actions-row td {
    padding: 10px 8px;
    border-top: 0;
}

.crm-quote-actions {
    width: 100%;
}

.crm-quote-actions .crm-followup-open {
    display: flex;
    width: 100%;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    text-align: center;
}


/* =========================================
   RECENT ACTIVITY TABLE - DESKTOP
========================================= */

.crm-activity-table {
    width: 100%;
    table-layout: fixed;
}

.crm-activity-actions-row td {
    padding: 10px 8px;
    border-top: 0;
}

.crm-activity-actions-row .crm-followup-open {
    display: flex;
    width: 100%;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    text-align: center;
}


/* =========================================
   MOBILE - 600px AND BELOW
========================================= */

@media (max-width: 600px) {

    /* Quote Summary: 2 columns */

    .crm-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 18px 14px;
    }

    .crm-summary-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    /* Modal buttons */

    .crm-modal-actions {
        grid-template-columns: 1fr;
    }

    /* FOLLOW-UP TABLE
       Due | Customer/Document | Subject/Status */

    .crm-followup-table {
        width: 100%;
        table-layout: fixed;
    }

    .crm-followup-table th:nth-child(3),
    .crm-followup-table th:nth-child(5),
    .crm-followup-document,
    .crm-followup-status-cell {
        display: none;
    }

    .crm-followup-table th:nth-child(1) {
        width: 30%;
    }

    .crm-followup-table th:nth-child(2) {
        width: 42%;
    }

    .crm-followup-table th:nth-child(4) {
        width: 28%;
    }

    .crm-followup-table td {
        padding: 8px 6px;
        vertical-align: top;
        word-break: break-word;
    }

    .crm-mobile-document {
        display: block;
        margin-top: 4px;
        font-size: 12px;
        color: #666;
    }

    .crm-mobile-status {
        display: inline-flex;
        margin-top: 6px;
        padding: 3px 8px;
        border-radius: 999px;
        background: #fff3cd;
        color: #856404;
        font-size: 12px;
        font-weight: 600;
    }

    .crm-followup-actions-row {
        display: table-row;
    }

    .crm-followup-actions-row td {
        padding: 8px 6px 14px;
        border-top: 0;
    }

    .crm-followup-actions-row .crm-followup-actions {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        width: 100%;
    }

    .crm-followup-open,
    .crm-followup-complete,
    .crm-followup-cancel {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        text-align: center;
        white-space: nowrap;
    }

    /* QUOTE OPPORTUNITY TABLE
       Date | Customer/Quote | Value/Status */

    .crm-quote-table {
        width: 100%;
        table-layout: fixed;
    }

    .crm-quote-table th:nth-child(2),
    .crm-quote-table td:nth-child(2),
    .crm-quote-table th:nth-child(5),
    .crm-quote-table td:nth-child(5) {
        display: none;
    }

    .crm-quote-table th:nth-child(1) {
        width: 30%;
    }

    .crm-quote-table th:nth-child(3) {
        width: 42%;
    }

    .crm-quote-table th:nth-child(4) {
        width: 28%;
    }

    .crm-quote-date {
        white-space: nowrap;
    }

    .crm-quote-table td {
        padding: 8px 5px;
        vertical-align: top;
        overflow-wrap: anywhere;
    }

    .crm-mobile-quote-number {
        display: block;
        margin-top: 4px;
        color: #666;
        font-size: 12px;
    }

    .crm-mobile-quote-status {
        display: block;
        margin-top: 7px;
    }

    /* RECENT ACTIVITY TABLE
       Date | Customer/Document | Activity/Subject
       User hidden */

    .crm-activity-table {
        width: 100%;
        table-layout: fixed;
    }

    .crm-activity-table th:nth-child(3),
    .crm-activity-document,
    .crm-activity-table th:nth-child(5),
    .crm-activity-table td:nth-child(5) {
        display: none;
    }

    .crm-activity-table th:nth-child(1) {
        width: 30%;
    }

    .crm-activity-table th:nth-child(2) {
        width: 40%;
    }

    .crm-activity-table th:nth-child(4) {
        width: 30%;
    }

    .crm-activity-table td {
        padding: 8px 5px;
        vertical-align: top;
        overflow-wrap: anywhere;
    }

    .crm-activity-table .crm-mobile-document {
        display: block;
        margin-top: 4px;
        font-size: 12px;
        color: #666;
    }
}