/* Components CSS */
/* This file contains styles for reusable components */

/* ===== Upload Components ===== */
.upload-section {
    background-color: var(--light-bg);
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 2rem;
    position: relative;
}

.drop-area {
    border: 2px dashed #ccc;
    border-radius: 5px;
    padding: 20px;
    margin-bottom: 20px;
    text-align: center;
    background-color: #f9f9f9;
    transition: background-color 0.3s, border-color 0.3s;
}

.drop-area.drag-over {
    background-color: rgba(0, 123, 255, 0.1);
    border-color: #007bff;
    animation: pulse 1.5s infinite;
}

.drop-area.invalid-file {
    background-color: rgba(220, 53, 69, 0.1);
    border-color: #dc3545;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.4);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(0, 123, 255, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 123, 255, 0);
    }
}

.drop-area input[type="file"] {
    display: none;
}

.drop-area label {
    background-color: var(--primary-color);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    display: inline-block;
    margin-top: 10px;
    transition: background-color 0.3s;
}

.drop-area label:hover {
    background-color: var(--primary-color);
}

.drop-area p {
    margin: 10px 0;
}

.files-container {
    min-height: 50px;
    border: 1px solid #eee;
    padding: 10px;
    border-radius: 4px;
    background-color: #fcfcfc;
}

/* Single visit mode */
.files-container.single-visit {
    background-color: #f0f8ff; /* Light blue background to distinguish it */
    border: 1px solid #b8d4f5;
}

.visit-container {
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    overflow: hidden;
}

.visit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--primary-color);
    padding: 10px;
    border-bottom: 1px solid #ddd;
}

.visit-title {
    margin: 0;
    font-size: 16px;
    font-weight: bold;
    color: white;
}

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

.visit-actions button {
    background-color: #6c757d;
    color: white;
    border: none;
    border-radius: 3px;
    padding: 3px 6px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.3s;
}

.visit-actions button:hover {
    background-color: #5a6268;
}

.visit-actions .remove-visit {
    background-color: #dc3545;
}

.visit-actions .remove-visit:hover {
    background-color: #c82333;
}

.file-item {
    margin-bottom: 10px;
    background-color: white;
    border: 1px solid #eee;
    border-radius: 4px;
    overflow: hidden;
}

.file-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
}

.file-info {
    flex: 1;
}

.file-name {
    font-weight: bold;
    margin-bottom: 5px;
}

.project-info {
    margin-bottom: 5px;
    font-size: 0.9em;
}

.results-count-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.8em;
    color: #6c757d;
}

.remove-file {
    cursor: pointer;
    padding: 5px;
    color: #dc3545;
}

.remove-file:hover {
    color: #bd2130;
}

.ags-messages {
    margin-bottom: 15px;
}

.message {
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 4px;
}

.message.info {
    background-color: #cff4fc;
    color: #055160;
}

.message.success {
    background-color: #d1e7dd;
    color: #0f5132;
}

.message.warning {
    background-color: #fff3cd;
    color: #664d03;
}

.message.error {
    background-color: #f8d7da;
    color: #842029;
}

.loading-indicator {
    display: none;
    text-align: center;
    margin-top: 20px;
}

.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.drop-placeholder {
    border: 2px dashed #007bff;
    background-color: rgba(0, 123, 255, 0.1);
    height: 50px;
    margin-bottom: 10px;
    border-radius: 4px;
}

.being-dragged {
    opacity: 0.5;
    background-color: #f8f9fa;
}

.empty-visit .visit-header {
    background-color: #808080; /* Mid-grey color */
}

.empty-visit .files-container {
    background-color: #f0f0f0; /* Light grey background */
    border: 2px dashed #dee2e6;
    min-height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.empty-visit .files-container::before {
    content: "EMPTY VISIT: Move a file here or delete visit";
    color: #666;
    font-style: italic;
}

/* Process button disabled state */
.btn.disabled,
button.disabled,
#ags-uploader-process-button.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #d3d3d3;
    border-color: #ccc;
}

.file-list {
    margin-top: 1rem;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 4px;
    display: none;
}

.files-container.ui-sortable-placeholder {
    visibility: visible !important;
    border: 2px dashed var(--primary-color);
    background-color: rgba(0, 123, 255, 0.1);
    height: 80px;
}

