/* Moving Status Plugin - Frontend Styles */

/* Reset and Base Styles */
.msp-admin-panel *,
.msp-client-tracker * {
    box-sizing: border-box;
}

/* Common Components */
.msp-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
}

.msp-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.msp-btn:active {
    transform: translateY(0);
}

.msp-btn-primary {
    background: linear-gradient(135deg, #007cba 0%, #005a87 100%);
    color: white;
}

.msp-btn-primary:hover {
    background: linear-gradient(135deg, #005a87 0%, #004666 100%);
    color: white;
}

.msp-btn-secondary {
    background: #f8f9fa;
    color: #495057;
    border: 1px solid #dee2e6;
}

.msp-btn-secondary:hover {
    background: #e9ecef;
    color: #495057;
}

.msp-btn-outline {
    background: transparent;
    color: #007cba;
    border: 1px solid #007cba;
}

.msp-btn-outline:hover {
    background: #007cba;
    color: white;
}

.msp-btn-danger {
    background: #dc3545;
    color: white;
}

.msp-btn-danger:hover {
    background: #c82333;
    color: white;
}

/* Loading Spinner */
.msp-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px;
    color: #6c757d;
}

.msp-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007cba;
    border-radius: 50%;
    animation: msp-spin 1s linear infinite;
}

@keyframes msp-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Messages */
.msp-field-help {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #6c757d;
    font-style: italic;
}

.msp-form-group textarea[name="client_notes"] {
    border-left: 3px solid #007cba;
    background-color: #f8f9ff;
}

.msp-form-group textarea[name="client_notes"]:focus {
    border-left-color: #0056b3;
    background-color: #ffffff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Messages */
.msp-messages {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    max-width: 400px;
}

.msp-message {
    padding: 16px 20px;
    margin-bottom: 12px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: msp-slide-in 0.3s ease;
}

.msp-message-success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid #28a745;
}

.msp-message-error {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid #dc3545;
}

.msp-message-info {
    background: #d1ecf1;
    color: #0c5460;
    border-left: 4px solid #17a2b8;
}

@keyframes msp-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Error Messages */
.msp-error {
    background: #f8d7da;
    color: #721c24;
    padding: 16px;
    border-radius: 6px;
    border-left: 4px solid #dc3545;
    margin: 20px 0;
}

/* Modal Styles */
.msp-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.msp-modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: msp-modal-in 0.3s ease;
}

@keyframes msp-modal-in {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.msp-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #dee2e6;
}

.msp-modal-header h2 {
    margin: 0;
    font-size: 20px;
    color: #212529;
}

.msp-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.msp-modal-close:hover {
    background: #f8f9fa;
    color: #495057;
}

/* Form Styles */
.msp-job-form {
    padding: 24px;
}

.msp-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.msp-form-group {
    margin-bottom: 20px;
}

.msp-form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #495057;
}

.msp-form-group input,
.msp-form-group select,
.msp-form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.msp-form-group input:focus,
.msp-form-group select:focus,
.msp-form-group textarea:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.25);
}

.msp-form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding-top: 20px;
    border-top: 1px solid #dee2e6;
}

/* Admin Panel Styles */
.msp-admin-panel {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.msp-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #dee2e6;
}

.msp-header h1 {
    margin: 0 0 16px 0;
    font-size: 20px;
    color: #212529;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    text-align: center;
}

.msp-filters {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.msp-search-box {
    display: flex;
}

.msp-search-box input {
    flex: 1;
    padding: 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 16px;
    width: 100%;
}

.msp-filter-box select,
.msp-sort-box select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    background: white;
}

.msp-jobs-container {
    padding: 24px;
}

.msp-job-card {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    transition: all 0.2s ease;
}

.msp-job-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

/* Mobile-specific styles */
@media (max-width: 768px) {
    .msp-header {
        padding: 12px;
    }
    
    .msp-header h1 {
        font-size: 18px;
    }
    
    .msp-job-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .msp-job-title {
        font-size: 16px;
    }
    
    .msp-job-details {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .msp-job-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .msp-job-actions .msp-btn {
        padding: 8px;
        min-width: 40px;
        justify-content: center;
    }
    
    .msp-job-actions .msp-btn span {
        display: none;
    }
    
    .msp-job-actions .msp-btn::before {
        content: attr(data-icon);
        font-size: 18px;
    }
    
    a[href^="tel:"],
    a[href^="mailto:"],
    a[href^="http"] {
        color: #007cba;
        text-decoration: underline;
    }
    
    .msp-job-details-collapsed {
        display: none;
    }
    
    .msp-job-details-expanded {
        display: block;
        margin-top: 12px;
        padding-top: 12px;
        border-top: 1px solid #eee;
    }
}

.msp-job-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.msp-job-title {
    font-size: 18px;
    font-weight: 600;
    color: #212529;
    margin: 0;
}

.msp-job-number {
    font-size: 14px;
    color: #6c757d;
    margin: 0;
}

.msp-job-actions {
    display: flex;
    gap: 8px;
}

.msp-job-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.msp-job-detail {
    font-size: 14px;
}

.msp-job-detail strong {
    color: #495057;
    display: block;
    margin-bottom: 4px;
}

.msp-job-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 16px;
    border-top: 1px solid #dee2e6;
}

