:root {
    --background-primary: #121212;
    --background-secondary: #1e1e1e;
    --background-input: #2c2c2c;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --text-tertiary: #c0c0c0;
    --text-light: #ffffff;
    --border-primary: #333;
    --accent-primary: #007bff;
    --accent-primary-darker: #0056b3;
    --accent-primary-shadow: rgba(0, 123, 255, 0.25);
    --error: #ff4d4d;
    --success: #28a745;
    --divider-color: #ff4d4d;
}

/* General Body Styles */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background-primary);
    color: var(--text-primary);
    margin: 0;
    position: relative;
}

/* Styles for the login/signup pages, which don't have the .app-body class */
body:not(.app-body) {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden; /* Prevents scrollbars from the background element */
}

main {
    width: 100%;
    max-width: 400px;
    padding: 20px;
    z-index: 1; /* Ensure login form is on top */
    position: relative; /* Establish stacking context */
}

/* Login Container */
.login-container {
    background-color: rgba(30, 30, 30, 0.9); /* Semi-transparent background */
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    text-align: center;
}

h1 {
    color: var(--text-light);
    margin-bottom: 8px;
}

.login-container p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* Form Styles */
#login-form, #signup-form {
    display: flex;
    flex-direction: column;
}

.form-group {
    margin-bottom: 16px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9em;
    color: var(--text-tertiary);
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-primary);
    background-color: var(--background-input);
    color: var(--text-primary);
    border-radius: 4px;
    box-sizing: border-box; /* Ensures padding doesn't affect width */
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-primary-shadow);
}

/* =================================
   Custom Context Menu
   ================================= */

#context-menu {
    display: none;
    position: absolute;
    z-index: 1500;
    background-color: var(--background-input);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.context-menu-item {
    padding: 8px 12px;
    background-color: var(--background-input);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s, color 0.2s;
}

.context-menu-item:hover {
    background-color: var(--error);
    color: var(--text-light);
}

/* =================================
   Layout Controls Styles
   ================================= */

.layout-controls {
    display: flex;
    flex-direction: column;
    align-items: stretch; /* Stretch items to fill the width */
    gap: 8px;
    flex-shrink: 0; /* Prevent the container from shrinking */
    width: 250px; /* Give it a fixed width */
}

.saved-layouts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 3-column grid */
    gap: 4px; /* Smaller gap */
}

.layout-button {
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    padding: 2px 4px; /* Reduced padding */
    background-color: var(--background-input);
    color: var(--text-secondary);
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    text-align: center;
    font-size: 0.75em; /* Reduced font size */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

/* Divider Card Styles */
.divider-card {
    background-color: transparent;
    border: none;
    border-top: 5px solid var(--divider-color); /* The visible line */
    height: 1px; /* Small height */
    min-height: 1px;
    padding: 0;
    margin: 0px 0;
    box-shadow: none;
    position: relative;
    cursor: grab;
}

.divider-card:hover {
    border-top: 2px solid var(--accent-primary);
    box-shadow: none;
}

.divider-delete-btn {
    position: absolute;
    top: 50%;
    right: 5px;
    transform: translateY(-50%);
    background: var(--background-secondary);
    border: 1px solid var(--border-primary);
    color: var(--text-secondary);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    line-height: 18px;
}

.divider-card:hover .divider-delete-btn {
    display: flex; /* Show on hover */
}

.divider-delete-btn:hover {
    color: var(--error);
    border-color: var(--error);
}

/* Menu Button and Menu */
.menu-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
}

.menu {
    display: none;
    position: absolute;
    right: 0;
    top: 40px;
    background-color: var(--background-input);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    padding: 8px;
    z-index: 10;
    min-width: 150px;
}

.menu a {
    display: block;
    padding: 8px 12px;
    color: var(--text-primary);
    text-decoration: none;
}

.menu a:hover {
    background-color: var(--accent-primary);
}

button {
    padding: 12px;
    background-color: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: background-color 0.2s;
}

button:hover {
    background-color: var(--accent-primary-darker);
}

