/* Silva Jobsite Plugin - Modern UX/UI Design */

:root {
    --silva-primary: #667eea;
    --silva-primary-dark: #764ba2;
    --silva-success: #10b981;
    --silva-danger: #ef4444;
    --silva-warning: #ff9800;
    --silva-gray-50: #f9fafb;
    --silva-gray-100: #f3f4f6;
    --silva-gray-200: #e5e7eb;
    --silva-gray-300: #d1d5db;
    --silva-gray-700: #374151;
    --silva-gray-900: #111827;
    --silva-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --silva-shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
    --silva-header-height: 60px;
    --silva-nav-height: 80px;
}

/* Mobile-First Reset for Work Glove Friendly Design */
* {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    -webkit-touch-callout: none;
}

/* ========================================
   APP SHELL STRUCTURE - MOBILE OPTIMIZED
   ======================================== */

/* Main App Container - Normal Page Flow */
.silva-app-shell {
    position: relative;
    display: block;
    background: #ffffff;
    min-height: 100vh;
    /* iOS Safe Area Support for Notch and Home Indicator */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Fullscreen Mode - Only when explicitly needed (mobile app) */
.silva-app-shell-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99999;
}

/* Hide WordPress Theme Footer ONLY in Fullscreen Mode */
body:has(.silva-app-shell-fullscreen) footer,
body:has(.silva-app-shell-fullscreen) .site-footer,
body:has(.silva-app-shell-fullscreen) #footer,
body:has(.silva-app-shell-fullscreen) .footer,
body:has(.silva-app-shell-fullscreen) .footer-wrapper,
body:has(.silva-app-shell-fullscreen) #colophon,
body:has(.silva-app-shell-fullscreen) .site-info {
    display: none !important;
    visibility: hidden !important;
}

/* Lock Body ONLY in Fullscreen Mode */
body:has(.silva-app-shell-fullscreen) {
    overflow: hidden !important;
    height: 100vh !important;
    position: fixed !important;
    width: 100% !important;
}

/* Header - Fixed Top (only in fullscreen mode) */
.silva-app-shell-fullscreen .silva-app-header {
    min-height: calc(var(--silva-header-height) + env(safe-area-inset-top));
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 0 20px 10px 20px;
    padding-top: env(safe-area-inset-top);
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
    z-index: 100;
}

.silva-app-header-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1;
    padding-bottom: 2px;
}

.silva-app-logout {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    text-decoration: none;
    color: white;
    font-weight: 600;
    font-size: 14px;
    line-height: 1;
    white-space: nowrap;
    transition: all 0.2s ease;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.silva-app-logout:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.silva-logout-icon {
    font-size: 18px;
}

.silva-logout-text {
    font-size: 14px;
}

/* Content Area - Scrollable (fullscreen mode) */
.silva-app-shell-fullscreen .silva-app-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    background: #ffffff;
    position: relative;
    z-index: 1;
    isolation: isolate;
}

/* Content Area - Normal page flow *(only in fullscreen mode) */
.silva-app-shell-fullscreen .silva-app-content {
    background: #ffffff;
    position: relative;
}

/* Bottom Navigation - Fixed Bottom */
.silva-app-nav {
    min-height: calc(var(--silva-nav-height) + env(safe-area-inset-bottom));
    background: #ffffff;
    border-top: 3px solid var(--silva-gray-200);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: var(--silva-nav-height);
    align-content: start;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
    z-index: 100;
}

.silva-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #6b7280;
    transition: all 0.2s ease;
    padding: 10px 8px;
    border: none;
    background: none;
    height: var(--silva-nav-height);
}

.silva-nav-item:hover {
    background: var(--silva-gray-50);
}

.silva-nav-item.active {
    color: var(--silva-primary);
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
}

.silva-nav-icon {
    font-size: 28px;
    margin-bottom: 4px;
    line-height: 1;
}

