/* General Body and Font Styles */
body {
    font-family: 'Poppins', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f8f9fa; /* Lighter background for a modern feel */
    color: #343a40; /* Darker text for readability */
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Header Styles */
.header {
    background-color: #ffffff;
    padding: 15px 40px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.header-left {
    display: flex;
    flex-direction: column;
}

.logo {
    margin: 0;
    color: #007bff; /* Primary blue for branding */
    font-weight: 700;
    font-size: 1.9em;
}

.welcome-message {
    margin: 0;
    font-size: 0.9em;
    color: #6c757d; /* Muted text for secondary info */
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Search Bar */
.search-bar {
    position: relative;
    display: flex;
    align-items: center;
}

.search-bar i {
    position: absolute;
    left: 12px;
    color: #adb5bd;
}

.search-bar input {
    padding: 10px 15px 10px 40px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 0.95em;
    width: 250px;
    transition: all 0.3s ease;
    background-color: #f1f3f5; /* Slightly darker input background */
}

.search-bar input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    outline: none;
    background-color: #ffffff;
}

/* Add Deal Button */
.add-deal-btn {
    background-color: #28a745; /* Success green */
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95em;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s ease, transform 0.1s ease;
    font-weight: 500;
}

.add-deal-btn:hover {
    background-color: #218838;
    transform: translateY(-1px);
}

.add-deal-btn:active {
    transform: translateY(0);
}

/* Main Content Area */
.main-content {
    padding: 30px 40px;
}

/* Deal Summary Cards */
.deal-summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 25px;
    margin-bottom: 35px;
}

.card {
    background-color: #ffffff;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 18px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    cursor: pointer;
    border: 1px solid transparent; /* Default transparent border */
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.card.active {
    border-color: #007bff; /* Highlight active filter with primary blue */
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25); /* Subtle glowing effect */
}

.card-icon {
    font-size: 2.2em;
    color: #007bff; /* Icon color matches primary brand */
}

.card-content p {
    margin: 0;
    font-size: 0.95em;
    color: #6c757d;
}

.card-content h3 {
    margin: 5px 0 0;
    font-size: 1.6em;
    color: #343a40;
    font-weight: 600;
}

/* All Deals Section */
.all-deals-section h2 {
    color: #343a40;
    margin-bottom: 25px;
    font-size: 1.8em;
    font-weight: 600;
}

.deals-table-container {
    background-color: #ffffff;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    overflow-x: auto; /* Ensures table is scrollable on smaller screens */
}

.deals-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
    min-width: 800px; /* Ensure table doesn't get too cramped */
}

.deals-table th, .deals-table td {
    padding: 15px 20px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.deals-table th {
    background-color: #f8f9fa;
    color: #495057;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    font-size: 0.85em;
}

.deals-table tbody tr:last-child td {
    border-bottom: none; /* No border for the last row */
}

.deals-table tbody tr:hover {
    background-color: #f2f7ff; /* Lighter blue hover effect */
}

/* Status Badges */
.status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 600;
    color: white;
    display: inline-block;
    min-width: 80px;
    text-align: center;
    text-transform: capitalize; /* Make status text look nicer */
}

