/* 
File name: deals_detail.css
Version: 2025-03-02_v1.0
Purpose: Enhanced styling for the deals detail page
*/

/* Deal Detail Header Improvements */
.deals-detail-header {
    width: 100%;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    padding: 30px;
    margin-bottom: 30px;
}

.deals-detail-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.deals-detail-title h1 {
    font-size: 28px;
    color: #2c3e50;
    margin: 0;
    font-weight: 600;
}

.deals-detail-actions {
    display: flex;
    gap: 15px;
}

.deals-detail-actions .crm-button {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
}

/* Deal Info Grid Layout */
.deals-detail-info {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.crm-data-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 5px;
    padding: 12px 15px;
    background-color: #f8f9fa;
    border-radius: 6px;
    transition: background-color 0.2s;
}

.crm-data-row:hover {
    background-color: #f1f3f5;
}

.crm-data-label {
    font-size: 14px;
    color: #6c757d;
    margin-bottom: 8px;
    font-weight: 500;
}

.crm-data-value {
    font-size: 16px;
    color: #2c3e50;
    font-weight: 500;
}

.crm-data-value a {
    color: #3498db;
    text-decoration: none;
}

.crm-data-value a:hover {
    text-decoration: underline;
}

/* Badge Styling */
.deals-badge {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    color: white;
    letter-spacing: 0.3px;
}

/* Deal Content Container */
.deals-detail-container {
    display: flex;
    gap: 30px;
    margin: 0 auto;
    max-width: 1200px;
    padding: 0 20px;
}

.deals-detail-main {
    flex: 3;
    min-width: 300px;
}

.deals-detail-sidebar {
    flex: 1;
    min-width: 280px;
}

/* Section Styling */
.deals-detail-section, 
.crm-section {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    overflow: hidden;
}

.deals-detail-section-header, 
.crm-section-header {
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    background-color: #f8f9fa;
}

.deals-detail-section-title, 
.crm-section-title {
    margin: 0;
    font-size: 18px;
    color: #2c3e50;
    font-weight: 600;
}

.deals-detail-section-content, 
.crm-section-content {
    padding: 20px;
}

/* Forms within sections */
.crm-section form {
    margin-bottom: 0;
}

.crm-section textarea, 
.crm-section input[type="text"], 
.crm-section select {
    width: 100%;
    padding: 12px;
    border: 1px solid #dde2e6;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 15px;
}

.crm-section textarea {
    min-height: 120px;
    resize: vertical;
}

.crm-section button[type="submit"],
.crm-section input[type="submit"] {
    padding: 10px 20px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    float: right;
}

.crm-section button[type="submit"]:hover,
.crm-section input[type="submit"]:hover {
    background-color: #2980b9;
}

/* Tables within sections */
.crm-section table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
}

.crm-section table th {
    text-align: left;
    padding: 12px 15px;
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-size: 14px;
    font-weight: 600;
    color: #495057;
}

.crm-section table td {
    padding: 15px;
    border-bottom: 1px solid #e9ecef;
    font-size: 14px;
    color: #2c3e50;
}

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

.crm-section table tr:hover {
    background-color: #f8f9fa;
}

