/* Common styles for the WhatsApp Business application with AdminLTE */

:root {
    --whatsapp-green: #128C7E;
    --whatsapp-light-green: #25D366;
    --whatsapp-dark-green: #075E54;
}

/* Override AdminLTE colors with WhatsApp green */
.bg-primary, .btn-primary, .page-item.active .page-link {
    background-color: var(--whatsapp-green) !important;
    border-color: var(--whatsapp-green) !important;
}

.btn-primary:hover {
    background-color: var(--whatsapp-dark-green) !important;
    border-color: var(--whatsapp-dark-green) !important;
}

.text-primary {
    color: var(--whatsapp-green) !important;
}

.border-primary {
    border-color: var(--whatsapp-green) !important;
}

.sidebar-dark-primary .nav-sidebar > .nav-item > .nav-link.active {
    background-color: var(--whatsapp-green);
}

/* Main sidebar */
.main-sidebar {
    background-color: var(--whatsapp-dark-green);
}

.sidebar-dark-primary {
    background-color: var(--whatsapp-dark-green);
}

/* Brand logo */
.brand-link {
    background-color: var(--whatsapp-green);
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-link .brand-image {
    margin-top: -3px;
}

/* Navbar */
.main-header.navbar {
    background-color: var(--whatsapp-green);
    border-bottom: 1px solid #dee2e6;
}

/* Navbar dropdown */
.navbar-nav .dropdown-toggle {
    color: #6c757d;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    transition: all 0.2s;
}

.navbar-nav .dropdown-toggle:hover,
.navbar-nav .dropdown-toggle:focus {
    color: var(--whatsapp-green);
    background-color: rgba(18, 140, 126, 0.1);
}

.navbar-nav .dropdown-menu {
    padding: 0.5rem 0;
    border: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    border-radius: 0.5rem;
}

.navbar-nav .dropdown-item {
    padding: 0.5rem 1rem;
    color: #6c757d;
    transition: all 0.2s;
}

.navbar-nav .dropdown-item:hover,
.navbar-nav .dropdown-item:focus {
    color: var(--whatsapp-green);
    background-color: rgba(18, 140, 126, 0.1);
}

.navbar-nav .dropdown-item.active {
    color: white;
    background-color: var(--whatsapp-green);
}

.navbar-nav .dropdown-item i {
    margin-right: 0.5rem;
    width: 1.25rem;
    text-align: center;
}

/* Dropdown submenu styles */
.dropdown-submenu {
    position: relative;
}

.dropdown-submenu > .dropdown-menu {
    top: 0;
    left: 100%;
    margin-top: -6px;
    margin-left: -1px;
    border-radius: 0.25rem;
}

.dropdown-submenu:hover > .dropdown-menu {
    display: block;
}

.dropdown-submenu > a:after {
    display: block;
    content: " ";
    float: right;
    width: 0;
    height: 0;
    border-color: transparent;
    border-style: solid;
    border-width: 5px 0 5px 5px;
    border-left-color: #ccc;
    margin-top: 5px;
    margin-right: -10px;
}

.dropdown-submenu:hover > a:after {
    border-left-color: var(--whatsapp-green);
}

/* Content wrapper */
.content-wrapper {
    background-color: #f4f6f9;
}

/* Override AdminLTE v4 specific classes */
.bg-success {
    background-color: var(--whatsapp-green) !important;
}

.btn-success {
    background-color: var(--whatsapp-green) !important;
    border-color: var(--whatsapp-green) !important;
}

.btn-success:hover {
    background-color: var(--whatsapp-dark-green) !important;
    border-color: var(--whatsapp-dark-green) !important;
}

/* Cards */
.card {
    box-shadow: 0 0 1px rgba(0,0,0,.125), 0 1px 3px rgba(0,0,0,.2);
    margin-bottom: 1rem;
}

.card-primary.card-outline {
    border-top: 3px solid var(--whatsapp-green);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid rgba(0,0,0,.125);
    padding: 0.75rem 1.25rem;
}

/* Customer avatar */
.customer-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--whatsapp-green);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 10px;
}

.customer-info {
    display: flex;
    align-items: center;
}

/* Info box */
.info-box {
    box-shadow: 0 0 1px rgba(0,0,0,.125), 0 1px 3px rgba(0,0,0,.2);
    border-radius: 0.25rem;
    background-color: #fff;
    display: flex;
    margin-bottom: 1rem;
    min-height: 80px;
    padding: 0.5rem;
    position: relative;
    width: 100%;
}

.info-box .info-box-icon {
    border-radius: 0.25rem;
    align-items: center;
    display: flex;
    font-size: 1.875rem;
    justify-content: center;
    text-align: center;
    width: 70px;
}

.info-box .info-box-icon.bg-primary {
    background-color: var(--whatsapp-green) !important;
}

.info-box .info-box-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.8;
    flex: 1;
    padding: 0 10px;
}

