/* CSS Variables for Light & Dark Themes */
/* Navbar Logo */
.navbar-logo{
    width:42px;
    height:42px;
    object-fit:contain;
    margin-right:10px;
}

.navbar-brand{
    font-weight:700;
    font-size:1.5rem;
}

:root {
    --primary-color: #0d6efd;
    --primary-hover: #0b5ed7;
    --primary-rgb: 13, 110, 253;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-color: #212529;
    --text-muted: #6c757d;
    --border-color: #e9ecef;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.4);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.08);
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --transition-speed: 0.3s;
}

/* Dark Theme Variables */
[data-bs-theme="dark"] {
    --bg-color: #0b0f19;
    --card-bg: #141b2d;
    --text-color: #f3f4f6;
    --text-muted: #9ca3af;
    --border-color: #242f47;
    --glass-bg: rgba(20, 27, 45, 0.7);
    --glass-border: rgba(36, 47, 71, 0.4);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.4);
}

/* Base Elements */
body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    transition: background-color var(--transition-speed) ease, color var(--transition-speed) ease;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* Typography & Accent Gradients */
.gradient-text {
    background: linear-gradient(135deg, var(--primary-color), #00d2ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

.gradient-bg {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0099ff 100%);
    color: #ffffff;
}

/* Custom Cards */
.custom-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease, background-color var(--transition-speed) ease, border-color var(--transition-speed) ease;
}

.custom-card:hover {
    box-shadow: var(--shadow-lg);
}

/* Custom Buttons & Touch Targets */
.btn {
    border-radius: var(--radius-sm);
    padding: 0.6rem 1.5rem;
    font-weight: 600;
    transition: all var(--transition-speed) ease;
}

.btn-lg {
    padding: 0.8rem 2rem;
    border-radius: var(--radius-md);
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    transform: translateY(-1px);
}

/* QR Type Selector Buttons */
.qr-type-btn {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.85rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.qr-type-btn .icon {
    font-size: 1.5rem;
    margin-bottom: 0.4rem;
}

.qr-type-btn .label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-color);
}

.qr-type-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.qr-type-btn.active {
    background-color: rgba(var(--primary-rgb), 0.08);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1px var(--primary-color);
}

/* Live Preview Card */
.preview-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 280px;
    background: radial-gradient(circle, var(--bg-color) 0%, var(--card-bg) 100%);
    border-radius: var(--radius-md);
    border: 2px dashed var(--border-color);
    padding: 1.5rem;
    position: relative;
}

#qrcode-canvas-wrapper {
    background-color: #ffffff;
    padding: 1rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: inline-block;
    transition: transform var(--transition-speed) ease;
}

#qrcode-canvas-wrapper:hover {
    transform: scale(1.03);
}

#qrcode-canvas-wrapper canvas,
#qrcode-canvas-wrapper img {
    max-width: 100%;
    height: auto !important;
}

/* Tabs & UI Forms */
.nav-pills .nav-link {
    border-radius: var(--radius-sm);
    font-weight: 600;
    padding: 0.6rem 1.2rem;
    color: var(--text-muted);
}

.nav-pills .nav-link.active {
    background-color: var(--primary-color) !important;
    color: #ffffff !important;
}

.form-floating > label {
    color: var(--text-muted);
}