/* When no content is present */
.no-content-message {
    padding: 20px;
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

/* Description section */
.description-content {
    padding: 20px;
    font-size: 15px;
    line-height: 1.6;
    color: #2c3e50;
}

/* Responsive adjustments */
@media (max-width: 992px) {
    .deals-detail-container {
        flex-direction: column;
    }
    
    .deals-detail-info {
        grid-template-columns: 1fr;
    }
    
    .deals-detail-title {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .deals-detail-title h1 {
        font-size: 24px;
    }
}

@media (max-width: 768px) {
    .deals-detail-header {
        padding: 20px;
    }
    
    .crm-data-row {
        padding: 10px;
    }
    
    .deals-detail-actions .crm-button {
        padding: 8px 15px;
        font-size: 13px;
    }
}

/* ============================================================================
 * v2.1 redesign — uses design tokens from /static/css/proforma_design.css
 * 2026-04-06: refactored from hand-rolled hex codes to switchboard tokens.
 * Page is /crm/deals/<id>, served by deals_crud_module.view_deal,
 * template is crm/templates/deals_detail_view.html (which links proforma_design.css).
 * Class names live here so the template stays presentation-free.
 * ============================================================================ */

.crm-container {
    max-width: 1500px;
    width: 96%;
    margin: 0 auto;
    padding: var(--gap-md);
}

.deal-top-row { margin-bottom: var(--gap-md); }

/* Two-column body — left reference, right action stack (sticky) */
.deals-detail-container {
    display: flex;
    gap: var(--gap-md);
    align-items: flex-start;
}
.deals-detail-col-left {
    flex: 0 0 38%;
    min-width: 0;
}
.deals-detail-col-right {
    flex: 1 1 0;
    min-width: 0;
    position: sticky;
    top: var(--gap-md);
    align-self: flex-start;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}

.deal-section {
    background: var(--crm-card-bg);
    border: 1px solid var(--crm-card-border);
    border-radius: var(--radius);
    padding: var(--gap-md);
    margin-bottom: var(--gap-md);
    box-shadow: 0 1px 3px var(--crm-card-shadow);
}
.deal-section h3 {
    margin-top: 0;
    color: var(--navy);
    border-bottom: 1px solid var(--crm-card-border);
    padding-bottom: var(--gap-sm);
    font-family: var(--font-heading);
    font-size: 1.05rem;
}

/* Action Summary — top-of-page prominent action list */
.action-summary {
    background: var(--crm-card-bg);
    border: 1px solid var(--crm-card-border);
    border-left: 4px solid var(--navy);
    border-radius: var(--radius);
    padding: 14px 18px;
    margin-bottom: var(--gap-md);
    box-shadow: 0 1px 3px var(--crm-card-shadow);
}
.action-summary-title {
    font-family: var(--font-heading);
    font-size: .9rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--navy);
    margin: 0 0 10px;
    font-weight: 700;
}
.action-summary-list { list-style: none; padding: 0; margin: 0; }
.action-summary-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: var(--gap-sm) 10px;
    margin-bottom: 4px;
    border-radius: 4px;
    cursor: pointer;
    line-height: 1.4;
    font-size: .95rem;
    color: var(--ink);
    transition: background-color .12s;
}
.action-summary-item:hover { background: var(--light); }
.action-summary-badge {
    display: inline-block;
    flex-shrink: 0;
    padding: 3px 9px;
    border-radius: 3px;
    font-family: var(--font-heading);
    font-size: .7rem;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: .04em;
    min-width: 60px;
    text-align: center;
    margin-top: 2px;
}
.action-summary-badge.action  { background: var(--navy); }
.action-summary-badge.blocked { background: var(--crm-badge-red); }
.action-summary-badge.need    { background: var(--crm-badge-yellow); }
.action-summary-text { flex: 1; color: var(--ink); }
.action-summary-matter {
    display: block;
    font-family: var(--font-heading);
    font-size: .7rem;
    color: var(--subtle);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-top: 3px;
}
.action-summary-empty { color: var(--subtle); font-size: .9rem; font-style: italic; margin: 0; }

/* Action summary header (title row + controls) */
.action-summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.action-summary-controls { display: flex; align-items: center; gap: 10px; }
.action-summary-add-btn {
    background: var(--navy);
    color: var(--cream);
    border: none;
    padding: 5px 12px;
    border-radius: var(--radius);
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-heading);
    letter-spacing: .03em;
}
.action-summary-add-btn:hover { background: var(--ink); }
.action-summary-toggle {
    color: var(--subtle);
    font-size: .8rem;
    text-decoration: none;
    border-bottom: 1px dotted var(--subtle);
}
.action-summary-toggle:hover { color: var(--navy); border-bottom-color: var(--navy); }

/* + Add todo composer */
.todo-add-form {
    display: none;
    align-items: center;
    gap: 8px;
    background: var(--light);
    border: 1px solid var(--rule);
    padding: 10px;
    border-radius: var(--radius);
    margin-bottom: 10px;
}
.todo-add-form input[type="text"] {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid var(--rule);
    border-radius: 4px;
    font-size: .9rem;
    font-family: var(--font-body);
}
.todo-add-form select {
    padding: 7px 10px;
    border: 1px solid var(--rule);
    border-radius: 4px;
    font-size: .85rem;
    background: white;
    max-width: 200px;
}
.todo-add-save-btn, .todo-add-cancel-btn {
    padding: 7px 14px;
    border-radius: 4px;
    font-size: .85rem;
    cursor: pointer;
    border: none;
    font-weight: 600;
}
.todo-add-save-btn { background: var(--navy); color: var(--cream); }
.todo-add-save-btn:hover { background: var(--ink); }
.todo-add-cancel-btn { background: transparent; color: var(--subtle); border: 1px solid var(--rule); }
.todo-add-cancel-btn:hover { background: var(--light); color: var(--ink); }