.silva-nav-label {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Employee Pages - Cards & Containers */
.silva-clock-wrap,
.silva-material-wrap,
.silva-profile-wrap,
.silva-tasks-wrap,
.silva-login-wrap {
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
    background: #ffffff !important;
    min-height: auto;
    position: relative;
}

/* Clock Wrap - Centered Content */
.silva-clock-wrap {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Profile, Material, and Tasks Wraps - Full Content */
.silva-profile-wrap,
.silva-material-wrap,
.silva-tasks-wrap {
    display: block;
    justify-content: flex-start;
}

@media (min-width: 768px) {
    /* Tablet: Maintain accessible button sizing */
    .silva-btn {
        padding: 14px 28px;
        font-size: 16px;
        min-height: auto;
    }
    
    /* Scale inputs for tablet */
    .silva-field input,
    .silva-field select,
    .silva-field textarea {
        padding: 14px 16px;
        font-size: 16px;
        min-height: 48px;
    }
}

@media (min-width: 1024px) {
    /* Desktop: Standard estimator sizing */
    .silva-btn {
        padding: 12px 24px;
        font-size: 15px;
        min-height: auto;
    }
    
    .silva-field input,
    .silva-field select,
    .silva-field textarea {
        padding: 12px 16px;
        font-size: 15px;
        min-height: 48px;
    }
    
    .silva-field label {
        font-size: 16px;
    }
    
    /* Multi-column layouts for wider screens */
    .silva-profile-wrap [style*="grid-template-columns: 1fr 1fr 1fr"] {
        gap: 16px !important;
    }
    
    .silva-clock-wrap [style*="grid-template-columns: 1fr 1fr"] {
        gap: 16px !important;
    }
}

.silva-clock-title {
    text-align: center;
    margin: 0 0 24px;
    font-size: 24px;
    font-weight: 700;
    color: var(--silva-gray-900);
    letter-spacing: -0.025em;
}

/* Form Fields - Mobile Optimized with Large Touch Targets */
.silva-field {
    margin-bottom: 20px;
}

.silva-field-inline {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 768px) {
    .silva-field-inline {
        grid-template-columns: 1fr 1fr;
    }
}

.silva-field label {
    display: block;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--silva-gray-900);
    font-size: 18px;
}

.silva-field input,
.silva-field select,
.silva-field textarea {
    width: 100%;
    padding: 18px 16px;
    border-radius: 12px;
    border: 3px solid var(--silva-gray-300);
    font-size: 18px;
    transition: all 0.2s ease;
    background: white;
    min-height: 56px; /* Minimum 48px recommended for mobile touch */
    font-weight: 500;
}

.silva-field input:focus,
.silva-field select:focus,
.silva-field textarea:focus {
    outline: none;
    border-color: var(--silva-primary);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
}

.silva-field input:disabled,
.silva-field select:disabled {
    background: var(--silva-gray-100);
    cursor: not-allowed;
    opacity: 0.6;
}

/* Auto-filled job selection indicator */
.silva-field select.silva-auto-filled {
    border-color: var(--silva-success);
    background: linear-gradient(135deg, #f0fdf4 0%, #ffffff 100%);
}

.silva-field select.silva-auto-filled:focus {
    border-color: var(--silva-success);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15);
}

/* Timer Display */
.silva-timer {
    text-align: center;
    margin: 32px 0;
}

.silva-timer-circle {
    width: 160px;
    height: 160px;
    margin: 0 auto 16px;
    border-radius: 50%;
    border: 6px solid var(--silva-success);
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    font-weight: 700;
    color: var(--silva-gray-900);
    box-shadow: 0 8px 16px rgba(16, 185, 129, 0.15);
    transition: all 0.3s ease;
}

.silva-timer-circle:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 24px rgba(16, 185, 129, 0.2);
}

.silva-timer-label {
    color: var(--silva-gray-700);
    font-size: 14px;
    font-weight: 500;
}

/* Buttons - Hub Standardized Sizing */
.silva-actions {
    text-align: center;
    margin: 24px 0;
}

