/* File: /css/edit-proposal-modal.css */

/* New variables for sleekness */
:root {
    --modal-bg-color: var(--background-surface);
    --modal-border-color: var(--border-color);
    --modal-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    --tab-hover-bg: var(--background-surface-alt);
    --table-header-bg: rgba(109, 73, 255, 0.323); /* Slightly transparent primary color */
    --table-header-text: var(--text-color-on-primary);
    --table-row-hover-bg: var(--background-surface-alt);
    --total-border-color: var(--border-color);
}

.modal-overlay {
    /* Existing styles should cover this */
}

.modal.edit-proposal-modal {
    width: 90%;
    max-width: 1200px;
    background-color: var(--modal-bg-color);
    border-radius: var(--border-radius-lg); /* Softer corners */
    box-shadow: var(--modal-shadow); /* More pronounced shadow */
    border: 1px solid var(--modal-border-color); /* Subtle border */
    overflow: hidden; /* Ensures content respects border-radius */
}

.modal.edit-proposal-modal .modal-content {
    max-height: calc(90vh - 100px); /* Adjust based on header/footer height */
    overflow-y: auto;
    padding-right: 1rem; /* Compensate for scrollbar to keep padding consistent */
}

/* Collapsible Section Styling - Sleekness Minimalism */
.collapsible-section {
    margin-bottom: 0.4rem; /* Even less spacing between sections */
    /* Removed border-radius from the section itself */
    overflow: hidden; /* Ensures children respect the border-radius */
    transition: all 0.3s ease; /* Smooth transition for section changes */
}

.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0.6rem 1.5rem; /* Reduced vertical padding for a more compact look */
    background-color: transparent; /* Truly transparent background when closed */
    border: none; /* No border when closed */
    border-radius: var(--border-radius-md); /* Rounded corners for the header */
    cursor: pointer;
    font-size: 0.95rem; /* Slightly smaller font size */
    font-weight: 400; /* Even lighter font weight for minimalism */
    color: var(--text-color-secondary); /* Softer default text color */
    transition: all 0.3s ease;
}

.collapsible-header:hover {
    background-color: var(--background-surface-alt); /* Very subtle background on hover */
    color: var(--text-color-primary); /* Darker text on hover for subtle emphasis */
}

.collapsible-header.active {
    background-color: var(--primary-color); /* Primary color for active header */
    color: var(--table-header-text); /* White text on primary background */
    border-bottom: none; /* No bottom border when active to blend with content */
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    box-shadow: none; /* Removed shadow for active header for ultimate minimalism */
}

.collapsible-header .collapse-icon {
    transition: transform 0.3s ease;
}

.collapsible-header.active .collapse-icon {
    transform: rotate(180deg);
}

.collapsible-content {
    padding: 0 1.5rem; /* Set horizontal padding, vertical padding to 0 when closed */
    background-color: var(--modal-bg-color); /* Match modal background */
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out, padding 0.4s ease-out;
}

.collapsible-content.active {
    max-height: 1000px; /* A large enough value to accommodate content */
    padding: 0.8rem 1.5rem; /* Apply desired padding when active */
    /* Removed border-top to make it flow seamlessly from the header */
}

/* Details Tab*/
.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); /* Slightly wider min-width */
    gap: 1.5rem; /* Slightly reduced gap */
}

.details-grid dl {
    margin: 0;
    background-color: var(--background-surface-alt); /* Subtle background for each detail block */
    padding: 1rem;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--modal-border-color);
}

.details-grid dt {
    font-weight: 600;
    color: var(--text-color-primary); /* Darker for emphasis */
    margin-bottom: 0.5rem; /* More space */
    font-size: 0.9rem; /* Slightly smaller for labels */
    text-transform: uppercase; /* Make labels uppercase */
    letter-spacing: 0.05em;
}

.details-grid dd {
    margin-left: 0;
    margin-bottom: 0; /* Remove bottom margin */
    padding-left: 0; /* Remove padding-left */
    border-left: none; /* Remove border-left */
    color: var(--text-color-secondary); /* Softer color for values */
    font-size: 1rem;
    font-weight: 500;
}

