/**
 * Basic Styling for Stays Tracker
 */

/* --- General & Variables --- */
:root {
    --primary-bg: #f8f9fa;
    --secondary-bg: #ffffff;
    --border-color: #dee2e6;
    --text-color: #212529;
    --header-bg: #e9ecef;
    --button-bg: #007bff;
    --button-text: #ffffff;
    --button-hover-bg: #0056b3;
    --current-day-bg: #eeeeee; /* Light yellow for current day */
    --error-color: #dc3545;
    --success-color: #28a745;
    --input-border: #ced4da;
    --summary-width: 300px; /* Width for the fixed summary section */
    --gap: 20px; /* Gap between columns */
    --auth-bg: #f0f0f0; /* Background for auth controls */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    /* Remove body padding to allow full width layout */
    /* padding: 20px; */
    background-color: var(--primary-bg);
    color: var(--text-color);
    line-height: 1.5;
}

h1, h2 {
    margin-top: 0;
}

button {
    padding: 8px 15px;
    background-color: var(--button-bg);
    color: var(--button-text);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

button:hover {
    background-color: var(--button-hover-bg);
}

input[type="text"],
input[type="password"],
input[type="number"] {
    padding: 8px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
}

/* --- Login Section --- */
#login-section {
    max-width: 400px;
    margin: 50px auto;
    padding: 20px;
    background-color: var(--secondary-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#login-form div {
    margin-bottom: 15px;
}

#login-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

#login-form input {
    width: 100%;
}

#login-form button {
    width: 100%;
    padding: 10px;
}

.error-message {
    color: var(--error-color);
    font-size: 0.9em;
    margin-top: 10px;
}

.hint {
    font-size: 0.8em;
    color: #6c757d;
    margin-top: 15px;
    text-align: center;
}

/* --- App Layout --- */
.app-container {
    display: flex;
    gap: var(--gap);
    padding: var(--gap); /* Add padding around the container */
    /* Adjust height calculation if needed, or let it be natural */
    /* height: calc(100vh - 50px); /* Example: Subtract auth bar height */
    box-sizing: border-box;
}

.calendar-container {
    flex-grow: 1; /* Takes remaining space */
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevents flex item from overflowing */
    height: 100%; /* Fill parent height */
    overflow-y: auto; /* Make this column scrollable */
}

.summary-container {
    width: var(--summary-width);
    flex-shrink: 0; /* Prevent shrinking */
    height: fit-content; /* Only as tall as its content */
    /* Make it sticky/fixed */
    position: sticky; /* Use sticky for better flow */
    top: var(--gap); /* Stick below the top padding */
}

/* Adjust app-section within calendar-container if needed */
#app-section {
    /* Remove original margin if any */
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    height: 100%; /* Allow table to grow */
}

#app-section header {
    /* Styles for header inside calendar container */
     display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--header-bg);
    padding: 10px 20px;
    border-radius: 4px;
    margin-bottom: 15px; /* Space below header */
    flex-shrink: 0; /* Prevent header shrinking */
}
#app-section header h1 {
    margin: 0;
}

/* --- Summary Section --- */
#summary-section {
    background-color: var(--secondary-bg);
    padding: 15px 20px; /* Adjusted padding */
    border: 1px solid var(--border-color);
    border-radius: 8px; /* Slightly larger radius */
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); /* Subtle shadow */
}

#summary-section div {
    /* Use flexbox for label-value alignment */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0; /* Vertical padding */
    border-bottom: 1px dashed var(--border-color); /* Dashed separator */
    margin-bottom: 0; /* Remove bottom margin as border handles spacing */
}

#summary-section div:last-child {
    border-bottom: none; /* No border for the last item */
}

#summary-section h2 {
    margin: 0;
    font-size: 0.95em; /* Slightly smaller label */
    color: #6c757d; /* Lighter grey label color */
    font-weight: normal; /* Less emphasis on label */
    /* Add icons */
    display: flex;
    align-items: center;
}

/* Specific Icons */
#summary-section div:nth-of-type(1) h2::before { content: '💰'; margin-right: 8px; }
#summary-section div:nth-of-type(2) h2::before { content: '📊'; margin-right: 8px; }
#summary-section div:nth-of-type(3) h2::before { content: '📉'; margin-right: 8px; }
#summary-section div:nth-of-type(4) h2::before { content: '➡️'; margin-right: 8px; }

/* Special layout for Next Destination div */
#summary-section div:nth-of-type(4) {
    flex-direction: column; /* Stack label and value */
    align-items: flex-start; /* Align items to the start (left) */
    padding-bottom: 5px; /* Slightly adjust padding */
    border-bottom: none; /* Remove border as layout is different */
}

#summary-section div:nth-of-type(4) h2 {
    margin-bottom: 5px; /* Add space below the label */
}

/* Remove styles specific to the old p tag structure */
/* #summary-section div:nth-of-type(4) p#next-destination { ... } */

/* Style the container paragraph */
#summary-section p.next-destination-details {
    text-align: left;
    width: 100%;
    line-height: 1.3;
    margin: 0;
    padding: 0;
}

/* Style the location span */
#summary-section span.location {
    display: block; /* Ensure it takes its own line */
    font-size: 1.1em; /* Slightly larger for emphasis */
    font-weight: 600; /* Semi-bold */
    color: var(--text-color);
    margin-bottom: 3px; /* Space below location */
}

/* Style the date/days span */
#summary-section span.date-days {
    display: block; /* Ensure it takes its own line */
    font-size: 0.9em;
    color: #6c757d; /* Lighter color for secondary info */
}