.silva-btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s ease;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-height: auto;
    width: 100%;
}

.silva-btn:hover,
.silva-btn:active {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.silva-btn-primary {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
}

.silva-btn-primary:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.silva-btn-secondary {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #fff;
}

.silva-btn-secondary:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

.silva-btn-outline {
    background: white;
    border: 4px solid var(--silva-primary);
    color: var(--silva-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.silva-btn-outline:hover {
    background: var(--silva-primary);
    color: white;
}

.silva-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Photo Upload Form */
.silva-photo-form {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 2px solid var(--silva-gray-200);
}

/* Tips & Info Boxes */
.silva-tip-box {
    margin-top: 24px;
    padding: 14px 16px;
    border-radius: 10px;
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
    border-left: 4px solid var(--silva-primary);
    font-size: 14px;
    color: var(--silva-gray-700);
    line-height: 1.6;
}

.silva-tip-box strong {
    color: var(--silva-primary);
    font-weight: 700;
}

.silva-tip {
    margin-top: 8px;
    font-size: 13px;
    color: var(--silva-gray-700);
    font-style: italic;
}

/* Login Form Specific */
.silva-login-form {
    margin-top: 24px;
}

.silva-login-form button {
    width: 100%;
    margin-top: 8px;
}

/* Material Request Form */
.silva-material-form button {
    width: 100%;
    margin-top: 8px;
}

/* Admin Tables Enhancement */
.widefat.silva-enhanced {
    border: 1px solid var(--silva-gray-200);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--silva-shadow);
}

.widefat.silva-enhanced thead {
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
}

.widefat.silva-enhanced thead th {
    font-weight: 700;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.05em;
    color: var(--silva-gray-700);
    padding: 14px 12px;
    border-bottom: 2px solid var(--silva-gray-300);
}

.widefat.silva-enhanced tbody tr {
    transition: background-color 0.15s ease;
}

.widefat.silva-enhanced tbody tr:hover {
    background: var(--silva-gray-50);
}

/* Status Badges */
.silva-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.silva-badge-success {
    background: #d1fae5;
    color: #065f46;
}

.silva-badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.silva-badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.silva-badge-info {
    background: #dbeafe;
    color: #1e40af;
}

/* Loading States */
.silva-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--silva-gray-200);
    border-radius: 50%;
    border-top-color: var(--silva-primary);
    animation: silva-spin 0.8s linear infinite;
}

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

/* Success Messages */
.silva-success-message {
    padding: 12px 16px;
    background: #d1fae5;
    border-left: 4px solid var(--silva-success);
    border-radius: 8px;
    color: #065f46;
    font-weight: 500;
    margin-bottom: 20px;
}

.silva-error-message {
    padding: 12px 16px;
    background: #fee2e2;
    border-left: 4px solid var(--silva-danger);
    border-radius: 8px;
    color: #991b1b;
    font-weight: 500;
    margin-bottom: 20px;
}

/* Mobile Responsive Improvements - Work Glove Optimized */
@media (max-width: 640px) {
    body {
        font-size: 16px;
    }
    
    .silva-btn {
        width: 100%;
        padding: 14px 24px;
        font-size: 16px;
        min-height: auto;
    }
    
    .silva-field input,
    .silva-field select,
    .silva-field textarea {
        font-size: 16px;
        padding: 14px 16px;
        min-height: 48px;
    }
    
    .silva-field label {
        font-size: 16px;
        margin-bottom: 12px;
    }
}

/* Very Small Screens - Compact Navigation */
@media (max-width: 380px) {
    .silva-nav-icon {
        font-size: 24px;
        margin-bottom: 2px;
    }
    
    .silva-nav-label {
        font-size: 11px;
    }
    
    .silva-nav-item {
        padding: 8px 4px;
    }
}

/* High Contrast for Outdoor Visibility */
@media (prefers-contrast: high) {
    .silva-btn {
        border: 4px solid currentColor;
    }
    
    .silva-field input,
    .silva-field select {
        border-width: 4px;
    }
}