/* Message container for success/error feedback */
.message {
    min-height: 1.2em; /* Prevents layout shift */
    font-size: 0.9em;
    margin-top: 16px;
    font-weight: bold;
}

.error-message {
    color: var(--error);
}

.success-message {
    color: var(--success);
}

/* Sign-up Link */
.auth-link {
    margin-top: 20px;
    font-size: 0.9em;
}

.auth-link a {
    color: var(--accent-primary);
    text-decoration: none;
}

.auth-link a:hover {
    text-decoration: underline;
}

/* Background for Login/Signup */
#background-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.15;
    pointer-events: none;
    overflow: hidden;
    transform: scale(1.0);
    filter: blur(1px);
}

/* =================================
   Main Application Styles
   ================================= */

/* App-specific body styles to override login page styles */
.app-body {
    display: block;
    justify-content: initial;
    align-items: initial;
    height: auto;
    padding-top: 20px; /* Space for the sticky header */
}

/* Override main for app layout */
.app-body main {
    max-width: none;
    padding: 0;
}

/* Dashboard Header */
.dashboard-container {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: var(--background-secondary);
    padding: 8px 32px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    border-bottom: 1px solid var(--border-primary);
    height: 104px;
    box-sizing: border-box;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 32px;
    max-width: 1600px;
    margin: 0 auto;
    margin-bottom: 20px;
}


.dashboard-section {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1 1 auto;
}

.shift-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

.shift-info-inputs, .modality-trackers {
    display: flex;
    gap: 16px;
}

.modality-item {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    padding: 4px 8px;
    background-color: var(--background-input);
}

.modality-name {
    font-size: 0.8em;
    font-weight: bold;
    color: var(--text-secondary);
}

.modality-value {
    font-size: 1.1em;
    font-weight: bold;
    color: var(--text-light);
    min-width: 20px;
    text-align: center;
}

.live-metrics {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

.live-metrics-row {
    display: flex;
    gap: 16px;
}

.metric-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    padding: 8px 16px;
    background-color: var(--background-primary);
    min-width: 100px; /* Ensure items have a consistent width */
    text-align: center;
    box-sizing: border-box;
}

.metric-title {
    font-size: 0.8em;
    color: var(--text-secondary);
    font-weight: bold;
    text-transform: uppercase;
}

.metric-value {
    font-size: 1.4em;
    color: var(--text-light);
    font-weight: bold;
}

.dashboard-container input[type="text"],
.dashboard-container input[type="number"],
.dashboard-container input[type="datetime-local"],
.dashboard-container select {
    padding: 8px 12px;
    background-color: var(--background-input);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    border-radius: 4px;
    min-width: 150px;
}

.dashboard-container input[type="text"]:focus,
.dashboard-container input[type="number"]:focus,
.dashboard-container select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-primary-shadow);
}

.dashboard-container input[type="number"].input-narrow {
    min-width: 120px;
    width: 120px;
}

.dashboard-container .shift-controls button {
    padding: 8px 16px;
    font-size: 0.9em;
}


#end-shift-btn {
    background-color: var(--error);
}

#end-shift-btn:hover {
    background-color: #c82333; /* Darker red */
}


/* Procedure Grid */
.procedure-grid {
    display: flex;
    gap: 10px;
    padding: 5px 10px;
    max-width: 1600px;
    margin: 0 auto;
    align-items: flex-start; /* Align columns to the top */
}

.grid-column {
    flex: 1; /* Each column will take up equal space */
    display: flex;
    flex-direction: column;
    gap: 5px; /* Spacing between cards in a column */
    min-height: 50px; /* Ensure even empty columns are droppable */
    min-width: 250px; /* Add this line */
}

