/* Dashboard Stylesheet - SureSend Deliverability Suite */

/* CSS Variables - Brand Colors */
:root {
    --brand-deep: #154e63;
    --brand-mid: #2a6b86;
    --brand-accent: #e5bf78;
    --bg: rgba(0, 0, 0, 0.03); /* Subtle gray background for contrast */
    --card: #FFFFFF;
    --muted: #5a6872; /* Darkened for better contrast on light backgrounds */
    --text: #0d2a33;
    --border: #e5e7eb;
    
    /* Health grades */ 
    --grade-a: #22c55e;
    --grade-b: #3b82f6;
    --grade-c: #f59e0b;
    --grade-d: #ef4444;
    --grade-f: #dc2626;
}

/* Base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;             
    background-attachment: fixed;       /* Keep gradient fixed during scroll */
    min-height: 100vh;                 /* Ensure gradient covers full viewport */
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* App shell container */
.app-shell {
    display: flex;
    width: 96%;
    max-width: 1500px; /* Original width - tables will scroll horizontally */
    height: 96%;
    margin: 20px auto;
    background: var(--bg); /* Use the gray background color for outer shell */
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(21, 78, 99, 0.20), 0 1px 2px rgba(21, 78, 99, 0.12);
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background: var(--brand-deep);
    display: flex;
    flex-direction: column;
    padding: 24px;
    overflow-y: auto;
}

/* Logo */
.logo-container {
    margin-bottom: 24px;
}

.logo {
    height: 40px;
    width: auto;
}

/* Navigation tabs */
.nav-tabs {
    margin-bottom: 24px;
}

.nav-tab {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.9);
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 8px;
    display: block;
}

.nav-tab:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.nav-tab.active {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--brand-accent);
}

.tab-name {
    font-weight: 600;
    font-size: 14px;
    display: block;
    margin-bottom: 4px;
}

.tab-description {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    display: block;
}

/* Filter section */
.filter-section {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 16px;
}

.filter-title {
    color: rgba(255, 255, 255, 0.9);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 16px;
}

.filter-group {
    margin-bottom: 16px;
}

.filter-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    display: block;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.date-range {
    display: flex;
    gap: 12px;
}

.date-input-group {
    flex: 1;
}

.date-label {
    color: rgba(255, 255, 255, 0.5);
    font-size: 11px;
    display: block;
    margin-bottom: 4px;
}

.date-input {
    width: 100%;
    padding: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: white;
    font-size: 12px;
}

.filter-select {
    width: 100%;
    padding: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: white;
    font-size: 12px;
}

.generate-report {
    width: 100%;
    padding: 10px;
    background: var(--brand-accent);
    color: var(--text);
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.generate-report:hover {
    background: #d4ae67;
}

/* Sidebar logout link */
.sidebar-logout {
    padding: 16px 0;
    margin-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.logout-link {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 14px;
    display: block;
    padding: 8px 16px;
    border-radius: 6px;
    transition: all 0.2s;
}

.logout-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.9);
}

/* Main content area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 28px 36px; /* Original padding */
    overflow-y: auto;
    min-height: 665px;
    background: white; /* WHITE BACKGROUND FOR MAIN CONTENT */
}

/* Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.3); /* Subtle text shadow for better contrast on gray background */
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 16px;
}

#last-updated {
    color: var(--text); /* Use main text color for better contrast on gray background */
    opacity: 0.7; /* Slightly transparent to show it's secondary */
    font-size: 12px;
    font-weight: 500; /* Slightly heavier for readability */
}