/* Specific Status Colors (can be customized) */
.status.seller { background-color: #007bff; }
.status.buyer { background-color: #6610f2; } /* Indigo */
.status.investor { background-color: #fd7e14; } /* Orange */
.status.investment { background-color: #20c997; } /* Teal */
.status.project { background-color: #dc3545; } /* Danger red */


/* Action Buttons in Table */
.action-buttons {
    display: flex;
    gap: 8px;
}

.action-btn {
    background: none;
    border: none;
    color: #007bff;
    cursor: pointer;
    font-size: 1.15em;
    padding: 8px;
    border-radius: 50%; /* Circular buttons */
    transition: background-color 0.2s ease, color 0.2s ease;
    display: flex; /* For perfect centering of icon */
    justify-content: center;
    align-items: center;
    width: 35px; /* Fixed width for consistent circles */
    height: 35px; /* Fixed height */
}

.action-btn:hover {
    background-color: #e6f2ff;
    color: #0056b3;
}

.action-btn.delete-btn {
    color: #dc3545; /* Red for delete */
}

.action-btn.delete-btn:hover {
    background-color: #ffe6e6;
    color: #c82333;
}

/* Modal Overlay */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place relative to the viewport */
    z-index: 1000; /* High z-index to cover everything */
    left: 0;
    top: 0;
    width: 100vw; /* Use viewport width */
    height: 100vh; /* Use viewport height */
    background-color: rgba(0, 0, 0, 0.6); /* Darker overlay */
    backdrop-filter: blur(3px); /* Subtle blur effect on background */
    
    /* Ensure flexbox properties are always active for centering when shown */
    display: flex;
    justify-content: center; /* Center horizontally */
    align-items: center; /* Center vertically */
    
    /* Allow scroll only if content overflows the modal, not the entire page */
    overflow-y: auto; /* Enable vertical scroll if content is too tall */
    -webkit-overflow-scrolling: touch; /* Smoother scrolling on iOS */
    
    padding: 20px; /* Padding for small screens to prevent content touching edges */
    box-sizing: border-box; /* Include padding in width/height calculation */
}

.modal:not(.show) {
    display: none; /* Hide if not explicitly 'show' class */
}

/* Modal Content Box */
.modal-content {
    background-color: #ffffff;
    padding: 35px;
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    position: relative;
    max-width: 950px; /* Slightly larger max-width for forms */
    width: 100%; /* Take full width up to max-width */
    box-sizing: border-box; /* Include padding in width calculation */
    animation: fadeIn 0.3s ease-out; /* Smooth entrance animation */
    
    /* Ensures inner elements participate in flex context and stack */
    display: flex; 
    flex-direction: column; 
    
    /* Important for content scrolling within the modal if it gets too tall */
    max-height: calc(100vh - 40px); /* Max height relative to viewport, minus padding */
    overflow-y: auto; /* Enable scrolling for content within modal if it exceeds max-height */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-content h2 {
    margin-top: 0;
    color: #343a40;
    font-size: 2em;
    margin-bottom: 25px;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 15px;
    font-weight: 600;
}

/* Close Button in Modal */
.close-button {
    color: #adb5bd;
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close-button:hover,
.close-button:focus {
    color: #343a40;
}

/* Form Grid Layout */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); /* Auto-adjust columns */
    gap: 25px;
    margin-bottom: 30px;
    /* Explicitly setting min-width for grid to ensure it can shrink properly within flex container */
    min-width: 0;
}

.form-group {
    margin-bottom: 0; /* Managed by grid gap */
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #495057;
    font-size: 0.9em;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
    font-size: 0.95em;
    color: #495057;
    background-color: #ffffff;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-group input[type="text"]:focus,
.form-group input[type="number"]:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    outline: none;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Readonly/Disabled Field Styling */
.form-group input[readonly],
.form-group input[disabled],
.form-group select[disabled],
.form-group textarea[disabled] {
    background-color: #e9ecef; /* Light gray background */
    cursor: not-allowed;
    color: #6c757d;
    border-color: #dee2e6;
}

/* Full Width Form Fields */
.form-group.full-width {
    grid-column: 1 / -1; /* Spans across all available grid columns */
}

/* Submit Button in Modal */
.submit-deal-btn {
    background-color: #007bff; /* Primary blue */
    color: white;
    border: none;
    padding: 14px 30px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.05em;
    font-weight: 600;
    display: block; /* Make it a block element to center with margin auto */
    width: fit-content; /* Adjust width to content */
    margin: 30px auto 0 auto; /* Center button and add top margin */
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.submit-deal-btn:hover {
    background-color: #0056b3;
    transform: translateY(-1px);
}

.submit-deal-btn:active {
    transform: translateY(0);
}

/* New styles for View Deal Details Table */
.view-deal-details-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 25px;
    font-size: 1em;
}

.view-deal-details-table th,
.view-deal-details-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.view-deal-details-table th {
    background-color: #f8f9fa;
    color: #495057;
    font-weight: 600;
    width: 35%; /* Adjust label column width */
}

.view-deal-details-table td {
    color: #343a40;
    width: 65%; /* Adjust value column width */
}

.view-deal-details-table tr:last-child th,
.view-deal-details-table tr:last-child td {
    border-bottom: none;
}

/* Responsive Adjustments */
@media (max-width: 992px) {
    .header {
        padding: 15px 25px;
    }
    .main-content {
        padding: 25px 25px;
    }
    .deal-summary-cards {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
        gap: 20px;
    }
    .modal-content {
        max-width: 90%;
        padding: 30px;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    .header-right {
        width: 100%;
        justify-content: space-between;
        gap: 10px;
    }
    .search-bar {
        flex-grow: 1;
    }
    .search-bar input {
        width: 100%;
        min-width: unset; /* Override min-width if necessary */
    }
    .add-deal-btn {
        padding: 10px 15px;
        font-size: 0.9em;
    }
    .deal-summary-cards {
        grid-template-columns: 1fr; /* Stack cards vertically */
    }
    .deals-table th, .deals-table td {
        padding: 12px 15px;
    }
    .deals-table {
        min-width: 600px; /* Keep minimum width for table */
    }
    .form-grid {
        grid-template-columns: 1fr; /* Stack form fields vertically */
        gap: 20px;
    }
    .modal-content {
        padding: 25px;
        max-height: calc(100vh - 30px); /* Adjust max-height for smaller padding */
    }
    .modal-content h2 {
        font-size: 1.6em;
        margin-bottom: 20px;
    }
    .close-button {
        font-size: 28px;
        top: 15px;
        right: 20px;
    }
    .view-deal-details-table th,
    .view-deal-details-table td {
        display: block; /* Stack header and data for small screens */
        width: 100%;
    }
    .view-deal-details-table th {
        text-align: left;
        padding-bottom: 5px;
    }
    .view-deal-details-table td {
        padding-top: 5px;
        padding-bottom: 15px;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 10px 15px;
    }
    .logo {
        font-size: 1.6em;
    }
    .main-content {
        padding: 15px;
    }
    .card {
        padding: 20px;
    }
    .card-icon {
        font-size: 1.8em;
    }
    .card-content h3 {
        font-size: 1.3em;
    }
    .all-deals-section h2 {
        font-size: 1.5em;
    }
    .action-btn {
        font-size: 1em;
        width: 30px;
        height: 30px;
        padding: 6px;
    }
    .modal-content {
        padding: 20px;
        max-height: calc(100vh - 20px); /* Adjust max-height for even smaller padding */
    }
    .modal-content h2 {
        font-size: 1.5em;
    }
    .submit-deal-btn {
        padding: 10px 20px;
        font-size: 0.95em;
    }
}