:root {
    --whatsapp-green: #25D366;  /* Cor principal do WhatsApp */
    --instagram-gradient: linear-gradient(45deg, #405DE6, #5851DB, #833AB4, #C13584, #E1306C, #FD1D1D);
    --streamlit-blue: #0068c9;
    --streamlit-gray: #262730;
    --streamlit-light-bg: #f8f9fa;
    --streamlit-sidebar: #f0f2f6;
    --streamlit-text: #262730;
    --twilio-dark-blue: #0D122B;
    --twilio-red: #F22F46;
    --twilio-white: #FFFFFF;
    --twilio-text: #1A1F36;
    --linkedin-blue: #0077B5;
    --linkedin-light-blue: #e8f3fc;
    --chat-bg: #efeae2;  /* Cor de fundo do WhatsApp */
    --message-received: #fff;
    --message-sent: #e1ffc7;
    --message-status: #e8f4fd;
    --neutral-gray: #4b5563;
    --neutral-light-gray: #f8f9fa;
    --post-history-bg: #f5f7fa;
    --post-history-border: #e2e8f0;
    --post-history-text: #334155;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--neutral-light-gray);
    color: var(--twilio-text);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* Navbar estilo Streamlit */
.streamlit-navbar {
    background-color: var(--streamlit-gray);
    padding: 0.8rem 1rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.streamlit-navbar .navbar-brand {
    color: white;
    font-weight: 600;
}

.streamlit-nav {
    display: flex;
    gap: 0.5rem;
}

.streamlit-nav .nav-item {
    margin: 0 0.15rem;
}

.streamlit-nav .nav-link {
    color: rgba(255, 255, 255, 0.8) !important;
    padding: 0.5rem 0.8rem;
    border-radius: 0.4rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.2s ease;
}

.streamlit-nav .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white !important;
    transform: translateY(-2px);
}

.streamlit-nav .nav-icon {
    font-size: 1.2rem;
    margin-bottom: 0.2rem;
}

.streamlit-nav .nav-text {
    font-size: 0.8rem;
    font-weight: 500;
}

/* Estilos para tema Twilio (vermelho) */
body.twilio-theme {
    background-color: var(--neutral-light-gray);
}

body.twilio-theme .navbar {
    background-color: var(--twilio-red);
}

/* Estilos para tema LinkedIn (azul) */
body.linkedin-theme {
    background-color: var(--linkedin-light-blue);
}

body.linkedin-theme .navbar {
    background-color: var(--linkedin-blue);
}

/* Páginas específicas com tema personalizado */
body.whatsapp-theme {
    background-color: var(--chat-bg);
}

body.whatsapp-theme .navbar {
    background-color: var(--whatsapp-green);
}

body.instagram-theme .navbar {
    background: var(--instagram-gradient);
}

.container-fluid {
    padding: 0;
    height: calc(100vh - 56px);
}

.card {
    border: none;
    border-radius: 0;
    box-shadow: none;
    height: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
    background-color: var(--twilio-white);  /* Fundo branco para o card */
}

.card-header {
    background-color: var(--twilio-white);
    border-bottom: 1px solid #eee;
    padding: 1rem;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background-color: var(--chat-bg);  /* Fundo similar ao WhatsApp */
    display: flex;
    flex-direction: column;
}

.message-item {
    max-width: 75%;
    margin-bottom: 1rem;
    padding: 8px 12px;
    border-radius: 7px;
    position: relative;
    box-shadow: 0 1px 0.5px rgba(0,0,0,0.13);
}

.message-received {
    background-color: var(--message-received);
    margin-right: auto;
    border-top-left-radius: 0;
    align-self: flex-start;
}

.message-sent {
    background-color: var(--message-sent);
    margin-left: auto;
    border-top-right-radius: 0;
    align-self: flex-end;
}

.message-content {
    font-size: 0.95rem;
    line-height: 1.4;
    margin-bottom: 4px;
    word-wrap: break-word;
}

/* Lista de Conversas */
.conversation-link {
    display: block;
    text-decoration: none;
    color: var(--twilio-text);
    margin-bottom: 10px;
    transition: transform 0.2s;
    background-color: var(--twilio-white);
    padding: 1rem;
    border-radius: 8px;
}

.conversation-link:hover {
    transform: translateY(-2px);
    text-decoration: none;
    color: var(--twilio-text);
}

.sender {
    font-weight: 600;
    font-size: 1rem;
    color: var(--twilio-dark-blue);
}

.type-badge, .status-badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
    background-color: #e9ecef;
    margin-left: 8px;
}

.type-badge {
    background-color: #e9ecef;
    color: #495057;
}

.status-badge {
    background-color: #e9ecef;
    color: #495057;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.message-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 5px;
}

.conversation-info {
    flex: 1;
    min-width: 0;
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 5px;
}

.phone-number {
    font-weight: 600;
    font-size: 0.95rem;
}

.timestamp {
    font-size: 0.75rem;
    color: #666;
    white-space: nowrap;
    margin-left: 10px;
}

.last-message {
    color: #666;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Container de Mensagens */

.date-divider {
    text-align: center;
    margin: 20px 0;
    position: relative;
    color: #666;
    font-size: 0.9rem;
    background: var(--chat-bg);
    padding: 5px 15px;
    display: inline-block;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 15px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}


.message-status {
    background-color: var(--message-status);
    margin-left: auto;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 10px;
    color: #666;
}

.message-type {
    font-size: 0.75rem;
    padding: 2px 8px;
}

.message-time {
    font-size: 0.75rem;
    color: #666;
    margin-left: 8px;
}

.message-footer {
    text-align: right;
    margin-top: 4px;
}

.message-header {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}

/* Badge de tipos de mensagem */
.bg-success {
    background-color: #28a745!important;
    color: white;
}

.bg-info {
    background-color: #17a2b8!important;
    color: white;
}

.bg-warning {
    background-color: #ffc107!important;
    color: black;
}

.bg-secondary {
    background-color: #6c757d!important;
    color: white;
}

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

.message-time {
    font-size: 0.75rem;
    color: #666;
}


.message-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.message-type {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 10px;
    background-color: rgba(0,0,0,0.1);
    color: #666;
}

.message-status {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 10px;
    background-color: rgba(0,0,0,0.1);
    color: #666;
}

/* Alertas e navegação */
.alert {
    border: none;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.alert-danger {
    background-color: #fff1f0;
    color: #cc0000;
}

.nav-link {
    color: rgb(13, 13, 13,0.9) !important;
    font-weight: 500;
}

.nav-link:hover {
    color: #0939fb !important;
}

.navbar-nav {
    gap: 1rem;
}

code {
    background-color: #e9ecef;
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--whatsapp-green); /* Changed color here */
}

.alert-secondary {
    background-color: #f8f9fa;
    border-color: #e9ecef;
    color: #666;
}

.webhook-urls {
    font-family: 'Monaco', 'Consolas', monospace;
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
}

.webhook-urls ul {
    margin: 10px 0 0 0;
}

.webhook-urls li {
    margin: 5px 0;
}

/* Estilo para o badge de contagem de mensagens */
.badge.bg-primary {
    font-size: 0.75rem;
    padding: 3px 8px;
    margin-right: 8px;
}

/* Ajustes para a página de busca */
.search-form {
    margin-bottom: 20px;
}

.form-check {
    display: flex;
    align-items: center;
}

.form-check-input {
    margin-right: 0.5rem;
}

/* Estilos para o histórico de posts agendados */
.history-item {
    background-color: var(--post-history-bg);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.history-item:hover {
    background-color: var(--twilio-white);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transform: translateY(-2px);
}

.caption-preview {
    color: var(--post-history-text);
    font-style: italic;
    max-height: 60px;
    overflow: hidden;
}

.img-thumbnail {
    border: 1px solid var(--post-history-border);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.img-thumbnail:hover {
    transform: scale(1.05);
}

/* Adicionando Media Queries para Responsividade */
@media (max-width: 768px) {
    .container-fluid {
        height: calc(100vh - 56px);
    }

    .messages-container {
        padding: 0.5rem;
    }

    .message-item {
        max-width: 85%;
    }
    .nav-link {
        padding: 0.5rem;
    }
    .navbar {
        padding: 0.5rem;
    }

    .card-header {
        padding: 0.75rem;
    }

    /* Ajuste no cabeçalho da conversa */
    .conversation-header {
        flex-direction: column;
        gap: 0.25rem;
        align-items: flex-start;
    }

    .phone-number {
        font-size: 0.9rem;
        line-height: 1.2;
    }
}

@media (max-width: 576px) {
    .message-item {
        max-width: 90%;
    }

    .card-header {
        padding: 0.75rem;
    }

    .message-content {
        font-size: 0.9rem;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    .phone-number {
        font-size: 0.85rem;
        word-break: break-word;
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Ajustes para contato e período */
    .conversation-info {
        width: 100%;
        overflow: hidden;
    }

    .conversation-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    /* Ajuste para timestamps e status */
    .timestamp {
        font-size: 0.7rem;
    }

    .message-footer {
        margin-top: 2px;
        flex-wrap: wrap;
        gap: 4px;
    }

    .message-type, .message-status {
        font-size: 0.7rem;
        padding: 1px 4px;
    }

    /* Ajustes para o container principal */
    .container-fluid {
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* Ajustes para o cabeçalho da conversa */
    .card-header h5 {
        font-size: 1rem;
        margin: 0;
    }

    /* Ajuste para os badges */
    .badge {
        font-size: 0.65rem;
        padding: 2px 6px;
    }


    /* Garantir que os textos longos quebrem corretamente */

    /* Ajuste para botões e links na navbar */
    .nav-link {
        font-size: 0.9rem;
        padding: 0.25rem 0.5rem;
    }

    /* Ajuste para o botão voltar */
    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.875rem;
    }
}

.custom-toggler {
    border: none;
    color: #fff;
    font-size: 1.5rem;
    padding: 0.25rem 0.75rem;
    background-color: transparent;
}

.custom-toggler:focus {
    outline: none;
    box-shadow: none;
}

@media (max-width: 991px) {
    .navbar-nav {
        padding: 1rem 0;
    }

    .nav-item {
        margin: 0.5rem 0;
    }

    .nav-link {
        padding: 0.5rem 1rem;
    }

    .nav-icon {
        margin-right: 1rem;
        display: inline-block;
    }

    .nav-text {
        display: inline-block;
    }
}