/* Inherit variables and base styles from dashboard.css */

/* Loading Screen Styles */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255); /* Semi-transparent white background */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999; /* Ensure it's on top */
    transition: opacity 0.5s ease-out; /* Fade out transition */
}

#loading-screen.hidden {
    opacity: 0;
    pointer-events: none; /* Disable interaction when hidden */
}

.spinner {
    border: 6px solid var(--border-color, #f3f3f3); /* Light grey border */
    border-top: 6px solid var(--primary-color, #3498db); /* Blue border for the spinning part */
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
/* End Loading Screen Styles */


/* Header adjustments for controls */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    gap: 1rem; /* Space between title and controls */
}

.disparos-controls {
    display: flex;
    gap: 0.8rem; /* Space between buttons */
}

/* Use existing button styles if available, or define basic ones */
.disparos-controls .btn {
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: background-color 0.3s ease, opacity 0.3s ease;
    color: white; /* Assuming buttons have white text */
}

.disparos-controls .btn:hover {
    opacity: 0.9;
}

.disparos-controls .btn-warning {
    background-color: var(--warning-color, #f59e0b); /* Use variable or fallback */
}
.disparos-controls .btn-success { /* Added for Despausar state */
    background-color: var(--success-color, #10b981); /* Use variable or fallback */
}

.disparos-controls .btn-danger {
    background-color: var(--error-color, #ef4444); /* Use variable or fallback */
}


.disparos-list-container {
    overflow-x: auto; /* Enable horizontal scrolling on small screens */
    margin-bottom: 1.5rem; /* Space before pagination */
}

.disparos-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    font-size: 0.95rem; /* Slightly smaller font for table */
}

.disparos-table th,
.disparos-table td {
    padding: 0.8rem 1rem; /* Adjust padding */
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap; /* Prevent text wrapping initially */
}

.disparos-table th {
    background-color: var(--section-bg);
    color: var(--text-color);
    font-weight: 600; /* Make headers bolder */
}

.disparos-table tbody tr:hover {
    background-color: var(--section-bg); /* Highlight row on hover */
}

/* Status Indicator Styles */
.disparos-table td span[class^="status-"] {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.6rem;
    border-radius: 12px; /* Pill shape */
    font-weight: 500;
    font-size: 0.85rem;
}

.disparos-table td span[class^="status-"] i {
    font-size: 0.9em;
}

.status-sent {
    background-color: rgba(16, 185, 129, 0.1); /* Light green */
    color: var(--success-color);
}

.status-pending {
    background-color: rgba(245, 158, 11, 0.1); /* Light amber */
    color: #d97706; /* Darker amber */
}

.status-failed {
    background-color: rgba(239, 68, 68, 0.1); /* Light red */
    color: var(--error-color);
}

/* Action Button Styles */
.disparos-table .action-btn {
    background: none;
    border: none;
    color: var(--light-text);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.3rem;
    transition: color 0.3s ease;
    margin-right: 0.5rem; /* Space between buttons */
}

.disparos-table .action-btn:hover {
    color: var(--primary-color);
}

.disparos-table .retry-btn:hover {
    color: var(--success-color); /* Green for retry */
}

.disparos-table .view-btn:hover {
    color: var(--primary-color); /* Blue for view */
}


/* Pagination Controls - Reuse styles from dashboard.css if possible */
/* If pagination-controls styles are not global, copy them here */
.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.pagination-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 0.6rem 1.2rem;
    cursor: pointer;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: background-color 0.3s ease;
}

.pagination-btn:hover:not(:disabled) {
    background-color: var(--secondary-color);
}

.pagination-btn:disabled {
    background-color: var(--border-color);
    color: var(--light-text);
    cursor: not-allowed;
}

#disparosPageInfo {
    font-size: 0.9rem;
    color: var(--light-text);
}

/* Modal Styles - Enhanced */
.modal-overlay {
    position: fixed; /* Keep fixed */
    top: 0;
    left: 0; /* Keep covering screen */
    width: 100%; /* Keep covering screen */
    height: 100%; /* Keep covering screen */
    background-color: rgba(0, 0, 0, 0.7); /* Slightly darker overlay */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease; /* Slightly slower fade */
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    padding: 2.5rem; /* More padding */
    border-radius: 12px; /* More rounded corners */
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15); /* Softer shadow */
    text-align: center;
    position: relative;
    max-width: 420px; /* Slightly wider */
    width: 90%;
    transform: translateY(-20px) scale(0.95); /* Start slightly up and smaller */
    opacity: 0; /* Start transparent for animation */
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.4s ease; /* Smoother animation */
    border-top: 4px solid var(--primary-color); /* Accent border */
}

.modal-overlay.show .modal-content {
    transform: translateY(0) scale(1); /* Animate to final position */
    opacity: 1; /* Fade in */
}

.modal-icon { /* Style for the icon */
    font-size: 3rem; /* Larger icon */
    margin-bottom: 1.5rem;
    display: block; /* Make it block to center easily */
    color: var(--primary-color); /* Default icon color */
}

.modal-icon.success {
    color: var(--success-color); /* Green for success */
}

.modal-icon.warning {
    color: var(--warning-color); /* Orange for warning */
}

.modal-content h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--text-color);
    font-weight: 600; /* Bolder title */
    font-size: 1.4rem;
}

