/* --- General Body Styling --- */
body {
    margin: 0;
    font-family: 'Poppins', sans-serif;
    background-color: #f4f7f6;
    color: #333;
}

/* --- Login Page Specifics --- */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    padding: 20px;
}

.login-card {
    background-color: #ffffff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-card h2 {
    margin-top: 0;
    font-weight: 700;
    color: #2c3e50;
}

.login-card p {
    margin-bottom: 30px;
    color: #7f8c8d;
}

/* --- Form Element Styling --- */
.input-group {
    margin-bottom: 20px;
    text-align: left;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
}

.input-group input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    box-sizing: border-box;
}

.input-group input:focus {
    outline: none;
    border-color: #3498db;
}

.login-button {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 8px;
    background-color: #3498db;
    color: white;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.login-button:hover {
    background-color: #2980b9;
}

.error-message {
    color: #e74c3c;
    margin-top: 15px;
    font-size: 14px;
    height: 20px;
}

/* --- Dashboard Layout --- */
.dashboard-container {
    display: flex;
    min-height: 100vh;
    background-color: #f4f7f6;
}

/* --- Sidebar Styling --- */
.sidebar {
    width: 260px;
    background-color: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
    padding: 20px;
    flex-shrink: 0;
}

/* --- FIX: Center Logo in Admin Sidebar --- */
.sidebar-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding-bottom: 20px;
    border-bottom: 1px solid #34495e;
}

.sidebar-nav {
    flex-grow: 1;
    margin-top: 30px;
}

.sidebar-nav .nav-item {
    display: block;
    color: #ecf0f1;
    text-decoration: none;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 10px;
    transition: background-color 0.3s;
}

.sidebar-nav .nav-item:hover {
    background-color: #34495e;
}

.sidebar-nav .nav-item.active {
    background-color: #3498db;
    font-weight: 500;
}

.logout-button {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 8px;
    background-color: #e74c3c;
    color: white;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.logout-button:hover {
    background-color: #c0392b;
}


/* --- Main Content Styling --- */
.main-content {
    flex-grow: 1;
    padding: 40px;
    overflow-x: hidden; /* Prevent horizontal scroll */
}

.main-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 40px;
}

.main-header h1 {
    margin: 0;
    font-size: 32px;
    color: #2c3e50;
}

.main-header p {
    color: #7f8c8d;
    font-size: 18px;
    margin: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 30px;
}

.stat-card {
    background-color: #ffffff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.stat-card h4 {
    margin-top: 0;
    color: #7f8c8d;
    font-size: 16px;
    font-weight: 500;
}

.stat-card .stat-value {
    font-size: 36px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 0;
}

/* --- Form Styling --- */
.form-card {
    background-color: #ffffff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}
.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
}
.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    font-family: 'Poppins', sans-serif;
    box-sizing: border-box;
}
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}
.submit-button {
    width: auto;
    padding: 15px 30px;
    border: none;
    border-radius: 8px;
    background-color: #3498db;
    color: white;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
}
.submit-button:hover {
    background-color: #2980b9;
}

/* Approval List Styling */
.approval-list .item {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.approval-list .item-info h4 { margin: 0 0 5px 0; }
.approval-list .item-info p { margin: 0; color: #7f8c8d; }
.approval-list .item-actions button {
    padding: 8px 15px;
    margin-left: 10px;
    border-radius: 5px;
    cursor: pointer;
}
.btn-approve { background-color: #2ecc71; color: white; border: none; }
.btn-reject { background-color: #e74c3c; color: white; border: none; }

/* --- Property Grid & Card Styling --- */
.property-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
}

.property-card {
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.07);
    overflow: hidden;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.property-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.property-card-image {
    width: 100%;
    height: 200px;
    background-color: #ecf0f1;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #bdc3c7;
    font-size: 14px;
    background-size: cover;
    background-position: center;
}

.property-card-content {
    padding: 20px;
}

.property-card-content h4 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 18px;
    color: #2c3e50;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.property-card-location {
    font-size: 14px;
    color: #7f8c8d;
    margin-bottom: 15px;
}

.property-card-price {
    font-size: 22px;
    font-weight: 700;
    color: #3498db;
    margin-bottom: 15px;
}

.property-card-details {
    display: flex;
    justify-content: space-between;
    padding-top: 15px;
    border-top: 1px solid #f4f7f6;
    font-size: 14px;
    color: #34495e;
}

.property-card-link {
    text-decoration: none;
    color: inherit;
}

/* Property Detail Page Styling */
.details-card {
    background-color: #ffffff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}
.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    font-size: 16px;
}

/* --- Modal Styling --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 0;
    border: 1px solid #888;
    width: 80%;
    max-width: 600px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    animation: animatetop 0.4s;
}

@keyframes animatetop {
  from {top: -300px; opacity: 0}
  to {top: 0; opacity: 1}
}

.modal-header {
    padding: 20px 30px;
    background-color: #3498db;
    color: white;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
}

.modal-body {
    padding: 30px;
}

.close-button {
    color: #fff;
    font-size: 28px;
    font-weight: bold;
}

.close-button:hover,
.close-button:focus {
    color: #f1f1f1;
    text-decoration: none;
    cursor: pointer;
}

/* --- Leads Table Styling --- */
.leads-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.leads-table th, .leads-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}

.leads-table th {
    background-color: #f8f9fa;
    font-weight: 500;
    color: #34495e;
}

.leads-table tr:last-child td {
    border-bottom: none;
}

.leads-table tr:hover {
    background-color: #f4f7f6;
}

/* --- Status Badge Styling --- */
.status-badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    text-transform: capitalize;
}