.form-control, .form-select {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

.form-control:focus, .form-select:focus {
    background-color: var(--card-bg);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
    color: var(--text-color);
}

/* Slider Custom Styling */
.form-range::-webkit-slider-thumb {
    background: var(--primary-color);
}
.form-range::-moz-range-thumb {
    background: var(--primary-color);
}

/* Drag and Drop Zone */
.drag-drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    background-color: rgba(var(--primary-rgb), 0.02);
    padding: 3rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.drag-drop-zone:hover, .drag-drop-zone.dragover {
    border-color: var(--primary-color);
    background-color: rgba(var(--primary-rgb), 0.05);
}

.drag-drop-zone .icon {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

/* Camera Scanner Container */
.scanner-viewport-wrapper {
    position: relative;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: var(--radius-md);
    background: #000;
}

#reader {
    width: 100% !important;
    height: 100% !important;
    position: relative;
    overflow: hidden;
    border: none !important;
}

/* 
 * Style html5-qrcode's default visual scan region (#reader__scan_region) directly.
 * This dynamically aligns our custom blue corners and subtle non-intimidating border 
 * EXACTLY to the real scanning bounding box calculated by the library, on all devices.
 */
#reader__scan_region {
    /* Subtle thin border around the real scanning box, overriding default white border */
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 16px !important;
    box-sizing: border-box !important;
    
    /* Dynamic corner markers using linear-gradients on background */
    background: 
        /* Top-Left Corner */
        linear-gradient(to right, var(--primary-color) 3px, transparent 3px) 0 0,
        linear-gradient(to bottom, var(--primary-color) 3px, transparent 3px) 0 0,
        /* Top-Right Corner */
        linear-gradient(to left, var(--primary-color) 3px, transparent 3px) 100% 0,
        linear-gradient(to bottom, var(--primary-color) 3px, transparent 3px) 100% 0,
        /* Bottom-Left Corner */
        linear-gradient(to right, var(--primary-color) 3px, transparent 3px) 0 100%,
        linear-gradient(to top, var(--primary-color) 3px, transparent 3px) 0 100%,
        /* Bottom-Right Corner */
        linear-gradient(to left, var(--primary-color) 3px, transparent 3px) 100% 100%,
        linear-gradient(to top, var(--primary-color) 3px, transparent 3px) 100% 100% !important;
    background-size: 18px 18px !important;
    background-repeat: no-repeat !important;
    
    /* Modern soft pulsing blue glow inside scan box */
    background-color: rgba(var(--primary-rgb), 0.04) !important;
    animation: pulse-glow 2.5s ease-in-out infinite !important;
}

#reader video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}

/* Hide the old static manual overlay so only one dynamic scan guide exists */
.scanner-overlay {
    display: none !important;
}

/* Custom Scanner Tabs (Obvious Inactive Tabs) */
.custom-scanner-tabs {
    background-color: transparent !important;
    gap: 12px;
}

.custom-scanner-tabs .nav-link {
    background-color: var(--card-bg) !important;
    color: var(--primary-color) !important;
    border: 2px solid var(--primary-color) !important;
    transition: all var(--transition-speed) ease-in-out;
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 700;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-scanner-tabs .nav-link i {
    color: var(--primary-color) !important;
    font-size: 1.1rem;
    transition: color var(--transition-speed) ease;
}

/* Hover Effect on Desktop */
@media (min-width: 992px) {
    .custom-scanner-tabs .nav-link:not(.active):hover {
        background-color: rgba(var(--primary-rgb), 0.08) !important;
        transform: translateY(-1.5px);
        box-shadow: var(--shadow-md);
        border-color: var(--primary-hover) !important;
        color: var(--primary-hover) !important;
    }
}

/* Active tab style override */
.custom-scanner-tabs .nav-link.active {
    background-color: var(--primary-color) !important;
    color: #ffffff !important;
    border-color: var(--primary-color) !important;
}

.custom-scanner-tabs .nav-link.active i {
    color: #ffffff !important;
}

/* Max Width Helper Classes */
.max-width-400 {
    max-width: 400px;
}
.max-width-360 {
    max-width: 360px;
}

/* Success Highlight and Pop Animations */
@keyframes pulseHighlight {
    0% {
        box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0.4);
        transform: scale(1);
    }
    30% {
        box-shadow: 0 0 0 15px rgba(var(--primary-rgb), 0);
        transform: scale(1.015);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(var(--primary-rgb), 0);
        transform: scale(1);
    }
}

.pulse-highlight {
    animation: pulseHighlight 0.8s cubic-bezier(0.25, 1, 0.5, 1);
}