.details-grid input.editable-field {
    width: 100%;
    padding: 0.4rem 0.6rem; /* Reduced padding */
    border: 1px solid transparent; /* Transparent border by default */
    border-radius: var(--border-radius-sm); /* Smaller border-radius */
    font-size: 0.95rem; /* Slightly smaller font */
    font-family: inherit;
    box-sizing: border-box;
    background-color: var(--background-body); /* Match body background */
    color: var(--text-color-primary);
    margin-top: 0.25rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.details-grid input.editable-field:hover {
    border-color: var(--border-color); /* Subtle border on hover */
}

.details-grid input.editable-field:focus {
    outline: none;
    border-color: var(--accent-color); /* Accent color on focus */
    box-shadow: 0 0 0 1px rgba(0, 196, 255, 0.1); /* Very subtle shadow on focus */
}

/* Services & Options Tab */
.proposal-table {
    width: 100%;
    table-layout: fixed; /* Enable fixed table layout for column width control */
    border-collapse: separate; /* Use separate for border-radius on cells */
    border-spacing: 0; /* Remove default spacing */
    margin-bottom: 1rem; /* Reduced margin */
    border-radius: var(--border-radius-md); /* Rounded corners for the table */
    overflow: hidden; /* Ensures rounded corners are visible */
    border: 1px solid var(--modal-border-color); /* Table border */
}

.proposal-table th,
.proposal-table td {
    padding: 0.6rem 1rem; /* Slightly reduced padding */
    text-align: left;
    border-bottom: 1px solid var(--modal-border-color); /* Lighter border */
    word-wrap: break-word; /* Ensure long words break */
}

.proposal-table th:nth-child(1), .proposal-table td:nth-child(1) { width: 20%; } /* Concept */
.proposal-table th:nth-child(2), .proposal-table td:nth-child(2) { width: 30%; } /* Description */
.proposal-table th:nth-child(3), .proposal-table td:nth-child(3) { width: 10%; } /* Term */
.proposal-table th:nth-child(4), .proposal-table td:nth-child(4) { width: 8%; } /* Quantity */
.proposal-table th:nth-child(5), .proposal-table td:nth-child(5) { width: 12%; } /* Unit Price */
.proposal-table th:nth-child(6), .proposal-table td:nth-child(6) { width: 15%; } /* Line Total */
.proposal-table th:nth-child(7), .proposal-table td:nth-child(7) { width: 5%; } /* Delete button */

.proposal-table th {
    background-color: var(--table-header-bg); /* Primary color for header */
    color: var(--table-header-text); /* White text on primary background */
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.proposal-table tbody tr:last-child td {
    border-bottom: none; /* No border on the last row */
}

.proposal-table .text-right {
    text-align: right;
}

.proposal-table tbody tr:hover {
    background-color: var(--table-row-hover-bg); /* Softer hover effect */
}

.proposal-table input.editable-field,
.proposal-table textarea.editable-field {
    width: 100%;
    padding: 0.3rem 0.5rem; /* Even more reduced padding for table inputs */
    border: 1px solid transparent; /* Transparent border by default */
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    box-sizing: border-box;
    background-color: var(--background-body);
    color: var(--text-color-primary);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden; /* Hide scrollbar by default */
    white-space: nowrap; /* Keep text on one line for inputs */
    text-overflow: ellipsis; /* Add ellipsis for overflowed text in inputs */
}

.proposal-table textarea.editable-field {
    resize: vertical; /* Allow vertical resizing */
    min-height: 2.5em; /* Minimum height for textarea */
    white-space: normal; /* Allow text wrapping for textarea */
    overflow: auto; /* Show scrollbar when content overflows */
}

.proposal-table input.editable-field:hover,
.proposal-table textarea.editable-field:hover {
    border-color: var(--border-color); /* Subtle border on hover */
}

.proposal-table input.editable-field:focus,
.proposal-table textarea.editable-field:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 1px rgba(0, 196, 255, 0.1); /* Very subtle shadow on focus */
}

.proposal-table .delete-row-btn {
    background: none; /* No background */
    border: none; /* No border */
    color: var(--text-color-secondary); /* Subtle color */
    padding: 0.2rem; /* Minimal padding */
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 1rem; /* Icon size */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.proposal-table .delete-row-btn:hover {
    color: var(--accent-color-danger); /* Red on hover */
    background-color: var(--background-surface-alt); /* Subtle background on hover */
}

.add-row-btn {
    margin-top: 0.5rem;
    margin-bottom: 1rem; /* Slightly less space below add button */
    padding: 0.5rem 0.8rem; /* Reduced padding */
    font-size: 0.85rem; /* Slightly smaller font */
    background-color: var(--background-surface-alt); /* Subtle background */
    color: var(--text-color-primary); /* Default text color */
    border: 1px solid var(--border-color); /* Subtle border */
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.add-row-btn:hover {
    background-color: var(--primary-color); /* Primary color on hover */
    color: var(--table-header-text); /* White text on hover */
    border-color: var(--primary-color);
}

/* Financials Tab */
.totals-list {
    max-width: 450px; /* Slightly wider */
    margin-left: auto;
    font-size: 1.1rem;
    padding: 1rem; /* Reduced padding */
    background-color: var(--background-surface-alt); /* Subtle background */
    border-radius: var(--border-radius-md);
    border: 1px solid var(--modal-border-color);
}

.totals-list dt {
    float: left;
    clear: left;
    width: 60%;
    text-align: right;
    padding-right: 1.5rem; /* More padding */
    color: var(--text-color-secondary); /* Softer color */
    font-weight: 500;
}

.totals-list dd {
    margin-left: 65%;
    font-weight: 600;
    color: var(--text-color-primary); /* Darker for values */
    margin-bottom: 0.75rem; /* Space between items */
}

.totals-list dd.editable-field {
    display: inline-block; /* Allow contenteditable to behave like a block */
    min-width: 50px; /* Ensure it has some width */
    border-bottom: 1px solid transparent; /* No border by default */
    padding-bottom: 2px;
    cursor: text;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.totals-list dd.editable-field:hover {
    background-color: var(--background-surface-alt); /* Very subtle background on hover */
}

.totals-list dd.editable-field:focus {
    outline: none;
    border-bottom-color: var(--accent-color); /* Accent color on focus */
    background-color: var(--background-body); /* Slightly different background when focused */
}

.totals-list .grand-total {
    font-size: 1.4rem; /* Slightly larger */
    color: var(--primary-color);
    border-top: 2px solid var(--total-border-color); /* Consistent border color */
    padding-top: 1rem; /* More padding */
    margin-top: 1rem; /* More margin */
    font-weight: 700; /* Bolder */
}