.msp-status-update {
    display: flex;
    align-items: center;
    gap: 12px;
}

.msp-status-update select {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

/* Status Badges */
.msp-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.msp-status-in_transit_pickup {
    background: #fff3cd;
    color: #856404;
}

.msp-status-arrived_pickup {
    background: #d1ecf1;
    color: #0c5460;
}

.msp-status-departed_pickup {
    background: #d4edda;
    color: #155724;
}

.msp-status-storage_transit {
    background: #f8d7da;
    color: #721c24;
}

.msp-status-left_storage {
    background: #e2e3e5;
    color: #383d41;
}

.msp-status-in_transit_destination {
    background: #cce5ff;
    color: #004085;
}

.msp-status-icon {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

/* Pagination */
.msp-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 24px;
    border-top: 1px solid #dee2e6;
}

.msp-pagination-btn {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    background: white;
    color: #495057;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.msp-pagination-btn:hover {
    background: #f8f9fa;
}

.msp-pagination-btn.active {
    background: #007cba;
    color: white;
    border-color: #007cba;
}

.msp-pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Client Tracker Styles */
.msp-client-tracker {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.msp-tracker-header {
    text-align: center;
    margin-bottom: 40px;
}

.msp-tracker-header h2 {
    font-size: 28px;
    color: #212529;
    margin-bottom: 12px;
}

.msp-tracker-header p {
    font-size: 16px;
    color: #6c757d;
    margin: 0;
}

.msp-tracking-form {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
}

.msp-input-group {
    display: flex;
    gap: 12px;
}

.msp-input-group input {
    flex: 1;
    padding: 14px 16px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 16px;
}

.msp-tracking-results {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.msp-job-details {
    padding: 30px;
}

.msp-job-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #dee2e6;
}

.msp-job-header h3 {
    font-size: 24px;
    color: #212529;
    margin-bottom: 8px;
}

.msp-client-name {
    font-size: 18px;
    color: #6c757d;
}

.msp-current-status {
    text-align: center;
    margin-bottom: 30px;
}

.msp-addresses {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.msp-address-item h4 {
    font-size: 16px;
    color: #495057;
    margin-bottom: 8px;
}

.msp-address {
    font-size: 14px;
    color: #6c757d;
    line-height: 1.5;
}

.msp-status-history h4 {
    font-size: 20px;
    color: #212529;
    margin-bottom: 20px;
}

/* Timeline Styles */
.msp-timeline {
    position: relative;
    padding-left: 30px;
}

.msp-timeline::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #dee2e6;
}

.msp-timeline-item {
    position: relative;
    margin-bottom: 20px;
}

.msp-timeline-marker {
    position: absolute;
    left: -22px;
    top: 0;
    width: 16px;
    height: 16px;
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.msp-timeline-item.msp-current .msp-timeline-marker {
    border-color: #007cba;
    background: #007cba;
}

.msp-timeline-icon {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #dee2e6;
}

.msp-timeline-item.msp-current .msp-timeline-icon {
    background: white;
}

.msp-timeline-content {
    padding: 8px 0;
}

.msp-timeline-status {
    font-weight: 500;
    color: #212529;
    margin-bottom: 4px;
}

.msp-timeline-date {
    font-size: 14px;
    color: #6c757d;
}

/* Timeline Note Styles */
.msp-timeline-note {
    background: #f8f9ff;
    border-left: 3px solid #007cba;
    padding: 12px;
    border-radius: 4px;
    margin-top: 8px;
    font-style: italic;
    color: #495057;
    line-height: 1.4;
}

.msp-timeline-note-label {
    font-weight: 600;
    color: #007cba;
    font-size: 14px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.msp-timeline-note-label::before {
    content: "💬";
    font-size: 16px;
}

/* Different styling for note timeline items */
.msp-timeline-item.msp-timeline-note .msp-timeline-marker {
    border-color: #007cba;
    background: #f8f9ff;
}

.msp-timeline-item.msp-timeline-note .msp-timeline-icon {
    color: #007cba;
    font-size: 10px;
}

/* Status timeline items */
.msp-timeline-item.msp-timeline-status .msp-timeline-marker {
    border-color: #28a745;
    background: #d4edda;
}

.msp-timeline-item.msp-timeline-status .msp-timeline-icon {
    background: #28a745;
}

/* Admin user info in timeline */
.msp-timeline-admin {
    font-size: 12px;
    color: #6c757d;
    margin-top: 4px;
    font-style: italic;
}

.msp-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    padding-top: 30px;
    border-top: 1px solid #dee2e6;
}

/* History Modal */
.msp-history-content {
    padding: 24px;
    max-height: 400px;
    overflow-y: auto;
}

/* Responsive Design */
@media (max-width: 768px) {
    .msp-filters {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .msp-form-row {
        grid-template-columns: 1fr;
    }
    
    .msp-job-details {
        grid-template-columns: 1fr;
    }
    
    .msp-job-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .msp-job-actions {
        width: 100%;
        justify-content: flex-start;
    }
    
    .msp-job-status {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .msp-status-update {
        width: 100%;
    }
    
    .msp-input-group {
        flex-direction: column;
    }
    
    .msp-addresses {
        grid-template-columns: 1fr;
    }
    
    .msp-actions {
        flex-direction: column;
    }
    
    .msp-modal {
        padding: 10px;
    }
    
    .msp-modal-content {
        max-height: 95vh;
    }
}

@media (max-width: 480px) {
    .msp-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .msp-job-card {
        padding: 16px;
    }
    
    .msp-tracking-form {
        padding: 20px;
    }
    
    .msp-job-details {
        padding: 20px;
    }
    
    /* Better button layout for mobile */
    .msp-job-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .msp-job-actions .msp-btn {
        width: 100%;
        justify-content: center;
        padding: 12px 16px;
        font-size: 14px;
    }
    
    /* Stack filters vertically on mobile */
    .msp-filters {
        flex-direction: column;
        gap: 12px;
    }
    
    .msp-search-box,
    .msp-filter-box,
    .msp-sort-box {
        width: 100%;
    }
    
    /* Better pagination for mobile */
    .msp-pagination {
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .msp-pagination-btn {
        min-width: 44px;
        padding: 10px 8px;
    }
    
    /* Form improvements for mobile */
    .msp-form-row {
        flex-direction: column;
    }
    
    .msp-form-group {
        width: 100%;
    }
    
    /* Timeline improvements for mobile */
    .msp-timeline-item {
        padding-left: 30px;
    }
    
    .msp-timeline-marker {
        left: 10px;
    }
}

/* Portrait mode specific styles */
@media (max-width: 768px) and (orientation: portrait) {
    .msp-admin-panel {
        padding: 10px;
    }
    
    .msp-job-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .msp-job-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    .msp-job-actions .msp-btn {
        font-size: 12px;
        padding: 8px 12px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    /* Better spacing for job cards in portrait */
    .msp-job-card {
        margin-bottom: 16px;
    }
    
    .msp-job-details {
        font-size: 14px;
    }
    
    /* Client tracker improvements */
    .msp-client-tracker {
        padding: 15px;
    }
    
    .msp-input-group {
        flex-direction: column;
        gap: 12px;
    }
    
    .msp-input-group input {
        width: 100%;
        margin-bottom: 12px;
    }
    
    .msp-input-group button {
        width: 100%;
    }
    
    /* Status badge improvements */
    .msp-status-badge {
        font-size: 11px;
        padding: 4px 8px;
    }
    
    /* Modal improvements for portrait */
    .msp-modal-content {
        margin: 20px 10px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .msp-modal-header {
        padding: 15px 20px;
    }
    
    .msp-job-form {
        padding: 20px;
    }
    
    /* Form actions stack vertically */
    .msp-form-actions {
        flex-direction: column;
        gap: 12px;
    }
    
    .msp-form-actions .msp-btn {
        width: 100%;
    }
}

/* Landscape mode on mobile devices */
@media (max-width: 768px) and (orientation: landscape) {
    .msp-job-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .msp-job-actions .msp-btn {
        flex: 1;
        min-width: 80px;
        font-size: 11px;
        padding: 6px 8px;
    }
    
    .msp-modal-content {
        max-height: 85vh;
    }
}

/* Touch-friendly improvements */
@media (pointer: coarse) {
    .msp-btn {
        min-height: 44px;
        padding: 12px 20px;
    }
    
    .msp-pagination-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .msp-status-select {
        min-height: 44px;
        padding: 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    textarea,
    select {
        min-height: 44px;
        padding: 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
}