/* Base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    color: #2c3e50;
    font-size: 2rem;
}

nav {
    display: flex;
    gap: 15px;
}

nav a {
    color: #3498db;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 4px;
    transition: background-color 0.3s;
}

nav a:hover {
    background-color: #ecf0f1;
}

/* Login form */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-form {
    background: white;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-form h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 10px;
}

.login-form h2 {
    text-align: center;
    color: #7f8c8d;
    font-weight: normal;
    margin-bottom: 30px;
}

.error-message {
    background-color: #e74c3c;
    color: white;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 20px;
    text-align: center;
}

/* Form elements */
.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: flex;
    gap: 15px;
    align-items: end;
}

.form-row .form-group {
    flex: 1;
}

label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #2c3e50;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    transition: border-color 0.3s;
}

input:focus,
select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* Buttons */
button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #2980b9;
}

button:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
}

.login-btn {
    width: 100%;
    padding: 15px;
    font-size: 18px;
}

/* Trip form */
.trip-form {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.trips-section {
    margin-top: 30px;
}

.trips-section h2 {
    color: #2c3e50;
    margin-bottom: 20px;
}

/* Trip rows */
.trip-row {
    display: grid;
    grid-template-columns: 74px 1fr 1fr 120px 80px;
    gap: 10px;
    align-items: center;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 10px;
    border: 1px solid #e9ecef;
}

.trip-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.trip-number {
    font-weight: bold;
    color: #6c757d;
    text-align: center;
    min-width: 20px;
}

.kebab-menu {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.kebab-btn {
    background: none !important;
    background-color: transparent !important;
    border: none !important;
    color: #6c757d !important;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    line-height: 1;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none !important;
    outline: none !important;
}

.kebab-btn:hover {
    background-color: #e9ecef;
    color: #495057;
}

.kebab-btn.has-selections {
    background-color: #333 !important;
    color: white !important;
}

.kebab-btn.has-selections:hover {
    background-color: #555 !important;
    color: white !important;
}

/* Kebab dropdown menu */
.kebab-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    min-width: 180px;
    z-index: 1000;
    display: none;
    padding: 4px 0;
}

.kebab-dropdown.show {
    display: block;
}

.kebab-option {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s ease;
    user-select: none;
}

.kebab-option:hover {
    background-color: #f8f9fa;
}

.kebab-option.selected {
    background-color: #e3f2fd;
}

.option-checkbox {
    color: #6c757d;
    font-family: monospace;
    font-size: 14px;
    width: 16px;
    text-align: center;
}

.kebab-option.selected .option-checkbox {
    color: #007bff;
}

.option-label {
    font-size: 12px;
    color: #333;
    white-space: nowrap;
}

/* Kebab option with input field */
.kebab-option-input {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: default;
}

.kebab-option-input:hover {
    background-color: white;
}

.spend-amount-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.spend-amount-input {
    width: 56px;
    padding: 2px 20px 2px 4px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 11px;
    box-sizing: border-box;
    outline: none;
    height: 20px;
}

.spend-amount-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.clear-spend-btn {
    position: absolute;
    right: 2px;
    background: none !important;
    border: none !important;
    color: #6c757d;
    font-size: 16px;
    cursor: pointer;
    padding: 0 !important;
    width: 16px !important;
    height: 16px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none !important;
    outline: none !important;
    margin: 0 !important;
    transition: color 0.2s;
}

.clear-spend-btn:hover {
    color: #495057;
}

.location-field,
.miles-field {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.location-field label,
.miles-field label {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 3px;
}

.location-field select,
.location-field input[type="text"],
.miles-field input[type="number"] {
    width: 100%;
}

.trip-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 !important;
    padding: 0;
}

#add-trip-btn {
    background-color: #27ae60;
    padding: 15px 30px;
    font-size: 16px;
}

#add-trip-btn:hover {
    background-color: #229954;
}

.delete-trip-btn {
    background-color: #e74c3c !important;
    color: white !important;
    border: none !important;
    width: 30px !important;
    height: 30px !important;
    border-radius: 0 !important;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

.delete-trip-btn:hover {
    background-color: #c0392b;
}

/* Total miles */
.total-miles {
    text-align: right;
    font-size: 18px;
    margin-top: 20px;
    padding: 15px;
    background-color: #e8f4f8;
    border-radius: 6px;
    color: #2c3e50;
}

/* Utilities page */
.utility-section {
    background: white;
    padding: 30px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.utility-section h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #ecf0f1;
}

/* Export form */
.export-form .form-row {
    align-items: flex-end;
}

#export-btn {
    background-color: #27ae60;
    white-space: nowrap;
}

#export-btn:hover {
    background-color: #229954;
}

/* Location management */
.locations-container {
    overflow-x: auto;
}

.locations-header {
    display: grid;
    grid-template-columns: 2fr 3fr 0.9fr 0.9fr 180px;
    gap: 10px;
    padding: 10px;
    background-color: #34495e;
    color: white;
    font-weight: bold;
    border-radius: 6px 6px 0 0;
}

.location-row {
    display: grid;
    grid-template-columns: 2fr 3fr 0.9fr 0.9fr 180px;
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid #ecf0f1;
    align-items: center;
}

.location-row:nth-child(even) {
    background-color: #f8f9fa;
}

.new-location {
    background-color: #e8f5e8;
    border: 2px dashed #27ae60;
    border-radius: 6px;
}

.location-actions {
    display: flex;
    gap: 5px;
}

.save-location-btn {
    background-color: #3498db;
    padding: 6px 12px;
    font-size: 14px;
}

.delete-location-btn {
    background-color: #e74c3c;
    padding: 6px 12px;
    font-size: 14px;
}

.add-location-btn {
    background-color: #27ae60;
    padding: 6px 12px;
    font-size: 14px;
}

/* Route generation */
.routes-form {
    text-align: center;
}

.routes-form p {
    margin-bottom: 20px;
    color: #6c757d;
}

#update-routes-btn {
    background-color: #f39c12;
    padding: 15px 30px;
    font-size: 16px;
}

#update-routes-btn:hover {
    background-color: #e67e22;
}

.status-message {
    margin-top: 15px;
    padding: 10px;
    border-radius: 4px;
    display: none;
}

.status-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.status-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .trip-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .trip-header {
        justify-content: space-between;
        padding-bottom: 5px;
        border-bottom: 1px solid #dee2e6;
        margin-bottom: 10px;
    }
    
    .form-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .locations-header,
    .location-row {
        grid-template-columns: 1fr;
        gap: 5px;
    }
    
    .header-cell {
        display: none;
    }
}

/* Drag and Drop Styles */
.sortable-list {
    min-height: 50px;
}

.location-row[draggable="true"] {
    cursor: move;
    transition: all 0.2s ease;
}

.location-row.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
    z-index: 1000;
}

.drag-handle {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #6c757d;
    cursor: grab;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    user-select: none;
    transition: all 0.2s;
    min-width: auto;
}

.drag-handle:hover {
    background: #e9ecef;
    color: #495057;
    border-color: #adb5bd;
}

.drag-handle:active {
    cursor: grabbing;
    background: #dee2e6;
}

.sortable-list .location-row:hover {
    background-color: #f8f9fa;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Currency Input Styling */
.input-with-prefix {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.currency-prefix {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-weight: 500;
    pointer-events: none;
    z-index: 2;
    line-height: 1;
}

.input-with-prefix input {
    padding-left: 28px;
    width: 100%;
}