/* static/styles.css */

/* --- Variables --- */
:root {
    /* Color Palette */
    --primary-color: #0579bc; /* Primary Blue */
    --secondary-color: #6c757d; /* Standard secondary grey */
    --light-bg: #f8f9fa; /* Light grey background */
    --dark-text: #041c2c; /* Black Text */
    --light-text: #ffffff; /* White text */
    --border-color: #dee2e6; /* Standard border color */
    --hover-bg: #e9ecef; /* Light hover background */
    --primary-hover: #005a86; /* Link Hover (Darker Blue) */

    /* Layout Dimensions */
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 65px;
    --header-height: 60px; /* Approximate height of the fixed header */
}

/* --- General Styles --- */
/* Applies to the entire body and page structure */
body {
    font-family: 'DM Sans', sans-serif; /* Updated Font */
    color: var(--dark-text);
    background-color: #ffffff; /* Default white background */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.page-wrapper {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* Links */
a {
    color: var(--primary-color);
}

a:hover {
    color: var(--primary-hover);
    text-decoration: none;
}

/* --- Common Components --- */
/* Styles for buttons, cards, and forms */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--light-text);
    transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    color: var(--light-text);
}

.btn-secondary {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    color: var(--light-text);
}

.btn-secondary:hover {
    background-color: #5a6268;
    border-color: #545b62;
    color: var(--light-text);
}

.btn-outline-secondary {
    border-color: var(--secondary-color);
    color: var(--secondary-color);
}

.btn-outline-secondary:hover {
    background-color: var(--secondary-color);
    color: var(--light-text);
}

.card {
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 90, 156, 0.25); /* Primary color focus glow */
}

/* --- Footer --- */
/* Styles for the footer section */
.app-footer {
    background-color: var(--light-bg);
    border-top: 1px solid var(--border-color);
    color: var(--secondary-color);
    font-size: 0.9rem;
    padding: 1rem 0;
}

/* --- Authentication/Account Layout Specific Styles --- */
/* Styles specific to authentication and account pages */
.auth-layout {
    background-color: var(--light-bg); /* Light background for auth pages */
}

.auth-layout .auth-header {
    background-color: #ffffff; /* White header background */
    border-bottom: 1px solid var(--border-color);
}

.auth-layout main {
    flex-grow: 1; /* Ensure main content takes available space */
}

.auth-layout .card {
    background-color: #ffffff; /* White card background */
    padding: 2rem;
}

/* --- Portal Layout Specific Styles --- */
/* Styles specific to the portal layout */
.portal-layout {
    background-color: #ffffff; /* White background for portal */
}

/* Removed ineffective .portal-layout .wrapper rule */

/* --- Portal Header --- */
/* Styles for the portal header section */
.portal-header {
    height: var(--header-height);
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
    z-index: 1030; /* Ensure header is above sidebar */
    padding: 0 1rem; /* Add some horizontal padding */
}

.portal-header .logo {
    max-height: 40px; /* Control logo size */
}

.portal-header .company-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--dark-text);
}

.portal-header .user-info {
    font-size: 0.9rem;
}

/* --- Portal Sidebar --- */
/* Styles for the portal sidebar section */
.sidebar {
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height)); /* Full height minus header */
    position: fixed;
    top: var(--header-height);
    left: 0;
    background-color: var(--light-bg);
    border-right: 1px solid var(--border-color);
    padding-top: 1rem;
    transition: width 0.3s ease-in-out, transform 0.3s ease-in-out;
    z-index: 1020; /* Below header */
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Allow scrolling if needed */
}

/* Add margin-top to the main wrapper in portal layout */
.portal-layout .main-wrapper {
    margin-top: var(--header-height);
}

/* --- Sidebar Header --- */
/* Styles for the sidebar header section */
.sidebar-header {
    padding: 0 1rem 1rem 1rem; /* Keep padding */
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
    /* Ensure button is aligned left by default flex behavior */
    /* align-items-center is added in layout.html */
}

/* --- Sidebar Toggle Button --- */
/* Styles for the desktop sidebar toggle button */
#sidebarToggleDesktop {
    background: none;
    border: none;
    padding: 0.5rem; /* Add some padding for click area */
    line-height: 1; /* Prevent extra space */
    cursor: pointer;
    margin-right: auto; /* Push other potential header items to the right */
}

