/* Base Styles */
:root {
    --primary-color: #0077cc;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --error-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --white: #ffffff;
    --gray: #6c757d;
    --gray-light: #e9ecef;
    --text-color: #333;
    --text-light: #6c757d;
    --border-radius: 8px;
    --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(to right, #e0eafc, #cfdef3);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header Styles */
.site-header {
    background-color: var(--white);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 10px 0;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.site-logo {
    width: 70px;
    height: 70px;
    object-fit: contain;
}

.site-title {
    font-size: 24px;
    color: #1c3d5a;
    margin: 0;
    font-weight: 600;
}

/* Navigation Wrapper for Mobile Positioning */
.main-navigation-wrapper { /* This is the <nav> element */
    display: flex; /* Default for desktop */
    align-items: center;
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex; /* Default for desktop */
    gap: 15px;
}

.nav-list li {
    position: relative;
}

.nav-list li a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    padding: 10px 15px;
    transition: var(--transition);
    border-radius: var(--border-radius);
}

.nav-list li a:hover {
    color: var(--primary-color);
    background-color: var(--gray-light);
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: var(--white);
    min-width: 200px;
    box-shadow: var(--box-shadow);
    z-index: 1;
    border-radius: var(--border-radius);
    top: 100%;
    left: 0;
}

.dropdown-content a {
    color: var(--text-color);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    border-bottom: 1px solid var(--gray-light);
}

.dropdown-content a:hover {
    background-color: var(--gray-light);
    color: var(--primary-color);
}

.dropdown:hover .dropdown-content {
    display: block;
}

.mobile-menu-toggle {
    display: none; /* Hidden by default on desktop */
    cursor: pointer;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 21px;
}

.mobile-menu-toggle span {
    display: block;
    height: 3px;
    width: 100%;
    background-color: var(--text-color);
    border-radius: 3px;
    transition: var(--transition);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 20px 0;
}

.container {
    max-width: 850px;
    width: 90%;
    background: var(--white);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin: 20px auto;
}

h1, h2, h3 {
    font-family: Arial, sans-serif;
    color: #1c3d5a;
    margin-top: 0;
}

h1 {
    font-size: 28px;
    color: var(--primary-color);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

h2 {
    font-size: 26px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

h3 {
    font-size: 22px;
    margin-bottom: 10px;
}

p, li {
    font-family: Arial, sans-serif;
    color: var(--text-color);
    font-size: 17px;
    line-height: 1.7;
    text-align: justify;
    margin-bottom: 15px;
}

ul, ol {
    padding-left: 22px;
    margin-bottom: 20px;
}

.icon-small {
    width: 50px;
    height: 50px;
    vertical-align: middle;
}

/* Camera Section */
.camera-section {
    background: var(--gray-light);
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
}

.camera-select {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 16px;
    margin-bottom: 10px;
    background: var(--white);
}

.refresh-btn {
    padding: 8px 16px;
    background-color: var(--secondary-color);
    border: none;
    color: var(--white);
    border-radius: var(--border-radius);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.refresh-btn:hover {
    background-color: #5a6268;
}

/* Video Container */
.video-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin-bottom: 20px;
    background: #000;
    border-radius: var(--border-radius);
    overflow: hidden;
    aspect-ratio: 1 / 1;
}

video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

/* Scanning Overlay */
.scanning-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    display: none;
}

.scanning-overlay.active {
    display: block;
}

.corner {
    position: absolute;
    width: 30px;
    height: 30px;
    border: 3px solid #00ff00;
}

.top-left {
    top: 20px;
    left: 20px;
    border-right: none;
    border-bottom: none;
}

.top-right {
    top: 20px;
    right: 20px;
    border-left: none;
    border-bottom: none;
}

.bottom-left {
    bottom: 20px;
    left: 20px;
    border-right: none;
    border-top: none;
}

.bottom-right {
    bottom: 20px;
    right: 20px;
    border-left: none;
    border-top: none;
}

.scanning-line {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #00ff00, transparent);
    animation: scan 2s ease-in-out infinite;
}

@keyframes scan {
    0% { transform: translateY(0); }
    100% { transform: translateY(100%); }
}

/* Camera Controls */
.camera-controls {
    margin: 20px 0;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-primary:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: var(--white);
}

.btn-secondary:hover {
    background-color: #545b62;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(108, 117, 125, 0.3);
}

/* Status Messages */
.status-message {
    margin: 15px 0;
    padding: 12px;
    border-radius: var(--border-radius);
    font-weight: 500;
    display: none;
}

.status-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.status-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

.status-message.info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
    display: block;
}

.status-message.loading {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    display: block;
}

.divider {
    margin: 30px 0;
    font-size: 18px;
    font-weight: bold;
    color: #555;
    text-align: center;
    position: relative;
    display: flex;
    align-items: center;
}

.divider::before,
.divider::after {
    content: "";
    flex: 1;
    border-bottom: 1px solid #ddd;
    margin: auto;
}

.divider::before {
    margin-right: 10px;
}

.divider::after {
    margin-left: 10px;
}

/* Upload Section */
input[type='file'] {
    padding: 15px;
    border: 2px dashed #ccc;
    border-radius: var(--border-radius);
    cursor: pointer;
    width: 100%;
    background: #fafafa;
    transition: var(--transition);
}

input[type='file']:hover {
    border-color: var(--primary-color);
    background: #f0f8ff;
}

.image-preview {
    margin: 20px 0;
    text-align: center;
    display: none;
}

.image-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--border-radius);
    border: 2px solid #ddd;
}

