/**
 * Keyboard Shortcuts CSS
 * Visual styling for keyboard navigation and focus indicators
 */

/* =====================================================
   KEYBOARD FOCUS INDICATORS
   ===================================================== */

/* Enhanced focus outline for keyboard navigation */
.keyboard-focus-active {
    outline: 3px solid #4e73df !important;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(78, 115, 223, 0.25) !important;
    transition: all 0.2s ease;
}

/* Remove outline for mouse users (accessibility best practice) */
*:focus:not(:focus-visible) {
    outline: none;
}

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 3px solid #4e73df;
    outline-offset: 2px;
}

/* Enhanced focus for inputs */
input:focus,
select:focus,
textarea:focus {
    border-color: #4e73df !important;
    box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.25) !important;
}

/* Button focus states */
button:focus,
.btn:focus {
    box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.5) !important;
}

/* =====================================================
   CART KEYBOARD NAVIGATION
   ===================================================== */

/* Keyboard focused cart item */
#cartItems tr.keyboard-focused,
.mobile-cart-item.keyboard-focused {
    background-color: #e3f2fd !important;
    border-left: 4px solid #2196f3 !important;
    transform: scale(1.01);
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3) !important;
    transition: all 0.2s ease;
}

/* Selected cart items */
#cartItems tr.selected,
.mobile-cart-item.selected {
    background-color: #fff3cd !important;
    border-left: 4px solid #ffc107 !important;
}

/* Cart item hover (secondary to keyboard focus) */
#cartItems tr:hover:not(.keyboard-focused),
.mobile-cart-item:hover:not(.keyboard-focused) {
    background-color: #f8f9fa;
    cursor: pointer;
}

/* =====================================================
   KEYBOARD SHORTCUT HINTS
   ===================================================== */

/* Keyboard hint badges on buttons */
.kbd-hint {
    display: inline-block;
    padding: 2px 6px;
    margin-left: 6px;
    font-size: 9px;
    font-weight: 600;
    color: #fff;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    vertical-align: middle;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.btn:hover .kbd-hint,
button:hover .kbd-hint,
label:hover .kbd-hint {
    opacity: 1;
}

/* KBD element styling */
kbd {
    display: inline-block;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    color: #fff;
    background-color: #2c3e50;
    border-radius: 4px;
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
    font-family: 'Courier New', monospace;
    margin: 0 2px;
    white-space: nowrap;
}

kbd + kbd {
    margin-left: 4px;
}

/* =====================================================
   KEYBOARD INDICATOR (FLOATING)
   ===================================================== */

.keyboard-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 12px 20px;
    border-radius: 50px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    display: none;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    animation: slideInUp 0.5s ease, pulse 2s ease-in-out infinite;
}

.keyboard-indicator i {
    font-size: 18px;
}

.keyboard-indicator kbd {
    background-color: rgba(255, 255, 255, 0.3);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: none;
    padding: 3px 8px;
    font-size: 11px;
}

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

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

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

/* Shortcut section styling */
.shortcut-section {
    border-left: 4px solid #4e73df;
    padding-left: 15px;
    margin-bottom: 25px;
}

.shortcut-category {
    font-size: 16px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e9ecef;
}

.shortcut-category i {
    margin-right: 8px;
    font-size: 18px;
}

/* Individual shortcut item */
.shortcut-item {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f1f1f1;
    transition: background-color 0.2s ease;
}

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

.shortcut-item:hover {
    background-color: #f8f9fa;
    padding-left: 10px;
    margin-left: -10px;
    margin-right: -10px;
    padding-right: 10px;
}

.shortcut-item kbd {
    min-width: 45px;
    text-align: center;
    margin-right: 15px;
    flex-shrink: 0;
}

.shortcut-desc {
    color: #5a6c7d;
    font-size: 14px;
    flex-grow: 1;
}

/* Workflow examples */
.workflow-example {
    padding-left: 15px;
    border-left: 3px solid #28a745;
}

.workflow-example strong {
    color: #28a745;
    display: block;
    margin-bottom: 8px;
}