.modal-content p {
    margin-bottom: 2rem; /* More space before button */
    color: var(--light-text);
    font-size: 1rem;
    line-height: 1.6;
}

.modal-content .btn { /* Style the OK button */
    padding: 0.8rem 2rem; /* Larger button */
    font-size: 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    background-color: var(--primary-color);
    color: white;
    font-weight: 500;
}

.modal-content .btn:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px); /* Slight lift on hover */
}

.modal-content .btn:active {
    transform: translateY(0); /* Press down effect */
}


.close-modal-btn {
    position: absolute;
    top: 15px; /* Adjust position */
    right: 15px; /* Adjust position */
    font-size: 1.5rem; /* Slightly smaller */
    background: none;
    border: none;
    color: var(--light-text);
    cursor: pointer;
    transition: color 0.3s ease, transform 0.2s ease;
    padding: 5px; /* Easier to click */
    line-height: 1;
}

.close-modal-btn:hover {
    color: var(--error-color);
    transform: scale(1.1); /* Slightly enlarge on hover */
}


/* Responsive Adjustments */
@media (max-width: 768px) {
    .modal-content {
        padding: 2rem; /* Adjust padding for smaller screens */
        width: 85%; /* Slightly narrower modal on tablets */
    }
    .modal-icon {
        font-size: 2.5rem;
    }
    .modal-content h3 {
        font-size: 1.2rem;
    }
    .modal-content p {
        font-size: 0.95rem;
    }
    .section-header {
        flex-direction: column;
        align-items: flex-start; /* Align items to the start */
    }

    .disparos-controls {
        width: 100%; /* Make controls take full width */
        justify-content: flex-start; /* Align buttons to start */
        margin-top: 0.5rem; /* Add some space below the header title */
    }

    .disparos-table th,
    .disparos-table td {
        font-size: 0.88rem; /* Slightly smaller font */
        padding: 0.5rem 0.7rem; /* Further reduced padding */
        vertical-align: middle; /* Align content vertically */
    }

    .disparos-table td span[class^="status-"] {
        font-size: 0.8rem;
        padding: 0.2rem 0.5rem;
    }

    .disparos-table .action-btn {
        font-size: 1rem;
        padding: 0.2rem; /* Slightly smaller padding */
    }

    .pagination-controls {
        flex-direction: column;
        gap: 0.8rem;
        align-items: stretch; /* Make buttons full width */
    }

    .pagination-btn {
        width: 100%;
        justify-content: center;
    }

}

