/* Custom styles for Antispam Project */

/* Global font consistency */
body, 
.form-control, 
.btn, 
input, 
select, 
textarea, 
.card, 
.alert,
.badge,
.navbar-brand {
    font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif !important;
}

/* Email detail labels */
.form-label-custom {
    font-weight: bold;
    margin-bottom: 0.25rem;
    color: #e9ecef !important;
}

/* Dark theme enforcement */
html, body {
    background-color: #212529 !important; 
    color: #e9ecef !important;
}

/* Improved contrast for muted elements */
.text-muted {
    color: #adb5bd !important;
}

/* Improved contrast for .text-secondary elements */
.text-secondary {
    color: #9da6af !important;
}

/* Main content area padding */
.container {
    padding-top: 20px;
    padding-bottom: 20px;
}

/* Card styling */
.card {
    margin-bottom: 20px;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(0, 0, 0, 0.15);
    background-color: #2c3034 !important;
    border-color: #373b3e !important;
}

.card-header {
    background-color: #212529 !important;
    border-bottom: 1px solid #373b3e !important;
}

/* Chart container */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Badge for ESP in email list */
.esp-badge {
    font-size: 0.8rem;
    padding: 5px 8px;
}

/* Authentication badges */
.auth-badge {
    margin-right: 5px;
}

/* Footer styling */
.footer {
    margin-top: 3rem;
    padding: 1rem 0;
    border-top: 1px solid rgba(33, 37, 41, 0.125);
}

/* Custom X-header highlighting */
.x-header {
    background-color: rgba(38, 143, 255, 0.1);
}

/* Table improvements */
.table-hover tbody tr:hover {
    background-color: rgba(33, 37, 41, 0.2) !important;
}

/* Force dark theme for all tables and elements */
.table {
    color: #e9ecef !important;
    background-color: #2c3034 !important;
}

.table td, .table th {
    border-color: #373b3e !important;
}

.table thead th {
    border-bottom-color: #373b3e !important;
}

/* Improve form control contrast */
.form-control, .form-select {
    background-color: #2c3034 !important;
    border-color: #495057 !important;
    color: #e9ecef !important;
}

/* Make dropdown items more readable */
.dropdown-menu {
    background-color: #343a40 !important;
    border-color: #495057 !important;
}

.dropdown-item {
    color: #e9ecef !important;
}

.dropdown-item:hover {
    background-color: #495057 !important;
}

/* Improve table background opacity */
.table-secondary.bg-opacity-25 {
    background-color: rgba(108, 117, 125, 0.25) !important;
}

.table-success.bg-opacity-25 {
    background-color: rgba(25, 135, 84, 0.25) !important;
}

/* Login card styling */
.login-card {
    max-width: 400px;
    margin: 0 auto;
    margin-top: 100px;
}

/* Truncate long text */
.text-truncate {
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Status badge with better contrast */
.status-badge {
    color: rgba(0, 0, 0, 0.8) !important;
    font-weight: 500;
}

/* Add specific styles for email details page */
.html-content-wrapper {
    background-color: #1e2430 !important;
    border-color: #2c3344 !important;
}

#html-iframe {
    background-color: white !important;
}

/* Navbar and main elements */
.navbar {
    background-color: #212529 !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 0.75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    transition: all 0.3s ease;
}

