/**
 * QR Code Generator Styles
 */

/* QR Canvas Container */
.qr-canvas-container {
    min-height: 280px;
    border-radius: 12px;
    position: relative;
    transition: background-color 0.3s ease;
}

.qr-canvas {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}

.qr-placeholder {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* QR Info Grid */
.qr-info {
    padding: 12px;
    background: rgba(var(--v-theme-surface-variant), 0.3);
    border-radius: 8px;
}

/* Learning Mode Styles */
.learn-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.learn-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.learn-label {
    font-size: 0.875rem;
    color: rgba(var(--v-theme-on-surface), 0.7);
    min-width: 140px;
}

.learn-value {
    font-family: 'Roboto Mono', monospace;
    font-size: 0.875rem;
    background: rgba(var(--v-theme-primary), 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    word-break: break-all;
}

.learn-bits {
    letter-spacing: 1px;
    color: rgb(var(--v-theme-primary));
}

/* Mask Comparison */
.mask-comparison {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.mask-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 16px;
    background: rgba(var(--v-theme-surface-variant), 0.5);
    border-radius: 8px;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.mask-item.mask-best {
    background: rgba(var(--v-theme-primary), 0.15);
    border-color: rgb(var(--v-theme-primary));
}

.mask-number {
    font-weight: 600;
    font-size: 0.875rem;
}

.mask-penalty {
    font-size: 0.75rem;
    color: rgba(var(--v-theme-on-surface), 0.6);
}

/* Damage Canvas */
.damage-canvas {
    border-radius: 8px;
    cursor: crosshair;
    max-width: 100%;
    height: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Binary visualization */
.binary-display {
    font-family: 'Roboto Mono', monospace;
    font-size: 0.75rem;
    line-height: 1.8;
    word-break: break-all;
    background: rgba(var(--v-theme-surface-variant), 0.3);
    padding: 12px;
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.binary-display .bit-1 {
    color: rgb(var(--v-theme-primary));
    font-weight: 600;
}

.binary-display .bit-0 {
    color: rgba(var(--v-theme-on-surface), 0.4);
}

/* Codeword display */
.codeword-display {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.codeword {
    font-family: 'Roboto Mono', monospace;
    font-size: 0.75rem;
    padding: 2px 6px;
    background: rgba(var(--v-theme-primary), 0.1);
    border-radius: 4px;
}

.codeword.ec {
    background: rgba(var(--v-theme-secondary), 0.15);
    color: rgb(var(--v-theme-secondary));
}

/* Matrix visualization for learning mode */
.matrix-view {
    display: inline-block;
    border: 1px solid rgba(var(--v-theme-on-surface), 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.matrix-row {
    display: flex;
}

.matrix-cell {
    width: 8px;
    height: 8px;
    flex-shrink: 0;
}

.matrix-cell.dark {
    background: #000;
}

.matrix-cell.light {
    background: #fff;
}

.matrix-cell.finder {
    background: #1976d2;
}

.matrix-cell.alignment {
    background: #7b1fa2;
}

.matrix-cell.timing {
    background: #388e3c;
}

.matrix-cell.format {
    background: #f57c00;
}

/* Step cards animation */
.stat-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .qr-canvas-container {
        min-height: 220px;
    }
    
    .learn-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .learn-label {
        min-width: auto;
    }
    
    .mask-comparison {
        justify-content: center;
    }
}

/* Dark mode adjustments */
.v-theme--dark .learn-value {
    background: rgba(var(--v-theme-primary), 0.2);
}

.v-theme--dark .mask-item {
    background: rgba(255, 255, 255, 0.05);
}

.v-theme--dark .mask-item.mask-best {
    background: rgba(var(--v-theme-primary), 0.2);
}

.v-theme--dark .binary-display {
    background: rgba(255, 255, 255, 0.05);
}

/* Print styles */
@media print {
    .qr-canvas {
        max-width: 300px;
    }
}

/* Matrix animation canvas */
.matrix-anim-canvas {
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
    image-rendering: pixelated;
    max-width: 100%;
}

/* Color legend */
.matrix-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
}

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

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
    display: inline-block;
}

/* ── Bitstream Visualizer ──────────────────────────────────────────────── */

/* Color tokens for each segment type */
.bs-mode      { --bs-bg: #1976D2; --bs-bit1: #fff; --bs-bit0: rgba(255,255,255,0.45); }
.bs-count     { --bs-bg: #7B1FA2; --bs-bit1: #fff; --bs-bit0: rgba(255,255,255,0.45); }
.bs-data      { --bs-bg: #37474F; --bs-bit1: #80DEEA; --bs-bit0: rgba(255,255,255,0.35); }
.bs-terminator{ --bs-bg: #E65100; --bs-bit1: #fff; --bs-bit0: rgba(255,255,255,0.45); }
.bs-pad-bits  { --bs-bg: #558B2F; --bs-bit1: #fff; --bs-bit0: rgba(255,255,255,0.45); }
.bs-pad-cw    { --bs-bg: #6D4C41; --bs-bit1: #fff; --bs-bit0: rgba(255,255,255,0.45); }

/* Scrollable container for the full bitstream */
.bitstream-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    max-height: 320px;
    overflow-y: auto;
    padding: 10px;
    background: rgba(var(--v-theme-surface-variant), 0.3);
    border-radius: 8px;
}

/* One segment = one character/chunk */
.bs-segment {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    background: var(--bs-bg);
    border-radius: 4px;
    padding: 3px 4px 4px;
    cursor: help;
    transition: transform 0.1s, box-shadow 0.1s;
    min-width: 18px;
}

.bs-segment:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    z-index: 1;
}

/* Character label above bits */
.bs-char {
    font-size: 9px;
    font-weight: 700;
    color: rgba(255,255,255,0.9);
    line-height: 1;
    margin-bottom: 3px;
    max-width: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: 'Roboto Mono', monospace;
}

/* Bit row */
.bs-bits {
    display: flex;
    gap: 1px;
}

.bs-bit {
    font-size: 7px;
    font-family: 'Roboto Mono', monospace;
    line-height: 1.4;
    width: 7px;
    text-align: center;
    border-radius: 1px;
}

.bs-bit-1 { color: var(--bs-bit1); font-weight: 700; }
.bs-bit-0 { color: var(--bs-bit0); }

/* Legend row */
.bitstream-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 14px;
    margin-bottom: 10px;
}

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

.bs-dot {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    display: inline-block;
    flex-shrink: 0;
}

.bs-dot.bs-mode       { background: #1976D2; }
.bs-dot.bs-count      { background: #7B1FA2; }
.bs-dot.bs-data       { background: #37474F; }
.bs-dot.bs-terminator { background: #E65100; }
.bs-dot.bs-pad-bits   { background: #558B2F; }
.bs-dot.bs-pad-cw     { background: #6D4C41; }

/* Dark mode tweaks */
.v-theme--dark .bitstream-wrap {
    background: rgba(255,255,255,0.04);
}

/* ── Mask Comparison Grid ─────────────────────────────────────────────── */
.mask-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

@media (max-width: 600px) {
    .mask-grid { grid-template-columns: repeat(4, 1fr); }
}

.mask-grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 4px 6px;
    border-radius: 8px;
    border: 2px solid rgba(var(--v-theme-on-surface), 0.1);
    cursor: pointer;
    transition: all 0.15s ease;
}

.mask-grid-item:hover {
    border-color: rgb(var(--v-theme-primary));
    transform: translateY(-2px);
}

.mask-grid-active {
    border-color: rgb(var(--v-theme-primary)) !important;
    background: rgba(var(--v-theme-primary), 0.08);
}

.mask-grid-best {
    box-shadow: 0 0 0 2px rgb(var(--v-theme-success));
}

.mask-mini-canvas {
    image-rendering: pixelated;
    border-radius: 4px;
    max-width: 80px;
    max-height: 80px;
}

.mask-preview-canvas {
    image-rendering: pixelated;
    border-radius: 6px;
    max-width: 100%;
}

.mask-grid-label {
    display: flex;
    align-items: center;
    margin-top: 4px;
    font-size: 11px;
    font-weight: 600;
}

.mask-grid-penalty {
    font-size: 10px;
    margin-top: 2px;
}

.mask-detail {
    background: rgba(var(--v-theme-surface-variant), 0.3);
    border-radius: 8px;
    margin-top: 12px;
}

/* ── Version Comparison ───────────────────────────────────────────────── */
.version-preview-wrap {
    padding: 8px;
    border-radius: 8px;
    border: 2px solid rgba(var(--v-theme-on-surface), 0.1);
    transition: border-color 0.2s;
}

.version-current {
    border-color: rgb(var(--v-theme-primary));
    background: rgba(var(--v-theme-primary), 0.05);
}

.version-preview-canvas {
    image-rendering: pixelated;
    border-radius: 4px;
    display: block;
}

/* ── GF Calculator ────────────────────────────────────────────────────── */
.gf-results {
    background: rgba(var(--v-theme-surface-variant), 0.3);
    border-radius: 8px;
    padding: 16px;
}

.gf-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.gf-label {
    font-size: 0.875rem;
    color: rgba(var(--v-theme-on-surface), 0.7);
    min-width: 180px;
}

.gf-calc {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.gf-op {
    font-size: 0.875rem;
    font-weight: 600;
    color: rgba(var(--v-theme-on-surface), 0.5);
}

.gf-result {
    background: rgba(var(--v-theme-primary), 0.15) !important;
    color: rgb(var(--v-theme-primary)) !important;
    font-weight: 700 !important;
}
