/* General Styles */
body {
    font-family: sans-serif;
    margin: 0;
    background-color: #f4f4f4;
    color: #333;
}

h1 {
    text-align: center;
    color: #5a5a5a;
    margin-bottom: 20px;
}

header {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.report-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    gap: 15px; /* Add gap between items */
}

.info-item label {
    margin-right: 5px;
    font-weight: bold;
}

.info-item input[type="text"],
.info-item input[type="date"] {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.info-item.period {
    display: flex;
    gap: 15px; /* Gap between From and To */
    align-items: center;
}

.info-item.period > div { /* Style From/To containers */
    display: flex;
    align-items: center;
}

main {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.controls {
    margin-bottom: 20px;
    display: flex;
    flex-wrap: wrap; /* Allow buttons to wrap */
    gap: 10px; /* Add space between buttons */
}

.controls button {
    padding: 10px 15px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.controls button:hover {
    background-color: #0056b3;
}

/* Table Styles */
.table-container {
    overflow-x: auto; /* Enable horizontal scrolling on small screens */
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

thead {
    background-color: #8B4513; /* Brown color like the screenshot */
    color: white;
}

th, td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: left;
    vertical-align: middle;
}

tbody tr:nth-child(even) {
    background-color: #fff3e0; /* Light orange for alternating rows */
}

tbody tr:nth-child(odd) {
    background-color: #ffffff;
}

tbody td input[type="text"],
tbody td input[type="date"],
tbody td input[type="number"],
tbody td select {
    width: 95%; /* Make inputs fill cell */
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 3px;
    box-sizing: border-box; /* Include padding and border in width */
}

/* Style for Notes cell to indicate clickability */
.notes-cell {
    cursor: pointer;
    color: #007bff; /* Blue color to suggest interactivity */
    text-decoration: underline;
    max-width: 150px; /* Limit width */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.notes-cell:hover {
    color: #0056b3;
}

tfoot {
    font-weight: bold;
    background-color: #eee;
}

tfoot td {
    text-align: right;
}

tfoot td:nth-last-child(3) { /* Adjusted for new Notes column */
    text-align: right;
    padding-right: 20px;
}

tfoot input[type="number"] {
     width: 80px; /* Smaller width for Advances input */
     text-align: right;
}

.delete-btn {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
}

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

/* Correlation View */
#correlation-view {
    background-color: #e9ecef;
    padding: 15px;
    border-radius: 5px;
    margin-top: 20px;
}

#correlation-view h2, #correlation-view h3 {
    margin-top: 0;
    color: #495057;
}

#correlation-view ul {
    list-style: none;
    padding: 0;
}

#correlation-view li {
    background-color: #fff;
    margin-bottom: 5px;
    padding: 8px;
    border-radius: 3px;
    border: 1px solid #ced4da;
}

/* Modal Styles */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1000; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%; /* Could be more or less, depending on screen size */
    max-width: 1000px;
    border-radius: 8px;
    position: relative;
}

.close-button, .close-categorization-button {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
}

.close-button:hover,
.close-button:focus,
.close-categorization-button:hover,
.close-categorization-button:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

#notes-modal-text {
    padding: 5px;
    max-height: 500px;
    overflow-y: auto;
}

/* Categorization Modal Specific Styles */
#categorization-details {
    margin-bottom: 15px;
    padding: 10px;
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    display: flex;
    gap: 20px;
}

#categorization-details .expense-header {
    flex: 0 0 40%;
    margin-bottom: 0;
}

#categorization-details .expense-details {
    flex: 0 0 60%;
    margin-top: 0;
}

#categorization-details .expense-header p {
    margin: 5px 0;
    font-size: 1.1em;
}

#categorization-details hr {
    display: none; /* Remove the horizontal line since we're using columns */
}

#categorization-details .expense-details p {
    margin: 5px 0;
}

#categorization-options label {
    display: block;
    margin-bottom: 4px 0 0 0;
    cursor: pointer;
}

#categorization-options input[type="radio"] {
    margin-right: 8px;
}

#skip-expense-cat {
    font-weight: bold;
}

#confirm-category-btn, #skip-category-btn {
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 15px;
    margin-right: 10px;
}

#confirm-category-btn {
    background-color: #28a745;
    color: white;
}

#confirm-category-btn:hover {
    background-color: #218838;
}

#skip-category-btn {
    background-color: #ffc107;
    color: #333;

}

#skip-category-btn:hover {
    background-color: #e0a800;
}

