/* Note Editor Modal Styles */

/* Floating Window Container */
.note-editor-window {
    position: fixed;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    z-index: 10000;
    border: 1px solid #d0d0d0;
    overflow: hidden;
}

/* Title bar as drag handle */
.note-editor-window .modal-header {
    cursor: move;
    user-select: none;
}

/* Ensure modal body fills available space and scrolls */
.note-editor-window .modal-body {
    flex: 1;
    overflow-y: auto;
}

/* Resize handles - invisible hit areas on edges and corners */
.resize-handle {
    position: absolute;
    z-index: 1;
}
.resize-handle-n  { top: -4px; left: 8px; right: 8px; height: 8px; cursor: n-resize; }
.resize-handle-s  { bottom: -4px; left: 8px; right: 8px; height: 8px; cursor: s-resize; }
.resize-handle-e  { right: -4px; top: 8px; bottom: 8px; width: 8px; cursor: e-resize; }
.resize-handle-w  { left: -4px; top: 8px; bottom: 8px; width: 8px; cursor: w-resize; }
.resize-handle-ne { top: -4px; right: -4px; width: 12px; height: 12px; cursor: ne-resize; }
.resize-handle-nw { top: -4px; left: -4px; width: 12px; height: 12px; cursor: nw-resize; }
.resize-handle-se { bottom: -4px; right: -4px; width: 12px; height: 12px; cursor: se-resize; }
.resize-handle-sw { bottom: -4px; left: -4px; width: 12px; height: 12px; cursor: sw-resize; }

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    overflow-y: auto;
    padding: 20px;
}

/* Modal Content */
.modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    width: 100%;
}

.modal-large {
    max-width: 900px;
}

/* Modal Header */
.modal-header {
    background: linear-gradient(135deg, #F0F7F5 0%, #F0F7F5 100%);
    color: #2c3e50;
    padding: 20px 24px;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #e0e0e0;
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: #2c3e50;
}

.close-btn {
    background: none;
    border: none;
    color: #999;
    font-size: 32px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: color 0.2s;
}

.close-btn:hover {
    color: #333;
}

/* Modal Body */
.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* Modal Footer */
.modal-footer {
    padding: 16px 24px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    border-radius: 0 0 8px 8px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #6c757d;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #ec5f59;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error Message */
.error-message {
    background-color: #f8d7da;
    color: #721c24;
    padding: 12px 16px;
    border-radius: 4px;
    border: 1px solid #f5c6cb;
    margin-bottom: 16px;
}

/* Note Editor Form */
.note-editor-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Note Sections */
.note-section {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
}

.note-section h3 {
    margin: 0 0 16px 0;
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 2px solid #ec5f59;
    padding-bottom: 8px;
}

.section-placeholder {
    padding: 20px;
    background: white;
    border: 2px dashed #dee2e6;
    border-radius: 4px;
    text-align: center;
    color: #6c757d;
    font-style: italic;
}

/* Form Styling */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 6px;
    font-size: 14px;
}

.form-group label .required {
    color: #c53030;
    margin-left: 2px;
}

.form-control {
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: #ec5f59;
    box-shadow: 0 0 0 3px rgba(232, 114, 106, 0.1);
}

.form-control:disabled,
.form-control[readonly] {
    background-color: #e9ecef;
    cursor: not-allowed;
}

select.form-control {
    cursor: pointer;
}

select.form-control:disabled {
    cursor: not-allowed;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #ec5f59 0%, #D4605A 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(232, 114, 106, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
}

.btn-pdf {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
}

.btn-pdf:hover:not(:disabled) {
    background: linear-gradient(135deg, #218838 0%, #1aa179 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

.btn-pdf:disabled {
    background: #6c757d;
}

.pdf-icon {
    font-size: 1.1em;
}

.btn-spinner {
    border: 2px solid #ffffff;
    border-top: 2px solid transparent;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    animation: spin 0.8s linear infinite;
}

/* Responsive Design */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 10px;
    }

    .modal-content {
        max-height: 95vh;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-header h2 {
        font-size: 20px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 12px 16px;
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .note-section {
        padding: 16px;
    }
}

/* Contact Records List */
.contact-records-list {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.contact-record-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    margin-bottom: 12px;
    transition: background-color 0.2s;
}

.contact-record-item:last-child {
    margin-bottom: 0;
}

.contact-record-item:hover {
    background: #e9ecef;
}

/* Allocated (greyed out) contact records */
.contact-record-item.allocated {
    opacity: 0.6;
    background: #e9ecef;
}

.contact-record-item.allocated:hover {
    background: #e9ecef;
}

.contact-record-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
}

.contact-record-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 24px; /* Ensure consistent height */
}

.contact-record-text {
    flex: 1;
    font-size: 14px;
    color: #495057;
    font-weight: 500;
    line-height: 1.4;
    display: flex;
    align-items: center;
}

.contact-record-include {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    height: 24px; /* Match the min-height of parent */
}

.include-label {
    font-size: 14px;
    color: #495057;
    font-weight: 500;
    line-height: 1.4;
    margin: 0;
    padding: 0;
}

.contact-record-checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin: 0;
    padding: 0;
    height: 24px; /* Explicit height for alignment */
}

.contact-record-checkbox.disabled {
    cursor: not-allowed;
}