@keyframes successPop {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.25); }
    100% { transform: scale(1); opacity: 1; }
}

.success-pop {
    animation: successPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

/* Floating Action / Bottom Friendly Elements for Mobile */
@media (max-width:991px){
    .navbar-logo{
        width:34px;
        height:34px;
    }

    .navbar-brand{
        font-size:1.35rem;
    }
}

@media (max-width: 767.98px) {
    .btn-mobile-bottom {
        position: fixed;
        bottom: 15px;
        left: 15px;
        right: 15px;
        z-index: 1030;
        box-shadow: var(--shadow-lg);
    }
    body {
        padding-bottom: 70px; /* Safe padding for bottom sticky buttons */
    }
    .qr-type-btn {
        padding: 0.6rem;
    }
    .qr-type-btn .icon {
        font-size: 1.2rem;
        margin-bottom: 0.2rem;
    }
    .qr-type-btn .label {
        font-size: 0.75rem;
    }
}

/* History Card & Table List */
.history-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color var(--transition-speed) ease;
}

.history-item:hover {
    background-color: rgba(var(--primary-rgb), 0.03);
}

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

/* Toast Notification Styling */
.toast-container {
    z-index: 1090;
}

.custom-toast {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    color: var(--text-color);
}

/* Header & Navbar Glassmorphism */
.navbar {
    background-color: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
}

.navbar-brand {
    font-weight: 800;
    font-size: 1.4rem;
}

.nav-link {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-color);
    transition: color var(--transition-speed) ease;
}

.nav-link:hover, .nav-link.active {
    color: var(--primary-color) !important;
}