.info-box .info-box-text, .info-box .progress-description {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.info-box .info-box-number {
    display: block;
    font-weight: 700;
}

/* Custom styles for chat interface */
.direct-chat .card-body {
    overflow-x: hidden;
    padding: 0;
    position: relative;
}

.direct-chat-messages {
    height: 250px;
    overflow: auto;
    padding: 10px;
}

.direct-chat-msg {
    margin-bottom: 10px;
}

.direct-chat-msg:after {
    display: block;
    clear: both;
    content: "";
}

.direct-chat-messages, .direct-chat-contacts {
    transition: transform .5s ease-in-out;
}

.direct-chat-text {
    border-radius: 0.3rem;
    background-color: #d2d6de;
    border: 1px solid #d2d6de;
    color: #444;
    margin: 5px 0 0 50px;
    padding: 5px 10px;
    position: relative;
}

.direct-chat-text:after, .direct-chat-text:before {
    border: solid transparent;
    border-right-color: #d2d6de;
    content: " ";
    height: 0;
    pointer-events: none;
    position: absolute;
    right: 100%;
    top: 15px;
    width: 0;
}

.direct-chat-text:after {
    border-width: 5px;
    margin-top: -5px;
}

.direct-chat-text:before {
    border-width: 6px;
    margin-top: -6px;
}

.right .direct-chat-text {
    margin-left: 0;
    margin-right: 50px;
    background-color: var(--whatsapp-light-green);
    border-color: var(--whatsapp-light-green);
    color: #fff;
}

.right .direct-chat-text:after, .right .direct-chat-text:before {
    border-left-color: var(--whatsapp-light-green);
    border-right-color: transparent;
    left: 100%;
    right: auto;
}

.direct-chat-img {
    border-radius: 50%;
    float: left;
    height: 40px;
    width: 40px;
}

.right .direct-chat-img {
    float: right;
}

.direct-chat-infos {
    display: block;
    font-size: 0.875rem;
    margin-bottom: 2px;
}

.direct-chat-name {
    font-weight: 600;
}

.direct-chat-timestamp {
    color: #697582;
    font-size: 0.75rem;
}

.direct-chat-contacts-open .direct-chat-contacts {
    transform: translate(0, 0);
}

.direct-chat-contacts {
    background-color: #343a40;
    bottom: 0;
    color: #fff;
    height: 250px;
    overflow: auto;
    position: absolute;
    top: 0;
    transform: translate(101%, 0);
    width: 100%;
}

.contacts-list {
    padding-left: 0;
    list-style: none;
}

.contacts-list-item {
    border-bottom: 1px solid rgba(0, 0, 0, 0.2);
    padding: 10px;
    margin: 0;
}

.contacts-list-item:last-of-type {
    border-bottom: 0;
}

.contacts-list-img {
    border-radius: 50%;
    float: left;
    width: 40px;
}

.contacts-list-info {
    color: #fff;
    margin-left: 45px;
}

.contacts-list-name, .contacts-list-status {
    display: block;
}

.contacts-list-name {
    font-weight: 600;
}

.contacts-list-status {
    font-size: 0.875rem;
}

.contacts-list-date {
    color: #ced4da;
    font-weight: 500;
}

.contacts-list-msg {
    color: #b1bbc4;
}

.direct-chat-danger .right > .direct-chat-text {
    background-color: #dc3545;
    border-color: #dc3545;
    color: #fff;
}

.direct-chat-danger .right > .direct-chat-text:after, .direct-chat-danger .right > .direct-chat-text:before {
    border-left-color: #dc3545;
}

.direct-chat-primary .right > .direct-chat-text {
    background-color: var(--whatsapp-green);
    border-color: var(--whatsapp-green);
    color: #fff;
}

.direct-chat-primary .right > .direct-chat-text:after, .direct-chat-primary .right > .direct-chat-text:before {
    border-left-color: var(--whatsapp-green);
}

.direct-chat-warning .right > .direct-chat-text {
    background-color: #ffc107;
    border-color: #ffc107;
    color: #1f2d3d;
}

.direct-chat-warning .right > .direct-chat-text:after, .direct-chat-warning .right > .direct-chat-text:before {
    border-left-color: #ffc107;
}

.direct-chat-info .right > .direct-chat-text {
    background-color: #17a2b8;
    border-color: #17a2b8;
    color: #fff;
}

.direct-chat-info .right > .direct-chat-text:after, .direct-chat-info .right > .direct-chat-text:before {
    border-left-color: #17a2b8;
}

.direct-chat-success .right > .direct-chat-text {
    background-color: #28a745;
    border-color: #28a745;
    color: #fff;
}

.direct-chat-success .right > .direct-chat-text:after, .direct-chat-success .right > .direct-chat-text:before {
    border-left-color: #28a745;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .content-wrapper {
        margin-left: 0 !important;
    }

    /* Navbar responsive adjustments */
    .navbar-nav .nav-item {
        margin: 5px 0;
    }

    .navbar-collapse {
        background-color: white;
        padding: 10px;
        border-radius: 0.25rem;
        box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    }

    /* Ensure navbar-collapse is hidden on mobile devices */
    .navbar-collapse.d-none {
        display: none !important;
    }

    /* Target the specific navbar-collapse by ID to ensure it's hidden on mobile */
    #navbarCollapse {
        display: none !important;
    }

    .navbar-nav form.d-inline {
        margin-top: 10px;
    }

    .navbar-nav .btn-sm {
        width: 100%;
    }

    /* Dropdown responsive adjustments */
    .navbar-nav .dropdown-menu {
        position: static;
        float: none;
        width: 100%;
        margin-top: 0.5rem;
        background-color: #f8f9fa;
        box-shadow: none;
        border: 1px solid #e9ecef;
    }

    .navbar-nav .dropdown-item {
        padding: 0.5rem 1rem;
    }

    .navbar-nav .dropdown-divider {
        margin: 0.5rem 0;
    }

    /* Responsive adjustments for dropdown submenu */
    .dropdown-submenu > .dropdown-menu {
        position: static;
        left: 0;
        margin-left: 1rem;
        box-shadow: none;
        border: none;
        background-color: transparent;
    }

    .dropdown-submenu > a:after {
        transform: rotate(90deg);
    }
}
