:root {
    --primary-color: #ff9800;
    --secondary-color: #22223b;
    --accent-color: #f2e9e4;
    --white: #fff;
    --text-color: #22223b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
}

/* Navigation Bar */
.navbar {
    background-color: var(--secondary-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
}

.logo h1 {
    color: var(--white);
    font-size: 1.5rem;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-links a {
    color: var(--white);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.nav-links a:hover {
    color: var(--primary-color);
}

.nav-auth-links {
    display: flex;
    gap: 1rem;
    margin-left: auto;
}

.register-btn, .login-btn, .logout-btn, .dashboard-btn {
    padding: 0.5rem 1rem;
    border-radius: 5px;
    text-decoration: none;
    text-align: center;
    transition: background-color 0.3s ease;
    white-space: nowrap;
}

.register-btn {
    background-color: var(--primary-color);
    color: var(--white) !important;
}
.register-btn:hover {
    background-color: #e68a00;
}

.login-btn {
    background-color: var(--accent-color);
    color: var(--secondary-color) !important;
}
.login-btn:hover {
    background-color: #e0d7d2;
}

.logout-btn {
    background-color: #dc3545;
    color: var(--white) !important;
}
.logout-btn:hover {
    background-color: #c82333;
}

.dashboard-btn {
    background-color: var(--accent-color);
    color: var(--secondary-color) !important;
}
.dashboard-btn:hover {
    background-color: #e0d7d2;
}

.door-to-door-btn {
    background-color: #28a745;
    color: var(--white) !important;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    text-decoration: none;
    text-align: center;
    transition: background-color 0.3s ease;
    white-space: nowrap;
    font-weight: 600;
}
.door-to-door-btn:hover {
    background-color: #218838;
    color: var(--white) !important;
}

.logo a {
    color: var(--white);
    text-decoration: none;
}

.navbar-icons {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.navbar-search {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.navbar-search input {
    padding: 0.4rem 0.8rem;
    border: 1px solid #ddd;
    border-radius: 5px 0 0 5px;
    outline: none;
    width: 200px;
    transition: width 0.3s ease-in-out;
}

.navbar-search button {
    padding: 0.4rem 0.8rem;
    border: none;
    background: var(--primary-color);
    color: #fff;
    border-radius: 0 5px 5px 0;
    cursor: pointer;
}

.messenger-icon {
    font-size: 1.5rem;
    color: var(--white);
}

.hamburger {
    display: none;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--white);
}

.hamburger span {
    width: 25px;
    height: 3px;
    background-color: var(--white);
    transition: 0.3s;
}

/* Main Content */
main {
    margin-top: 80px;
    padding: 2rem;
}

.hero {
    text-align: center;
    padding: 4rem 2rem;
    background-color: var(--accent-color);
    color: var(--secondary-color);
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

/* Footer */
footer {
    background-color: var(--secondary-color);
    color: var(--white);
    padding: 3rem 2rem 1rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.contact-info h3, .quick-links h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.quick-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.quick-links a {
    color: var(--white);
    text-decoration: none;
}

.quick-links a:hover {
    color: var(--primary-color);
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Responsive Design */
@media screen and (max-width: 992px) {
    .navbar-search input {
        width: 120px;
    }

    .nav-links {
        gap: 1rem;
    }
}

@media screen and (max-width: 768px) {
    .nav-links {
        display: none;
        position: fixed;
        top: 60px; /* Adjust based on navbar height */
        left: -100%;
        width: 280px;
        height: calc(100vh - 60px);
        background-color: var(--secondary-color);
        flex-direction: column;
        align-items: flex-start;
        padding: 2rem;
        transition: left 0.4s ease-in-out;
        gap: 1.5rem;
        box-shadow: 5px 0 15px rgba(0,0,0,0.2);
        z-index: 1001; /* Ensure sidebar is on top */
        overflow-y: auto; /* Enable vertical scrolling */
        overflow-x: hidden; /* Hide horizontal scroll */
    }

    .nav-auth-links {
        margin-left: 0;
        flex-direction: row;
        width: 100%;
        gap: 1rem;
        margin-top: auto; /* Pushes to the bottom */
        padding-top: 1.5rem;
        border-top: 1px solid rgba(255,255,255,0.2);
        flex-shrink: 0; /* Prevent shrinking */
    }

    .nav-links.active {
        display: flex;
        left: 0;
    }

    .navbar {
        padding: 0.8rem 1rem;
        justify-content: space-between;
        flex-wrap: nowrap;
    }

    .navbar-icons {
        gap: 1rem;
        flex-shrink: 0;
        align-items: center;
    }

    .navbar-search {
        display: flex;
    }

    .navbar-search input {
        width: 90px;
        font-size: 0.9rem;
        padding: 0.3rem 0.5rem;
    }

    .navbar-search button {
        padding: 0.3rem 0.5rem;
    }

    .hamburger {
        display: block;
    }

    .logo h1 {
        font-size: 1.1rem;
        white-space: nowrap;
    }

    .nav-links a {
        width: 100%;
        text-align: left;
        padding: 1rem;
        font-size: 1.1rem;
        font-weight: bold;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        flex-shrink: 0; /* Prevent shrinking */
        white-space: nowrap; /* Prevent text wrapping */
    }

    .nav-links .register-btn,
    .nav-links .login-btn,
    .nav-links .dashboard-btn,
    .nav-links .logout-btn {
        width: auto;
        padding: 0.8rem 1.2rem !important;
        border-bottom: none;
    }

    .nav-links a:last-of-type {
        border-bottom: none;
    }

    .nav-links a {
        color: var(--white);
    }

    .nav-links .login-btn {
        color: var(--secondary-color) !important;
        background-color: var(--accent-color);
        padding: 0.8rem 1rem !important;
    }

    .nav-links .register-btn {
        color: var(--white) !important;
        background-color: var(--primary-color);
        padding: 0.8rem 1rem !important;
    }

    .register-btn, .login-btn {
        text-align: center !important;
        padding: 0.8rem 1rem !important;
    }
}

/* C&F Agent Page Styles */
.page-header {
    background-color: var(--primary-color);
    color: white;
    padding: 3rem 0;
    text-align: center;
}

.page-header h1 {
    margin: 0;
    font-size: 2.5rem;
}

.cf-agent-content {
    padding: 4rem 0;
}

.service-description {
    text-align: center;
    max-width: 800px;
    margin: 0 auto 3rem;
}

.service-description h2 {
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 3rem;
}

.service-card {
    background: white;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
    text-align: center;
    transition: transform 0.3s ease;
}

.service-card:hover {
    transform: translateY(-5px);
}

.service-card i {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.service-card h3 {
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

.contact-section {
    text-align: center;
    padding: 3rem 0;
    background-color: #f8f9fa;
    border-radius: 10px;
}

.contact-section h2 {
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

.cta-button {
    display: inline-block;
    background-color: var(--primary-color);
    color: white;
    padding: 1rem 2rem;
    border-radius: 5px;
    text-decoration: none;
    margin-top: 1rem;
    transition: background-color 0.3s ease;
}

.cta-button:hover {
    background-color: #e05e00;
}

/* Messenger Popup Styles */
.messenger-popup {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px;
    height: 500px;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    transform: scale(0);
    transform-origin: bottom right;
    transition: transform 0.3s ease-in-out;
    z-index: 1001;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.messenger-popup.active {
    transform: scale(1);
}

.messenger-header {
    padding: 0.75rem 1rem;
    background-color: var(--secondary-color);
    color: var(--white);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ddd;
    cursor: grab;
    flex-shrink: 0;
}

.messenger-header h3 {
    margin: 0;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
}

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

.messages-display-section {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.messages-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.messages-header h4 {
    margin: 0;
    color: var(--secondary-color);
    font-size: 0.85rem;
}

.refresh-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 3px 6px;
    border-radius: 3px;
    cursor: pointer;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.message-input-section {
    padding: 1rem;
    background-color: #f9f9f9;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

#message-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

#message-form textarea {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: none;
    height: 40px;
    line-height: 1.4;
}

.send-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

/* Individual Message Styles */
.message-item {
    margin-bottom: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    max-width: 90%;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    overflow-wrap: break-word;
}

.message-client {
    background: #e3f2fd;
    margin-left: 0;
    margin-right: auto;
    border-bottom-left-radius: 2px;
}

.message-admin {
    background: #f3e5f5;
    margin-left: auto;
    margin-right: 0;
    border-bottom-right-radius: 2px;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
    font-size: 0.7rem;
}

.message-sender {
    font-weight: bold;
    color: var(--secondary-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
    flex-shrink: 0;
}

.message-time {
    color: #666;
    font-size: 0.65rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.message-content {
    color: #333;
    line-height: 1.3;
    margin: 0;
    font-size: 0.8rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.message-reply {
    margin-top: 6px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 6px;
    border-left: 2px solid var(--primary-color);
    max-width: 100%;
}

.message-reply-label {
    font-weight: bold;
    color: var(--primary-color);
    font-size: 0.7rem;
    margin-bottom: 3px;
}

.no-messages {
    text-align: center;
    color: #666;
    padding: 20px 10px;
    font-style: italic;
    font-size: 0.8rem;
}

.messenger-icon {
    position: relative;
}

/* Admin Sidebar and Container - Updated for Flex Layout */
.admin-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background-color: var(--secondary-color);
    color: var(--white);
    padding: 2rem;
    height: 100vh;
    overflow-y: auto;
    z-index: 1001;
}

.sidebar h2 {
    color: var(--primary-color);
    margin-bottom: 2rem;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
}

.sidebar-menu li {
    margin-bottom: 1rem;
}

.sidebar-menu a {
    color: var(--white);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

.sidebar-menu a:hover {
    background-color: var(--primary-color);
}

.main-content {
    flex: 1;
    padding: 2rem;
    width: auto;
}

/* =================================
   Admin Responsive Styles
==================================== */
.admin-main-header {
    display: none; /* Hidden on desktop */
}

@media screen and (max-width: 768px) {
    .admin-container {
        flex-direction: column;
        padding-top: 60px; /* Add padding to the container itself */
    }

    .admin-container .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        width: 280px;
        height: 100vh;
        z-index: 1002;
        transition: left 0.3s ease-in-out;
        box-shadow: 0 0 15px rgba(0,0,0,0.2);
    }

    .admin-container .sidebar.active {
        left: 0;
        z-index: 1001;
    }

    .admin-main-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1rem;
        background-color: var(--white);
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        z-index: 1001;
    }

    .admin-hamburger {
        font-size: 1.5rem;
        color: var(--secondary-color);
        cursor: pointer;
    }

    .admin-container .main-content {
        padding-top: 1rem; /* Reset padding here */
        width: 100%;
        margin-left: 0; /* Reset margin */
    }

    .admin-header {
        display: none; /* Hide original desktop header */
    }
}

/* Messenger layout hotfix */
.messenger-popup {
    display: flex;
    flex-direction: column;
}

.messenger-header,
.message-input-section {
    flex-shrink: 0;
}

.messages-display-section {
    flex: 1;
    min-height: 0;
}

/* Hotfix to ensure message area is visible */
.messages-display-section {
    min-height: 300px;
}

/* Make homepage card images larger */
.homepage-card-img {
    width: 80%;
    height: 3in;
    object-fit: cover;
    border-radius: 8px 8px 0 0;
    margin-bottom: 0.5rem;
}

@media (max-width: 600px) {
    .homepage-card-img {
        height: 2in;
    }
}

.homepage-card {
    border: 2.5px solid orange;
    border-radius: 14px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

@media (max-width: 600px) {
    .homepage-card {
        border: none;
        box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    }
}
