/* Custom styles for SMS Portal */

/* Dashboard card hover effects */
.card {
    transition:
        transform 0.2s ease-in-out,
        box-shadow 0.2s ease-in-out;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Status badges */
.badge {
    font-size: 0.75rem;
}

/* Table hover effects */
.table-hover tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.075);
}

/* Unread message styling */
.table-light {
    background-color: #f8f9fa !important;
    font-weight: 500;
}

.table-light td:first-child {
    border-left: 3px solid #007bff !important;
    position: relative;
}

.table-light td:first-child::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(135deg, #007bff, #0056b3);
    border-radius: 0 2px 2px 0;
}

/* Enhanced NEW badge styling */
.badge.bg-primary {
    background: linear-gradient(135deg, #007bff, #0056b3) !important;
    color: white !important;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    animation: badgePulse 2s ease-in-out infinite;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.3);
}

@keyframes badgePulse {
    0%,
    100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* Unread indicator in conversations */
.unread-indicator {
    background: linear-gradient(135deg, #e7f3ff, #d1ecf1);
    border: 1px solid #b3d9ff;
    border-radius: 6px;
    padding: 6px 10px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.unread-indicator .fa-circle {
    color: #007bff;
    animation: dotPulse 1.5s ease-in-out infinite;
}

@keyframes dotPulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Message preview styling */
.text-decoration-none {
    color: inherit;
}

.text-decoration-none:hover {
    color: #0d6efd;
    text-decoration: underline;
}

/* Alert styling */
.alert {
    border-radius: 0.5rem;
}

/* Button styling */
.btn {
    border-radius: 0.375rem;
}

/* Footer styling */
.footer {
    border-top: 1px solid #dee2e6;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .navbar-brand {
        font-size: 1.1rem;
    }

    .btn-group {
        display: flex;
        flex-direction: column;
    }

    .btn-group .btn {
        margin-bottom: 0.25rem;
    }
}

/* Loading spinner */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Custom form styling */
.form-control:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Message attachment indicator */
.fa-paperclip {
    color: #6c757d;
    font-size: 0.8rem;
}

/* Quick actions button styling */
.d-flex.flex-wrap.gap-2 .btn {
    margin-bottom: 0.5rem;
}

/* Statistics card animations */
@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.card.bg-primary:hover,
.card.bg-success:hover,
.card.bg-warning:hover,
.card.bg-danger:hover {
    animation: pulse 0.3s ease-in-out;
}

/* Message status colors */
.badge.bg-success {
    background-color: #198754 !important;
}

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

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

/* Navigation active state */
.nav-link.active {
    font-weight: 600;
}

/* Pagination styling */
.pagination .page-link {
    color: #0d6efd;
}

.pagination .page-item.active .page-link {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

/* Auto-refresh and new message styling */
.table-success {
    background-color: #d1ecf1 !important;
    border-left: 4px solid #17a2b8;
    animation: highlightFade 3s ease-out;
}

@keyframes highlightFade {
    0% {
        background-color: #d1ecf1;
        border-left-color: #17a2b8;
    }
    100% {
        background-color: inherit;
        border-left-color: transparent;
    }
}

/* New messages notification */
#new-messages-notification {
    border-left: 4px solid #17a2b8;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Auto-refresh toggle styling */
.form-check-input:checked {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

.form-check-input:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Refresh status indicator */
#last-refresh {
    font-size: 0.875rem;
    color: #6c757d;
}

#refresh-time {
    font-weight: 500;
    color: #495057;
}

/* Enhanced table row transitions */
#messages-table-body tr {
    transition: all 0.3s ease;
}

#messages-table-body tr:hover {
    transform: scale(1.01);
}

/* Loading state for refresh */
.refresh-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Notification badge animation */
@keyframes notificationPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

#new-messages-count {
    animation: notificationPulse 0.6s ease-in-out infinite;
}

/* Manual Refresh Button Styling */
#manual-refresh-btn,
#dashboard-refresh-btn {
    transition: all 0.2s ease-in-out;
}

#manual-refresh-btn:hover,
#dashboard-refresh-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#manual-refresh-btn:active,
#dashboard-refresh-btn:active {
    transform: scale(0.95);
}

#manual-refresh-btn:disabled,
#dashboard-refresh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Refresh button spinner animation */
#manual-refresh-btn .fa-spin,
#dashboard-refresh-btn .fa-spin {
    animation: fa-spin 1s infinite linear;
}

/* Conversation Timeline Styles */
.conversation-timeline {
    max-height: 70vh;
    overflow-y: auto;
    padding: 1rem;
    position: relative;
}

.timeline-item {
    display: flex;
    margin-bottom: 1.5rem;
    position: relative;
}

.timeline-item::before {
    content: "";
    position: absolute;
    left: 30px;
    top: 50px;
    bottom: -1.5rem;
    width: 2px;
    background: #e9ecef;
    z-index: 1;
}

.timeline-item:last-child::before {
    display: none;
}

.timeline-marker {
    flex-shrink: 0;
    width: 60px;
    position: relative;
    z-index: 2;
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    font-size: 1.2rem;
    color: white;
}

.avatar.outbound {
    background: linear-gradient(135deg, #007bff, #0056b3);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.avatar.inbound {
    background: linear-gradient(135deg, #28a745, #1e7e34);
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
}

.timeline-content {
    flex: 1;
    margin-left: 1rem;
}

.message-bubble {
    max-width: 80%;
    position: relative;
}

.timeline-item.outbound .message-bubble {
    margin-left: auto;
}

.timeline-item.inbound .message-bubble {
    margin-right: auto;
}

.message-header {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.sender-name {
    font-weight: 600;
    margin-right: 0.5rem;
}

.timeline-item.outbound .sender-name {
    color: #007bff;
}

.timeline-item.inbound .sender-name {
    color: #28a745;
}

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

.message-status {
    margin-left: auto;
    margin-right: 0.5rem;
}

.message-body {
    background: white;
    padding: 1rem;
    border-radius: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    word-wrap: break-word;
}

.timeline-item.outbound .message-body {
    background: #007bff;
    color: white;
    margin-left: auto;
}

.timeline-item.outbound .message-body::before {
    content: "";
    position: absolute;
    right: -8px;
    top: 15px;
    width: 0;
    height: 0;
    border-left: 8px solid #007bff;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

.timeline-item.inbound .message-body::before {
    content: "";
    position: absolute;
    left: -8px;
    top: 15px;
    width: 0;
    height: 0;
    border-right: 8px solid white;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

.message-actions {
    margin-top: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.timeline-item:hover .message-actions {
    opacity: 1;
}

.timeline-item.outbound .message-actions {
    text-align: right;
}

.message-media {
    margin-top: 0.5rem;
}

.media-item {
    margin-bottom: 0.5rem;
}

.media-item img {
    border-radius: 12px;
    max-height: 200px;
    object-fit: cover;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .timeline-marker {
        width: 50px;
    }

    .avatar {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .message-bubble {
        max-width: 90%;
    }

    .timeline-item::before {
        left: 25px;
    }

    .timeline-content {
        margin-left: 0.5rem;
    }
}

/* Animation for new messages */
@keyframes slideInMessage {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.timeline-item.new-message {
    animation: slideInMessage 0.3s ease-out;
}
