/* Reset and 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;
}

/* Utility classes */
.hidden {
    display: none !important;
}

.btn-primary {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: #0056b3;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.btn-secondary:hover {
    background-color: #545b62;
}

.btn-success {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

.btn-success:hover {
    background-color: #1e7e34;
}

.error-message {
    background-color: #f8d7da;
    color: #721c24;
    padding: 10px;
    border-radius: 4px;
    margin-top: 10px;
    border: 1px solid #f5c6cb;
}

.success-message {
    background-color: #d4edda;
    color: #155724;
    padding: 10px;
    border-radius: 4px;
    margin-top: 10px;
    border: 1px solid #c3e6cb;
}

/* Login page styles */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
}

.login-card header {
    text-align: center;
    margin-bottom: 30px;
}

.login-card h1 {
    color: #333;
    margin-bottom: 10px;
}

.login-card p {
    color: #666;
    font-size: 14px;
}

.login-form {
    display: flex;
    flex-direction: column;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.form-row {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.form-row .form-group {
    margin-bottom: 10px;
}

.form-row .form-group:first-child {
    flex-shrink: 0;
    min-width: 180px;
}

.form-group-grow {
    flex-grow: 1;
}

.login-btn {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.login-btn:hover {
    background-color: #0056b3;
}

/* Dashboard styles */
.dashboard {
    min-height: 100vh;
    background-color: #f8f9fa;
}

.dashboard-header {
    background: white;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dashboard-header h1 {
    color: #333;
    margin: 0;
}

.user-nav {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-nav span {
    font-weight: 500;
    color: #333;
}

.dashboard-content {
    padding: 30px;
    width: 1080px;
    margin: 0 auto;
}

.group-section {
    background: white;
    margin-bottom: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.group-header {
    background-color: #f8f9fa;
    padding: 24px;
    border-bottom: 1px solid #dee2e6;
}

.group-header h2 {
    color: #333;
    margin: 0;
    font-size: 18px;
}

.jobs-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    padding: 24px;
}

.job-card {
    background: none;
    border: none;
    border-radius: 0;
    padding: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    color: inherit;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.job-card:hover {
    background: #e9ecef;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    text-decoration: none;
    color: inherit;
}

.job-card h3 {
    color: #007bff;
    margin-bottom: 10px;
    font-size: 16px;
}

.job-card p {
    color: #666;
    font-size: 14px;
    line-height: 1.5;
}

/* Modal styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #333;
}

.modal-form {
    padding: 20px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: flex-end;
}

/* Job pages styles */
.job-container {
    min-height: 100vh;
    background-color: #f8f9fa;
}

.job-header {
    background: white;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.job-header h1 {
    color: #333;
    margin: 0;
}

.upload-section {
    max-width: 1080px;
    margin: 30px auto;
    padding: 0 20px;
}

.upload-form {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.progress-container {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background-color: #007bff;
    transition: width 0.3s;
    width: 0%;
}

#progress-text {
    font-size: 14px;
    color: #666;
}

.result-message {
    padding: 15px;
    border-radius: 4px;
    margin-top: 20px;
}

/* XML Preview styles */
.xml-preview-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-top: 20px;
}

.preview-header {
    padding: 20px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-header h3 {
    margin: 0;
    color: #333;
}

.preview-actions {
    display: flex;
    gap: 10px;
}

.xml-content {
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 0 0 8px 8px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-x: auto;
}

/* Responsive design */
@media (max-width: 1140px) {
    .dashboard-content {
        width: 95%;
        max-width: 1080px;
        padding: 30px 20px;
    }
}

@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        padding: 15px;
    }

    .user-nav {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .dashboard-content {
        width: 100%;
        padding: 20px 15px;
    }

    .jobs-grid {
        grid-template-columns: 1fr;
        padding: 16px;
        gap: 16px;
    }

    .job-card {
        padding: 20px;
    }

    .group-header {
        padding: 20px;
    }

    .job-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
        padding: 15px;
    }

    .preview-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .preview-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .modal-actions {
        flex-direction: column;
    }

    .modal-actions button {
        width: 100%;
    }
}

/* Image Upload Preview Styles */
.preview-section {
    margin-top: 20px;
    padding: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.image-preview-item {
    position: relative;
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
}

.image-preview-item.valid {
    border-color: #28a745;
}

.image-preview-item.invalid {
    border-color: #dc3545;
}

.image-preview-thumbnail {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 8px;
}

.image-preview-filename {
    font-size: 12px;
    color: #666;
    margin-bottom: 5px;
    word-break: break-all;
}

.image-preview-status {
    font-size: 11px;
    font-weight: bold;
    margin-bottom: 8px;
}

.image-preview-item.valid .image-preview-status {
    color: #28a745;
}

.image-preview-item.invalid .image-preview-status {
    color: #dc3545;
}

.image-remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-remove-btn:hover {
    background: #c82333;
}

.invalid-files {
    margin-top: 20px;
    padding: 15px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
}

.invalid-files h4 {
    color: #721c24;
    margin-bottom: 10px;
}

.invalid-files ul {
    color: #721c24;
    margin-left: 20px;
}

.form-help {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: #666;
}

.upload-status {
    margin-top: 10px;
}

.upload-status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 5px;
    background: white;
    border-radius: 4px;
    border-left: 4px solid #6c757d;
}

.upload-status-item.uploading {
    border-left-color: #007bff;
}

.upload-status-item.success {
    border-left-color: #28a745;
}

.upload-status-item.error {
    border-left-color: #dc3545;
}

.upload-status-filename {
    font-weight: 500;
    flex: 1;
    margin-right: 10px;
}

.upload-status-result {
    font-size: 12px;
    font-weight: bold;
}

.upload-status-item.uploading .upload-status-result {
    color: #007bff;
}

.upload-status-item.success .upload-status-result {
    color: #28a745;
}

.upload-status-item.error .upload-status-result {
    color: #dc3545;
}

/* Piecework listing styles */
.piecework-section {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.loading-message {
    text-align: center;
    padding: 40px;
    color: #666;
}

.error-message {
    background-color: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 4px;
    margin: 20px 0;
    text-align: center;
}

.piecework-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.piecework-table {
    /* Container for all piecework rows */
}

.piecework-row {
    border-bottom: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.piecework-row:last-child {
    border-bottom: none;
}

.piecework-main {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 15px 20px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.piecework-main:hover {
    background-color: #f8f9fa;
}

.work-name {
    font-weight: 600;
    color: #007bff;
    cursor: pointer;
    transition: color 0.2s ease;
    min-width: 200px;
    flex-shrink: 0;
}

.work-name:hover {
    color: #0056b3;
}

.work-desc {
    color: #333;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-operations {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.get-file-label {
    color: #666;
    font-size: 14px;
    font-weight: 500;
}

.btn-get-file, .btn-upload-file {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s;
}

.btn-get-file:hover {
    background-color: #545b62;
}

.btn-upload-file {
    background-color: #007bff;
}

.btn-upload-file:hover {
    background-color: #0056b3;
}

.current-status {
    color: #28a745;
    font-weight: 500;
    min-width: 120px;
    text-align: right;
    flex-shrink: 0;
}

.status-history {
    background-color: #f8f9fa;
    border-top: 1px solid #e9ecef;
    padding: 10px 20px;
}

.status-item {
    padding: 8px 0;
    color: #666;
    font-size: 14px;
    border-left: 3px solid #007bff;
    padding-left: 15px;
    margin-bottom: 5px;
}

.status-item:last-child {
    margin-bottom: 0;
}

.no-status {
    color: #999;
    font-style: italic;
    text-align: center;
    padding: 15px;
}

.no-data {
    text-align: center;
    padding: 60px;
    color: #666;
    font-size: 16px;
}

/* Pagination styles */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background-color: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.page-info {
    font-weight: 500;
    color: #333;
}

.pagination-container .btn-secondary {
    min-width: 80px;
}

.pagination-container .btn-secondary:disabled {
    background-color: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
}

.pagination-container .btn-secondary:disabled:hover {
    background-color: #e9ecef;
}

/* Responsive design */
@media (max-width: 768px) {
    .piecework-section {
        padding: 10px;
    }

    .piecework-main {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 15px;
    }

    .work-name {
        min-width: auto;
        font-size: 16px;
    }

    .work-desc {
        white-space: normal;
        overflow: visible;
        text-overflow: initial;
    }

    .file-operations {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .current-status {
        min-width: auto;
        text-align: left;
        font-size: 14px;
    }

    .status-history {
        padding: 10px 15px;
    }

    .pagination-container {
        flex-direction: column;
        gap: 10px;
    }
}
