﻿/**
 * QR Scanner Styling - Indtjek Mobil App
 * 
 * @author GitHub Copilot
 * @created 2025-12-13
 */

:root {
    --scanner-accent: #4A8B6B;
    --scanner-accent-dark: #136a49;
    --scanner-accent-rgb: 16, 185, 129;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    overscroll-behavior: none;
}

/* desktop-mode-fix: Samsung zoom applied, use real screen height */
html.desktop-mode-fix,
html.desktop-mode-fix body {
    height: var(--real-height, 100vh) !important;
    max-height: var(--real-height, 100vh) !important;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #fff;
    color: #1a1a1a;
    height: 100vh;
    height: 100dvh;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overscroll-behavior: none;
    margin: 0;
    padding: 0;
}

.scanner-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 1rem;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    overflow-y: hidden;
    overflow-x: hidden;
    overscroll-behavior: none;
    min-height: 0;
}

.scanner-container.allow-scroll {
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
}

.scanner-header {
    text-align: center;
    padding: 0.25rem 0 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    width: 100%;
    flex-shrink: 0;
}

body.install-required .scanner-header {
    padding-bottom: 0.5rem;
}

.scanner-logo {
    height: 22px;
    width: auto;
    opacity: 0.9;
}

.scanner-header h1 {
    font-size: clamp(1.25rem, 3.5vw, 2rem);
    font-weight: 600;
    color: #1a1a1a;
    margin: 0;
}

.scanner-frame {
    position: relative;
    width: 100%;
    width: min(100%, 50dvh, calc(100dvh - 260px));
    aspect-ratio: 1 / 1;
    max-height: 50vh; /* fallback for browsers without dvh */
    margin: 0 auto;
    border-radius: 16px;
    overflow: hidden;
    background: #475569;
}

body.install-required .scanner-frame,
body.app-in-browser .scanner-frame {
    display: flex;
    align-items: center;
    justify-content: center;
}

body.install-required .scanner-frame #qr-reader,
body.install-required .scanner-frame .scanner-overlay,
body.install-required .scanner-frame .scanner-start,
body.install-required .scanner-frame .torch-btn,
body.install-required .scanner-frame .zoom-controls,
body.install-required .scanner-frame .debug-btn,
body.app-in-browser .scanner-frame #qr-reader,
body.app-in-browser .scanner-frame .scanner-overlay,
body.app-in-browser .scanner-frame .scanner-start,
body.app-in-browser .scanner-frame .torch-btn,
body.app-in-browser .scanner-frame .zoom-controls,
body.app-in-browser .scanner-frame .debug-btn {
    display: none !important;
}

.browser-notice,
.install-notice {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem 1.5rem;
    color: #e2e8f0;
    gap: 1rem;
    position: relative;
    z-index: 5;
}

/* Show correct notice based on state */
body.app-in-browser .browser-notice {
    display: flex;
}

body.install-required .install-notice {
    display: flex;
}

body.install-required .install-inline {
    display: none !important;
}

body.app-in-browser .install-inline {
    display: none !important;
}

/* Hide browser-notice when not installed */
body.install-required .browser-notice {
    display: none;
}

.browser-notice i,
.install-notice i {
    font-size: 2.5rem;
    color: #94a3b8;
    margin-bottom: 0.5rem;
}

.browser-notice-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
}

.browser-notice-text {
    font-size: 0.9rem;
    color: #94a3b8;
    line-height: 1.5;
}

.install-notice-btn {
    margin-top: 0.5rem;
    padding: 0.6rem 1.5rem;
    font-size: 0.95rem;
}

body.install-required .scanner-status,
body.app-in-browser .scanner-status {
    display: none;
}

.scanner-start {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    text-align: center;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(2px);
    border-radius: 16px;
    padding: 1rem;
}

.scanner-start.hidden {
    display: none;
}

.scanner-start .btn {
    padding: 0.75rem 1.5rem;
}

.scanner-start-hint {
    color: #e2e8f0;
    font-size: 0.875rem;
}

.scanner-frame.is-paused .scan-line {
    display: none;
}

/* aspect-ratio: 1/1 on .scanner-frame handles the square ratio */