.workflow-example ol {
    margin-bottom: 0;
}

.workflow-example ol li {
    margin-bottom: 5px;
    color: #495057;
}

/* =====================================================
   PRODUCT SEARCH RESULTS KEYBOARD NAVIGATION
   ===================================================== */

.product-result-item.keyboard-focused,
.mobile-search-result-item.keyboard-focused {
    background-color: #e3f2fd !important;
    border-left: 4px solid #2196f3 !important;
    transform: scale(1.02);
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.4) !important;
    transition: all 0.15s ease;
}

/* =====================================================
   ACCESSIBILITY ENHANCEMENTS
   ===================================================== */

/* Skip to main content link */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 0;
    background: #4e73df;
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 10000;
    border-radius: 0 0 4px 0;
}

.skip-to-main:focus {
    top: 0;
}

/* Focus trap indicator for modals */
.modal.show::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 3px solid #4e73df;
    pointer-events: none;
    z-index: 1049;
    animation: modalFocusBorder 0.3s ease;
}

@keyframes modalFocusBorder {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* =====================================================
   PRINT STYLES FOR HELP GUIDE
   ===================================================== */

@media print {
    .keyboard-indicator,
    .modal-header button,
    .modal-footer {
        display: none !important;
    }
    
    .modal-dialog {
        max-width: 100% !important;
        margin: 0 !important;
    }
    
    .modal-content {
        border: none !important;
        box-shadow: none !important;
    }
    
    .shortcut-section {
        page-break-inside: avoid;
    }
    
    kbd {
        border: 1px solid #333;
        background-color: #f8f9fa;
        color: #333;
        box-shadow: none;
    }
}

/* =====================================================
   RESPONSIVE MOBILE KEYBOARD STYLES
   ===================================================== */

@media (max-width: 768px) {
    .keyboard-indicator {
        bottom: 80px;
        right: 10px;
        font-size: 12px;
        padding: 10px 16px;
    }
    
    .kbd-hint {
        display: none; /* Hide hints on small screens */
    }
    
    .shortcut-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .shortcut-item kbd {
        margin-bottom: 5px;
    }
    
    /* Stack shortcut columns on mobile */
    #keyboardShortcutsModal .row {
        display: block;
    }
    
    #keyboardShortcutsModal .col-md-6 {
        padding-left: 0;
        padding-right: 0;
    }
}

/* =====================================================
   KEYBOARD NAVIGATION HIGHLIGHTS
   ===================================================== */

/* Highlight active navigation area */
.nav-keyboard-active {
    outline: 2px dashed #4e73df;
    outline-offset: 5px;
}

/* Quick visual feedback for actions */
@keyframes actionFeedback {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(0.95);
        opacity: 0.7;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.keyboard-action-feedback {
    animation: actionFeedback 0.3s ease;
}

/* =====================================================
   CUSTOM SCROLLBAR FOR HELP MODAL
   ===================================================== */

#keyboardShortcutsModal .modal-body::-webkit-scrollbar {
    width: 8px;
}

#keyboardShortcutsModal .modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#keyboardShortcutsModal .modal-body::-webkit-scrollbar-thumb {
    background: #4e73df;
    border-radius: 4px;
}

#keyboardShortcutsModal .modal-body::-webkit-scrollbar-thumb:hover {
    background: #2e59d9;
}

/* =====================================================
   TOOLTIP ENHANCEMENTS FOR KEYBOARD USERS
   ===================================================== */

[data-keyboard-hint]::after {
    content: attr(data-keyboard-hint);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #2c3e50;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    margin-bottom: 5px;
    z-index: 1000;
}

[data-keyboard-hint]:focus::after,
[data-keyboard-hint]:hover::after {
    opacity: 1;
}

/* =====================================================
   DISABLED STATE FOR KEYBOARD NAVIGATION
   ===================================================== */

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button:disabled:focus,
input:disabled:focus,
select:disabled:focus,
textarea:disabled:focus {
    outline: none !important;
    box-shadow: none !important;
}