#sidebarToggleDesktop:focus {
    outline: none; /* Remove focus outline */
    box-shadow: none;
}

#sidebarToggleDesktop i {
    font-size: 1.2rem; /* Adjust icon size if needed */
}

/* --- Sidebar Navigation Links --- */
/* Styles for the sidebar navigation links */
.sidebar .nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--dark-text);
    font-size: 0.95rem;
    white-space: nowrap; /* Prevent text wrapping */
    overflow: hidden; /* Hide text when collapsing */
    text-overflow: ellipsis;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.sidebar .nav-link i.fa-fw {
    width: 1.25em; /* Fixed width for icons */
    margin-right: 0.75rem;
    font-size: 1.1em;
    flex-shrink: 0; /* Prevent icon from shrinking */
}

.sidebar .nav-link:hover {
    background-color: var(--hover-bg);
    color: var(--dark-text);
}

.sidebar .nav-link.active {
    background-color: var(--primary-color);
    color: var(--light-text);
    font-weight: 600;
}

.sidebar .nav-link.active:hover {
    background-color: var(--primary-hover);
    color: var(--light-text);
}

/* --- Sidebar Footer --- */
/* Styles for the sidebar footer section */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Collapsed Sidebar Styles */
.sidebar.sidebar-collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.sidebar-collapsed .sidebar-header {
    padding: 0 0.5rem 1rem 0.5rem;
    justify-content: center;
}

.sidebar.sidebar-collapsed .nav-link span {
    display: none; /* Hide text */
}

.sidebar.sidebar-collapsed .nav-link {
    justify-content: center;
    padding: 0.75rem 0.5rem;
}

.sidebar.sidebar-collapsed .nav-link i.fa-fw {
    margin-right: 0;
}

/* Portal Content Area */
.content-area {
    /* Base styles for content area - applied always */
    width: 100%; /* Take full width initially */
    transition: margin-left 0.3s ease-in-out;
    /* Removed position: relative; and z-index: 1; to test modal interaction */
}

/* Apply margin ONLY when in portal layout and sidebar is NOT collapsed */
.portal-layout .content-area {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    /* Transition applied to content-area base style */
}

/* Adjust margin when sidebar IS collapsed (using class on wrapper) */
.portal-layout.sidebar-is-collapsed .content-area {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
}

/* Ensure no margin when in auth layout */
.auth-layout .content-area {
    margin-left: 0;
}

/* --- Tables --- */
.table {
    border: 1px solid var(--border-color);
}

.table thead th {
    background-color: var(--light-bg);
    border-bottom: 2px solid var(--border-color);
    color: var(--dark-text);
    font-weight: 600;
}

.table tbody tr:hover {
    background-color: var(--hover-bg);
}

.table td, .table th {
    vertical-align: middle;
}

/* --- Responsiveness --- */

/* Medium devices (tablets, less than 992px) */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%); /* Hide sidebar off-screen */
        width: var(--sidebar-width); /* Keep width consistent */
        z-index: 1040; /* Ensure sidebar is above content when shown */
        transition: transform 0.3s ease-in-out;
    }

    .sidebar.show {
        transform: translateX(0); /* Slide in sidebar */
    }

    /* Ensure content aligns left as if sidebar were collapsed when sidebar is hidden on medium/small screens */
    .portal-layout .content-area {
        margin-left: var(--sidebar-collapsed-width) !important; /* Set margin to collapsed width */
        width: calc(100% - var(--sidebar-collapsed-width)) !important; /* Adjust width accordingly */
        padding-left: 0 !important;     /* Remove left padding to align content with margin */
        padding-right: 1rem !important; /* Keep some right padding */
    }

    /* Overlay for when sidebar is open on small screens */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1035; /* Below sidebar, above content */
        display: none; /* Hidden by default */
    }

    .sidebar.show + .content-area + .sidebar-overlay {
        display: block; /* Show overlay */
    }

    /* Adjust header for mobile toggle */
    .portal-header .user-info {
        display: none; /* Hide user info/logout in header on small screens */
    }
}