@media (max-width: 576px) {
    .disparos-table th,
    .disparos-table td {
        white-space: normal; /* Allow wrapping on very small screens */
        padding: 0.4rem 0.5rem; /* Base padding */
        /* padding-top: 1.5em; Remove fixed top padding */
        font-size: 0.8rem; /* Even smaller font */
        display: block; /* Stack cells vertically */
        text-align: right; /* Align content text to the right */
        border-bottom: none; /* Remove default border */
        position: relative; /* Keep relative for potential future use, but ::before is not absolute now */
        min-height: auto; /* Let content determine height */
        box-sizing: border-box; /* Include padding in height calculation */
        overflow-wrap: break-word; /* Ensure long words break */
    }
    .disparos-table td::before { /* Add labels using pseudo-elements */
        content: attr(data-label); /* Get label from data attribute */
        /* position: absolute; Remove absolute positioning */
        /* top: 0.4rem; */
        /* left: 0.5rem; */
        display: block; /* Make label a block element */
        text-align: left; /* Align label text to the left */
        font-weight: bold;
        color: var(--text-color);
        margin-bottom: 0.2em; /* Add space below the label */
        /* width: 45%; Remove fixed width */
        padding-right: 0; /* Remove padding */
        white-space: normal; /* Allow label to wrap if needed */
    }
    .disparos-table thead { /* Hide table header */
        display: none;
    }
    .disparos-table tbody tr { /* Add borders between rows */
        display: block;
        margin-bottom: 0.8rem;
        border: 1px solid var(--border-color);
        border-radius: 4px;
        padding: 0.5rem;
        background-color: var(--section-bg); /* Add background to each "card" */
    }
     .disparos-table tbody tr:last-child {
        margin-bottom: 0; /* Remove margin from last row */
    }
     .disparos-table td:last-child { /* Ensure actions are visible */
        text-align: right; /* Keep actions aligned right */
        /* padding-top: 1.5em; Remove fixed padding */
        min-height: auto; /* Match min-height */
    }
     .disparos-table td span[class^="status-"] { /* Adjust status indicator */
        /* float: right; */ /* Keep float removed */
        display: inline-block; /* Ensure it behaves like a block for alignment */
        margin-top: 0; /* Reset margin */
        vertical-align: baseline; /* Try baseline alignment */
    }
     /* Target the horario cell specifically if needed, or rely on general td alignment */
     .disparos-table td[data-label="Horário"] {
         vertical-align: baseline; /* Align horario text with baseline */
     }

     .disparos-table .action-btn { /* Adjust action buttons */
        margin-right: 0;
        margin-left: 0.3rem;
    }

    .disparos-controls .btn {
        padding: 0.5rem 1rem; /* Adjust button padding */
        font-size: 0.85rem;
    }
    .modal-content {
        width: 95%; /* Slightly more width */
        padding: 1.5rem; /* Reduce padding further */
    }
    .modal-content h3 {
        font-size: 1.1rem;
    }
    .modal-content p {
        font-size: 0.9rem;
        margin-bottom: 1.5rem; /* Adjust space */
    }
    .modal-content .btn {
        padding: 0.7rem 1.5rem;
        font-size: 0.9rem;
    }
    #disparoModal .modal-content {
        padding: 1.5rem;
    }
    #disparoModal .modal-content strong {
        min-width: 60px; /* Adjust min-width */
    }
    #disparoModalMensagem {
        padding: 0.5rem;
        max-height: 200px; /* Adjust max height */
    }
}

/* Progress Bar Styles */
.progress-container {
    margin-top: 1rem; /* Space above the progress bar */
    margin-bottom: 1.5rem; /* Space below the progress bar, before the table */
    padding: 0.8rem 1rem;
    background-color: var(--section-bg); /* Match section background */
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    width: 100%; /* Ensure full width */
    box-sizing: border-box; /* Include padding in width calculation */
}

.progress-bar-label {
    font-size: 0.85rem; /* Slightly smaller font on mobile */
    color: var(--light-text);
    margin-bottom: 0.5rem;
    text-align: center;
    word-wrap: break-word; /* Allow label text to wrap */
}

.progress-bar-label span {
    font-weight: 600;
    color: var(--text-color);
}

.progress-bar {
    width: 100%;
    height: 12px; /* Slightly thicker bar */
    background-color: var(--border-color); /* Background of the empty part */
    border-radius: 6px;
    overflow: hidden; /* Ensure fill stays within bounds */
}