.status-new { background-color: #eaf2fa; color: #3498db; }
.status-assigned { background-color: #fef3e0; color: #f39c12; }
.status-contacted { background-color: #e8f6f3; color: #1abc9c; }
.status-closed { background-color: #e9f7ef; color: #2ecc71; }
.status-rejected { background-color: #f9ebea; color: #e74c3c; }


.agent-option {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: background-color 0.2s;
}
.agent-option:hover {
    background-color: #f4f7f6;
}

/* --- Agent Grid & Card Styling --- */
.agent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
}

.agent-card {
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    padding: 25px;
    text-align: center;
}

.agent-card h4 {
    margin-top: 0;
    margin-bottom: 5px;
    font-size: 18px;
}

.agent-card p {
    color: #7f8c8d;
    margin-bottom: 20px;
}

.filter-bar { margin-bottom: 20px; }
.filter-btn {
    padding: 8px 15px;
    border: 1px solid #ddd;
    background-color: #fff;
    border-radius: 20px;
    cursor: pointer;
    margin-left: 10px;
}
.filter-btn.active {
    background-color: #3498db;
    color: white;
    border-color: #3498db;
}

a.agent-card-link {
    text-decoration: none;
    color: inherit;
}

.profile-header { display: flex; align-items: center; gap: 20px; }
.profile-image { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; }
.submit-button-small {
    padding: 8px 15px; border: none; border-radius: 8px;
    background-color: #7f8c8d; color: white; cursor: pointer;
}

.agent-card-photo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 15px;
    border: 3px solid #f4f7f6;
}

/* --- Form Fieldset Styling --- */
fieldset {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 30px;
}
legend {
    font-weight: 500;
    font-size: 18px;
    padding: 0 10px;
    color: #34495e;
}
.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}
.input-group-suffix {
    position: relative;
}
.input-group-suffix input {
    padding-right: 50px;
}
.input-group-suffix span {
    position: absolute;
    right: 15px;
    top: 42px;
    color: #7f8c8d;
}

.form-grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

/* --- Property Image Gallery Styling --- */
.property-thumbnail {
    width: 100%;
    max-height: 500px;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 20px;
}
.property-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 20px;
}
.gallery-image {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
}

.leads-table .lead-name-link {
    font-weight: 500;
    color: #3498db;
    text-decoration: none;
}
.leads-table .lead-name-link:hover {
    text-decoration: underline;
}

/* --- Table Action Button Styling --- */
.leads-table .assign-button,
.leads-table .update-status-button {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid #ddd;
    background-color: #ffffff;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.leads-table .assign-button:hover,
.leads-table .update-status-button:hover {
    background-color: #f4f7f6;
    border-color: #ccc;
}

.leads-table .assign-button:hover {
    background-color: #eaf2fa;
    border-color: #3498db;
    color: #3498db;
}

/* --- ROLE-BASED VISIBILITY RULES --- */
#nav-agents,
#add-user-btn,
#pending-approvals-section {
    display: none;
}
body.role-director #nav-agents,
body.role-director #add-user-btn,
body.role-director #pending-approvals-section,
body.role-regional-manager #nav-agents,
body.role-regional-manager #add-user-btn,
body.role-regional-manager #pending-approvals-section {
    display: block;
}
#my-leads-section {
    display: none;
}
body.role-agent #my-leads-section {
    display: block;
}
body.role-agent #add-lead-btn {
    display: none;
}


/* ===================================================================== */
/* --- RESPONSIVE STYLES --- */
/* ===================================================================== */

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: #2c3e50;
    font-size: 24px;
    cursor: pointer;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

/* --- TABLET & MOBILE STYLES (992px and down) --- */
@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100%;
        z-index: 1001;
        transition: left 0.3s ease-in-out;
    }

    .sidebar.active {
        left: 0;
    }
    
    .sidebar-overlay.active {
        display: block;
    }

    .main-content {
        width: 100%;
    }

    .mobile-menu-toggle {
        display: block;
    }
}