/* ==========================================================================
   HUB MODAL SYSTEM - Unified with Estimator Dashboard
   ========================================================================== */

/* Modal wrapper - fixed full screen */
.silva-modal,
.modal-overlay,
.hub-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    z-index: 10000 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(0, 0, 0, 0.5) !important;
    backdrop-filter: blur(4px);
}

/* Hidden state */
.silva-modal[style*="display: none"],
.silva-modal[style*="display:none"],
.hub-modal[style*="display: none"],
.hub-modal[style*="display:none"] {
    display: none !important;
}

/* Modal content - centered box */
.modal-content,
.hub-modal-content {
    position: relative !important;
    background: white !important;
    border-radius: 12px !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3) !important;
    max-width: 600px !important;
    width: 90% !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
    animation: modalSlideIn 0.3s ease-out;
    z-index: 10001 !important;
    margin: 0 !important;
    transform: none !important;
}

.modal-content.modal-large,
.hub-modal-content.modal-large {
    max-width: 900px !important;
}

/* Prevent body scroll when modal open */
body.modal-open {
    overflow: hidden !important;
}

/* Modal animation */
@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Modal header */
.modal-header,
.hub-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
    border-radius: 12px 12px 0 0;
}

.modal-header h2,
.modal-header h3,
.hub-modal-header h2,
.hub-modal-header h3 {
    margin: 0 !important;
    font-size: 20px !important;
    font-weight: 600 !important;
    color: #1f2937 !important;
}

/* Modal close button */
.modal-close,
.hub-modal-close {
    background: none !important;
    border: none !important;
    font-size: 28px !important;
    color: #9ca3af !important;
    cursor: pointer !important;
    padding: 0 !important;
    width: 32px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 6px !important;
    transition: all 0.2s !important;
    line-height: 1 !important;
}

.modal-close:hover,
.hub-modal-close:hover {
    background: #f3f4f6 !important;
    color: #1f2937 !important;
}

/* Modal body */
.modal-body,
.hub-modal-body {
    padding: 24px;
}

/* Modal footer */
.modal-footer,
.hub-modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
    position: sticky;
    bottom: 0;
    background: white;
    border-radius: 0 0 12px 12px;
}

/* Mobile modal adjustments */
@media (max-width: 768px) {
    .modal-content,
    .hub-modal-content {
        width: 95% !important;
        max-height: 95vh !important;
    }
    
    .modal-header,
    .hub-modal-header {
        padding: 16px 20px;
    }
    
    .modal-body,
    .hub-modal-body {
        padding: 20px;
    }
    
    .modal-footer,
    .hub-modal-footer {
        padding: 16px 20px;
        flex-wrap: wrap;
    }
    
    .modal-footer .hub-btn,
    .hub-modal-footer .hub-btn,
    .modal-footer .silva-btn,
    .hub-modal-footer .silva-btn {
        flex: 1;
        min-width: 120px;
    }
}

/* ==========================================================================
   HUB BUTTON SYSTEM - Unified with Estimator Dashboard
   ========================================================================== */

/* Hub button variants matching estimator */
.hub-btn {
    display: inline-block;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.hub-btn-primary {
    background: white;
    color: #667eea;
}

.hub-btn-primary:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.hub-btn-small {
    padding: 8px 16px;
    font-size: 13px;
}

.hub-btn-success {
    background: #10b981;
    color: white;
}

.hub-btn-success:hover {
    background: #059669;
}

.hub-btn-warning {
    background: #ff9800;
    color: white;
}

.hub-btn-warning:hover {
    background: #f57c00;
}

.hub-btn-danger {
    background: #ef4444;
    color: white;
}

.hub-btn-danger:hover {
    background: #dc2626;
}

.hub-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Smooth Animations */
* {
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

input, select, textarea, button {
    transition: all 0.2s ease;
}
