/* Tab Navigation Styles for BC-UR Playground */
/* Mobile-first, touch-optimized design matching purple gradient theme */

/* Tab Navigation Container (Sticky Header) */
.tab-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: white;
    border-bottom: 2px solid #e1e4e8;
    margin: -40px -40px 30px -40px; /* Extend to container edges */
    padding: 0 40px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Tab button container - mobile-first vertical stack */
.tab-buttons {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
}

/* Individual Tab Buttons */
.tab-button {
    flex: 1;
    padding: 16px 20px;
    background: white;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 15px;
    font-weight: 500;
    color: #586069;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    min-height: 44px; /* Touch target minimum */
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
}

.tab-button:hover {
    background: #f6f8fa;
    color: #24292e;
}

.tab-button:focus {
    outline: 2px solid #667eea;
    outline-offset: -2px;
}

/* Active Tab State */
.tab-button.active {
    color: #667eea;
    background: linear-gradient(to bottom, white 0%, #f6f8fa 100%);
    border-bottom-color: #667eea;
    font-weight: 600;
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

/* Tab icon styling */
.tab-button .tab-icon {
    font-size: 18px;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.tab-button.active .tab-icon {
    opacity: 1;
}

/* Tab Content Containers */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

.tab-content.hidden {
    display: none;
}

/* Mobile swipe hint */
.tab-nav::after {
    content: '';
    display: none;
}

@media (max-width: 599px) and (hover: none) and (pointer: coarse) {
    .tab-nav::after {
        content: 'Swipe tabs to navigate →';
        display: block;
        text-align: center;
        font-size: 11px;
        color: #586069;
        padding: 4px 0 8px;
        opacity: 0.7;
        animation: fadeOut 3s ease forwards;
    }
}

@keyframes fadeOut {
    0%, 70% { opacity: 0.7; }
    100% { opacity: 0; }
}

/* Smooth fade-in animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Tablet breakpoint (600px+) - 2 columns */
@media (min-width: 600px) {
    .tab-buttons {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .tab-button {
        flex: 1 1 50%; /* 2 columns */
        text-align: center;
        justify-content: center;
        border-bottom: none;
        border-bottom: 3px solid transparent;
    }
}

/* Desktop breakpoint (900px+) - horizontal layout */
@media (min-width: 900px) {
    .tab-buttons {
        flex-wrap: nowrap;
    }

    .tab-button {
        flex: 1 1 auto; /* Equal width distribution */
        min-width: 0;
    }
}

/* Accessibility: Reduce motion preference */
@media (prefers-reduced-motion: reduce) {
    .tab-button,
    .tab-content {
        animation: none;
        transition: none;
    }
}

/* Focus visible for keyboard navigation */
.tab-button:focus-visible {
    outline: 3px solid #667eea;
    outline-offset: -3px;
    border-radius: 4px;
}

/* Disabled state (for future use) */
.tab-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f6f8fa;
}

.tab-button:disabled:hover {
    background: #f6f8fa;
    color: #586069;
}

/* Loading state for tab content */
.tab-content.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Tab badge (for notifications/counts) */
.tab-badge {
    display: inline-block;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: #dc3545;
    color: white;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    line-height: 20px;
    text-align: center;
    margin-left: auto;
}

.tab-button.active .tab-badge {
    background: #667eea;
}

/* Tab label text */
.tab-label {
    flex: 1;
}

/* Compact mobile layout (< 400px) */
@media (max-width: 399px) {
    .tab-nav {
        margin: -40px -20px 20px -20px; /* Adjust for smaller container padding */
        padding: 0 20px;
    }

    .tab-button {
        padding: 14px 16px;
        font-size: 14px;
    }

    .tab-button .tab-icon {
        font-size: 16px;
    }
}

/* Print styles */
@media print {
    .tab-nav {
        position: static;
        border-bottom: 1px solid #e1e4e8;
        box-shadow: none;
    }

    .tab-button:not(.active) {
        display: none;
    }

    .tab-content:not(.active) {
        display: none;
    }
}

/* ===== QR Scanner Styles ===== */

/* Scanner Controls */
.scanner-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

/* Video Preview Container */
.scanner-preview {
    width: 100%;
    max-width: 600px;
    margin: 16px auto;
    border: 2px solid #e1e4e8;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    position: relative;
}

#scanner-video {
    width: 100%;
    height: auto;
    display: block;
    max-height: 450px;
    object-fit: contain;
}

/* Progress Bar Container */
.progress-bar-container {
    width: 100%;
    height: 8px;
    background: #e1e4e8;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    width: 0%;
    transition: width 0.3s ease;
}

/* Blocks Grid Visualization */
.blocks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 8px;
    margin-top: 12px;
    padding: 12px;
    background: #f6f8fa;
    border-radius: 6px;
}

.block-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #e1e4e8;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: help;
}