.refresh-button {
    padding: 8px 16px;
    background: var(--brand-mid);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.refresh-button:hover {
    background: var(--brand-deep);
}

/* Summary cards */
.summary-row {
    display: flex;
    gap: 18px;
    margin-bottom: 28px;
}

.summary-card {
    flex: 1;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px;
}

.card-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-display {
    font-size: 36px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.health-grade .grade {
    font-size: 48px;
    color: var(--grade-a);
}

.card-description {
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 8px;
}

.card-meta {
    font-size: 11px;
    color: var(--muted);
    display: flex;
    gap: 12px;
}

/* Content card */
.content-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Ensure clean edges */
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    background: white; /* Keep header white */
}

.card-header .card-title {
    color: var(--text);
    font-weight: 600; /* Slightly heavier for better contrast */
}

.card-header .card-subtitle {
    color: var(--muted);
    font-size: 13px;
    margin-top: 4px;
}

.card-body {
    padding: 24px;
    flex: 1;
    overflow-y: auto;
    background: white; /* Ensure card body stays white */
}

.component-info {
    background: #FFFFFF;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 20px;
}

.component-info h3 {
    font-size: 16px;
    margin-bottom: 12px;
}

.component-list {
    list-style: none;
    padding-left: 20px;
}

.component-list li {
    position: relative;
    margin-bottom: 8px;
    font-size: 14px;
}

.component-list li:before {
    content: "•";
    position: absolute;
    left: -15px;
    color: var(--brand-accent);
}

.load-data-button {
    margin-top: 16px;
    padding: 10px 20px;
    background: var(--brand-mid);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.load-data-button:hover {
    background: var(--brand-deep);
}

/* Component containers */
.component-container {
    margin-bottom: 24px;
    padding: 20px;
    background: #FFFFFF;
    border-radius: 6px;
    min-height: 100px;
}

.component-content {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
}

/* Table containers and wrappers */
.table-container {
    width: 100%;
    overflow: visible; /* Allow table wrapper to handle overflow */
}

.table-wrapper {
    width: 100%;
    overflow-x: auto; /* Enable horizontal scrolling */
    overflow-y: visible;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.data-table {
    width: 100%;
    min-width: 1100px; /* Increased to accommodate trend arrows without wrapping */
    border-collapse: collapse;
}

/* Prevent trend arrows from wrapping in table cells */
.data-table td {
    white-space: nowrap; /* Keep percentage and arrow on same line */
}

/* Loading state */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--muted);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
}

::-webkit-scrollbar-thumb {
    background: var(--brand-mid);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--brand-deep);
}