.image-preview.active {
    display: block;
}

/* Result Section */
.result-section {
    margin-top: 30px;
}

#resultDisplay {
    font-size: 18px;
    font-weight: bold;
    color: var(--success-color);
    background: #e7ffe7;
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    word-break: break-word;
    font-family: 'Courier New', monospace;
    text-align: left;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 15px;
}

.result-actions .btn {
    flex: 1;
    min-width: 120px;
}

/* Info Sections */
.info-section {
    background-color: var(--white);
    margin: 30px auto;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.08);
}

/* Footer Styles */
.site-footer {
    background-color: #1c3d5a;
    color: var(--white);
    padding: 40px 0 20px;
    margin-top: auto; /* Pushes footer to the bottom */
}

.footer-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    gap: 30px;
}

.footer-section {
    flex: 1;
    min-width: 200px;
    margin-bottom: 20px;
}

.footer-section h3 {
    color: var(--white);
    font-size: 20px;
    margin-bottom: 20px;
    position: relative;
    padding-bottom: 10px;
    display: flex; /* Ensure logo and text are on one line */
    align-items: center;
    gap: 10px; /* Space between logo and text */
}

.footer-section h3 .site-logo { /* Targeting logo within footer h3 */
    width: 40px; /* Smaller logo in footer */
    height: 40px;
}

.footer-section h3::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 50px;
    height: 2px;
    background-color: var(--primary-color);
}

.footer-section p {
    color: #cfdef3;
    line-height: 1.6;
    text-align: left; /* Ensure text alignment is left */
}

.footer-section ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-section ul li {
    margin-bottom: 10px;
}

.footer-section ul li a {
    color: #cfdef3;
    text-decoration: none;
    transition: var(--transition);
}

.footer-section ul li a:hover {
    color: var(--white);
    padding-left: 5px;
}

.footer-columns {
    display: flex;
    gap: 20px;
}

.footer-column {
    flex: 1;
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    margin-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-bottom p {
    color: #cfdef3;
    margin: 0;
}

/* Floating Contact Button */
.floating-contact-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    text-decoration: none;
}

.contact-icon {
    width: 50px;
    height: 50px;
    background-color: #8800f8;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: var(--transition);
}

.contact-icon svg {
    width: 25px;
    height: 25px;
    fill: white; /* Ensure SVG icon is white */
}