#summary-section p {
    font-size: 1.2em; /* Slightly reduced main font size */
    font-weight: 600; /* Semi-bold value */
    margin: 0;
    text-align: right; /* Align value to the right */
    color: var(--text-color); /* Standard text color for value */
}

/* Override for Next Destination text - allow wrapping */
#summary-section #next-destination {
    font-size: 1em; /* Smaller font for potentially long text */
    font-weight: normal;
    white-space: normal; /* Allow wrapping */
    line-height: 1.3;
}

/* Style the new summary items */
#summary-section #monthly-estimate,
#summary-section #monthly-remaining {
    color: #555; /* Slightly lighter text color */
    font-size: 1.1em; /* Adjusted size */
    font-weight: 500; /* Medium weight */
}

#summary-section #monthly-estimate::before,
#summary-section #monthly-remaining::before {
    content: ""; /* Remove the tilde prefix - icons added to H2 */
    color: inherit;
}

/* --- Calendar Navigation --- */
#calendar-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-shrink: 0; /* Prevent nav shrinking */
}

#calendar-nav h2 {
    margin: 0;
}

/* --- Calendar Table --- */
#calendar-table {
    font-size: 13px;
    width: 100%;
    border-collapse: collapse;
    background-color: var(--secondary-bg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    /* Allow table to take remaining space if needed */
    flex-grow: 1;
    /* Ensure table itself isn't the scrolling element if calendar-container scrolls */
}

#calendar-table th,
#calendar-table td {
    border: 1px solid var(--border-color);
    padding: 6px 8px; /* Reduced padding */
    text-align: left;
    vertical-align: middle;
    font-size: 0.95em; /* Slightly smaller font */
}

#calendar-table thead th {
    background-color: var(--header-bg);
    font-weight: bold;
    position: sticky;
    top: 0;
    z-index: 10;
}

#calendar-table tbody tr:nth-child(even) {
    background-color: var(--primary-bg);
}

#calendar-table tbody tr.current-day {
    background-color: var(--current-day-bg) !important; /* Use important to override nth-child */
    font-weight: bold;
}

#calendar-table tbody tr.next-destination-highlight {
    background-color: #cfe2ff !important; /* Light blue highlight */
    border-left: 3px solid #0d6efd; /* Add a distinct left border */
}

/* Style for editable cells */
#calendar-table td span.editable {
    cursor: pointer;
    display: inline-block;
    min-height: 1.4em; /* Adjust min-height */
    width: 100%;
    padding: 6px; /* Match reduced cell padding */
    box-sizing: border-box;
}
#calendar-table td span.editable:hover {
    background-color: #e9ecef; /* Subtle hover effect */
}

#calendar-table td input[type="text"],
#calendar-table td input[type="number"] {
    width: 100%;
    padding: 6px 8px; /* Match reduced cell padding */
    margin: 0;
    box-sizing: border-box;
    position: relative;
    /* Adjust positioning for new padding */
    top: -7px; 
    left: -9px;
    width: calc(100% + 18px);
    height: calc(100% + 14px); /* Adjust height for new padding */
    font-size: inherit;
    font-family: inherit;
}

#calendar-table input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    vertical-align: middle; /* Align checkbox nicely */
}

/* Adjust column widths if needed */
#calendar-table th:nth-child(1), td:nth-child(1) { /* Date */
   width: 180px;
   white-space: nowrap;
}
#calendar-table th:nth-child(2), td:nth-child(2) { /* Location */
    width: auto; /* Let it take remaining space */
}
#calendar-table th:nth-child(3), td:nth-child(3) { /* Price */
   width: 100px;
}
#calendar-table th:nth-child(4), td:nth-child(4) { /* Booked */
   width: 80px;
   text-align: center;
}
/* Removed Actions column styling */

/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column; /* Stack columns vertically */
        height: auto; /* Allow height to adjust to content */
        padding: 10px; /* Reduce padding */
        gap: 15px;
    }

    .calendar-container {
        overflow-y: visible; /* Disable scrolling for the container */
        height: auto;
    }

    .summary-container {
        width: 100%; /* Full width */
        position: static; /* Remove sticky behavior */
    }

    #calendar-table thead th {
        position: static; /* Remove sticky header on small screens */
    }

    #calendar-table th,
    #calendar-table td {
        padding: 8px;
        font-size: 0.9em;
    }

    #app-section header h1,
    #calendar-nav h2 {
        font-size: 1.2em;
    }
}

/* Highlight for the next destination row */
.next-destination-highlight {
    background-color: #e6f7ff; /* Light blue background */
    font-weight: bold;
}

.next-destination-highlight td:first-child {
    font-weight: bold; /* Make the date bold too */
}

/* Add a star before the date in the highlighted row */
.next-destination-highlight td:first-child::before {
    content: '⭐️';
    margin-right: 0.5em; /* Add some space between star and date */
}

/* --- New Authentication Styles --- */
.auth-controls {
    display: flex;
    justify-content: flex-end; /* Align to the right */
    align-items: center;
    padding: 10px 20px; /* Padding */
    background-color: var(--auth-bg);
    border-bottom: 1px solid var(--border-color);
}

.auth-status {
    display: flex;
    align-items: center;
    gap: 10px; /* Space between address and button */
}

.auth-status.hidden,
.auth-controls > .btn.hidden {
    display: none;
}

#user-address {
    font-family: monospace;
    font-size: 0.9em;
    background-color: #e0e0e0;
    padding: 4px 8px;
    border-radius: 4px;
}

.auth-btn {
    /* Slightly smaller buttons for the auth bar */
    padding: 6px 12px;
    font-size: 0.9em;
}

#sign-out-btn {
    background-color: var(--error-color); /* Use error color for sign out */
}

#sign-out-btn:hover {
    background-color: #c82333; /* Darker red on hover */
} 