/* Responsive breakpoints */
@media (max-width: 980px) {
    .app-shell {
        flex-direction: column;
        height: auto;
        width: 98%;
    }
    
    .sidebar {
        width: 100%;
        flex-direction: row;
        padding: 16px;
        overflow: visible; /* Changed from overflow-x: auto to visible */
        align-items: center;
        justify-content: space-between;
        position: relative;
    }
    
    /* Logo stays visible */
    .logo-container {
        margin-bottom: 0;
        margin-right: auto;
    }
    
    /* Hamburger menu buttons */
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 6px;
        cursor: pointer;
        margin-left: 12px;
        transition: all 0.2s;
    }
    
    .mobile-menu-toggle:hover {
        background: rgba(255, 255, 255, 0.15);
        border-color: rgba(255, 255, 255, 0.3);
    }
    
    .mobile-menu-toggle.active {
        background: rgba(255, 255, 255, 0.2);
        border-color: var(--brand-accent);
    }
    
    /* Hamburger icon */
    .hamburger-icon {
        display: flex;
        flex-direction: column;
        width: 20px;
        height: 14px;
        justify-content: space-between;
    }
    
    .hamburger-icon span {
        display: block;
        height: 2px;
        width: 100%;
        background: rgba(255, 255, 255, 0.9);
        border-radius: 2px;
        transition: all 0.3s;
    }
    
    /* X icon when active */
    .mobile-menu-toggle.active .hamburger-icon span:nth-child(1) {
        transform: translateY(6px) rotate(45deg);
    }
    
    .mobile-menu-toggle.active .hamburger-icon span:nth-child(2) {
        opacity: 0;
    }
    
    .mobile-menu-toggle.active .hamburger-icon span:nth-child(3) {
        transform: translateY(-6px) rotate(-45deg);
    }
    
    /* Mobile menu containers */
    .mobile-menu-container {
        display: flex;
        gap: 12px;
        align-items: center;
    }
    
    /* Navigation dropdown */
    .nav-tabs {
        display: none;
        position: fixed; /* Changed from absolute to fixed */
        top: 80px; /* Fixed position from top */
        left: 16px;
        right: 16px;
        background: var(--brand-deep);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 8px;
        padding: 12px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
        z-index: 10001;
        max-height: 70vh;
        overflow-y: auto;
    }
    
    .nav-tabs.show {
        display: block !important;
        animation: slideDown 0.3s ease-out;
    }
    
    .nav-tab {
        min-width: 100%;
        margin-bottom: 8px;
    }
    
    .nav-tab:last-child {
        margin-bottom: 0;
    }
    
    /* Filter section dropdown */
    .filter-section {
        display: none;
        position: fixed; /* Changed from absolute to fixed */
        top: 80px; /* Fixed position from top */
        left: 16px;
        right: 16px;
        background: var(--brand-deep);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 8px;
        padding: 16px;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
        z-index: 10001;
        max-height: 70vh;
        overflow-y: auto;
    }
    
    .filter-section.show {
        display: block !important;
        animation: slideDown 0.3s ease-out;
    }
    
    /* Slide down animation */
    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    /* Overlay for mobile menus */
    .mobile-menu-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 9999;
    }
    
    .mobile-menu-overlay.show {
        display: block;
        animation: fadeIn 0.3s ease-out;
    }
    
    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }
    
    .summary-row {
        flex-wrap: wrap;
    }
    
    .summary-card {
        min-width: calc(50% - 9px);
    }
}



/* Hide hamburger menus on desktop */
@media (min-width: 981px) {
    .mobile-menu-toggle {
        display: none !important;
    }
    
    .mobile-menu-container {
        display: none !important;
    }
    
    .mobile-menu-overlay {
        display: none !important;
    }
    
    .desktop-only {
        display: block;
    }
}

/* Mobile-specific styles */
@media (max-width: 980px) {
    .desktop-only {
        display: none !important;
    }
    
    /* Add sign out link to filter section on mobile */
    .filter-section::after {
        content: '';
        display: block;
        height: 1px;
        background: rgba(255, 255, 255, 0.1);
        margin: 20px 0 16px;
    }
    
    .filter-section .mobile-sign-out {
        display: block;
        color: rgba(255, 255, 255, 0.7);
        text-decoration: none;
        font-size: 14px;
        text-align: center;
        padding: 10px;
        background: rgba(255, 255, 255, 0.05);
        border-radius: 6px;
        transition: background 0.2s;
    }
    
    .filter-section .mobile-sign-out:hover {
        background: rgba(255, 255, 255, 0.1);
    }
}

@media (max-width: 640px) {
    .app-shell {
        margin: 0;
        width: 100%;
        border-radius: 0;
    }
    
    .main-content {
        padding: 16px;
    }
    
    .summary-row {
        flex-direction: column;
    }
    
    .summary-card {
        min-width: 100%;
    }
}

/* Filter Component Styles - Modular filter UI styling */

/* Multi-select wrapper */
.multi-select-wrapper {
    position: relative;
}

/* Multi-select display */
.multi-select-display {
    padding: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: white;
    font-size: 12px;
    cursor: pointer;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s;
}

.multi-select-display:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.multi-select-display:focus {
    outline: none;
    border-color: var(--brand-accent);
}

/* Multi-select dropdown */
.multi-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #1a5a70;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    margin-top: 4px;
    max-height: 250px;
    overflow-y: auto;
    display: none;
    z-index: 1000;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* Filter search input */
.filter-search {
    width: 100%;
    padding: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 12px;
}

.filter-search::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.filter-search:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.12);
}