/* Torch/Flash button */
.torch-btn {
    position: absolute;
    bottom: 1rem;
    right: calc(1rem - 11px);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    font-size: 1.25rem;
    cursor: pointer;
    z-index: 10;
    pointer-events: all;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.torch-btn i {
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.8));
}

.torch-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

.torch-btn.active {
    background: #fbbf24;
    border-color: #f59e0b;
    color: #1a1a1a;
}

.torch-btn.active i {
    animation: glow 1.5s ease-in-out infinite;
    filter: none;
}

@keyframes glow {
    0%, 100% { opacity: 1; text-shadow: 0 0 5px #fff; }
    50% { opacity: 0.8; text-shadow: 0 0 10px #fff, 0 0 20px #fbbf24; }
}

/* Zoom controls */
.zoom-controls {
    position: absolute;
    right: calc(1rem - 11px);
    bottom: 5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 10;
}

.zoom-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    pointer-events: all;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zoom-btn i {
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.8));
}

.zoom-btn:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.8);
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

.zoom-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.zoom-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Debug button */
.debug-btn {
    position: absolute;
    top: 1rem;
    left: 1rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    z-index: 10;
    pointer-events: all;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.debug-btn i {
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.8));
}

.debug-btn:hover {
}

.debug-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    border-color: rgba(255, 255, 255, 0.4);
}

/* Debug overlay */
.debug-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 90%;
    max-height: 80vh;
    overflow: hidden;
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -40%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.debug-header {
    background: linear-gradient(135deg, var(--scanner-accent), var(--scanner-accent-dark));
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.debug-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.debug-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.debug-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.debug-content {
    padding: 1rem;
    max-height: 60vh;
    overflow-y: auto;
    font-size: 0.875rem;
}

.debug-item {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid var(--scanner-accent);
}

.debug-item strong {
    display: block;
    color: var(--scanner-accent);
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.debug-item-value {
    color: #1a1a1a;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

.debug-supported {
    color: #10b981;
    font-weight: 600;
}

.debug-not-supported {
    color: #ef4444;
    font-weight: 600;
}

#qr-reader {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 12px;
    overflow: hidden;
}

#qr-reader video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scan-region {
    position: relative;
    width: min(250px, 70%);
    height: min(250px, 70%);
}

/* Scan instruction overlay */
.scanner-info p strong {
    color: var(--scanner-accent);
    font-weight: 600;
}

/* Corner markers */
.corner {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 3px solid var(--scanner-accent);
    animation: pulse 2s ease-in-out infinite;
}

.corner-tl {
    top: 0;
    left: 0;
    border-right: none;
    border-bottom: none;
    border-radius: 8px 0 0 0;
}

.corner-tr {
    top: 0;
    right: 0;
    border-left: none;
    border-bottom: none;
    border-radius: 0 8px 0 0;
}

.corner-bl {
    bottom: 0;
    left: 0;
    border-right: none;
    border-top: none;
    border-radius: 0 0 0 8px;
}

.corner-br {
    bottom: 0;
    right: 0;
    border-left: none;
    border-top: none;
    border-radius: 0 0 8px 0;
}

/* Animated scan line */
.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--scanner-accent), transparent);
    animation: scan 2s linear infinite;
    box-shadow: 0 0 10px var(--scanner-accent);
}