.navbar.scrolled {
    padding: 0.5rem 1rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.bg-dark {
    background-color: #212529 !important;
}

/* Fix for long email addresses in input fields */
.form-control[readonly] {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Improve page headers visibility */
h1 {
    color: #ffffff !important;
    font-weight: 600 !important;
    font-size: 24px !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

h2 {
    font-size: 20px !important;
}

h3, h4, h5, h6 {
    font-size: 18px !important;
}

/* Improve hyperlink contrast */
a {
    color: #7fe2ff !important; /* Brighter blue for links on dark backgrounds */
    transition: color 0.2s ease-in-out;
}

a:hover {
    color: #a8ebff !important;
    text-decoration: underline !important;
}

a.btn {
    color: inherit !important; /* Don't affect buttons */
}

/* Special styling for links in alerts and requirements sections */
.alert a, 
.card-body .alert a,
.gmail-requirements a {
    color: #0b4d8c !important; /* Darker blue for better contrast on light/yellow backgrounds */
    text-decoration: underline;
    font-weight: 600;
}

.alert a:hover, 
.card-body .alert a:hover,
.gmail-requirements a:hover {
    color: #073464 !important;
    text-decoration: underline !important;
}

/* Specific override for warning alerts which have yellow backgrounds */
.alert-warning a {
    color: #664d03 !important; /* Dark brown that contrasts with yellow */
    font-weight: 700;
}

.alert-warning a:hover {
    color: #332701 !important; /* Even darker brown on hover */
}

/* Modern navbar styling */
.navbar-nav .nav-link {
    color: #e9ecef !important;
    font-weight: 400;
    position: relative;
    padding-left: 0.8rem !important;
    padding-right: 0.8rem !important;
    transition: all 0.2s ease;
}

.navbar-nav .nav-link:hover {
    color: #ffffff !important;
    text-decoration: none !important;
}

.navbar-nav .nav-link.active {
    color: #ffffff !important;
    font-weight: 500;
}

/* Animated active indicator */
.navbar-nav .nav-link.active::after {
    content: '';
    position: absolute;
    width: 70%;
    height: 2px;
    background-color: #0d6efd;
    bottom: 0;
    left: 15%;
    border-radius: 4px;
}

/* Specific styling for navbar brand to prevent blue color and underline */
.navbar-brand {
    color: #ffffff !important; 
    text-decoration: none !important;
    font-weight: 500;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
    padding: 0.5rem 1rem;
}

.navbar-brand:hover {
    color: #ffffff !important;
    text-decoration: none !important;
}

/* Improved button styling for better readability */
.btn {
    font-weight: 500 !important;
    border-width: 2px !important;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

/* Primary buttons with better contrast */
.btn-primary {
    background-color: #0d6efd !important;
    border-color: #0a58ca !important;
    color: #ffffff !important;
}

.btn-primary:hover, .btn-primary:focus {
    background-color: #0b5ed7 !important;
    border-color: #0a58ca !important;
}

/* Secondary buttons with better contrast */
.btn-secondary {
    background-color: #6c757d !important;
    border-color: #565e64 !important;
    color: #ffffff !important;
}

.btn-secondary:hover, .btn-secondary:focus {
    background-color: #5c636a !important;
    border-color: #565e64 !important;
}

/* Success buttons with better contrast */
.btn-success {
    background-color: #198754 !important;
    border-color: #146c43 !important;
    color: #ffffff !important;
}

.btn-success:hover, .btn-success:focus {
    background-color: #157347 !important;
    border-color: #146c43 !important;
}

/* Danger buttons with better contrast */
.btn-danger {
    background-color: #dc3545 !important;
    border-color: #b02a37 !important;
    color: #ffffff !important;
}

.btn-danger:hover, .btn-danger:focus {
    background-color: #bb2d3b !important;
    border-color: #b02a37 !important;
}

/* Warning buttons with better contrast - darker text for visibility */
.btn-warning {
    background-color: #ffc107 !important;
    border-color: #cc9a05 !important;
    color: #000000 !important;
    font-weight: 600 !important;
}

.btn-warning:hover, .btn-warning:focus {
    background-color: #ffca2c !important;
    border-color: #cc9a05 !important;
}

/* Info buttons with better contrast */
.btn-info {
    background-color: #0dcaf0 !important;
    border-color: #0aa1c0 !important;
    color: #000000 !important;
    font-weight: 600 !important;
}

.btn-info:hover, .btn-info:focus {
    background-color: #31d2f2 !important;
    border-color: #0aa1c0 !important;
}

/* Light buttons with better contrast - darker text for visibility */
.btn-light {
    background-color: #f8f9fa !important;
    border-color: #d3d4d5 !important;
    color: #212529 !important;
    font-weight: 600 !important;
}

.btn-light:hover, .btn-light:focus {
    background-color: #e9ecef !important;
    border-color: #d3d4d5 !important;
}

/* Dark buttons with better contrast */
.btn-dark {
    background-color: #212529 !important;
    border-color: #1a1e21 !important;
    color: #ffffff !important;
}

.btn-dark:hover, .btn-dark:focus {
    background-color: #1c1f23 !important;
    border-color: #1a1e21 !important;
}

/* Outline buttons with better hover states */
.btn-outline-primary:hover, .btn-outline-primary:focus,
.btn-outline-secondary:hover, .btn-outline-secondary:focus,
.btn-outline-success:hover, .btn-outline-success:focus,
.btn-outline-danger:hover, .btn-outline-danger:focus {
    color: #ffffff !important;
}

.btn-outline-warning:hover, .btn-outline-warning:focus,
.btn-outline-info:hover, .btn-outline-info:focus,
.btn-outline-light:hover, .btn-outline-light:focus {
    color: #000000 !important;
}

.breadcrumb-item.active {
    color: #e9ecef !important; /* Make active breadcrumb item more visible */
}

.breadcrumb-item + .breadcrumb-item::before {
    color: #adb5bd !important; /* Separator color */
}

/* Responsive improvements for mobile */
@media (max-width: 576px) {
    .container {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    h1 {
        font-size: 22px !important;
    }
    
    .table-responsive {
        font-size: 15px !important;
    }
}

/* Ensure tables display content properly */
.table td {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal;
    word-wrap: break-word;
}

/* ESP favicon display */
.esp-favicon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    background-color: #fff;
    border-radius: 4px;
}

/* Improve small buttons readability */
.btn-sm {
    font-weight: 500 !important;
    font-size: 14px !important;
    padding: 0.35rem 0.6rem !important;
}

/* Add a slight box shadow to buttons for better depth */
.btn {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2) !important;
}

/* Improved contrast for disabled buttons */
.btn:disabled, .btn.disabled {
    opacity: 0.65 !important;
    cursor: not-allowed;
}

/* Better styling for button groups */
.btn-group .btn {
    position: relative;
    border-width: 2px !important;
}

/* ESP Detection Rate overrides to fix contrast issues */
.badge.bg-secondary, .badge.bg-secondary[style*="background"], .badge.grey, .badge.gray {
    background-color: #343a40 !important;
    color: #ffffff !important;
}

/* Force ESP Detection badges to always have proper contrast */
.esp-detection-stats .badge, 
.badge.badge-blue, .badge.badge-purple, .badge.text-white,
.badge[class*="primary"], .badge[class*="blue"], .badge[class*="purple"] {
    color: #ffffff !important;
    font-weight: 600 !important;
}

/* Ensure blue is used for primary badges */
.esp-detection-stats .badge.bg-primary, 
.badge.bg-primary, .badge.bg-blue, .badge.bg-purple,
.badge.blue, .badge.purple, .badge[style*="background: rgb(90, 50, 234)"],
.badge[style*="background-color: rgb(90, 50, 234)"] {
    background-color: #0d6efd !important;
}

/* Fixed ESP counter cards */
.card .badge[style*="background"] {
    background-color: #0d6efd !important;
    color: #ffffff !important;
}

/* Fixed ESP counter Unknown cards */
.card .badge.bg-dark, .card .badge.bg-secondary, .card .badge.bg-gray, .card .badge.bg-grey {
    background-color: #343a40 !important;
    color: #ffffff !important;
}

/* Status bar styling */
#status-bar {
    color: inherit !important;
    text-decoration: none !important;
}

#status-bar:hover {
    text-decoration: none !important;
}

/* Ensure all progress bars have proper contrast */
.progress-bar,
.progress-bar.bg-purple, .progress-bar.bg-primary, .progress-bar.blue,
.progress-bar[style*="background: rgb(90, 50, 234)"], 
.progress-bar[style*="background-color: rgb(90, 50, 234)"] {
    background-color: #0d6efd !important;
}

.progress-bar.bg-secondary, .progress-bar.bg-gray, .progress-bar.bg-grey, .progress-bar.gray, .progress-bar.grey,
.progress-bar.bg-dark {
    background-color: #6c757d !important; /* Lighter gray to stand out against dark background */
}

/* Force all inline styles for ESP badges to be overridden */
[style*="background: rgb(90, 50, 234)"], [style*="background-color: rgb(90, 50, 234)"] {
    background-color: #0d6efd !important;
}

[style*="background: rgb(107, 114, 128)"], [style*="background-color: rgb(107, 114, 128)"] {
    background-color: #343a40 !important;
}

/* Email Headers styling - Ensuring consistent fonts */
#headersTable td,
#headersTable .header-name,
#headersTable .header-value,
#headersTable pre {
    font-family: var(--bs-font-sans-serif) !important;
    line-height: 1.5 !important;
}