/* Multi-select options */
.multi-select-option {
    display: flex;
    align-items: center;
    padding: 8px;
    cursor: pointer;
    font-size: 12px;
    color: white;
    transition: background 0.1s;
}

.multi-select-option:hover {
    background: rgba(255, 255, 255, 0.05);
}

.multi-select-option input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

/* Select all option styling */
.multi-select-option:has(.select-all) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 600;
}

/* Date input readonly styling */
.date-input[readonly] {
    cursor: default;
    opacity: 0.8;
}

.date-input[readonly]:hover {
    background: rgba(255, 255, 255, 0.08);
}

/* Loading overlay */
.main-content.loading {
    position: relative;
    pointer-events: none;
}

.main-content.loading::after {
    content: 'Loading...';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 500;
    color: var(--brand-deep);
    z-index: 100;
}

/* Table styles for performance component */
.mailbox-performance-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.mailbox-performance-table th {
    text-align: left;
    padding: 12px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--muted);
    background: #FFFFFF;
}

.mailbox-performance-table td {
    padding: 12px;
}

.mailbox-performance-table tbody tr {
    transition: background 0.1s;
}

.mailbox-performance-table tbody tr:hover {
    background: rgba(0, 0, 0, 0.02);
}

/* No data message */
.no-data-message {
    text-align: center;
    padding: 40px;
    color: var(--muted);
}

/* Scrollbar styling for dropdowns */
.multi-select-dropdown::-webkit-scrollbar {
    width: 6px;
}

.multi-select-dropdown::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.multi-select-dropdown::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.multi-select-dropdown::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Filter group spacing adjustments */
.filter-section .filter-group {
    margin-bottom: 16px;
}

.filter-section .filter-group:last-of-type {
    margin-bottom: 20px;
}

/* ==========================================
   LOGIN PAGE STYLES
   ========================================== */

/* Login page body layout */
body.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
}

/* Login container */
.login-container {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(21, 78, 99, 0.18);
    padding: 48px;
    width: 100%;
    max-width: 400px;
    backdrop-filter: blur(10px);
}

/* Login logo */
.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo img {
    height: 48px;
    width: auto;
}

/* Login title */
.login-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text);
    text-align: center;
    margin-bottom: 32px;
}

/* Form styles */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.form-input:focus {
    outline: none;
    border-color: var(--brand-mid);
    box-shadow: 0 0 0 2px rgba(42, 107, 134, 0.15);
}

/* Login button - matching dashboard style */
.login-button {
    width: 100%;
    padding: 12px;
    background: var(--brand-accent);
    color: var(--text);
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    cursor: pointer;
    transition: all 0.2s;
}

.login-button:hover {
    background: #d4ae67;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(229, 191, 120, 0.4);
}

.login-button:active {
    transform: translateY(0);
}

/* Flash messages */
.flash-message {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 14px;
    animation: slideIn 0.3s ease-out;
}

.flash-message.success {
    background: #d1fae5;
    border-color: #a7f3d0;
    color: #065f46;
}

.flash-message.info {
    background: #dbeafe;
    border-color: #bfdbfe;
    color: #1e40af;
}

.flash-message.warning {
    background: #fed7aa;
    border-color: #fdba74;
    color: #9a3412;
}

/* Animation for flash messages */
@keyframes slideIn {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Mobile responsiveness for login */
@media (max-width: 480px) {
    .login-container {
        margin: 20px;
        padding: 32px 24px;
    }
    
    .login-title {
        font-size: 20px;
    }
}

/* Responsive adjustments for dashboard */
@media (max-width: 980px) {
    .multi-select-dropdown {
        max-height: 200px;
    }
}

@media (max-width: 640px) {
    .multi-select-dropdown {
        max-height: 150px;
    }
    
    .mailbox-performance-table {
        font-size: 12px;
    }
    
    .mailbox-performance-table th,
    .mailbox-performance-table td {
        padding: 8px;
    }
}