.contact-record-checkbox input[type="checkbox"] {
    cursor: pointer;
    margin: 0;
    padding: 0;
    width: 16px;
    height: 16px;
    vertical-align: baseline;
    position: relative;
    top: 2px; /* Push checkbox down slightly to align with text baseline */
}

.contact-record-checkbox input[type="checkbox"]:disabled {
    cursor: not-allowed;
}

.allocated-badge {
    font-size: 11px;
    color: #6c757d;
    background: #dee2e6;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: auto;
}

.contact-record-details {
    margin-left: 0; /* Remove left margin since checkbox is now on the right */
}

.contact-details-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 13px;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.contact-details-input:focus {
    outline: none;
    border-color: #ec5f59;
    box-shadow: 0 0 0 2px rgba(232, 114, 106, 0.1);
}

.contact-details-input:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
    color: #6c757d;
}

.contact-details-input.disabled-input {
    background-color: #f5f5f5;
    border-color: #ddd;
}

.contact-details-input::placeholder {
    color: #6c757d;
    font-style: italic;
}

/* Excluded (unchecked) contact records */
.contact-record-item.excluded {
    opacity: 0.7;
}

.contact-record-item.excluded .contact-record-text {
    color: #6c757d;
}

.info-message {
    padding: 12px 16px;
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
    border-radius: 4px;
    font-size: 14px;
}


/* Read-only form display */
.form-control-static {
    padding: 10px 12px;
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    color: #495057;
    font-size: 14px;
}

/* Hide logo from web interface, show only in PDF */
.pdf-only-header {
    display: none !important;
}

/* Show logo only when printing/generating PDF */
@media print {
    .pdf-only-header {
        display: flex !important;
    }
}

/* Agreed Actions Table Styles */
.section-container {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
}

.section-container h3 {
    margin: 0 0 16px 0;
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 2px solid #ec5f59;
    padding-bottom: 8px;
}

.table-responsive {
    overflow-x: auto;
    margin-bottom: 16px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.table-bordered {
    border: 1px solid #dee2e6;
}

.note-editor-window .table thead th,
.note-editor-standalone .table thead th {
    background: linear-gradient(135deg, #ec5f59 0%, #D4605A 100%);
    color: white;
    font-weight: 600;
    padding: 12px;
    text-align: left;
    border-bottom: 2px solid #5a67d8;
}

.table tbody td {
    padding: 12px;
    border-bottom: 1px solid #dee2e6;
    vertical-align: top;
}

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

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

.table .form-control {
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 14px;
    width: 100%;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.table .form-control:focus {
    outline: none;
    border-color: #ec5f59;
    box-shadow: 0 0 0 2px rgba(232, 114, 106, 0.1);
}

.table textarea.form-control {
    resize: vertical;
    min-height: 60px;
}

/* Button styles for agreed actions */
.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 3px;
}

.btn-outline-danger {
    background: transparent;
    color: #c53030;
    border: 1px solid #feb2b2;
}

.btn-outline-danger:hover:not(:disabled) {
    background: #fde8e8;
    color: #c53030;
}

.me-2 {
    margin-right: 8px;
}

.mt-2 {
    margin-top: 8px;
}

/* Agreed Actions Section Styles */
#agreed-actions-section {
    margin-top: 20px;
}

.agreed-actions-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    overflow: hidden;
}

.agreed-actions-table thead {
    background: linear-gradient(135deg, #F0F7F5 0%, #F0F7F5 100%);
}

.agreed-actions-table th {
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 2px solid #dee2e6;
    font-size: 14px;
}

.agreed-actions-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

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

.agreed-actions-table tr:hover {
    background-color: #f8f9fa;
}

.agreed-action-input,
.agreed-who-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.agreed-action-input:focus,
.agreed-who-input:focus {
    border-color: #ec5f59;
    outline: 0;
    box-shadow: 0 0 0 3px rgba(232, 114, 106, 0.15);
}

.agreed-actions-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.agreed-actions-buttons .btn {
    padding: 8px 16px;
    font-size: 13px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.agreed-actions-buttons .btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
}

.agreed-actions-buttons .btn-secondary:hover {
    background: #5a6268;
}

.agreed-actions-buttons .btn-outline {
    background: transparent;
    color: #6c757d;
    border: 1px solid #6c757d;
}

.agreed-actions-buttons .btn-outline:hover {
    background: #6c757d;
    color: white;
}

/* Multi-select dropdown for Outcomes auto-populate */
.outcomes-autopopulate {
    margin-bottom: 8px;
}

.multi-select-dropdown {
    position: relative;
    display: inline-block;
}

.multi-select-btn {
    padding: 6px 14px;
    background: #f0f4ff;
    border: 1px solid #c0c8e0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #4a5568;
    transition: background 0.2s;
}

.multi-select-btn:hover {
    background: #e0e8ff;
}

.multi-select-options {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    z-index: 100;
    min-width: 220px;
    padding: 6px 0;
    margin-top: 2px;
}

.multi-select-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    transition: background 0.15s;
}

.multi-select-option:hover {
    background: #f5f7ff;
}

.multi-select-option input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.multi-select-done {
    padding: 6px 14px;
    border-top: 1px solid #e9ecef;
    margin-top: 4px;
    text-align: right;
}

.multi-select-done-btn {
    padding: 5px 16px;
    background: #4a7cf7;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.multi-select-done-btn:hover {
    background: #3a6ce7;
}