/* Procedure Card */
.procedure-card {
    background-color: var(--background-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 6px; /* Slightly smaller radius */
    padding: 4px 8px; /* Reduced padding */
    display: flex;
    flex-direction: row; /* Horizontal layout */
    justify-content: space-between; /* Pushes header and controls apart */
    align-items: center; /* Vertically centers items */
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: box-shadow 0.2s;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

.flash-effect {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1px;
    height: 1px;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    opacity: 1;
    pointer-events: none;
}

.flash-effect.animate {
    animation: flash 1s ease-out;
}

@keyframes flash {
    from {
        transform: translate(-50%, -50%) scale(0);
        opacity: 1;
    }
    to {
        transform: translate(-50%, -50%) scale(400);
        opacity: 0;
    }
}

.procedure-card:hover {
    box-shadow: 0 0 5px var(--accent-primary-shadow); /* Subtle glow effect */
}

.column-placeholder {
    background-color: transparent;
    border: 2px dashed var(--border-primary);
    border-radius: 6px;
    min-height: 38px; /* Matches the approximate height of a procedure card */
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 0.9em;
}

.card-header {
    text-align: left;
    margin: 0;
    min-height: 0;
    flex-grow: 1; /* Allows header to take available space */
    overflow: hidden;
    white-space: nowrap;
}

.card-header h3 {
    font-size: 0.85em;
    color: var(--text-light);
    margin: 0 0 2px 0;
    text-overflow: ellipsis;
    overflow: hidden;
}

.card-header p {
    font-size: 0.8em;
    color: var(--text-secondary);
    margin: 0;
}

.card-controls {
    display: flex;
    align-items: center;
    gap: 8px; /* Space between count and button */
    flex-shrink: 0; /* Prevents controls from shrinking */
}

.case-count {
    font-size: 1em;
    font-weight: bold;
    color: var(--text-light);
    line-height: 1;
    margin: 0;
    padding: 0 4px;
}

.increment-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    font-size: 1em;
    line-height: 1;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* New Navigation Styles */
.main-nav {
    background-color: var(--background-secondary);
    padding: 8px 32px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    border-bottom: 1px solid var(--border-primary);
    margin-bottom: 20px;
}
.nav-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Dropdown Functionality */
.dropdown {
    position: relative;
}
.dropdown-menu {
    display: none; /* Hidden by default */
    position: absolute;
    right: 0;
    top: 100%;
    background-color: var(--background-input);
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    padding: 8px;
    z-index: 1100;
    min-width: 150px;
    flex-direction: column;
    gap: 8px;
}
.dropdown-menu.show {
    display: flex; /* Show the menu */
}

.dropdown-menu .dropdown-item-button {
    display: block;
    width: 100%;
    padding: 12px;
    border: none;
    background-color: var(--accent-primary);
    color: white;
    text-align: left;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    font-size: 1em;
    border-radius: 4px;
    font-weight: bold;
    transition: background-color 0.2s;
}

.dropdown-menu .dropdown-item-button:hover {
    background-color: var(--accent-primary-darker);
}

/* Start Page Styles */
.start-container {
    text-align: center;
    background-color: var(--background-secondary);
    padding: 50px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

#start-shift-btn {
    padding: 15px 30px;
    font-size: 1.2em;
    margin-top: 20px;
}

/* Modal Styles */
.modal {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
}

.modal-content {
    background-color: var(--background-secondary);
    margin: 15% auto;
    padding: 20px;
    border: 1px solid var(--border-primary);
    width: 80%;
    max-width: 500px;
    border-radius: 8px;
    position: relative;
}

.close-button {
    color: var(--text-secondary);
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close-button:hover,
.close-button:focus {
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
}

#start-shift-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#start-shift-form label {
    font-size: 0.9em;
    color: var(--text-tertiary);
}

#start-shift-form input {
    padding: 10px;
    border: 1px solid var(--border-primary);
    background-color: var(--background-input);
    color: var(--text-primary);
    border-radius: 4px;
}

#start-shift-form button {
    margin-top: 10px;
}

/* New Modal Styles for Start Shift */
#start-shift-modal {
    display: none; /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent black */
    justify-content: center;
    align-items: center;
    z-index: 2000; /* Ensure it's on top */
}