/* Activity Feed styling */
#activity-feed {
    max-height: 500px;
    overflow-y: auto;
    background-color: #22272e;
    border-radius: 8px;
    border: 1px solid #313640;
    scrollbar-width: thin;
    scrollbar-color: #495057 #22272e;
}

#activity-feed::-webkit-scrollbar {
    width: 8px;
}

#activity-feed::-webkit-scrollbar-track {
    background: #22272e;
    border-radius: 8px;
}

#activity-feed::-webkit-scrollbar-thumb {
    background-color: #495057;
    border-radius: 8px;
    border: 2px solid #22272e;
}

#activity-feed .list-group-item {
    background-color: transparent;
    border-color: #313640;
    border-left: none;
    border-right: none;
    border-top: none;
    padding: 0.75rem 1rem;
    transition: background-color 0.2s ease;
}

#activity-feed .list-group-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

#activity-feed .list-group-item:last-child {
    border-bottom: none;
}

#activity-feed .activity-item .badge {
    font-size: 12px !important;
    padding: 0.35rem 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* All badge sizes */
.badge {
    font-size: 14px !important;
    font-weight: 600 !important;
}

#activity-feed .activity-message {
    line-height: 1.4;
    color: #e9ecef;
}

/* Component badges in activity feed */
#activity-feed .badge.bg-dark {
    background-color: #343a40 !important;
}

#activity-feed .badge.bg-primary {
    background-color: #0d6efd !important;
}

#activity-feed .badge.bg-info {
    background-color: #0dcaf0 !important;
    color: #000 !important;
}

#activity-feed .badge.bg-success {
    background-color: #198754 !important;
}

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

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

/* Status indication styling */
#activity-feed .list-group-item-danger {
    background-color: rgba(220, 53, 69, 0.15) !important;
    color: #ea868f !important;
}

#activity-feed .list-group-item-warning {
    background-color: rgba(255, 193, 7, 0.15) !important;
    color: #ffda6a !important;
}

#activity-feed .list-group-item-success {
    background-color: rgba(25, 135, 84, 0.15) !important;
    color: #75b798 !important;
}

#activity-feed .list-group-item-info {
    background-color: rgba(13, 110, 253, 0.1) !important;
    color: #e9ecef !important;
}
