/**
 * Shared CSS for all pages in the work order system
 * This file contains common styles to prevent code duplication
 */

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: #f5f5f5;
    color: #333;
    padding-bottom: 60px; /* Space for bottom navigation */
}

/* Header styles */
.header {
    background: #1890ff;
    color: white;
    padding: 15px 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.header h1 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

/* Container styles */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 15px;
}

.auth-container {
    max-width: 600px;
    margin: 50px auto;
    background: white;
    border-radius: 8px;
    padding: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    text-align: center;
}

/* Typography */
h2 {
    color: #333;
    font-size: 20px;
    margin-bottom: 20px;
    text-align: center;
}

/* Info and content boxes */
.info-box {
    background: #f0f7ff;
    border-left: 4px solid #1890ff;
    padding: 15px;
    margin: 20px 0;
    border-radius: 4px;
}

.user-info {
    margin: 20px 0;
    padding: 15px;
    background: #fafafa;
    border-radius: 4px;
}

.user-info p {
    margin: 8px 0;
    color: #666;
}

/* Button styles */
.btn {
    background: #1890ff;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    width: 100%;
    margin-top: 20px;
}

.btn:active {
    background: #096dd9;
}

.btn:disabled {
    background: #d9d9d9;
    cursor: not-allowed;
}

.load-more-btn {
    background: #1890ff;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
}

.load-more-btn:disabled {
    background: #d9d9d9;
    cursor: not-allowed;
}

/* Status and message styles */
.status {
    text-align: center;
    margin: 20px 0;
    padding: 10px;
    border-radius: 4px;
}

.status.success {
    color: #52c41a;
    background: #f6ffed;
}

.status.error {
    color: #ff4d4f;
    background: #fff2f0;
}

/* Work order/task card styles */
.work-order-card {
    background: white;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-left: 4px solid #1890ff;
    transition: all 0.2s ease;
}

.work-order-card.clickable {
    cursor: pointer;
}

.work-order-card.clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-left-color: #096dd9;
}

.work-order-card.clickable:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.work-order-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.work-order-id {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.work-order-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.4;
}