#start-shift-modal > div {
    background-color: var(--background-secondary);
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 400px;
}

#start-shift-modal.modal-visible {
    display: flex;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 4px; /* Creates a small space between the label and the input */
}

.shift-info-inputs label {
    font-size: 0.8em;
    color: var(--text-tertiary); /* A light grey color from the existing theme */
    font-weight: bold;
}

/* --- New styles for Navigation Bar Inputs --- */

/* Style the container for the inputs within the nav bar */
.main-nav .shift-info-inputs {
    display: flex;
    gap: 15px; /* Adjust spacing between each input field */
    align-items: center;
    margin-right: auto; /* Pushes the controls to the far right */
    margin-left: 20px;
}

/* Make the input groups (label + input) more compact */
.main-nav .input-group {
    gap: 3px; /* Reduce space between label and its input */
}

/* Make the input boxes themselves smaller to fit in the bar */
.main-nav input[type="text"],
.main-nav input[type="number"],
.main-nav input[type="date"],
.main-nav input[type="time"] {
    padding: 5px 8px;
    font-size: 0.9em;
    font-family: inherit; /* Ensures consistent font */
}

.main-nav input[type="text"],
.main-nav input[type="number"] {
    min-width: 65px;
    width: 65px;
}

.main-nav input[type="date"],
.main-nav input[type="time"] {
    min-width: 100px;
    width: 100px;
}

/* Adjust the specifically narrow inputs */
.main-nav .input-narrow {
    min-width: 65px; /* Reduced from 110px */
    width: 65px; /* Reduced from 110px */
}

/* Adjust label font size for the more compact view */
.main-nav .shift-info-inputs label {
    font-size: 0.75em;
}

.pace-ahead {
    border: 10px solid var(--success);
}

.pace-behind {
    border: 10px solid #FFA500;
}

.pace-neutral {
    border: 10px solid var(--border-primary);
}

.column-header {
    position: relative;
    display: flex;
    justify-content: center; /* Center the drag lines */
    align-items: center;
    padding: 0; /* Revert padding */
    background-color: var(--background-input);
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    margin-bottom: 2px;
    box-sizing: border-box;
    height: 15px; /* Revert height */
    cursor: grab; /* Add grab cursor */
}

.drag-lines {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.drag-line {
    width: 200px;
    height: 1px;
    background-color: var(--text-secondary);
    margin: 1px 0;
}

.column-header:hover .drag-line {
    background-color: var(--text-primary);
}

.delete-column-btn {
    position: absolute;
    top: 50%;
    right: 5px;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    padding: 0;
    display: none;
    line-height: 1;
}

.grid-column:hover .delete-column-btn {
    display: block;
}

.delete-column-btn:hover {
    color: var(--error);
}

/* =================================
   Selector Page Styles
   ================================= */

.procedure-table {
    width: 100%;
    border-collapse: collapse;
    max-width: 800px;
    margin: 20px auto;
    background-color: var(--background-secondary);
    border-radius: 8px;
    overflow: hidden; /* Clips the corners of the rows */
}

.procedure-table th {
    font-weight: bold;
}

.procedure-table th, .procedure-table td {
    padding: 4px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border-primary);
}

.procedure-item:last-child td {
    border-bottom: none;
}


/* The switch - the box around the slider */
.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

/* Hide default HTML checkbox */
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* The slider */
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    -webkit-transition: .4s;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--accent-primary);
}

input:focus + .slider {
    box-shadow: 0 0 1px var(--accent-primary);
}

input:checked + .slider:before {
    -webkit-transform: translateX(26px);
    -ms-transform: translateX(26px);
    transform: translateX(26px);
}

/* Rounded sliders */
.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

.search-container {
    display: flex;
    justify-content: center;
    margin: 20px auto;
    max-width: 800px;
}

.search-input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-primary);
    background-color: var(--background-input);
    color: var(--text-primary);
    border-radius: 4px;
    font-size: 1em;
}

.search-input::placeholder {
    color: var(--text-secondary);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-primary-shadow);
}
