/* FILENAME: style.css */
:root {
    --primary-color: #4CAF50; /* Natural Green */
    --primary-dark-color: #388E3C; /* Darker green for hover */
    --secondary-color: #607D8B; /* Blue Grey for secondary actions */
    --background-color: #F8F9FA; /* Light background */
    --container-bg: #FFFFFF; /* White for cards/containers */
    --text-color: #212121; /* Dark grey for primary text */
    --muted-text: #757575; /* Medium grey for muted text */
    --border-color: #E0E0E0; /* Light grey for borders */
    --hover-bg: #F5F5F5; /* Lighter grey for hover states */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08); /* Small shadow */
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12); /* Medium shadow */
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.16); /* Large shadow */
    --accent-color: #2196F3; /* Blue for links/highlights */
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 0; /* Changed from 1.5rem to 0 for full control by layout */
    line-height: 1.7; /* Slightly increased for expressive feel */
    font-size: 16px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem; /* Added padding for consistent spacing */
}

/* General Layout & Components */
header {
    background-color: var(--container-bg);
    box-shadow: var(--shadow-sm);
    padding: 1rem 0;
    position: sticky; /* Make header sticky */
    top: 0;
    z-index: 1000;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h1.title {
    font-size: 2.5rem; /* Larger title */
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0; /* Remove margin from header title */
}

.subtitle {
    font-size: 1.2rem;
    color: var(--muted-text);
    margin-top: 0.5rem;
}

/* Loading Indicator */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem; /* More padding */
    gap: 1.5rem; /* More gap */
    color: var(--muted-text);
}
.loader {
    border: 6px solid #f3f3f3; /* Thicker loader */
    border-top: 6px solid var(--primary-color);
    border-radius: 50%;
    width: 60px; /* Larger loader */
    height: 60px;
    animation: spin 1s linear infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.hidden {
    display: none;
}

/* Links */
a {
    color: var(--primary-color); /* Default link color */
    text-decoration: none;
    transition: color 0.2s ease;
}
a:hover {
    color: var(--primary-dark-color);
    text-decoration: underline;
}
a:visited {
    color: var(--primary-color); /* Visited links same as primary for consistency */
}


/* Buttons */
.btn-primary, .btn-secondary, .btn-tertiary, .btn-primary-outline, .btn-primary-lg, .btn-secondary-lg, .btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem; /* Slightly more gap for expressive */
    padding: 0.85rem 1.8rem; /* More padding */
    border: none;
    border-radius: 12px; /* More rounded for Material 3 Expressive */
    font-size: 1.05rem; /* Slightly larger font */
    font-weight: 600; /* Bolder text */
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); /* Smoother transition */
    text-decoration: none;
    justify-content: center;
    box-shadow: var(--shadow-sm); /* Default shadow */
}

/* Apply default margin-top to buttons not already spaced by specific classes */
.btn-primary:not(.mt-6):not(.mt-4) {
    margin-top: 1.5rem;
}

/* Specific margin for Save API Settings button */
form#settingsForm .btn-primary {
    margin-top: 2rem; /* Increased space for this specific button */
}

a.btn-primary, a.btn-primary-lg {
    color: white;
}

.btn-primary {
    margin-top: 1.5rem; /* Default margin for primary buttons */
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.btn-primary:hover {
    background-color: var(--primary-dark-color);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px); /* Lift effect */
}