@media (max-width: 991.98px) {
    .navbar-collapse {
        width: 100%;
    }

    .mobile-nav-shell {
        display: flex;
        flex-direction: column;
        gap: 0.55rem;
        margin-top: 0.9rem;
        padding: 1rem;
        max-height: calc(100vh - 92px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        background: var(--card-bg);
        border: 1px solid var(--border-color);
        border-radius: 22px;
        box-shadow: var(--shadow-lg);
        position: relative;
    }

    .mobile-nav-shell::before,
    .mobile-nav-shell::after {
        display: block;
        color: var(--text-muted);
        pointer-events: none;
    }

    .mobile-nav-shell::before {
        content: "Browse Tools";
        font-size: 0.72rem;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        padding: 0 0.2rem 0.35rem;
    }

    .mobile-nav-shell::after {
        content: "TechHost \00a0\00b7\00a0 Free Online Tools";
        font-size: 0.72rem;
        line-height: 1.2;
        padding: 0.85rem 0.2rem 0.1rem;
        border-top: 1px solid var(--border-color);
    }

    .mobile-nav-link,
    .mobile-tools-toggle {
        min-height: 44px;
        border-radius: 16px;
        padding: 0.9rem 1rem;
        font-weight: 700;
        line-height: 1.2;
        text-decoration: none;
    }

    .mobile-nav-link {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 0.75rem;
        border: 1px solid transparent;
        background: transparent;
        color: var(--text-color);
        transition: background-color var(--transition-speed) ease, border-color var(--transition-speed) ease, transform var(--transition-speed) ease, color var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
    }

    .mobile-nav-link i,
    .mobile-category-button i,
    .mobile-tool-link i {
        width: 1.1rem;
        text-align: center;
        flex: 0 0 auto;
    }

    .mobile-nav-link.active {
        background-color: rgba(var(--primary-rgb), 0.12);
        color: var(--primary-color) !important;
        border-color: rgba(var(--primary-rgb), 0.18);
        box-shadow: inset 3px 0 0 var(--primary-color);
        font-weight: 800;
    }

    .mobile-category-link {
        border: 1px solid var(--border-color);
        background: rgba(var(--primary-rgb), 0.035);
    }

    .mobile-category-link:hover {
        background-color: rgba(var(--primary-rgb), 0.08);
        color: var(--text-color);
        border-color: var(--primary-color);
    }

    .mobile-tools-toggle {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        border: 1px solid var(--border-color);
        background: rgba(var(--primary-rgb), 0.045);
        color: var(--text-color);
        padding-right: 0.9rem;
        box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset;
    }

    .mobile-tools-toggle:hover,
    .mobile-tools-toggle:focus-visible {
        background-color: rgba(var(--primary-rgb), 0.08);
        color: var(--text-color);
        border-color: var(--primary-color);
        box-shadow: none;
    }

    .mobile-tools-toggle .mobile-chevron {
        transition: transform var(--transition-speed) ease;
    }

    .mobile-tools-toggle:not(.collapsed) .mobile-chevron {
        transform: rotate(180deg);
    }

    .mobile-tools-panel {
        margin-left: 0.2rem;
        padding-left: 0.85rem;
        border-left: 1px solid rgba(var(--primary-rgb), 0.14);
    }

    .mobile-tools-accordion .accordion-item {
        background: transparent;
        border: 0;
    }

    .mobile-category-item {
        margin-bottom: 0.5rem;
    }

    .mobile-category-button {
        min-height: 44px;
        padding: 0.9rem 1rem 0.9rem 0.8rem;
        border-radius: 16px;
        background: rgba(var(--primary-rgb), 0.03);
        box-shadow: none;
        font-weight: 800;
        color: var(--text-color);
        border: 1px solid transparent;
    }

    .mobile-category-button:not(.collapsed) {
        background-color: rgba(var(--primary-rgb), 0.085);
        color: var(--primary-color);
        border-color: rgba(var(--primary-rgb), 0.16);
    }

    .mobile-category-button:focus {
        box-shadow: none;
        border-color: transparent;
    }

    .mobile-tools-list {
        padding-left: 0.05rem;
    }

    .mobile-tool-link {
        min-height: 44px;
        display: flex;
        align-items: center;
        gap: 0.7rem;
        border: 0;
        border-radius: 14px;
        margin: 0.12rem 0;
        padding: 0.78rem 0.95rem 0.78rem 2.35rem;
        background: transparent;
        color: var(--text-color);
        font-size: 0.94rem;
        transition: background-color var(--transition-speed) ease, transform var(--transition-speed) ease, color var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
    }

    .mobile-tool-link:hover {
        background-color: rgba(var(--primary-rgb), 0.05);
        color: var(--text-color);
        transform: translateX(2px);
    }

.mobile-tool-link.active {
    background-color: rgba(var(--primary-rgb), 0.12);
    color: var(--primary-color) !important;
    font-weight: 800;
    box-shadow: inset 3px 0 0 var(--primary-color);
}

.mobile-tool-link + .mobile-tool-link {
    margin-top: 0.08rem;
}

.qrcode-caption {
    width: 100%;
    max-width: 100%;
    text-align: center;
    font-weight: 500;
    line-height: 1.35;
    letter-spacing: 0;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
    padding: 0 0.25rem;
}

#qrcode-canvas-wrapper {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.7rem;
    padding: 1rem;
}

#qrcode {
    display: flex;
    align-items: center;
    justify-content: center;
}

#qr-caption {
    resize: none;
}
}

/* Footer Section */
footer {
    background-color: var(--card-bg);
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
}

/* Page transitions / Fade in */
.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

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

/* Custom premium QR styling classes */
.template-card, .frame-card {
    transition: all var(--transition-speed) ease;
    border-width: 1.5px !important;
}

.template-card:hover, .frame-card:hover {
    border-color: var(--primary-color) !important;
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.template-card.active, .frame-card.active {
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.25) !important;
}

/* Sticky Preview panel on large screens */
@media (min-width: 992px) {
    .sticky-preview-column {
        position: sticky;
        top: 90px;
        align-self: start;
        z-index: 10;
    }
}