/* --- MOBILE ONLY STYLES (768px and down) --- */
@media (max-width: 768px) {
    .main-content {
        padding: 20px;
    }

    .main-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .main-header h1 {
        font-size: 24px;
    }
    
    .main-header p {
        font-size: 16px;
        margin-bottom: 20px;
    }

    .stats-grid,
    .form-grid,
    .form-grid-3,
    .form-grid-4,
    .agent-grid,
    .details-grid {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .leads-table thead {
        display: none;
    }

    .leads-table, .leads-table tbody, .leads-table tr, .leads-table td {
        display: block;
        width: 100%;
    }

    .leads-table tr {
        margin-bottom: 15px;
        border: 1px solid #eee;
        border-radius: 8px;
        overflow: hidden;
        box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    }

    .leads-table td {
        text-align: right;
        padding-left: 50%;
        position: relative;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .leads-table tr td:last-child {
        border-bottom: none;
    }

    .leads-table td:before {
        content: attr(data-label);
        position: absolute;
        left: 15px;
        width: calc(50% - 30px);
        text-align: left;
        font-weight: 500;
        color: #34495e;
    }
    
    .modal-content {
        width: 90%;
        margin: 20% auto;
    }
}

/* --- NEW: Status Badge Styling for Tours --- */

.status-scheduled { 
    background-color: #e8eaf6; /* A light indigo/purple */
    color: #3f51b5; 
}

.status-completed { 
    background-color: #e9f7ef; /* Same as 'closed' */
    color: #2ecc71; 
}

.status-canceled { 
    background-color: #f9ebea; /* Same as 'rejected' */
    color: #e74c3c; 
}

.status-requested {
    background-color: #fef3e0; /* A light amber/orange */
    color: #f39c12; 
}

/* --- Profile Page Button Styling --- */
.profile-actions {
    display: flex;
    gap: 15px; /* Adjust the space between buttons */
    margin-top: 20px;
}

.profile-actions .submit-button,
.profile-actions .logout-button {
    flex: 1; /* Makes both buttons take up equal space */
    width: 100%; /* Ensures they fill the container */
    margin-left: 0; /* Override any existing margins */
}

/* --- Admin Login Logo Styling --- */
.login-logo {
    max-width: 300px; /* Sets the logo width for PC */
    width: 100%;
    height: auto;
    margin-bottom: 15px;
}

/* --- Responsive styles for mobile devices --- */
@media (max-width: 768px) {
    .login-logo {
        max-width: 200px; /* Makes the logo smaller on mobile */
    }
}

/* --- Loan Calculator Styles --- */
.loan-calculator {
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.loan-calculator .form-group {
    margin-bottom: 15px;
}

.loan-calculator .form-group label {
    font-weight: 500;
    font-size: 0.9rem;
}

.loan-calculator input[type="range"] {
    width: 100%;
    cursor: pointer;
}

.loan-calculator input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    font-family: 'Poppins', sans-serif;
    box-sizing: border-box;
}

.calculator-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    min-height: 300px;
}

#emi-chart {
    max-width: 250px;
    margin: 0 auto;
}

#emi-details {
    width: 100%;
}

#emi-details p {
    margin: 8px 0;
    font-size: 1.1rem;
    text-align: center;
    font-weight: 500;
}

#emi-details p strong {
    color: var(--primary-color);
}

@media (min-width: 768px) {
    .loan-calculator {
        grid-template-columns: 1fr 1fr;
        align-items: center;
    }
}

/* --- Agent Performance Table --- */
.table-container {
    overflow-x: auto; /* Ensures table is scrollable on small screens */
}

.leads-table .lead-name-link {
    font-weight: 500;
    color: #3498db;
    text-decoration: none;
}

.leads-table .lead-name-link:hover {
    text-decoration: underline;
}

/* --- Item Action Button --- */
.approval-list .item-actions {
    display: flex;
    gap: 10px;
}

.approval-list .btn-view-details {
    padding: 8px 16px;
    background-color: #3498db;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.3s ease;
}

.approval-list .btn-view-details:hover {
    background-color: #2980b9;
}

/* --- Enhanced Agent Performance Table --- */
.table-container {
    overflow-x: auto; /* Allows horizontal scrolling on small screens */
}

.leads-table thead th {
    background-color: #f2f2f2;
    text-align: center;
    vertical-align: middle;
    border: 1px solid #ddd;
}

.leads-table tbody td {
    text-align: center;
    vertical-align: middle;
}

/* Specifically target the first column (Name) for left alignment */
.leads-table tbody td:first-child,
.leads-table thead th[rowspan="2"] {
    text-align: left;
    background-color: #f8f9fa; /* Slightly different background for the name column */
}

.leads-table thead th[colspan] {
    background-color: #e9ecef;
}