.btn-secondary {
    background-color: var(--secondary-color); /* Reverted to secondary color */
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.btn-secondary:hover {
    background-color: #455A64; /* Darker blue grey */
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.btn-tertiary { /* Used for Fetch Client List */
    background-color: var(--primary-color); /* Consistent with primary */
    color: white;
}
.btn-tertiary:hover {
    background-color: var(--primary-dark-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.btn-primary-outline {
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    box-shadow: none;
}
.btn-primary-outline:hover {
    background-color: rgba(76, 175, 80, 0.1); /* Light tint of natural green */
    color: var(--primary-dark-color);
    box-shadow: none;
    transform: translateY(-2px);
}

.btn-primary-lg {
    padding: 1.2rem 2.5rem; /* Larger padding */
    font-size: 1.25rem; /* Larger font */
    background-color: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-md);
    border-radius: 16px; /* Even more rounded */
}
.btn-primary-lg:hover {
    background-color: var(--primary-dark-color);
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
}

.btn-secondary-lg {
    padding: 1.2rem 2.5rem;
    font-size: 1.25rem;
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    box-shadow: none;
    border-radius: 16px;
}
.btn-secondary-lg:hover {
    background-color: rgba(76, 175, 80, 0.1);
    color: var(--primary-dark-color);
    box-shadow: none;
    transform: translateY(-3px);
}

.btn-danger {
    background-color: #F44336; /* Red */
    color: white;
}
.btn-danger:hover {
    background-color: #D32F2F; /* Darker red */
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.btn-primary:disabled, .btn-secondary:disabled, .btn-tertiary:disabled, .btn-danger:disabled {
    opacity: 0.5; /* More visible disabled state */
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Navigation Links - Dashboard/Settings */
header .nav-link { /* Target nav links specifically */
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
    text-decoration: none;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0; /* Prevent shrinking */
    min-width: 100px; /* Ensure consistent width if needed, adjust as per content */
    text-align: center; /* Center text within button */
}
header .nav-link.active { /* Specific style for active nav link */
    background-color: var(--primary-color);
    color: white;
}
header .nav-link.active:hover {
    background-color: var(--primary-dark-color);
    color: white;
}
header .nav-link:not(.active) { /* Default style for non-active nav links */
    background-color: transparent; /* Transparent background */
    color: var(--text-color); /* Default text color */
    box-shadow: none; /* No shadow by default */
}
header .nav-link:not(.active):hover {
    background-color: var(--hover-bg);
    color: var(--primary-color); /* Highlight text with primary color on hover */
}
header .nav-link.btn-secondary { /* Logout button */
    background-color: var(--secondary-color);
    color: white;
    border: none;
}
header .nav-link.btn-secondary:hover {
    background-color: #455A64;
    color: white;
}


/* Controls Section (Toggle All and Action Buttons) */
.controls {
    display: flex;
    align-items: center; /* Vertically align items */
    gap: 1.5rem; /* Increased gap */
    margin-bottom: 2rem; /* More margin below */
    flex-wrap: wrap;
    justify-content: space-between; /* Distribute items */
}

.button-group { /* New wrapper for right-aligned buttons */
    display: flex;
    align-items: center; /* Explicitly ensure vertical alignment within the group */
    gap: 1rem; /* Gap between buttons */
    flex-wrap: wrap;
    margin-left: auto; /* Push to the right */
}

/* Forms (Auth Container) */
.auth-container {
    background: var(--container-bg);
    padding: 3rem 2.5rem;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    max-width: 1024px;
    width: 100%;
    margin: 2rem auto; /* Center with margin */
    box-sizing: border-box;
}

.form-label {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.6rem;
}

.form-input {
    width: 100%;
    padding: 0.9rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 1.05rem;
    color: var(--text-color);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
    background-color: #FDFDFD;
}
.form-input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.25);
}

/* Global form-group spacing */
.form-group {
    margin-bottom: 1.2rem; /* Increased space below each form group (label + input) */
}
.form-group:last-of-type {
    margin-bottom: 0; /* No margin below the last form group */
}


/* Table Styles */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    background-color: var(--container-bg);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th, td {
    padding: 1.1rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

thead {
    background-color: #E8F5E9; /* Light green for header */
}

th {
    font-weight: 600;
    color: var(--muted-text);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background-color: #F1F8E9; /* Lighter green on hover */
}

.loading-text {
    text-align: center;
    color: var(--muted-text);
    padding: 2rem;
}

select.halo-select {
    width: 100%;
    padding: 0.6rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 0.95rem;
    background-color: #FDFDFD;
}
select.halo-select:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

/* Toggle Switch CSS */
.switch {
    position: relative;
    display: inline-block;
    width: 56px;
    height: 32px;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #BDBDBD; /* Grey for off state */
    transition: .4s;
    border-radius: 34px;
}
.slider:before {
    position: absolute;
    content: "";
    height: 24px; /* Larger thumb */
    width: 24px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
input:checked + .slider {
    background-color: var(--primary-color);
}
input:checked + .slider:before {
    transform: translateX(24px); /* Adjusted for larger thumb */
}

/* Status Icons */
.status-icon {
    font-size: 1.6rem; /* Slightly larger */
    font-weight: bold;
    text-align: center;
    display: block;
}
.icon-success {
    color: var(--primary-color); /* Green */
}
.icon-error {
    color: #F44336; /* Red */
}
.icon-neutral {
    color: #FFC107; /* Amber/Yellow */
}

/* Right alignment for numerical data */
td.usage-data {
    text-align: right;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* Column Widths (Adjusted for 7 columns) */
th:nth-child(1), td:nth-child(1) { width: 20%; } /* Wasabi Account (Source) */
th:nth-child(2), td:nth-child(2) { width: 30%; } /* HaloPSA Client (Target) - Wider */
th:nth-child(3), td:nth-child(3) { width: 8%; text-align: center; } /* Sync Active */
th:nth-child(4), td:nth-child(4) { width: 9%; text-align: right; } /* Last Usage GB - Slightly wider */
th:nth-child(5), td:nth-child(5) { width: 9%; text-align: right; } /* Last Usage TB - Slightly wider */
th:nth-child(6), td:nth-child(6) { width: 6%; text-align: center; } /* Status (Moved) - Slightly wider */
th:nth-child(7), td:nth-child(7) { width: 18%; font-size: 0.88rem; } /* Last Sync Time - Wider */


/* Overall Sync Status at the top */
.overall-sync-status {
    background-color: #E8F5E9;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    text-align: center;
    font-size: 1rem;
    color: var(--text-color);
    border: 1px solid #C8E6C9;
    box-shadow: var(--shadow-sm);
}

.overall-sync-status p {
    margin: 0;
}

.overall-sync-status span {
    font-weight: 600;
}

.overall-sync-status .status-success {
    color: var(--primary-color);
}

.overall-sync-status .status-error {
    color: #F44336;
}

td.sync-time {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* Log Box Styles */
#statusBox {
    margin-top: 2rem;
    background: #212121; /* Dark grey background */
    color: #E0E0E0; /* Light grey text */
    padding: 1.5rem;
    border-radius: 12px; /* More rounded */
    max-height: 300px;
    overflow-y: auto;
    box-shadow: var(--shadow-md); /* Add shadow */
}
#statusBox .log-title {
    margin-top: 0;
    font-size: 1.2rem;
    border-bottom: 1px solid #424242; /* Darker border */
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    color: white; /* White title */
}
#logOutput {
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.9rem;
}


/* Message Box Styles (from main.js) */
#message {
    padding: 1rem;
    border-radius: 8px;
    font-weight: 500;
    margin-top: 1rem;
    box-shadow: var(--shadow-sm);
}
#message.bg-green-100 {
    background-color: #E8F2FD; /* Light blue */
    color: #1976D2; /* Darker blue */
    border: 1px solid #BBDEFB;
}
#message.bg-red-100 {
    background-color: #FFEBEE; /* Light red */
    color: #D32F2F; /* Darker red */
    border: 1px solid #FFCDD2;
}
#message.bg-blue-100 {
    background-color: #E3F2FD; /* Light blue */
    color: #1976D2; /* Darker blue */
    border: 1px solid #BBDEFB;
}