.file-item {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 0.5rem;
    border-bottom: 1px solid #dee2e6;
    background-color: white;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    position: relative;
}

.file-item:last-child {
    margin-bottom: 0;
}

.file-item.being-dragged {
    opacity: 0.4;
    border: 1px dashed #ccc;
}

.dragging-clone {
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    border: 1px solid #ccc;
    background-color: white;
}

.drop-placeholder {
    height: 70px;
    background-color: rgba(0, 123, 255, 0.1);
    border: 2px dashed var(--primary-color);
    margin-bottom: 0.5rem;
    border-radius: 4px;
}

.file-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex: 1;
    background-color: #fff3e0;
    padding: 1rem;
    border-radius: 4px;
    cursor: move;
}

.file-content.dragging {
    opacity: 0.5;
    background-color: #ffe0b2;
}

.drop-indicator {
    height: 4px;
    background-color: var(--primary-color);
    margin: 0;
    position: relative;
    width: 100%;
}

.drop-indicator::before {
    content: '';
    position: absolute;
    left: 0;
    top: -4px;
    width: 10px;
    height: 10px;
    background-color: var(--primary-color);
    border-radius: 50%;
}

.file-info {
    flex: 1;
    margin-right: 1rem;
}

.file-name {
    font-weight: 500;
    color: var(--primary-color);
    margin-bottom: 0px;
}

.project-info {
    font-size: 0.9rem;
    color: #495057;
    margin-top: 0px;
}

.project-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.results-count-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed #ddd;
    font-size: 0.8rem;
    color: #565656;
}

.total-count {
    flex: 1;
    text-align: left;
}

.leachate-count {
    flex: 1;
    text-align: center;
}

.groundwater-count {
    flex: 1;
    text-align: right;
}

.transaction {
    flex: 1;
    text-align: left;
}

.project-name {
    flex: 1;
    text-align: right;
}

.file-content .remove-file {
    color: #dc3545;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    align-self: flex-start;
}

.file-content .remove-file:hover {
    color: #c82333;
}

.visit-container {
    margin-bottom: 1.5rem;
    border-radius: 6px;
    background-color: #f0f4f8;
    border: 1px solid #d0d9e6;
    overflow: hidden;
}

.visit-title {
    font-weight: bold;
    font-size: 1rem;
}

.visit-actions {
    display: flex;
    gap: 8px;
}

.visit-actions button {
    background-color: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 0.8rem;
    padding: 3px 6px;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.visit-actions button i {
    margin-right: 4px;
}

.visit-actions button:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.visit-actions .remove-visit {
    background-color: rgba(220, 53, 69, 0.3);
    border-color: rgba(220, 53, 69, 0.3);
}

.visit-actions .remove-visit:hover {
    background-color: rgba(220, 53, 69, 0.5);
}

.files-container {
    padding: 0.5rem;
    min-height: 40px;
    background-color: #f8f9fa;
    border-radius: 0 0 6px 6px;
}

.visit-container .visit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 1rem;
    background-color: var(--primary-color);
    color: white;
    width: 100%;
    box-sizing: border-box;
}

.files-container.single-visit .file-item {
    border-left: 3px solid #007bff;
}

/* ===== Tables ===== */
.table-responsive {
    overflow-x: auto;
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.results-table {
    width: 100%;
    margin-top: 1.5rem;
}

.results-table th {
    padding: 0.75rem 1rem;
    font-weight: 900;
    color: #000;
    background-color: white;
    text-transform: uppercase;
    border-bottom: 2px solid var(--border-color);
    border-top: 2px solid var(--primary-color);
    border-right: 1px solid #ccc;
    position: relative;
}

/* Preserve case for concentration headers with µg/l units */
.results-table th.preserve-case {
    text-transform: none;
}

.results-table th:last-child {
    border-right: none;
}

.results-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    border-right: 1px solid #ccc;
}

.results-table td:last-child {
    border-right: none;
}

.results-table tr:last-child td {
    border-bottom: none;
}

.results-table .determinant-name {
    font-weight: 700;
    color: var(--primary-color);
}