.work-order-description {
    color: #666;
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.work-order-info {
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

.info-row {
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.info-icon {
    font-size: 12px;
    width: 14px;
    flex-shrink: 0;
}

/* Badge styles */
.status-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.status-new { background: #e6f7ff; color: #1890ff; }
.status-assigned { background: #fff7e6; color: #fa8c16; }
.status-in-process { background: #f6ffed; color: #52c41a; }
.status-completed { background: #f0f0f0; color: #8c8c8c; }
.status-rejected { background: #fff1f0; color: #f5222d; }

.priority-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.priority-HIGH { background: #fff1f0; color: #f5222d; }
.priority-MEDIUM { background: #fff7e6; color: #fa8c16; }
.priority-LOW { background: #f6ffed; color: #52c41a; }

/* Loading and empty states */
.loading {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-state h3 {
    margin-bottom: 8px;
    color: #333;
}

.load-more-container {
    text-align: center;
    margin: 20px 0 40px;
}

/* Index page specific styles */
.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.user-info-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar-small {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.user-name-display {
    font-size: 14px;
    color: #666;
}

.logout-btn-small {
    background: #ff4d4f;
    padding: 6px 12px;
    font-size: 14px;
    width: auto;
    margin-top: 0;
}

/* Bottom Navigation - Standardized */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e8e8e8;
    display: flex;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
    z-index: 1000;
    height: 60px; /* Fixed height to prevent inconsistencies */
}

.nav-item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 8px;
    text-decoration: none;
    color: #666;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    min-height: 60px; /* Ensure consistent height */
    box-sizing: border-box;
}

.nav-item.active {
    color: #1890ff;
    background: #f0f7ff;
}

.nav-item:hover {
    color: #1890ff;
    background: #f9f9f9;
}

/* Work Order Detail Page Styles */
.detail-header {
    background: #1890ff;
    color: white;
    padding: 15px 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 15px;
}

.back-btn {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
}

.detail-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.detail-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 15px;
}

.detail-card {
    background: white;
    border-radius: 8px;
    padding: 0;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
}

.detail-section {
    padding: 16px;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
}

.detail-section:last-child {
    border-bottom: none;
}

.detail-section:nth-child(even) {
    background: #fafafa;
}

.section-title {
    font-size: 15px;
    font-weight: 600;
    color: #1890ff;
    margin-bottom: 12px;
    padding-bottom: 6px;
    border-bottom: 2px solid #e6f7ff;
    display: flex;
    align-items: center;
    gap: 6px;
}

.section-icon {
    width: 20px;
    height: 20px;
    background: #1890ff;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

.section-content {
    margin-top: 4px;
}

.detail-row {
    display: flex;
    margin-bottom: 8px;
    align-items: flex-start;
}

.detail-label {
    font-weight: 500;
    color: #666;
    min-width: 80px;
    flex-shrink: 0;
    padding-right: 10px;
    font-size: 13px;
}

.detail-value {
    color: #333;
    flex: 1;
    word-break: break-word;
    line-height: 1.4;
    font-size: 14px;
}

.description-text {
    white-space: pre-wrap;
    line-height: 1.5;
}

.comment-item {
    background: #fafafa;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
    border-left: 3px solid #1890ff;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 13px;
}

.comment-author {
    font-weight: 500;
    color: #333;
}

.comment-time {
    color: #999;
}

.comment-type {
    background: #e6f7ff;
    color: #1890ff;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 500;
}

.comment-text {
    color: #333;
    line-height: 1.4;
    font-size: 14px;
}

.no-comments {
    text-align: center;
    color: #999;
    padding: 20px;
    font-style: italic;
}

.badge-group {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.loading-detail, .error-detail {
    text-align: center;
    padding: 60px 20px;
}

.loading-detail {
    color: #666;
}

.error-detail {
    color: #f5222d;
}

.retry-btn {
    max-width: 200px;
    margin: 20px auto;
}

/* Completion form styles */
.completion-section {
    margin-top: 20px;
    border-top: 1px solid #f0f0f0;
    padding-top: 20px;
}

.completion-form {
    background: #fafafa;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

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

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.form-input, .form-textarea, .form-select {
    width: 100%;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    font-size: 14px;
    color: #333;
    box-sizing: border-box;
    transition: border-color 0.3s ease;
}

.form-input {
    height: 40px;
    padding: 0 12px;
}

.form-textarea {
    min-height: 80px;
    padding: 10px 12px;
    resize: vertical;
    line-height: 1.5;
}

.form-select {
    height: 40px;
    padding: 0 12px;
    background: white;
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
    outline: none;
    border-color: #1890ff;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.1);
}

.radio-group {
    display: flex;
    gap: 16px;
    margin-top: 6px;
}

.radio-option {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.radio-option input[type="radio"] {
    margin-right: 6px;
    width: 16px;
    height: 16px;
}

.radio-option label {
    font-size: 14px;
    color: #333;
    cursor: pointer;
}

.completion-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
}

.btn-complete {
    background: #52c41a;
    color: white;
    border: 1px solid #52c41a;
}

.btn-complete:hover {
    background: #389e0d;
    border-color: #389e0d;
}

.btn-complete:disabled {
    background: #f5f5f5;
    color: #d9d9d9;
    border-color: #d9d9d9;
    cursor: not-allowed;
}

.btn-cancel {
    background: white;
    color: #666;
    border: 1px solid #d9d9d9;
}

.btn-cancel:hover {
    background: #f5f5f5;
    border-color: #aaa;
}

.action-buttons {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    gap: 12px;
    z-index: 100;
}

.action-buttons .btn {
    flex: 1;
    padding: 12px 16px;
    font-size: 16px;
    font-weight: 500;
    border-radius: 6px;
}

.btn-secondary {
    background: white;
    color: #1890ff;
    border: 1px solid #1890ff;
}

.btn-secondary:hover {
    background: #f0f8ff;
    border-color: #1890ff;
}

.btn-primary {
    background: #1890ff;
    color: white;
    border: 1px solid #1890ff;
}

.btn-primary:hover {
    background: #40a9ff;
    border-color: #40a9ff;
}

.btn-warning {
    background: #faad14;
    color: white;
    border: 1px solid #faad14;
}

.btn-warning:hover {
    background: #d48806;
    border-color: #d48806;
}

.btn-complete {
    background: #52c41a;
    color: white;
    border: 1px solid #52c41a;
}

.btn-complete:hover {
    background: #389e0d;
    border-color: #389e0d;
}

/* Detail page specific styles */
.detail-container {
    padding-bottom: 20px;
}


/* Floating refresh button */
.floating-refresh {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: #1890ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(24, 144, 255, 0.3);
    cursor: pointer;
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    border: none;
    color: white;
}

.floating-refresh:hover {
    background: #0f7abd;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(24, 144, 255, 0.4);
}

.floating-refresh:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(24, 144, 255, 0.3);
}

.floating-refresh.refreshing {
    background: #52c41a;
    animation: refresh-spin 1s linear infinite;
}

.floating-refresh.refreshing:hover {
    background: #52c41a;
    transform: none;
}

.floating-refresh svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.floating-refresh:hover svg {
    transform: rotate(-15deg);
}

.floating-refresh.refreshing svg {
    animation: refresh-spin 1s linear infinite;
}

@keyframes refresh-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Hide floating refresh when not needed */
.floating-refresh.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

/* Utility classes */
.hidden {
    display: none !important;
}

/* Work details list styling */
.procedure-list, .tools-list, .parts-list {
    margin: 8px 0;
    padding-left: 20px;
}

.procedure-list li {
    margin: 6px 0;
    line-height: 1.4;
}

.tools-list li, .parts-list li {
    margin: 4px 0;
    line-height: 1.3;
}

.procedure-list li strong,
.tools-list li strong,
.parts-list li strong {
    color: #1890ff;
}

/* Responsive design */
@media (max-width: 480px) {
    body {
        padding-bottom: 56px; /* Smaller navigation on mobile */
    }
    
    .bottom-nav {
        height: 56px; /* Slightly smaller on mobile */
    }
    
    .nav-item {
        min-height: 56px;
        padding: 10px 6px;
        font-size: 13px;
    }
    
    .container {
        padding: 10px;
    }
    
    .work-order-card {
        padding: 12px;
    }
    
    .work-order-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

/* User Selector Component Styles */
.user-selector {
    width: 100%;
}

.user-search {
    margin-bottom: 10px;
}

.user-search .form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    font-size: 14px;
    background: white;
}

.user-search .form-input:focus {
    border-color: #1890ff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

.user-list {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    background: white;
}

.user-item {
    padding: 8px 12px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
}

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

.user-item:hover {
    background-color: #f5f5f5;
}

.user-item.selected {
    background-color: #e6f7ff;
    border-color: #1890ff;
}

.user-name {
    font-weight: 500;
    color: #333;
    font-size: 14px;
    flex: 1;
}

.loading-users, .no-users, .error-users {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

.error-users {
    color: #ff4d4f;
}

/* Reassignment Modal Styles */
.reassign-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.reassign-modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    max-height: 80%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.reassign-modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.reassign-modal-header h3 {
    margin: 0;
    font-size: 16px;
    color: #333;
}

.reassign-modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reassign-modal-close:hover {
    color: #333;
}

.reassign-modal-body {
    padding: 20px;
    flex: 1;
    overflow: auto;
}

.reassign-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

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

.reassign-modal .form-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #333;
}

.reassign-modal .form-textarea {
    width: 100%;
    min-height: 60px;
    padding: 8px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
}

.reassign-modal .form-textarea:focus {
    border-color: #1890ff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}