/* Progress Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6); /* Darker overlay */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--container-bg);
    padding: 2.5rem; /* More padding */
    border-radius: 16px; /* More rounded */
    box-shadow: var(--shadow-lg);
    text-align: center;
    width: 90%;
    max-width: 450px; /* Max width for modal */
    transform: translateY(-20px); /* Slight lift effect */
    transition: transform 0.3s ease;
}

.modal-overlay.visible .modal-content {
    transform: translateY(0);
}

.modal-title {
    font-size: 1.8rem; /* Larger title */
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

.modal-status {
    font-size: 1.1rem;
    color: var(--text-color);
    margin-bottom: 1rem;
}

.progress-bar-container {
    width: 100%;
    background-color: #E0E0E0; /* Light grey track */
    border-radius: 10px; /* Rounded corners for bar */
    height: 20px; /* Thicker bar */
    overflow: hidden;
    margin-bottom: 1rem;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.progress-bar {
    height: 100%;
    background-color: var(--primary-color); /* Green progress */
    width: 0%;
    border-radius: 10px;
    transition: width 0.4s ease-out; /* Smooth transition for progress */
}

.modal-eta {
    font-size: 0.95rem;
    color: var(--muted-text);
}

/* Specific spacing for MFA modal inputs */
.form-group {
    margin-bottom: 1.2rem; /* Increased space below each form group (label + input) */
}

/* Specific spacing for MFA modal buttons */
.mfa-modal-buttons { /* Container for horizontal buttons */
    display: flex;
    gap: 1rem; /* Space between buttons */
    margin-top: 1.5rem; /* Space above the button group */
    justify-content: center; /* Center the buttons within the flex container */
    flex-wrap: wrap; /* Allow buttons to wrap on smaller screens */
}

.mfa-modal-buttons button {
    flex: 1; /* Make buttons take equal width */
    min-width: 150px; /* Ensure buttons don't get too small */
    margin-top: 0 !important; /* Override individual button margin-top */
}

/* Centering for QR code canvas */
#qrcodeCanvas {
    display: flex; /* Use flexbox to center content */
    justify-content: center; /* Center horizontally */
    align-items: center; /* Center vertically */
    width: 200px; /* Set a fixed width for the container */
    height: 200px; /* Set a fixed height for the container */
    margin: 0 auto; /* Center the div itself */
    border: 1px solid var(--border-color); /* Optional: add a border for visibility */
    padding: 5px; /* Optional: add some padding */
    box-sizing: content-box; /* Ensure padding doesn't affect fixed size */
}

#qrcodeCanvas canvas {
    display: block; /* Ensure the canvas is a block element */
    margin: 0 auto; /* Center the canvas itself within the flex container */
}


