/**
 * Rehoboth Digital Job Cards - Utility Styles
 * Common CSS for toast notifications, loading spinners, modals, etc.
 */

/* =============================================================================
   TOAST NOTIFICATIONS
   ============================================================================= */

.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
    pointer-events: none;
}

.toast {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius-lg, 12px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    transform: translateX(450px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: auto;
    border-left: 4px solid;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    color: var(--gray-800, #1f2937);
    font-size: 14px;
    line-height: 1.5;
}

.toast-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--gray-400, #9ca3af);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    flex-shrink: 0;
}

.toast-close:hover {
    color: var(--gray-700, #374151);
}

/* Toast Types */
.toast-success {
    border-left-color: var(--success, #10b981);
}

.toast-success .toast-icon {
    color: var(--success, #10b981);
}

.toast-error {
    border-left-color: var(--danger, #ef4444);
}

.toast-error .toast-icon {
    color: var(--danger, #ef4444);
}

.toast-warning {
    border-left-color: var(--warning, #f59e0b);
}

.toast-warning .toast-icon {
    color: var(--warning, #f59e0b);
}

.toast-info {
    border-left-color: var(--primary, #399fdc);
}

.toast-info .toast-icon {
    color: var(--primary, #399fdc);
}

/* =============================================================================
   LOADING SPINNER
   ============================================================================= */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.loading-overlay.show {
    opacity: 1;
}

.loading-spinner-container {
    background: white;
    padding: 2.5rem 3rem;
    border-radius: var(--radius-xl, 16px);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    text-align: center;
    min-width: 200px;
}

.loading-spinner {
    width: 56px;
    height: 56px;
    border: 5px solid var(--gray-200, #e5e7eb);
    border-top-color: var(--primary, #399fdc);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

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

.loading-message {
    color: var(--gray-700, #374151);
    font-size: 16px;
    font-weight: 500;
    margin: 0;
}

/* =============================================================================
   FORM VALIDATION
   ============================================================================= */

input.invalid,
select.invalid,
textarea.invalid {
    border-color: var(--danger, #ef4444) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

.field-error {
    color: var(--danger, #ef4444);
    font-size: 13px;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.field-error::before {
    content: '⚠';
    font-size: 14px;
}

/* =============================================================================
   CONFIRM MODAL
   ============================================================================= */

.confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirm-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.confirm-modal-content {
    position: relative;
    background: white;
    border-radius: var(--radius-xl, 16px);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    max-width: 400px;
    width: 90%;
    padding: 2rem;
}

.confirm-modal-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900, #111827);
    margin-bottom: 1rem;
}

.confirm-modal-message {
    color: var(--gray-700, #374151);
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 2rem;
}

.confirm-modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.confirm-modal-cancel,
.confirm-modal-confirm {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-lg, 12px);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.confirm-modal-cancel {
    background: var(--gray-100, #f3f4f6);
    color: var(--gray-700, #374151);
}

.confirm-modal-cancel:hover {
    background: var(--gray-200, #e5e7eb);
}

.confirm-modal-confirm {
    background: var(--primary, #399fdc);
    color: white;
}

.confirm-modal-confirm:hover {
    background: var(--primary-dark, #1f7fb5);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(57, 159, 220, 0.3);
}

/* =============================================================================
   KEYBOARD HELP MODAL
   ============================================================================= */

.keyboard-help-modal {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
}

.keyboard-help-content {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius-lg, 12px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    max-width: 300px;
}

.keyboard-help-content h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-900, #111827);
    margin-bottom: 1rem;
}

.keyboard-help-content ul {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem 0;
}

.keyboard-help-content li {
    padding: 0.5rem 0;
    color: var(--gray-700, #374151);
    font-size: 14px;
}

.keyboard-help-content kbd {
    background: var(--gray-100, #f3f4f6);
    border: 1px solid var(--gray-300, #d1d5db);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: monospace;
    font-size: 12px;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1);
}

.keyboard-help-content button {
    width: 100%;
    padding: 0.5rem 1rem;
    background: var(--gray-100, #f3f4f6);
    border: none;
    border-radius: var(--radius-md, 8px);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    color: var(--gray-700, #374151);
    transition: background 0.2s;
}

.keyboard-help-content button:hover {
    background: var(--gray-200, #e5e7eb);
}

/* =============================================================================
   EMPTY STATES
   ============================================================================= */

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-state-icon {
    font-size: 64px;
    opacity: 0.3;
    margin-bottom: 1.5rem;
}

.empty-state-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-800, #1f2937);
    margin-bottom: 0.5rem;
}

.empty-state-message {
    color: var(--gray-600, #4b5563);
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 2rem;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.empty-state-action {
    background: var(--primary, #399fdc);
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: var(--radius-full, 9999px);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.empty-state-action:hover {
    background: var(--primary-dark, #1f7fb5);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(57, 159, 220, 0.3);
}

/* =============================================================================
   TOOLTIPS
   ============================================================================= */

.tooltip-wrapper {
    position: relative;
    display: inline-block;
}

.tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: var(--gray-900, #111827);
    color: white;
    padding: 6px 12px;
    border-radius: var(--radius-md, 8px);
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1000;
}

.tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--gray-900, #111827);
}

.tooltip-wrapper:hover .tooltip,
.tooltip.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-4px);
}

/* Tooltip positions */
.tooltip.top {
    bottom: 100%;
    top: auto;
}

.tooltip.bottom {
    top: 100%;
    bottom: auto;
    transform: translateX(-50%) translateY(8px);
}

.tooltip.bottom::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: var(--gray-900, #111827);
}

/* =============================================================================
   COPY BUTTON
   ============================================================================= */

.copy-btn {
    background: none;
    border: none;
    color: var(--primary, #399fdc);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm, 6px);
    font-size: 14px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.copy-btn:hover {
    background: var(--gray-100, #f3f4f6);
}

.copy-btn:active {
    transform: scale(0.95);
}

.copy-btn.copied {
    color: var(--success, #10b981);
}

/* =============================================================================
   HELP MODAL
   ============================================================================= */

.help-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10002;
    display: none;
    align-items: center;
    justify-content: center;
}

.help-modal.show {
    display: flex;
}

.help-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.help-modal-content {
    position: relative;
    background: white;
    border-radius: var(--radius-xl, 16px);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    padding: 2rem;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.help-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--gray-200, #e5e7eb);
}

.help-modal-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900, #111827);
    margin: 0;
}

.help-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--gray-400, #9ca3af);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md, 8px);
    transition: all 0.2s;
}

.help-modal-close:hover {
    background: var(--gray-100, #f3f4f6);
    color: var(--gray-700, #374151);
}

.help-section {
    margin-bottom: 2rem;
}

.help-section-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-800, #1f2937);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.help-section-content {
    color: var(--gray-600, #4b5563);
    line-height: 1.7;
}

.help-section-content ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.help-section-content li {
    margin: 0.5rem 0;
}

.help-section-content kbd {
    background: var(--gray-100, #f3f4f6);
    border: 1px solid var(--gray-300, #d1d5db);
    border-radius: 4px;
    padding: 2px 6px;
    font-family: monospace;
    font-size: 12px;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1);
}

/* =============================================================================
   BREADCRUMBS
   ============================================================================= */

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0;
    font-size: 14px;
    color: var(--gray-600, #4b5563);
}

.breadcrumbs a {
    color: var(--primary, #399fdc);
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumbs a:hover {
    color: var(--primary-dark, #1f7fb5);
    text-decoration: underline;
}

.breadcrumbs .separator {
    color: var(--gray-400, #9ca3af);
}

.breadcrumbs .current {
    font-weight: 600;
    color: var(--gray-800, #1f2937);
}

/* =============================================================================
   RESPONSIVE DESIGN
   ============================================================================= */

/* =============================================================================
   MOBILE TABLE IMPROVEMENTS
   ============================================================================= */

@media (max-width: 968px) {
    /* Convert table to card layout on mobile */
    .job-cards-table {
        display: block;
    }
    
    .job-cards-table thead {
        display: none;
    }
    
    .job-cards-table tbody {
        display: block;
    }
    
    .job-cards-table tr {
        display: block;
        margin-bottom: 1rem;
        background: white;
        border: 1px solid var(--gray-200, #e5e7eb);
        border-radius: 12px;
        padding: 1rem;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }
    
    .job-cards-table td {
        display: grid;
        grid-template-columns: 120px 1fr;
        padding: 0.75rem 0;
        border: none !important;
        border-bottom: 1px solid var(--gray-100, #f3f4f6) !important;
    }
    
    .job-cards-table td:last-child {
        border-bottom: none !important;
    }
    
    .job-cards-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--gray-600, #4b5563);
        padding-right: 1rem;
    }
    
    /* Add data labels to cells */
    .job-cards-table td:nth-child(1)::before { content: "Job Card #"; }
    .job-cards-table td:nth-child(2)::before { content: "Urgency"; }
    .job-cards-table td:nth-child(3)::before { content: "Type of Job"; }
    .job-cards-table td:nth-child(4)::before { content: "Reported by"; }
    .job-cards-table td:nth-child(5)::before { content: "Division"; }
    .job-cards-table td:nth-child(6)::before { content: "Location Type"; }
    .job-cards-table td:nth-child(7)::before { content: "Driver"; }
    .job-cards-table td:nth-child(8)::before { content: "Vehicle"; }
    .job-cards-table td:nth-child(9)::before { content: "Artisan"; }
}

@media (max-width: 768px) {
    .toast-container {
        left: 20px;
        right: 20px;
        top: 70px;
    }
    
    .toast {
        min-width: auto;
        width: 100%;
    }
    
    .confirm-modal-content {
        width: calc(100% - 40px);
    }
    
    .keyboard-help-modal {
        left: 20px;
        right: 20px;
        bottom: 20px;
    }
    
    .keyboard-help-content {
        max-width: none;
    }
    
    .help-modal-content {
        padding: 1.5rem;
    }
}

/* =============================================================================
   PRINT STYLES
   ============================================================================= */

@media print {
    .toast-container,
    .loading-overlay,
    .confirm-modal,
    .keyboard-help-modal {
        display: none !important;
    }
}