/* Responsive Design */
@media (max-width: 768px) {
    .report-info {
        flex-direction: column; /* Stack info items vertically */
        align-items: flex-start;
    }

    .info-item.period {
        flex-direction: column; /* Stack From/To vertically */
        align-items: flex-start;
        gap: 5px;
    }

    .controls {
        justify-content: center; /* Center buttons */
    }

    th, td {
        padding: 6px;
        font-size: 0.9em;
    }

    tbody td input[type="text"],
    tbody td input[type="date"],
    tbody td input[type="number"],
    tbody td select {
        width: 90%;
        font-size: 0.9em;
    }
    .modal-content {
        width: 90%;
        margin: 10% auto;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    h1 {
        font-size: 1.5em;
    }

    header, main {
        padding: 15px;
    }

    .controls button {
        width: 100%; /* Make buttons full width */
        margin-bottom: 5px;
    }

    th, td {
        padding: 4px;
        font-size: 0.8em;
    }
    .modal-content {
        width: 95%;
        margin: 5% auto;
        padding: 15px;
    }
}

.report-management {
    margin: 20px 0;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 5px;
}

.report-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.report-actions button {
    padding: 8px 15px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.report-actions button:hover {
    background-color: #0056b3;
}

.report-list {
    margin-top: 10px;
}

.report-item {
    padding: 10px;
    border-bottom: 1px solid #dee2e6;
}

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

/* Modal styles for report management */
#save-report-modal .modal-content,
#load-report-modal .modal-content {
    max-width: 500px;
}

.form-group {
    margin-bottom: 15px;
}

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

.form-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.form-actions button {
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.form-actions button:first-child {
    background-color: #007bff;
    color: white;
}

.form-actions button:last-child {
    background-color: #6c757d;
    color: white;
}

.form-actions button:hover {
    opacity: 0.9;
}

#expense-table td:nth-child(6),
#expense-table td:nth-child(7),
#expense-table td:nth-child(8),
#expense-table td:nth-child(9),
#expense-table td:nth-child(10),
#expense-table td:nth-child(11),
#expense-table td:nth-child(13) {
    text-align: right;
}
#expense-table td:nth-child(6) input,
#expense-table td:nth-child(7) input,
#expense-table td:nth-child(8) input,
#expense-table td:nth-child(9) input,
#expense-table td:nth-child(10) input,
#expense-table td:nth-child(11) input {
    text-align: right;
}

/* Categorization modal button styles */
#categorization-modal button {
    border: none;
    border-radius: 5px;
    padding: 8px 16px;
    margin: 5px;
    cursor: pointer;
    transition: background 0.2s;
    color: white;
    font-weight: 500;
}

#confirm-category-btn {
    background: #2e7d32;  /* Green */
}
#confirm-category-btn:hover {
    background: #1b5e20;
}

#skip-category-btn {
    background: #c62828;  /* Red */
}
#skip-category-btn:hover {
    background: #b71c1c;
}

#import-all-btn {
    background: #1565c0;  /* Blue */
}
#import-all-btn:hover {
    background: #0d47a1;
}

#skip-all-btn {
    background: #6a1b9a;  /* Purple */
}
#skip-all-btn:hover {
    background: #4a148c;
}

/* AI Modal Button Styles */
#ai-keep-expense-date-btn, #ai-set-to-rideshare-date-btn {
    border: none;
    border-radius: 5px;
    padding: 8px 16px;
    margin: 5px 10px 5px 0;
    cursor: pointer;
    transition: background 0.2s;
    color: white;
    font-weight: 500;
    font-size: 1em;
    min-width: 180px;
    display: inline-block;
}
#ai-keep-expense-date-btn {
    background: #1565c0; /* Blue */
}
#ai-keep-expense-date-btn:hover {
    background: #0d47a1;
}
#ai-set-to-rideshare-date-btn {
    background: #2e7d32; /* Green */
}
#ai-set-to-rideshare-date-btn:hover {
    background: #1b5e20;
}

#categorization-modal .modal-content {
    width: 120%;
    max-width: 1200px;
}

#modal-notes-save-btn {
    background: #2e7d32;
    color: white;
    border: none;
    border-radius: 4px;
    font-weight: 500;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 1em;
    transition: background 0.2s;
}
#modal-notes-save-btn:hover {
    background: #1b5e20;
}

#notes-modal-fixed-row .modal-notes-btn-row {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-end;
    width: 100%;
    margin-top: 10px;
}
.modal-ai-btn {
    background-color: #ef4444;
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.1em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    transition: background 0.2s;
}
.modal-ai-btn:hover {
    background-color: #b71c1c;
}

@keyframes spin {
  0% { transform: rotate(0deg);}
  100% { transform: rotate(360deg);}
}
#categorization-spinner-overlay {
  display: none;
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(255,255,255,0.7);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}
#categorization-modal.loading {
  pointer-events: none;
  opacity: 0.7;
}