/* Done / Reopen buttons on each todo row */
.todo-done-btn, .todo-reopen-btn {
    background: transparent;
    border: 1px solid var(--rule);
    color: var(--subtle);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
}
.todo-done-btn:hover { background: var(--green, #2d6a4f); color: white; border-color: var(--green, #2d6a4f); }
.todo-reopen-btn:hover { background: var(--navy); color: white; border-color: var(--navy); }

/* Default DO badge color */
.action-summary-badge.do { background: var(--navy); }
.action-summary-badge.done { background: var(--subtle); }

/* Archived section */
.action-summary-archived {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--rule);
}
.action-summary-archived-title {
    font-family: var(--font-heading);
    font-size: .8rem;
    color: var(--subtle);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 6px;
}
.action-summary-list-done { opacity: .6; }
.action-summary-item-done .action-summary-text { text-decoration: line-through; color: var(--subtle); }

/* Collapsible section drawer pattern (sd- prefix) */
.sd-section {
    background: var(--crm-card-bg);
    border: 1px solid var(--crm-card-border);
    border-radius: var(--radius);
    margin-bottom: var(--gap-md);
    box-shadow: 0 1px 3px var(--crm-card-shadow);
}
.sd-head {
    padding: 12px var(--gap-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--light);
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: 1px solid transparent;
}
.sd-section.open .sd-head { border-bottom-color: var(--crm-card-border); }
.sd-head .sd-caret {
    font-size: .85rem;
    color: var(--subtle);
    transition: transform .15s;
    display: inline-block;
}
.sd-section.open .sd-head .sd-caret { transform: rotate(90deg); }
.sd-head .sd-title {
    flex: 1;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1rem;
    color: var(--navy);
}
.sd-head .sd-count {
    font-size: .75rem;
    color: var(--subtle);
    padding: 2px var(--gap-sm);
    background: var(--cream);
    border-radius: 10px;
}
.sd-body { padding: var(--gap-md); display: none; }
.sd-section.open .sd-body { display: block; }

/* Matter accordion (kd- prefix, reused from kanban_deal idiom) */
.kd-matter {
    border: 1px solid var(--crm-card-border);
    border-radius: var(--radius);
    margin-bottom: var(--gap-sm);
}
.kd-matter-head {
    padding: var(--gap-sm) 12px;
    background: var(--light);
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    border-radius: var(--radius) var(--radius) 0 0;
}
.kd-matter-body { display: none; padding: var(--gap-sm) 12px; }
.kd-matter.open > .kd-matter-body { display: block; }
.kd-matter-head strong {
    font-family: var(--font-heading);
    color: var(--navy);
}
.kd-note {
    padding: 10px 0;
    border-bottom: 1px solid var(--crm-card-border);
}
.kd-note:last-child { border-bottom: none; }
.kd-note-meta {
    font-size: .75rem;
    color: var(--subtle);
    margin-bottom: 4px;
    font-family: var(--font-heading);
}
.kd-note-text {
    font-size: .95rem;
    line-height: 1.55;
    color: var(--ink);
}
.kd-note-text p { margin: 0 0 var(--gap-sm); }
.kd-note-text p:last-child { margin-bottom: 0; }
.kd-note-text ul { margin: 4px 0 var(--gap-sm); padding-left: 22px; }
.kd-note-text li { margin-bottom: 4px; }

.kd-note-input {
    width: 100%;
    min-height: 60px;
    padding: var(--gap-sm);
    border: 1px solid var(--crm-card-border);
    border-radius: 4px;
    resize: vertical;
    font-size: .9rem;
    font-family: var(--font-body);
    box-sizing: border-box;
}
.kd-btn {
    padding: 6px 14px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-heading);
    font-size: .85rem;
}
.kd-btn-primary { background: var(--navy); color: #fff; }
.kd-btn-secondary { background: var(--light); color: var(--ink); }

.matter-add-note-btn {
    background: var(--light);
    border: 1px dashed var(--crm-card-border);
    color: var(--muted);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-family: var(--font-heading);
    font-size: .85rem;
    margin: var(--gap-sm) 0;
    width: 100%;
    text-align: left;
}
.matter-add-note-btn:hover {
    background: var(--cream);
    border-color: var(--rule);
}
.note-composer-wrap {
    background: var(--cream);
    border: 1px solid var(--crm-card-border);
    border-radius: 4px;
    padding: 10px;
    margin: var(--gap-sm) 0;
}

/* Mini calendar grid */
.mini-cal { width: 100%; border-collapse: collapse; font-size: .8rem; }
.mini-cal th {
    padding: 4px 0;
    text-align: center;
    color: var(--subtle);
    font-family: var(--font-heading);
    font-weight: 500;
    font-size: .7rem;
    text-transform: uppercase;
}
.mini-cal td {
    text-align: center;
    padding: 6px 0;
    cursor: default;
    border-radius: 50%;
    width: 14.28%;
    height: 26px;
    vertical-align: middle;
    color: var(--ink);
}
.mini-cal td.in-month { color: var(--ink); }
.mini-cal td.out-month { color: var(--crm-card-border); }
.mini-cal td.has-activity {
    background: var(--crm-badge-yellow);
    cursor: pointer;
    font-weight: 600;
    color: #fff;
}
.mini-cal td.has-activity:hover { background: var(--gold); }
.mini-cal td.is-today { outline: 2px solid var(--navy); }
.mini-cal-header {
    text-align: center;
    font-family: var(--font-heading);
    font-weight: 600;
    padding: 4px 0 var(--gap-sm);
    color: var(--navy);
    font-size: .9rem;
    text-transform: uppercase;
    letter-spacing: .03em;
}

/* Activities list inside narrow right column */
.activities-list { margin-top: 12px; }
.act-row {
    padding: var(--gap-sm) 10px;
    border: 1px solid var(--crm-card-border);
    border-radius: 4px;
    margin-bottom: 6px;
    display: flex;
    align-items: flex-start;
    gap: var(--gap-sm);
    font-size: .9rem;
    background: var(--crm-card-bg);
}
.act-row.past { opacity: .55; }
.act-row .act-type {
    background: var(--light);
    color: var(--muted);
    padding: 2px var(--gap-sm);
    border-radius: 3px;
    font-family: var(--font-heading);
    font-size: .7rem;
    text-transform: uppercase;
    flex-shrink: 0;
}
.act-row .act-body { flex: 1; min-width: 0; }
.act-row .act-subject { font-weight: 600; color: var(--navy); word-wrap: break-word; }
.act-row .act-due {
    font-size: .75rem;
    color: var(--subtle);
    font-family: var(--font-heading);
}
.act-row .act-gcal {
    color: var(--navy);
    text-decoration: none;
    font-size: 1rem;
    flex-shrink: 0;
}

.add-act-form {
    background: var(--cream);
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 12px;
    border: 1px solid var(--crm-card-border);
}
.add-act-form input,
.add-act-form select,
.add-act-form textarea {
    width: 100%;
    padding: 6px var(--gap-sm);
    border: 1px solid var(--crm-card-border);
    border-radius: 3px;
    font-family: var(--font-body);
    font-size: .85rem;
    margin-bottom: 6px;
    box-sizing: border-box;
}
.add-act-form textarea { resize: vertical; min-height: 50px; }
.add-act-form .add-act-btn {
    background: var(--navy);
    color: #fff;
    padding: 6px 14px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-family: var(--font-heading);
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    width: 100%;
}
.add-act-form .add-act-btn:hover { background: var(--gold); color: var(--ink); }

.gcal-embed {
    width: 100%;
    border: 1px solid var(--crm-card-border);
    border-radius: 4px;
}

/* Responsive — collapse to single column under 1100px */
@media (max-width: 1100px) {
    .deals-detail-container { flex-direction: column; }
    .deals-detail-col-left,
    .deals-detail-col-right {
        position: static;
        flex: 1 1 auto;
        max-height: none;
        width: 100%;
    }
    .crm-container { width: 100%; padding: var(--gap-sm); }
}

/* Print/PDF — flatten to single column and force-expand everything */
@media print {
    .crm-container { width: 100%; max-width: none; padding: 0; }
    .deals-detail-container { flex-direction: column; }
    .deals-detail-col-left,
    .deals-detail-col-right {
        position: static;
        flex: 1 1 auto;
        max-height: none;
        width: 100%;
        overflow: visible;
    }
    .sd-section .sd-body { display: block !important; }
    .kd-matter .kd-matter-body { display: block !important; }
    .sd-head .sd-caret,
    .matter-add-note-btn,
    .add-act-form,
    .act-gcal { display: none !important; }
    .gcal-embed { display: none !important; }
    .deal-section, .sd-section, .kd-matter {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