.contact-pulse {
    position: absolute;
    width: 80px;
    height: 80px;
    background: #8800f8;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: -1;
    opacity: 0.4;
    animation: wave 2s infinite linear;
}

@keyframes wave {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0.4;
    }
    70% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 0.1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.4);
        opacity: 0;
    }
}

/* Responsive Design */
@media (max-width: 992px) {
    .header-container {
        flex-wrap: wrap;
        justify-content: space-between; /* Keep logo and toggle on opposite ends */
    }
    
    .main-navigation-wrapper { /* This is the <nav> element */
        width: 100%;
        order: 3; /* Puts navigation below logo/title on mobile */
        margin-top: 15px;
        position: absolute; /* Position relative to header-container */
        top: 100%; /* Place it below the header content */
        left: 0;
        background-color: var(--white); /* Background for the dropdown menu */
        box-shadow: var(--box-shadow);
        display: none; /* Hidden by default */
        flex-direction: column;
        align-items: flex-start; /* Align menu items to the left */
        padding: 10px 0;
        z-index: 990; /* Lower than header, but above main content */
    }
    
    .main-navigation-wrapper.active {
        display: flex; /* Show when active */
    }
    
    .nav-list {
        flex-direction: column;
        width: 100%; /* Take full width of its parent */
        gap: 0; /* Remove gap for stacked items */
    }
    
    .nav-list li {
        width: 100%; /* Make list items take full width */
    }

    .nav-list li a {
        padding: 12px 20px; /* Larger touch area and padding */
        display: block; /* Make links block-level */
        color: var(--text-color); /* Ensure text color is visible */
        border-radius: 0; /* No rounded corners for full-width items */
    }

    .nav-list li a:hover {
        background-color: var(--gray-light);
        color: var(--primary-color);
    }
    
    .dropdown-content {
        position: static; /* Allows content to flow naturally */
        box-shadow: none;
        display: none; /* Hidden by default on mobile, controlled by .dropdown.active */
        padding-left: 20px; /* Indent dropdown items */
        background-color: var(--gray-light); /* Different background for sub-items */
        border-radius: 0;
    }
    
    .dropdown:hover .dropdown-content {
        display: none; /* Disable hover effect for mobile */
    }
    
    .dropdown.active .dropdown-content {
        display: block; /* Show dropdown content when parent li has 'active' class */
    }
    
    .mobile-menu-toggle {
        display: flex; /* Show hamburger icon */
    }

    /* Hamburger animation for mobile toggle */
    .mobile-menu-toggle.active span:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }
    .mobile-menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    .mobile-menu-toggle.active span:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }

    .footer-container {
        flex-direction: column;
        align-items: center; /* Center footer sections */
    }
    
    .footer-section {
        min-width: 100%;
        text-align: center; /* Center text in footer sections */
    }

    .footer-section h3 {
        justify-content: center; /* Center logo and title in footer */
    }

    .footer-section h3::after {
        left: 50%;
        transform: translateX(-50%);
    }

    .footer-section ul {
        align-items: center; /* Center list items in footer */
    }
}

@media (max-width: 768px) {
    .site-title {
        font-size: 20px;
    }
    
    .site-logo {
        width: 60px;
        height: 60px;
    }
    
    .main-content-container { /* Adjusted for smaller screens */
        width: 95%;
        padding: 20px;
    }
    
    h1 {
        font-size: 24px;
    }
    
    .icon-small {
        width: 40px;
        height: 40px;
    }
    
    .result-actions {
        flex-direction: column;
    }
    
    .result-actions .btn {
        margin: 5px 0;
        width: 100%;
    }

    .footer-columns {
        flex-direction: column;
        gap: 0;
    }

    .floating-contact-btn {
        bottom: 20px;
        right: 20px;
    }

    .contact-icon {
        width: 45px;
        height: 45px;
    }

    .contact-pulse {
        width: 70px;
        height: 70px;
    }
}