@keyframes scan {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(250px); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Flash animation for successful scan */
@keyframes flash {
    0% { background: rgba(var(--scanner-accent-rgb), 0); }
    50% { background: rgba(var(--scanner-accent-rgb), 0.3); }
    100% { background: rgba(var(--scanner-accent-rgb), 0); }
}

.scanner-info {
    text-align: center;
    padding: 2rem 1rem 1rem;
    color: #94a3b8;
}

.scanner-info:empty {
    padding: 0;
    margin: 0;
}

body.install-required .scanner-info {
    padding: 0;
}

.admin-login {
    text-align: center;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 0.5rem;
    margin-top: 0.5rem;
    width: 100%;
    flex-shrink: 0;
}

body.install-required .admin-login {
    margin-top: 0.75rem;
}

.admin-login-note {
    font-size: clamp(0.75rem, 1.5vw, 0.95rem);
    font-weight: 600;
    color: #64748b;
    margin-bottom: 0.25rem;
    flex-basis: 100%;
    padding: 0.25rem 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.admin-login .login-module-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 1 1 0;
    min-height: clamp(64px, 10vw, 90px);
    padding: 12px 10px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: none;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    color: #fff;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
}
.login-module-btn i {
    font-size: clamp(1.3rem, 2.5vw, 2rem);
}
.login-module-btn span {
    font-size: clamp(0.7rem, 1.5vw, 1rem);
    font-weight: 500;
    letter-spacing: 0.02em;
}
.login-module-btn.tool-btn  { background: linear-gradient(135deg, #ef4444, #dc2626); }
.login-module-btn.fleet-btn { background: linear-gradient(135deg, #0f172a, #1f2937); }
.login-module-btn.qr-btn    { background: linear-gradient(135deg, #3b82f6, #2563eb); }

.login-module-btn i {
    animation: iconFloat 2.6s ease-in-out infinite;
}
.login-module-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

@keyframes iconPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.08); opacity: 0.9; }
}

@keyframes iconFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

@media (prefers-reduced-motion: reduce) {
    .login-module-btn i {
        animation: none;
    }
}

.scanner-status {
    text-align: center;
    padding: 1rem;
    font-size: 0.875rem;
    min-height: 3rem;
}

.scanner-status:empty {
    min-height: 0;
    padding: 0;
}

.app-version {
    text-align: center;
    font-size: 0.75rem;
    color: #94a3b8;
    padding-bottom: 0.5rem;
}

.scanner-status.success {
    color: #10b981;
    font-weight: 600;
}

.scanner-status.error {
    color: #ef4444;
}

/* Inline install hint */
.install-inline {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin: 0.5rem auto 0;
    width: calc(100% - 2rem);
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-left: 4px solid var(--scanner-accent);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    justify-content: center;
}

body.install-required .install-inline {
    margin-top: 0.25rem;
    margin-bottom: 1.25rem;
}

body.app-in-browser .install-inline {
    margin-top: 0.25rem;
    margin-bottom: 1.25rem;
}

.install-inline-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #e6f4ed;
    color: #2f7a5b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.install-inline-title {
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 0.25rem;
}

.install-inline-text {
    color: #6b7280;
    font-size: 0.9rem;
}

.install-inline-btn {
    white-space: nowrap;
}

@media (max-width: 600px) {
    .install-inline {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .install-inline-btn {
        width: 100%;
    }
}

/* Hide Html5Qrcode default UI elements */
#qr-reader__dashboard_section {
    display: none !important;
}

#qr-reader__header_message {
    display: none !important;
}

/* Login Modal */
.login-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.login-modal.active {
    display: flex;
}

.login-content {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    max-width: 400px;
    width: 100%;
    max-height: calc(100vh - 2rem);
    max-height: calc(100dvh - 2rem);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease-out;
    position: relative;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 600px) {
    .login-modal {
        padding: 0;
        align-items: stretch;
    }

    .login-content {
        max-width: none;
        width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        height: auto;
        max-height: none;
        border-radius: 0;
        /* iPhone Safari/PWA needs an internally scrollable dialog with safe-area space,
           otherwise the bottom buttons can end up below the visible viewport. */
        padding: calc(2rem + env(safe-area-inset-top, 0)) 1.5rem calc(2rem + env(safe-area-inset-bottom, 0));
        box-shadow: none;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-brand-logo {
    height: 60px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
    margin-bottom: 0.75rem;
}

.login-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 1rem;
    background: #f3f4f6;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.login-icon.module-key {
    background: #d1fae5;
    color: #10b981;
}

.login-icon.module-qr {
    background: #dbeafe;
    color: #3b82f6;
}

.login-icon.module-tool {
    background: #fee2e2;
    color: #ef4444;
}

.login-icon.module-vehicle,
.login-icon.module-fleet {
    background: #e2e8f0;
    color: #475569;
}

.login-modal.tool-admin .login-content,
.login-modal.tool-login .login-content {
    border-top: 6px solid #ef4444;
}

.login-modal.tool-admin .login-icon.module-tool,
.login-modal.tool-login .login-icon.module-tool {
    background: #fee2e2;
    color: #ef4444;
}

.login-header h2 {
    color: #1f2937;
    margin: 0 0 0.5rem 0;
    font-size: 1.5rem;
}

.login-header p {
    color: #6b7280;
    margin: 0;
    font-size: 0.875rem;
}

.login-badge {
    display: none;
    margin-top: 0.75rem;
    padding: 0.25rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-radius: 999px;
    background: #f3f4f6;
    color: #6b7280;
}

.login-badge.active {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.login-modal.tool-admin .login-badge,
.login-modal.tool-login .login-badge {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #ef4444;
}


.login-modal.tool-admin .btn-primary,
.login-modal.tool-login .btn-primary {
    background: #ef4444;
    border-color: #ef4444;
}

.login-modal.tool-admin .btn-primary:hover,
.login-modal.tool-admin .btn-primary:focus,
.login-modal.tool-login .btn-primary:hover,
.login-modal.tool-login .btn-primary:focus {
    background: #dc2626;
    border-color: #dc2626;
}

.login-modal.tool-admin .login-mobile-close,
.login-modal.tool-login .login-mobile-close {
    background: #ef4444;
    box-shadow: 0 8px 20px rgba(239, 68, 68, 0.25);
}

.login-modal.tool-admin .login-mobile-close:hover,
.login-modal.tool-login .login-mobile-close:hover {
    box-shadow: 0 10px 22px rgba(239, 68, 68, 0.3);
}

.login-modal.qr-login .login-content {
    border-top: 6px solid #3b82f6;
}

.login-modal.qr-login .btn-primary {
    background: #3b82f6;
    border-color: #3b82f6;
}

.login-modal.qr-login .btn-primary:hover,
.login-modal.qr-login .btn-primary:focus {
    background: #2563eb;
    border-color: #2563eb;
}

/* Key module login (green) */
.login-modal.key-login .login-content {
    border-top: 6px solid #10b981;
}

.login-modal.key-login .login-icon.module-key {
    background: #d1fae5;
    color: #10b981;
}

.login-modal.key-login .btn-primary {
    background: #10b981;
    border-color: #10b981;
}

.login-modal.key-login .btn-primary:hover,
.login-modal.key-login .btn-primary:focus {
    background: #059669;
    border-color: #059669;
}

/* Login mode tabs (Medarbejder / Ekstern) */
.login-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1.25rem;
    border-radius: 0.625rem;
    overflow: hidden;
    border: 2px solid #e2e8f0;
    background: #f8fafc;
}

.login-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem 0.75rem;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.login-tab:first-child {
    border-right: 1px solid #e2e8f0;
}

.login-tab.active {
    background: #3b82f6;
    color: #fff;
}

.login-tab:not(.active):hover {
    background: #e2e8f0;
    color: #334155;
}

/* Guest mode active indicator on modal */
.login-modal.guest-mode .login-content {
    border-top: 6px solid #f59e0b !important;
}

.login-modal.guest-mode .login-tab.active {
    background: #f59e0b;
}

.login-modal.guest-mode .btn-primary {
    background: #f59e0b !important;
    border-color: #f59e0b !important;
}

.login-modal.guest-mode .btn-primary:hover,
.login-modal.guest-mode .btn-primary:focus {
    background: #d97706 !important;
    border-color: #d97706 !important;
}

/* Guest mode badge */
.guest-mode-badge {
    display: none;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.5rem;
    padding: 0.3rem 0.75rem;
    background: #fef3c7;
    color: #92400e;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.login-modal.guest-mode .guest-mode-badge {
    display: inline-flex;
}

.login-modal.vehicle-login .login-content,
.login-modal.fleet-login .login-content {
    border-top: 6px solid #0f172a;
}


.login-modal.vehicle-login .btn-primary,
.login-modal.fleet-login .btn-primary {
    background: #0f172a;
    border-color: #0f172a;
}

.login-modal.vehicle-login .btn-primary:hover,
.login-modal.vehicle-login .btn-primary:focus,
.login-modal.fleet-login .btn-primary:hover,
.login-modal.fleet-login .btn-primary:focus {
    background: #1e293b;
    border-color: #1e293b;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group.company-ref-toggle-group {
    margin-bottom: 0.75rem;
}

.external-access-toggle {
    width: 100%;
    min-height: 42px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    color: #475569;
    border-radius: 10px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.external-access-toggle:hover,
.external-access-toggle:focus {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #334155;
}

.external-access-toggle[aria-expanded="true"] {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.external-access-chevron {
    transition: transform 0.16s ease;
    font-size: 0.76rem;
}

.external-access-toggle[aria-expanded="true"] .external-access-chevron {
    transform: rotate(180deg);
}

.form-group.remember-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 0.25rem;
}

/* Toggle switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
    margin: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #d1d5db;
    border-radius: 24px;
    transition: background 0.25s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 3px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider {
    background: #3b82f6;
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.toggle-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    user-select: none;
    margin: 0;
}

/* Module-specific toggle colors */
.tool-login .toggle-switch input:checked + .toggle-slider,
.tool-admin .toggle-switch input:checked + .toggle-slider { background: #ef4444; }
.key-login .toggle-switch input:checked + .toggle-slider { background: #10b981; }
.fleet-login .toggle-switch input:checked + .toggle-slider { background: #0f172a; }
.guest-mode .toggle-switch input:checked + .toggle-slider { background: #f59e0b; }

.form-label {
    display: block;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--scanner-accent);
    box-shadow: 0 0 0 3px rgba(var(--scanner-accent-rgb), 0.1);
}

.pin-input-wrap {
    position: relative;
}

.pin-input-wrap .form-control {
    padding-right: 3rem;
}

.pin-toggle-btn {
    position: absolute;
    top: 50%;
    right: 0.45rem;
    width: 2.25rem;
    height: 2.25rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #6b7280;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transform: translateY(-50%);
    transition: background 0.2s, color 0.2s;
}

.pin-toggle-btn:hover,
.pin-toggle-btn:focus {
    background: #f3f4f6;
    color: var(--scanner-accent);
    outline: none;
}

.pin-toggle-btn .fa-eye {
    --fa: "\f06e";
}

.pin-toggle-btn .fa-eye-slash {
    --fa: "\f070";
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--scanner-accent);
    color: white;
}

.btn-primary:hover {
    background: var(--scanner-accent-dark);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

.btn-outline {
    background: transparent;
    border: 2px solid #e5e7eb;
    color: #6b7280;
}

.btn-outline:hover {
    border-color: #9ca3af;
    color: #374151;
}

.btn-full {
    width: 100%;
}

.login-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 0.75rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    display: none;
}

.login-error.active {
    display: block;
}

/* Alert styling */
.alert {
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    align-items: start;
    gap: 0.75rem;
    font-size: 0.875rem;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid #f59e0b;
}

.alert i {
    margin-top: 0.125rem;
}

/* Install PWA Banner */
.install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 2px solid var(--scanner-accent);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    z-index: 9999;
    animation: slideUp 0.3s ease-out;
}

.install-banner-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    max-width: 600px;
    margin: 0 auto;
    position: relative;
}

.install-logo {
    height: 50px;
    width: auto;
    flex-shrink: 0;
}

.install-text {
    flex: 1;
}

.install-text h3 {
    margin: 0 0 0.25rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a1a;
}

.install-text p {
    margin: 0;
    font-size: 0.875rem;
    color: #666;
}

.install-banner .btn {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1.25rem;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.btn-close:hover {
    opacity: 1;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

/* ── Wide viewport (desktop-mode, tablet) ─────────────────────── */
@media (min-width: 600px) {
    .scanner-container {
        padding: 2rem;
    }
    
    .scanner-header {
        gap: 0.75rem;
        padding: 1rem 0 1.5rem;
    }
    
    .admin-login .login-module-btn {
        min-height: 80px;
        padding: 14px 12px;
        border-radius: 14px;
        gap: 10px;
    }
    
    .login-module-btn i {
        font-size: 1.75rem;
    }
    
    .login-module-btn span {
        font-size: 0.85rem;
    }
    
    .admin-login-note {
        font-size: 0.85rem;
    }
    
    .install-inline {
        padding: 1.25rem;
    }
    
    .install-inline-icon {
        width: 52px;
        height: 52px;
        font-size: 1.4rem;
    }
    
    .install-inline-title {
        font-size: 1.1rem;
    }
    
    .install-inline-text {
        font-size: 1rem;
    }

    .scanner-status {
        font-size: 1rem;
    }

    .app-version {
        font-size: 0.85rem;
    }
}


