/* shadcn/ui inspired theme */
:root {
    /* Medium Gray background, Black text, White cards theme */
    --background: 0 0% 88%;       /* Medium Gray (#e0e0e0) */
    --foreground: 0 0% 0%;         /* Black */
    --card: 0 0% 100%;             /* White */
    --card-foreground: 0 0% 0%;     /* Black */
    --popover: 0 0% 100%;           /* White */
    --popover-foreground: 0 0% 0%; /* Black */
    --primary: 222.2 47.4% 11.2%; /* Dark Blue/Slate */
    --primary-foreground: 0 0% 98%; /* Near White */
    --primary-hover: 222.2 47.4% 20%;
    --secondary: 0 0% 96%;       /* Very Light Gray (#f5f5f5) */
    --secondary-foreground: 0 0% 0%; /* Black */
    --secondary-hover: 0 0% 90%;   /* Darker Very Light Gray */
    --muted: 0 0% 96%;           /* Very Light Gray (#f5f5f5) */
    --muted-foreground: 0 0% 40%;   /* Medium Gray (#666666) */
    --accent: 0 0% 96%;           /* Very Light Gray (#f5f5f5) */
    --accent-foreground: 0 0% 0%;     /* Black */
    --destructive: 0 84.2% 60.2%;   /* Red */
    --destructive-foreground: 0 0% 98%; /* Near White */
    --destructive-hover: 0 84.2% 50%;
    --border: 0 0% 80%;           /* Medium Gray Border (#cccccc) */
    --input: 0 0% 100%;           /* White Input background */
    --input-focus-ring: 222.2 47.4% 11.2%; /* Use primary color for ring */
    --radius: 0.5rem;

    /* Custom variables mapping */
    --primary-color: hsl(var(--primary));
    --primary-hover-color: hsl(var(--primary-hover));
    --secondary-color: hsl(var(--secondary));
    --secondary-hover-color: hsl(var(--secondary-hover));
    --danger-color: hsl(var(--destructive));
    --danger-hover-color: hsl(var(--destructive-hover));
    --light-bg: hsl(var(--background)); /* Medium Gray */
    --border-color: hsl(var(--border)); /* Medium Gray Border */
    --text-color: hsl(var(--foreground)); /* Black */
    --text-muted: hsl(var(--muted-foreground)); /* Medium Gray */
    --card-bg: hsl(var(--card)); /* White */
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --border-radius: var(--radius);
    --input-bg: hsl(var(--input)); /* White */
    --input-border-color: hsl(var(--border)); /* Medium Gray Border */
    --input-focus-border-color: hsl(var(--primary)); /* Dark Blue/Slate */
    --input-focus-box-shadow: 0 0 0 2px hsla(var(--input-focus-ring), 0.4);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; /* Common system font stack */
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 30px 15px; /* Reduced padding */
    background-color: var(--light-bg);
    color: var(--text-color);
    margin: 0;
    line-height: 1.5; /* Slightly tighter line height */
    -webkit-font-smoothing: antialiased; /* Smoother fonts */
    -moz-osx-font-smoothing: grayscale;
}

.container {
    width: 100%;
    max-width: 650px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    /* Add card styles here */
    background-color: var(--card-bg); /* White */
    color: hsl(var(--card-foreground)); /* Black Text */
    padding: 1.5rem; /* Apply padding here */
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color); /* Medium Gray Border */
}

h1 {
    color: var(--text-color);
    text-align: center;
    margin-bottom: 25px; /* Reduced margin */
    font-size: 1.75rem; /* Slightly smaller */
    font-weight: 700;
    letter-spacing: -0.025em;
}

.calculator, .log-section {
    /* Remove individual card styles */
    padding: 0; /* Remove padding, container has it now */
    border-radius: 0;
    box-shadow: none;
    border: none;
    background-color: transparent; /* Make transparent */
    color: inherit; /* Inherit text color from container */
}

.calculator {
    display: flex;
    flex-direction: column;
    gap: 18px; /* Reduced gap */
}
.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px; /* Reduced gap */
    position: relative;
}
label {
    font-weight: 500;
    color: var(--text-muted); /* Muted Slate (Darker) */
    margin-bottom: 0;
    font-size: 0.875rem;
}

input[type="text"],
input[type="date"] {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--input-border-color); /* Light Gray */
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    box-sizing: border-box;
    width: 100%;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    background-color: var(--input-bg); /* White */
    color: hsl(var(--foreground)); /* Black Text */
    height: 2.5rem;
}