.progress-bar-fill {
    height: 100%;
    width: 0%; /* Start at 0% */
    background-color: var(--primary-color); /* Color of the filled part */
    border-radius: 6px;
    transition: width 0.5s ease-in-out; /* Smooth transition */
    animation: progress-animation 3s linear infinite;
    background-image: linear-gradient(
      -45deg,
      rgba(255, 255, 255, 0.2) 25%,
      transparent 25%,
      transparent 50%,
      rgba(255, 255, 255, 0.2) 50%,
      rgba(255, 255, 255, 0.2) 75%,
      transparent 75%,
      transparent
    );
    background-size: 40px 40px;
}

@keyframes progress-animation {
    0% {
      background-position: 0 0;
    }
    100% {
      background-position: 40px 0;
    }
}

/* Modal de Detalhes do Disparo Styles - Enhanced */
#disparoModal .modal-content {
    text-align: left;
    max-width: 550px; /* Aumentar um pouco a largura */
    padding: 2rem; /* Aumentar o padding interno */
    border-radius: 8px; /* Suavizar bordas */
}

#disparoModal .modal-content h3 {
    margin-bottom: 1.5rem;
    text-align: center; /* Centralizar título */
    color: var(--primary-color); /* Cor do título */
}

#disparoModal .disparo-detail-row {
    display: flex; /* Usar flexbox para alinhar ícone e texto */
    align-items: flex-start; /* Alinhar ao topo para mensagens longas */
    margin-bottom: 0.8rem; /* Espaço entre as linhas de detalhes */
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--border-color); /* Separador visual */
}

/* Remover border-bottom da última linha de detalhe */
#disparoModal .disparo-detail-row:nth-last-of-type(2) { /* Target the last detail row before the button */
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 1.5rem; /* Add space before the OK button */
}

#disparoModalmsg {
    flex-direction: column;
}

#disparoModalmsg i {
    display: flex;
}

#msgesp {
    margin-left: 0.5rem;
}

#disparoModal .detail-icon {
    margin-right: 0.5rem; /* Mais espaço entre o ícone e o texto */
    color: var(--primary-color); /* Cor dos ícones */
    font-size: 1.1rem; /* Tamanho dos ícones */
    width: 1.2rem; /* Largura fixa para alinhar os textos */
    text-align: center; /* Centralizar o ícone no espaço */
    margin-top: 0.1rem; /* Pequeno ajuste vertical */
}

#disparoModal .modal-content strong {
    font-weight: 600;
    margin-right: 0.5rem; /* Mais espaço após o strong */
    min-width: 80px; /* Largura mínima para alinhar os títulos */
    display: inline-block; /* Para o min-width funcionar */
    color: var(--text-color); /* Cor do texto forte */
}

#disparoModal .modal-content span { /* Estilo geral para os spans de valor */
    color: var(--light-text); /* Cor mais suave para os valores */
    word-break: break-word; /* Quebrar palavras longas se necessário */
}

/* Specific styling for the message content span */
#disparoModalMensagem {
    display: block; /* Garante que o span ocupe a linha */
    white-space: pre-wrap; /* Preserve line breaks and wrap text */
    max-height: 250px; /* Aumentar max-height */
    overflow-y: auto; /* Add scrollbar if content exceeds max height */
    padding: 0.7rem; /* Aumentar padding */
    background-color: var(--section-bg, #f8f9fa);
    border-radius: 4px;
    margin-top: 0.5rem; /* Ajustar margem superior */
    border: 1px solid var(--border-color); /* Adicionar uma borda sutil */
    color: var(--text-color); /* Usar cor de texto padrão para a mensagem */
    line-height: 1.5; /* Melhorar espaçamento entre linhas */
}

/* Remover estilos de <p> que não são mais usados diretamente */
#disparoModal .modal-content p {
    margin-bottom: 0;
}

/* Centralizar o botão OK */
#disparoModal .modal-content .btn {
    display: block; /* Faz o botão ocupar a largura */
    margin: 1.5rem auto 0; /* Centraliza horizontalmente e adiciona margem superior */
    width: fit-content; /* Ajusta a largura ao conteúdo */
    padding-left: 2rem; /* Mais padding horizontal */
    padding-right: 2rem;
}