.results-table tr:hover {
    background-color: rgba(240, 115, 40, 0.05);
}

/* Sortable table styles */
th.sortable {
    cursor: pointer;
    padding-right: 1.5rem;
    position: relative;
}

th.sortable:after {
    content: "\f0dc"; /* fa-sort */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: #aaa;
    font-size: 0.8em;
}

th.sort-asc:after {
    content: "\f0de"; /* fa-sort-up */
    color: var(--primary-color);
}

th.sort-desc:after {
    content: "\f0dd"; /* fa-sort-down */
    color: var(--primary-color);
}

/* Visit header specific styles for multi-visit tables */
.results-table thead tr:last-child th.visit-header {
    text-align: center;
    white-space: nowrap;
    position: relative;
    min-width: 100px;
    padding: 0.5rem 1.5rem 0.5rem 0.5rem;
}

/* Ensure visit headers display horizontally */
.results-table thead tr {
    display: table-row;
}

.results-table thead tr th {
    display: table-cell;
    vertical-align: middle;
}

/* Fix for visit header layout */
.results-table th.visit-header {
    display: table-cell !important;
    float: none !important;
    width: auto !important;
}

/* Ensure table structure is preserved */
.results-table {
    table-layout: auto;
    border-collapse: collapse;
    width: 100%;
}

.results-table thead {
    display: table-header-group;
}

.results-table tbody {
    display: table-row-group;
}

/* Visit Summary table styles */
.visit-summary-table th,
.visit-summary-table td { white-space: nowrap; }

/* Allow wrapping for the last column (Groundwater/Surface Water Results) */
.visit-summary-table th:last-child,
.visit-summary-table td:last-child { white-space: normal; }

.visit-summary-table th {font-size:0.9em;}

.visit-summary-table td {font-size:0.8em;}

.visit-summary-table .filename {font-size:0.7em;}

.visit-summary-table .totals-row,
.visit-summary-table .tfoot tr {border-top:2px solid var(--border-color);}

/* Assessment column styling for Further Action */
.assessment-further-action {
    font-weight: bold;
    color: var(--primary-color);
}

/* ===== Controls and Filters ===== */
.controls {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.results-controls {
    margin: 2rem 0;
    background-color: var(--light-bg);
    border-radius: 8px;
    padding: 1.5rem;
}

.filters {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.results-summary {
    font-weight: 500;
    color: var(--dark-gray);
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
}

/* Area, Sample Type, and SOM Percentage Selectors */
.area-type-selector,
.sample-type-selector,
.som-percentage-selector {
    display: flex;
    align-items: center;
    background-color: var(--light-bg);
    padding: 0.5rem 1rem;
    border-radius: 4px;
}

.area-type-selector label,
.sample-type-selector label,
.som-percentage-selector label {
    margin-right: 0.75rem;
    font-weight: 700;
    color: var(--primary-color);
}

.area-type-selector select,
.sample-type-selector select,
.som-percentage-selector select {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: white;
    font-family: 'Roboto', sans-serif;
    color: var(--dark-gray);
    min-width: 150px;
    cursor: pointer;
}

.area-type-selector select:focus,
.sample-type-selector select:focus,
.som-percentage-selector select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(240, 115, 40, 0.2);
}

/* ===== Radio Button Groups ===== */
.radio-button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.5rem;
}

.radio-button-wrapper {
    position: relative;
}

.radio-button-wrapper input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.radio-button-wrapper label {
    display: inline-block;
    padding: 0.8rem 1.5rem;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #495057;
}

.radio-button-wrapper input[type="radio"]:checked + label {
    background-color: #3498db;
    color: white;
    border-color: #3498db;
}

.radio-button-wrapper label:hover {
    background-color: #e9ecef;
    border-color: #ced4da;
}

.radio-button-wrapper input[type="radio"]:checked + label:hover {
    background-color: #2980b9;
}