/* Small devices (landscape phones, less than 768px) */
@media (max-width: 767.98px) {
    .portal-header .company-name {
        font-size: 1rem; /* Slightly smaller company name */
    }
    .content-area {
        padding: 1rem !important; /* Reduce padding */
    }
    .auth-layout .card {
        padding: 1.5rem; /* Reduce padding on auth cards */
    }
}

/* Extra small devices (portrait phones, less than 576px) */
@media (max-width: 575.98px) {
    .portal-header .logo {
        max-height: 30px; /* Smaller logo */
        margin-right: 0.5rem !important;
    }
     .portal-header .company-name {
        display: none !important; /* Hide company name on very small screens */
    }
    .auth-layout .card {
        padding: 1rem;
    }
    .table thead {
        display: none; /* Hide table header on very small screens */
    }
    .table tbody, .table tr, .table td {
        display: block; /* Stack table cells */
        width: 100%;
    }
    .table tr {
        margin-bottom: 1rem;
        border: 1px solid var(--border-color);
    }
    .table td {
        text-align: right; /* Align text to the right */
        padding-left: 50%; /* Create space for label */
        position: relative;
        border: none;
        border-bottom: 1px solid var(--border-color);
    }
    .table td::before {
        content: attr(data-label); /* Use data-label for pseudo-header */
        position: absolute;
        left: 10px;
        width: calc(50% - 20px);
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: bold;
        color: var(--dark-text);
    }
     .table td:last-child {
        border-bottom: none;
    }
}

/* Utility Classes */
.no-transition {
    transition: none !important;
}

/* Add some spacing */
.filter-controls {
    margin-bottom: 1rem;
}
/* Ensure table headers are clear */
.customer-table-container #customerTable th {
    white-space: nowrap;
}
/* Hide rows initially for JS filtering */
.customer-table-container #customerTable tbody tr.filtered-out {
    display: none;
}

/* --- Table Sorting Styles --- */
.sortable-table th.sortable-header {
    cursor: pointer;
    position: relative; /* Needed for absolute positioning of indicator */
}

.sortable-table th.sortable-header:hover {
    background-color: var(--hover-bg); /* Add hover effect */
}

.sortable-table th .sort-indicator {
    display: inline-block;
    width: 1em; /* Reserve space */
    text-align: right;
    margin-left: 0.3em;
    color: var(--secondary-color); /* Default color */
}

/* Font Awesome icons for sorting */
.sortable-table th.sort-asc .sort-indicator::after {
    font-family: "Font Awesome 6 Free"; /* Use Font Awesome */
    font-weight: 900; /* Solid style */
    content: "\f0de"; /* fa-sort-up */
    color: var(--primary-color); /* Active color */
}

.sortable-table th.sort-desc .sort-indicator::after {
    font-family: "Font Awesome 6 Free"; /* Use Font Awesome */
    font-weight: 900; /* Solid style */
    content: "\f0dd"; /* fa-sort-down */
    color: var(--primary-color); /* Active color */
}

/* Default indicator for sortable columns (before sorting) */
.sortable-table th.sortable-header:not(.sort-asc):not(.sort-desc) .sort-indicator::after {
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    content: "\f0dc"; /* fa-sort */
    color: #cccccc; /* Lighter grey for default */
    opacity: 0.5; /* Make it less prominent */
}


/* Prevent wrapping in specific table columns */
.date-col, .term-col, .autorenew-col, .expiry-col { /* Added term-col, autorenew-col, expiry-col */
    white-space: nowrap;
}

/* Prevent wrapping in Quote Items Move column */
#quoteItemsTable th:first-child,
#quoteItemsTable td:first-child {
    white-space: nowrap;
}

/* Order Status Notification Badge and Spinner */
#processing-order-count {
    display: none;
    position: relative;
    top: -8px;
    left: -5px;
}

#order-processing-spinner {
    display: none;
}

/* Onboarding Section Heading */
.onboarding-heading {
    cursor: pointer;
}

/* Progress Bar */
.progress-bar-custom-height {
    height: 25px;
}

/* BC Customer List Container */
.bc-customer-list-container {
    max-height: 350px;
    overflow-y: auto;
}