/* Base Button Styles (will be overridden by specific types) */
button {
    display: inline-flex; /* Align text/icons */
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius);
    font-size: 0.875rem; /* ~14px */
    font-weight: 500; /* Medium weight */
    padding: 0.5rem 1rem; /* ~8px 16px */
    height: 2.5rem; /* ~40px - Consistent height */
    box-sizing: border-box;
    width: 100%; /* Default to full width, override where needed */
    cursor: pointer;
    transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, color 0.15s ease-in-out, transform 0.1s ease, box-shadow 0.15s ease-in-out;
    border: 1px solid transparent; /* Start with transparent border */
    outline: none; /* Remove default outline */
}

/* Focus visible state for buttons (accessibility) */
button:focus-visible {
    outline: none;
    box-shadow: var(--input-focus-box-shadow); /* Use the input focus ring */
}

/* Remove this block as background-color is now set above */

input[type="text"]:focus,
input[type="date"]:focus {
    outline: none;
    border-color: var(--input-focus-border-color); /* Use primary color for border */
    box-shadow: var(--input-focus-box-shadow); /* Use subtle ring */
}

/* Remove this block as button styles are redefined above */

button:active {
    transform: scale(0.98);
}
/* Primary Button Style */
#logTripBtn {
    background-color: var(--primary-color); /* Dark Blue/Slate */
    border-color: var(--primary-color);
    color: hsl(var(--primary-foreground)); /* Near White */
}
#logTripBtn:hover {
    background-color: var(--primary-hover-color); /* Darker Blue/Slate */
    border-color: var(--primary-hover-color);
}

/* Secondary Button Style */
#nextDayBtn {
    background-color: var(--secondary-color); /* Very Light Gray */
    border-color: var(--secondary-color);
    color: hsl(var(--secondary-foreground)); /* Black */
    width: auto;
    flex-grow: 1;
}

#nextDayBtn:hover {
    background-color: var(--secondary-hover-color); /* Darker Very Light Gray */
    border-color: var(--secondary-hover-color);
}

/* Destructive Button Style */
#clearLogBtn, #copyLogBtn { /* Apply common styles to both header buttons */
    width: auto; /* Allow buttons to size to content */
    padding: 0.4rem 0.8rem; /* Slightly smaller padding for header buttons */
    font-size: 0.8rem; /* Slightly smaller font */
}

#clearLogBtn {
    background-color: var(--danger-color); /* Red */
    border-color: var(--danger-color);
    color: hsl(var(--destructive-foreground)); /* Near White */
}

/* Secondary Style for Copy Button */
#copyLogBtn {
    background-color: var(--secondary-color); /* Very Light Gray */
    border-color: var(--secondary-color);
    color: hsl(var(--secondary-foreground)); /* Black */
}

#clearLogBtn:hover {
    background-color: var(--danger-hover-color); /* Darker Red */
    border-color: var(--danger-hover-color);
}

#copyLogBtn:hover {
    background-color: var(--secondary-hover-color); /* Darker Very Light Gray */
    border-color: var(--secondary-hover-color);
}
 
/* Instructions Link Style */
.instructions-link {
    color: var(--primary-color); /* Use primary color for link */
    text-decoration: underline;
    font-size: 0.8rem; /* Match button font size */
    cursor: pointer;
    transition: color 0.15s ease-in-out;
    margin: 0 5px; /* Add some horizontal spacing */
    line-height: 1; /* Align vertically with buttons */
}
 
.instructions-link:hover {
    color: var(--primary-hover-color); /* Darken on hover */
}

/* Swap Button - Outline style for light gray background */
#swapBtn {
    background-color: transparent;
    border: 1px solid var(--border-color); /* Lighter Gray border */
    color: var(--text-muted); /* Medium Gray */
    padding: 0.5rem;
    font-size: 1rem;
    width: 2.5rem;
    height: 2.5rem;
    margin: 10px auto 10px auto;
    line-height: 1;
    display: block;
    border-radius: var(--border-radius);
}

#swapBtn:hover {
    background-color: hsl(var(--accent)); /* Very Light Gray bg */
    border-color: hsl(var(--accent));
    color: hsl(var(--accent-foreground)); /* Black text */
}
.date-controls {
    display: flex;
    align-items: center;
    gap: 10px; /* Reduced gap */
    flex-wrap: wrap;
}