/* Block States */
.block-cell.pending {
    background: #e1e4e8;
    color: #586069;
}

.block-cell.seen {
    background: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

.block-cell.decoded {
    background: #d4edda;
    border-color: #28a745;
    color: #155724;
    animation: blockDecoded 0.5s ease;
}

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

/* Grid Legend */
.grid-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 12px;
    padding: 8px;
    font-size: 13px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-color {
    width: 24px;
    height: 24px;
    border: 2px solid #e1e4e8;
    border-radius: 4px;
}

.legend-color.pending {
    background: #e1e4e8;
}

.legend-color.seen {
    background: #fff3cd;
    border-color: #ffc107;
}

.legend-color.decoded {
    background: #d4edda;
    border-color: #28a745;
}

/* Troubleshooting Tips */
.troubleshooting {
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    padding: 12px 16px;
    font-size: 13px;
    color: #856404;
}

.troubleshooting ul {
    margin: 8px 0 0 20px;
    padding: 0;
}

.troubleshooting li {
    margin: 4px 0;
}

/* Usage Instructions */
.usage-instructions {
    margin-top: 32px;
    padding: 16px;
    background: #f6f8fa;
    border-radius: 6px;
    font-size: 14px;
}

.usage-instructions ol {
    margin: 12px 0;
    padding-left: 24px;
}

.usage-instructions li {
    margin: 8px 0;
}

/* Mobile Optimizations for Scanner */
@media (max-width: 768px) {
    .scanner-preview {
        margin: 12px 0;
    }
    
    #scanner-video {
        max-height: 350px;
    }
    
    .blocks-grid {
        grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
        gap: 6px;
    }
    
    .block-cell {
        font-size: 11px;
    }
}

/* ===== Multi-UR Generator Styles ===== */

/* Mode Badge (Finite vs Infinite) */
.mode-badge {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.mode-badge.infinite {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.mode-badge.finite {
    background: #e1f5e6;
    border: 2px solid #28a745;
    color: #0a7a25;
}

/* Encoder Blocks Visualization */
.encoder-blocks-visualization {
    margin-top: 12px;
}

.encoder-grid-title {
    font-size: 13px;
    color: #586069;
    margin-bottom: 8px;
    font-weight: 500;
}

.encoder-blocks-grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 8px;
    padding: 12px;
    background: #f6f8fa;
    border-radius: 6px;
}

/* Parts List Styling (Finite Mode) */
#parts-list-output {
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 12px;
}

.parts-list-header {
    font-weight: 600;
    font-size: 13px;
    color: #24292e;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e1e4e8;
}

.part-item {
    padding: 12px;
    margin: 8px 0;
    background: white;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.part-item:hover {
    background: #f6f8fa;
    border-color: #667eea;
}

.part-item.active {
    background: #e8f0fe;
    border-color: #667eea;
    border-width: 2px;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.2);
}

.part-number {
    display: inline-block;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 4px;
    min-width: 80px;
}

.part-ur {
    display: block;
    word-break: break-all;
    color: #24292e;
    background: #f6f8fa;
    padding: 8px;
    border-radius: 4px;
    margin-top: 4px;
}

/* QR Canvas Styling */
#multi-ur-qr-canvas {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Export Button Special Styling */
#export-gif:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #e1e4e8;
}

/* Mobile Optimizations for Multi-UR Generator */
@media (max-width: 768px) {
    .mode-badge {
        font-size: 12px;
        padding: 6px 12px;
    }

    .encoder-blocks-grid-container {
        grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
        gap: 6px;
    }

    #parts-list-output {
        font-size: 11px;
    }

    .part-item {
        padding: 10px;
    }

    #multi-ur-qr-canvas {
        max-width: 90vw;
    }
}