/* Progress Bar Width */
.progress-bar-width {
    width: var(--onboarding-progress);
}

/* External Email Group */
#externalEmailGroup {
    display: none;
}

/* --- Payment Form AVS Field Overrides --- */
/* Style AVS fields to look more like the Moneris iframe fields */
.avs-input-override {
    border: 1px solid #6c757d; /* Use secondary grey for border */
    border-radius: 0; /* Remove rounded corners */
    box-shadow: none; /* Remove default box shadow */
    font-family: inherit; /* Use the default form font */
    padding: 0.375rem 0.75rem; /* Match default Bootstrap padding */
    line-height: 1.5; /* Match default Bootstrap line-height */
    font-size: 1rem; /* Match default Bootstrap font-size */
    background-color: #fff; /* Ensure white background */
    color: #495057; /* Default text color */
}

.avs-input-override:focus {
    border-color: #000000; /* Simple black border on focus */
    box-shadow: none; /* Remove Bootstrap's focus glow */
    outline: none; /* Remove default browser outline */
}

/* Entra Export Service Tile Animation */
.entra-export-animation {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 20px;
    border-radius: 8px;
    min-height: 120px; /* Ensure a minimum height for the animation */
    position: relative; /* For absolute positioning of elements if needed */
}

.entra-export-animation .icon-container {
    text-align: center;
}

.entra-export-animation .icon {
    font-size: 2.5rem; /* Larger icons */
}

.entra-export-animation .arrow-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px; /* Width for arrows */
    overflow: hidden; /* Hide arrows when not animating */
}

/* Active State: Data Flowing */
.entra-export-animation.active .icon-entra {
    color: #28a745; /* Green for Entra (source) */
}

.entra-export-animation.active .icon-storage {
    color: #007bff; /* Blue for Azure Storage (destination) */
}

.entra-export-animation.active .arrow {
    font-size: 1.5rem;
    color: #28a745; /* Green arrows */
    animation: data-flow 1.5s linear infinite;
    opacity: 0; /* Start hidden, animation will make it visible */
}

/* Staggered animation for multiple arrows */
.entra-export-animation.active .arrow:nth-child(1) {
    animation-delay: 0s;
}
.entra-export-animation.active .arrow:nth-child(2) {
    animation-delay: 0.5s;
}
.entra-export-animation.active .arrow:nth-child(3) {
    animation-delay: 1s;
}

@keyframes data-flow {
    0% {
        transform: translateX(-20px);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translateX(20px);
        opacity: 0;
    }
}

/* Inactive State: Connection Error */
.entra-export-animation.inactive {
    border: 2px dashed #dc3545; /* Red dashed border */
    background-color: #f8d7da; /* Light red background */
}

.entra-export-animation.inactive .icon-entra,
.entra-export-animation.inactive .icon-storage {
    color: #dc3545; /* Red icons */
}

.entra-export-animation.inactive .arrow-container {
    justify-content: center; /* Center the X icon */
}

.entra-export-animation.inactive .icon-error {
    font-size: 2rem;
    color: #dc3545; /* Red X icon */
    animation: pulse-error 1.5s infinite;
}

@keyframes pulse-error {
    0% {
        transform: scale(1);
        opacity: 0.7;
    }
    50% {
        transform: scale(1.1);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 0.7;
    }
}

.entra-export-animation .status-text {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.9rem;
    font-weight: bold;
}

.entra-export-animation.active .status-text {
    color: #28a745; /* Green text for active */
}

.entra-export-animation.inactive .status-text {
    color: #dc3545; /* Red text for inactive */
}

/* Account Information Tile Label No Wrap */
.account-info-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Sidebar Submenu --- */
.sidebar .nav .list-unstyled {
    padding-left: 20px; /* Indent the submenu */
}

.sidebar .nav .list-unstyled .nav-link {
    padding: 0.5rem 1rem; /* Adjust padding for submenu items */
    font-size: 0.9rem; /* Slightly smaller font for submenu items */
}

.sidebar .nav-link.dropdown-toggle::after {
    display: inline-block;
    margin-left: auto;
    transition: transform 0.3s;
}

.sidebar .nav-link.dropdown-toggle[aria-expanded="true"]::after {
    transform: rotate(90deg);
}