/* Responsive adjustments */
@media (max-width: 768px) {
    body {
        font-size: 15px;
    }
    .container {
        padding: 0 1rem;
    }
    .controls {
        flex-direction: column;
        align-items: stretch;
    }
    .controls button {
        width: 100%;
    }
    .master-toggle {
        width: 100%;
        justify-content: space-between;
        margin-right: 0;
        margin-bottom: 1rem;
    }
    .button-group {
        flex-direction: column;
        width: 100%;
        gap: 0.75rem;
    }
    /* Adjust table column widths for smaller screens */
    th, td {
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
    }
    th:nth-child(1), td:nth-child(1) { width: 25%; }
    th:nth-child(2), td:nth-child(2) { width: 25%; }
    th:nth-child(3), td:nth-child(3) { width: 10%; }
    th:nth-child(4), td:nth-child(4) { width: 10%; }
    th:nth-child(5), td:nth-child(5) { width: 10%; }
    th:nth-child(6), td:nth-child(6) { width: 5%; }
    th:nth-child(7), td:nth-child(7) { width: 15%; }

    .auth-container {
        padding: 2rem 1.5rem;
        border-radius: 16px;
    }
    .btn-primary-lg, .btn-secondary-lg {
        padding: 1rem 1.5rem;
        font-size: 1.05rem;
    }
    h2.text-3xl {
        font-size: 2rem;
    }

    .modal-content {
        padding: 1.5rem;
    }
    .modal-title {
        font-size: 1.5rem;
    }
}


/* FAQ Specific Styles for Material 3 Expressive */
.faq-list {
    max-width: 800px; /* Adjust as needed for the FAQ list width */
    margin: 0 auto; /* Center the FAQ list */
    /* Remove 'space-y-4' from HTML for controlled spacing with margin-bottom */
}

.faq-item {
    background-color: var(--container-bg);
    padding: 1.5rem 2rem; /* Adjusted padding for more expressive feel */
    border-radius: 16px; /* More rounded corners */
    box-shadow: var(--shadow-md); /* Medium shadow for elevation */
    margin-bottom: 1.25rem; /* Space between FAQ items */
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.faq-item:hover {
    transform: translateY(-2px); /* Slight lift on hover */
    box-shadow: var(--shadow-lg); /* More pronounced shadow on hover */
}

/* Remove any specific category info if not desired for Material 3 Expressive, or adjust its style */
.faq-category-info { /* Revert or adjust this if it was added from PNG styling */
    display: none; /* Hide this element to align with Material 3 expressive style */
}

h2.text-3xl { /* FAQ page main title styling, already good for M3 expressive */
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-color);
    text-align: center;
    margin-bottom: 2.5rem; /* More space below title */
}

.faq-question-header {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* No padding here, handled by .faq-item */
}

.faq-question-header h4 {
    font-size: 1.25rem; /* Larger font size for questions */
    font-weight: 600; /* Bolder for prominence */
    color: var(--text-color);
    margin: 0;
    flex-grow: 1;
}

.faq-toggle-icon {
    font-size: 2rem; /* Larger toggle icon */
    color: var(--muted-text);
    margin-left: 1.5rem; /* More space */
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); /* Smoother animation */
}

.faq-answer {
    padding-top: 1rem; /* Padding above answer content */
    /* No border-top for a cleaner look, letting padding define separation */
    color: var(--muted-text); /* Slightly lighter text for answers */
    font-size: 1.05rem; /* Slightly larger text for answers */
}

.faq-answer p {
    margin-bottom: 1rem; /* Space between paragraphs in answer */
}

.faq-answer ul {
    margin-top: 0.5rem; /* Space above list */
    margin-bottom: 1rem; /* Space below list */
}

.faq-answer li {
    margin-bottom: 0.5rem; /* Space between list items */
}

/* Icon rotation for arrow toggle */
.faq-toggle-icon {
    /* Set initial state for down arrow */
    transform: rotate(0deg);
}
.faq-item .faq-question-header.active .faq-toggle-icon {
    /* Rotate to up arrow when active */
    transform: rotate(180deg);
    color: var(--primary-color); /* Highlight active icon */
}