/* css/modal.css */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--background-surface);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-xl);
    width: 100%;
    max-width: 500px;
    box-shadow: var(--box-shadow-md);
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.modal-overlay.visible .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: var(--spacing-lg);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color-secondary);
}

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-size: 1rem;
    font-family: var(--font-primary);
    box-sizing: border-box; /* Important for width */
    transition: border-color 0.2s, box-shadow 0.2s;
    background-color: var(--background-surface-alt);
    color: var(--text-color-primary);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.notes-list {
    background-color: var(--background-surface-alt);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
    min-height: 80px;
    max-height: 200px;
    overflow-y: auto;
    color: var(--text-color-primary);
    list-style: none;
    margin: 0;
}

.notes-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--border-color);
}

.notes-list li:last-child {
    border-bottom: none;
}

.note-text {
    flex-grow: 1;
}

.note-date {
    font-size: 0.8rem;
    color: var(--text-color-secondary);
    margin-left: var(--spacing-md);
}

.delete-note-btn {
    background: none;
    border: none;
    color: var(--text-color-secondary);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 var(--spacing-sm);
}

.delete-note-btn:hover {
    color: var(--accent-color-danger);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(0, 196, 255, 0.2);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-md);
    margin-top: var(--spacing-lg);
}

/* --- Docs Modal Specific Styles --- */
.file-input {
    display: block;
    margin-bottom: var(--spacing-md);
}

#upload-btn {
    width: 100%;
}

.docs-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    background-color: var(--background-surface-alt);
}

.docs-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.docs-list li:last-child {
    border-bottom: none;
}

.docs-list .file-name {
    flex-grow: 1;
    color: var(--text-color-primary);
}

.docs-list .doc-actions button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-color-secondary);
    font-size: 1rem;
    margin-left: var(--spacing-sm);
    padding: var(--spacing-xs);
}

.docs-list .doc-actions button:hover {
    color: var(--accent-color);
}

.docs-list .doc-actions .delete-doc-btn:hover {
    color: var(--danger-color);
}

/* --- MVP Modal Specific Styles --- */
.input-with-button {
    display: flex;
    gap: var(--spacing-sm);
}

.input-with-button input {
    flex-grow: 1;
}

.saved-links-list {
    list-style: none;
    padding: 0;
    margin: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    background-color: var(--background-surface-alt);
}

.saved-links-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
}

.saved-links-list li:last-child {
    border-bottom: none;
}

.saved-links-list .link-info {
    flex-grow: 1;
    overflow: hidden;
}

.saved-links-list .link-type {
    font-weight: 600;
    color: var(--text-color-primary);
}

.saved-links-list .link-url {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
    color: var(--link-color-copilot);
    text-decoration: none;
}

.saved-links-list .link-url:hover {
    text-decoration: underline;
}

.saved-links-list .delete-link-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-color-secondary);
    font-size: 1.2rem;
    padding: var(--spacing-xs);
}

.saved-links-list .delete-link-btn:hover {
    color: var(--danger-color);
}

input[readonly] {
    background-color: var(--background-body) !important;
    cursor: pointer; /* Change cursor to indicate it's clickable */
}

input[readonly]:hover {
    text-decoration: underline; /* Underline on hover like a real link */
}

/* --- Select Lead Modal Specific Styles --- */
#select-lead-modal-overlay .modal-content {
    max-height: 400px; /* Define a max height for the content area */
    overflow-y: auto; /* Enable vertical scrolling */
    padding-top: var(--spacing-md); /* Add some padding above the list */
}

#select-lead-search {
    margin-bottom: var(--spacing-md);
}

.lead-selection-list {
    list-style: none;
    padding: 0;
    margin: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    background-color: var(--background-surface-alt);
}

.lead-selection-list .lead-item {
    display: flex;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.lead-selection-list .lead-item:last-child {
    border-bottom: none;
}

.lead-selection-list .lead-item:hover {
    background-color: var(--background-body);
}

.lead-selection-list .lead-name {
    font-weight: 600;
    color: var(--text-color-primary);
    flex-basis: 40%; /* Allocate more space for name */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lead-selection-list .lead-email {
    color: var(--text-color-secondary);
    font-size: 0.9rem;
    flex-basis: 40%; /* Allocate space for email */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-left: var(--spacing-md);
}

.lead-selection-list .lead-stage {
    /* Reusing stage-tag styles from list-view.css for consistency */
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: 1rem; /* Pill shape */
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid;
    margin-left: auto; /* Push to the right */
    flex-shrink: 0; /* Prevent shrinking */
}

/* Ensure stage colors are consistent (from list-view.css or main.css if global) */
.lead-selection-list .lead-stage.stage-new-lead { background-color: rgba(88, 101, 242, 0.2); color: #a9b2cc; border-color: #5865f2; }
.lead-selection-list .lead-stage.stage-contacted { background-color: rgba(87, 242, 135, 0.2); color: #a9b2cc; border-color: #57f287; }
.lead-selection-list .lead-stage.stage-proposal { background-color: rgba(254, 231, 92, 0.2); color: #a9b2cc; border-color: #fee75c; }
.lead-selection-list .lead-stage.stage-won { background-color: rgba(46, 204, 113, 0.2); color: #a9b2cc; border-color: #2ecc71; }
.lead-selection-list .lead-stage.stage-lost { background-color: rgba(237, 66, 69, 0.2); color: #a9b2cc; border-color: #ed4245; }