.date-controls label {
    flex-shrink: 0;
}

.date-controls input[type="date"] {
    width: auto;
    flex-grow: 1;
    min-width: 150px; /* Ensure minimum width */
}

#result {
    margin-top: 15px;
    text-align: center;
    font-size: 0.875rem;
    padding: 0.6rem 0.8rem;
    background-color: hsl(var(--muted)); /* Very Light Gray */
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color); /* Lighter Gray */
    color: var(--text-muted); /* Medium Gray */
}

#distance {
    font-weight: 600;
    color: var(--primary-color); /* Dark Blue/Slate */
}

/* Log Section Styles */
.log-section {
    padding-top: 20px;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px; /* Add gap between header items */
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.log-header h2 {
    margin: 0;
    color: hsl(var(--card-foreground)); /* Black */
    font-size: 1.25rem;
    font-weight: 600;
}

#logEntries {
    max-height: 350px; /* Slightly reduced height */
    overflow-y: auto;
    margin-bottom: 15px; /* Reduced space */
    padding-right: 8px; /* Reduced space */
}

#logEntries p {
    margin: 0 0 8px 0;
    padding: 0.75rem 1rem;
    background-color: var(--card-bg); /* White */
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    border: 1px solid var(--border-color); /* Lighter Gray */
    color: hsl(var(--card-foreground)); /* Black */
    line-height: 1.4;
    box-shadow: none;
    display: flex; /* Use flexbox to align text and button */
    justify-content: space-between; /* Push button to the right */
    align-items: center; /* Vertically align items */
    gap: 10px; /* Add space between text and button */
}

.log-entry-text {
    word-wrap: break-word; /* Allow text to wrap */
    flex-grow: 1; /* Allow text to take available space */
}

button.edit-log-btn {
    /* Basic styling for edit button */
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    color: hsl(var(--secondary-foreground));
    border-radius: var(--radius);
    cursor: pointer;
    flex-shrink: 0; /* Prevent button from shrinking */
    width: auto; /* Allow button to size to content */
    height: auto; /* Override default button height */
}

button.edit-log-btn:hover {
    background-color: var(--secondary-hover-color);
    border-color: var(--secondary-hover-color);
}

/* Delete Button Styling */
button.delete-log-btn {
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    background-color: var(--danger-color); /* Use destructive color */
    border-color: var(--danger-color);
    color: hsl(var(--destructive-foreground)); /* Near White */
    border-radius: var(--radius);
    cursor: pointer;
    flex-shrink: 0;
    width: auto;
    height: auto;
    margin-left: 5px; /* Add space between edit and delete */
}

button.delete-log-btn:hover {
    background-color: var(--danger-hover-color); /* Darker destructive color */
    border-color: var(--danger-hover-color);
}

/* Totals Section */
.log-totals {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color); /* Lighter Gray */
    color: hsl(var(--card-foreground)); /* Black */
}

.log-totals p {
    margin: 8px 0;
    font-size: 0.875rem; /* ~14px */
    font-weight: 500; /* Medium */
    background-color: transparent;
    border-left: none;
    padding: 0;
    display: flex;
    justify-content: space-between;
}

.log-totals span {
    color: hsl(var(--primary)); /* Dark Blue/Slate for value */
    font-weight: 600;
}

/* Custom Autocomplete Results List */
.results-list {
    display: none;
    position: absolute;
    top: calc(100% + 4px); /* Add small gap */
    left: 0;
    right: 0;
    background-color: hsl(var(--popover)); /* White */
    color: hsl(var(--popover-foreground)); /* Black */
    border: 1px solid var(--border-color); /* Lighter Gray */
    border-top: none;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: var(--card-shadow);
}
.results-list div {
    padding: 8px 12px; /* Reduced padding */
    cursor: pointer;
    font-size: 0.875rem;
}

.results-list div:hover {
    background-color: hsl(var(--accent)); /* Very Light Gray */
    color: hsl(var(--accent-foreground)); /* Black */
}

.results-list div.selected {
    background-color: var(--primary-color); /* Dark Blue/Slate */
    color: hsl(var(--primary-foreground)); /* Near White */
}

/* Small copy icon button for log entries */
button.copy-log-btn {
    background: none;
    border: none;
    padding: 0.2rem;
    margin-left: 0.5rem;
    width: auto;
    height: auto;
    font-size: 1rem;
    cursor: pointer;
}