/* ===== Data Source Indicator ===== */
.data-source {
    background-color: var(--card-background);
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.data-source i {
    color: var(--secondary-color);
    font-size: 1.2rem;
}

.data-source span {
    font-weight: 500;
    color: var(--text-color);
}

/* ===== Form Components ===== */
.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

.form-group input[type="password"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group input[type="checkbox"] {
    margin-right: 0.5rem;
}

/* ===== Loading Indicator ===== */
.loading-indicator {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.loading-indicator .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    margin: 0 auto 10px;
}

.loading-indicator p {
    color: var(--text-color);
    font-weight: 500;
}

.upload-section.loading .drop-area {
    opacity: 0.5;
    pointer-events: none;
}

.upload-section.loading .loading-indicator {
    display: block;
}

/* Loading spinner animation */
.loading-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    margin-right: 10px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Utility Components ===== */
.full-width {
    width: 100%;
}

.sample-options-row {
    display: flex;
    justify-content: space-between;
    width: 100%;
    gap: 1rem;
}

/* ===== Toggle Buttons ===== */
.toggle-button {
    background-color: #f8f9fa;
    color: #666;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    cursor: pointer;
    margin-left: auto;
    display: block;
    transition: all 0.2s ease;
}

.toggle-button:hover {
    background-color: #e9ecef;
    border-color: #ced4da;
}

/* ===== Group Header ===== */
.group-header {
    background-color: #f0f0f0;
}

.group-header-cell {
    padding: 0.5rem 1rem;
    font-weight: 700;
    color: #333;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
}

/* ===== File Metadata Section ===== */
.file-metadata-section {
    background-color: var(--light-bg);
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
}

.file-metadata-section .file-info {
    flex: 1;
    min-width: 250px;
    margin-top: 0;
    padding: 0;
    background-color: transparent;
    border: none;
}

.file-metadata-section .metadata-content {
    flex: 2;
    min-width: 300px;
}

/* ===== Metadata Section ===== */
.metadata-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background-color: var(--light-bg);
    border-radius: 6px;
}

.metadata-content {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.metadata-item {
    flex: 1;
    min-width: 250px;
}

.metadata-item strong {
    color: var(--primary-color);
    font-weight: 700;
    margin-right: 0.5rem;
}

/* ===== Checkbox Container ===== */
.checkbox-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.checkbox-container input[type="checkbox"] {
    margin-right: 8px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-container label {
    font-size: 1rem;
    color: #333;
    cursor: pointer;
}

/* ===== Table Container ===== */
.table-container {
    overflow-x: auto;
    margin-bottom: 1.5rem;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* ===== Results Button Container ===== */
.button-container {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 0.5rem;
}

/* ===== Results Header ===== */
.results-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 1.5rem;
}

/* ===== Copy Button ===== */
.copy-button {
    background-color: #2196F3 !important;
    color: white !important;
    border-color: #1976D2 !important;
}

.copy-button:hover {
    background-color: #1976D2 !important;
    border-color: #0D47A1 !important;
}

.copy-button i {
    margin-right: 5px;
}

/* ===== Copy Notification ===== */
.copy-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(33, 150, 243, 0.9);
    color: white;
    padding: 15px 25px;
    border-radius: 5px;
    font-weight: bold;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    display: none;
}

/* ===== Alert Message Components ===== */
.gw-message {
    padding: 12px 15px;
    margin: 15px 0;
    border-radius: 4px;
    font-weight: 500;
}

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

.gw-message.warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.gw-message.notice {
    background-color: #fff3cd;
    color: #664d03;
    border: 1px solid #ffe69c;
}

.gw-message.info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Media queries for component responsiveness */
@media (max-width: 768px) {
    .metadata-content {
        flex-direction: column;
    }
    
    .area-type-selector,
    .sample-type-selector,
    .som-percentage-selector {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .area-type-selector label,
    .sample-type-selector label,
    .som-percentage-selector label {
        margin-bottom: 0.5rem;
    }
    
    .sample-options-row {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .login-container {
        padding: 1.5rem;
    }
    
    .form-group {
        margin-bottom: 1rem;
    }
}

/* ===== Version Info Component ===== */
.version-info {
    text-align: center;
    margin: 10px 0 20px;
    padding: 5px;
    background-color: #f8f9fa;
    border-radius: 3px;
    font-size: 0.9em;
    color: #666;
}

.version-info a {
    color: #336699;
    text-decoration: none;
}

.version-info a:hover {
    text-decoration: underline;
} 

.type-header .type-header-cell { font-weight: bold;}