/* Import a Google Font (Example: Inter) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap');

/* Define CSS Variables for Colors and Fonts */
:root {
    --font-primary: 'Inter', sans-serif;
    --color-background: #f8f9fa; /* Very light gray */
    --color-surface: #ffffff; /* White for cards/sections */
    --color-text: #212529; /* Dark gray for text */
    --color-text-muted: #6c757d; /* Lighter gray for less important text */
    --color-primary: #0056b3; /* A shade of blue */
    --color-primary-darker: #00418a; /* Darker blue for hover */
    --color-accent: #28a745; /* Green for prices */
    --color-danger: #dc3545; /* Red for errors */
    --color-success: #198754; /* Green for success */
    --color-info: #0d6efd; /* Blue for info messages */
    --border-color: #dee2e6; /* Light gray for borders */
    --border-radius: 6px; /* Slightly rounded corners */
    --box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); /* Subtle shadow */
}

body {
    font-family: var(--font-primary);
    line-height: 1.6;
    margin: 0; /* Remove default body margin */
    padding: 0; /* Use padding on main container if needed */
    background-color: var(--color-background);
    color: var(--color-text);
    display: flex; /* Enable flexbox for overall layout */
    flex-direction: column; /* Stack header, main, footer vertically */
    min-height: 100vh; /* Ensure body takes at least full viewport height */
    align-items: center; /* Center content horizontally */
}

/* Optional Background Image Styling */
body::before {
    content: ""; /* Required for pseudo-elements */
    position: fixed; /* Fixed position stays in place when scrolling */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1; /* Place it behind all other content */

    background-image: url('/gas-pump-icon.svg'); /* Adjust path if needed */
    background-repeat: no-repeat;
    background-position: center center;
    background-size: contain;
    opacity: 0.05; /* Adjust transparency */
    pointer-events: none;
}


/* Main content wrapper for max-width and padding */
.container {
    width: 100%;
    max-width: 1000px; /* Max width for readability */
    padding: 20px;
    box-sizing: border-box; /* Include padding in width calculation */
}


header, main > section, footer { /* Apply card styling to sections */
    background-color: var(--color-surface);
    padding: 25px 30px; /* More padding */
    margin-bottom: 25px; /* More margin */
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid var(--border-color); /* Subtle border */
}

main {
    flex-grow: 1; /* Allow main content to take up available space */
    width: 100%; /* Ensure main takes width within container */
}

h1 {
    color: var(--color-primary);
    font-size: 2.2rem; /* Larger main title */
    margin-bottom: 15px;
    text-align: center;
}

h2 {
    color: var(--color-primary);
    font-size: 1.6rem; /* Slightly smaller section titles */
    margin-bottom: 20px; /* More space below H2 */
    border-bottom: 1px solid var(--border-color); /* Add subtle separator */
    padding-bottom: 10px;
}

#latest-prices p {
    margin: 8px 0;
    font-size: 1.1em;
}

#latest-prices span {
    font-weight: bold;
    color: var(--color-accent);
}
#latest-prices #latest-date {
    font-weight: normal;
    color: var(--color-text-muted);
    font-size: 0.9em;
}


.chart-container {
    position: relative;
    max-width: 100%; /* Allow chart to use container width */
    margin: 20px auto;
    min-height: 300px; /* Ensure chart has some minimum height */
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    font-size: 0.95em; /* Slightly smaller table text */
}

th, td {
    border: 1px solid var(--border-color);
    padding: 12px 15px; /* More padding in cells */
    text-align: left;
    vertical-align: middle;
}

th {
    background-color: #e9ecef; /* Keep light header */
    font-weight: bold;
    color: var(--color-text);
}

tbody tr:nth-child(even) {
    background-color: #f8f9fa; /* Use background color for even rows */
}
tbody tr:hover {
    background-color: #e9ecef; /* Subtle hover effect */
}


footer {
    text-align: center;
    font-size: 0.9em;
    color: var(--color-text-muted);
    margin-top: 30px; /* More space above footer */
    margin-bottom: 0; /* Footer might be last item */
    padding: 15px;
    background-color: transparent; /* Make footer less prominent */
    border: none;
    box-shadow: none;
}

#chart-loading, #table-loading, #logs-loading { /* Added logs loading */
    text-align: center;
    font-style: italic;
    color: var(--color-text-muted);
    padding: 20px;
}

/* --- Styles specifically for the Logs Page --- */

/* --- UPDATED BUTTON STYLES --- */
#trigger-section button#triggerScraperBtn { /* More specific selector */
    padding: 10px 20px; /* Slightly larger padding */
    font-size: 1em; /* Match base font size */
    font-weight: bold;
    cursor: pointer;
    background-color: var(--color-primary); /* Use primary color */
    color: var(--color-surface); /* White text */
    border: none; /* Remove default border */
    border-radius: var(--border-radius); /* Use defined radius */
    transition: background-color 0.2s ease, transform 0.1s ease; /* Smooth transitions */
    box-shadow: var(--box-shadow); /* Add subtle shadow */
}
#trigger-section button#triggerScraperBtn:hover:not(:disabled) { /* Hover effect only when enabled */
    background-color: var(--color-primary-darker); /* Use darker primary color */
    transform: translateY(-1px); /* Slight lift effect */
}
#trigger-section button#triggerScraperBtn:active:not(:disabled) { /* Click effect */
     transform: translateY(0px); /* Remove lift on click */
}
#trigger-section button#triggerScraperBtn:disabled {
    background-color: var(--color-text-muted); /* Use muted color when disabled */
    cursor: not-allowed;
    box-shadow: none; /* Remove shadow when disabled */
}
/* --- END OF UPDATED BUTTON STYLES --- */

#triggerStatus {
    color: var(--color-info); /* Default info color */
}


#logTable th:nth-child(1), /* Timestamp */
#logTable td:nth-child(1) {
    width: 25%;
    min-width: 160px; /* Ensure timestamp doesn't wrap too much */
}

#logTable th:nth-child(2), /* Status */
#logTable td:nth-child(2) {
    width: 10%;
    text-align: center;
    font-weight: bold;
}

#logTable th:nth-child(3), /* Message */
#logTable td:nth-child(3) {
    width: 35%;
}

#logTable th:nth-child(4), /* Error Details */
#logTable td:nth-child(4) {
    width: 30%;
    font-family: monospace;
    font-size: 0.85em;
    white-space: pre-wrap; /* Allow wrapping */
    word-break: break-word; /* Break long words/stacks */
    color: var(--color-danger); /* Red for errors */
}

/* Status-specific styling */
#logTable td:nth-child(2).status-success {
    color: var(--color-success);
}

#logTable td:nth-child(2).status-error {
    color: var(--color-danger);
}

#logTable tr.log-error-row {
    background-color: rgba(220, 53, 69, 0.05) !important; /* Light red background, !important to override nth-child */
}

/* Make table scrollable on small screens if needed */
@media (max-width: 768px) {
    #log-section {
        overflow-x: auto; /* Allow horizontal scrolling for the table container */
    }
    #logTable {
        min-width: 600px; /* Force table to be wider than small screens */
    }
}
