/* Basic Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    font-family: sans-serif;
}

body {
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Prevent body scroll, let .content handle scrolling */
}

.background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw; /* 100% of viewport width */
    height: 100vh; /* 100% of viewport height */
    /* A solid background color. You can change this or add a real image url() later. */
    background-color: #2d3748;
    z-index: -1; /* Ensures the background stays behind the content */
}

.content {
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center the content vertically */
    align-items: center;
    gap: 2rem;
    flex: 1; /* Takes up the remaining height under the top bar */
    padding: 1rem;
    padding-top: 2rem;
    padding-bottom: 2rem;
    overflow-y: auto; /* Allow vertical scrolling for content */
}

.view-toggle-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    background-color: rgba(45, 55, 72, 0.9);
    color: white;
    font-size: 0.85rem;
    font-weight: bold;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.view-toggle-btn.close-mode {
    background-color: rgba(229, 62, 62, 0.9); /* Red color for close action */
}

.view-toggle-btn.close-mode:hover {
    background-color: #c53030;
}

.help-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background-color: #4299e1;
    color: white;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.help-btn:hover {
    background-color: #2b6cb0;
}

.fullscreen-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    background-color: rgba(45, 55, 72, 0.9);
    color: white;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
    white-space: nowrap;
}

.fullscreen-btn:hover {
    background-color: #1a202c;
}

.fullscreen-btn.close-mode {
    background-color: rgba(229, 62, 62, 0.9);
}

.fullscreen-btn.close-mode:hover {
    background-color: #c53030;
}

/*
.debug-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    background-color: rgba(229, 62, 62, 0.9); /* Reddish to indicate debug */
    color: white;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
    z-index: 1600; /* Ensure it's on top of the table overlay but under scanner */
}
*/

.debug-btn:hover {
    background-color: #c53030;
}

.card {
    background-color: rgba(255, 255, 255, 0.9);
    padding: clamp(1.5rem, 5vw, 3rem); /* Responsive padding */
    border-radius: 15px;
    text-align: center;
    max-width: 700px;
    width: 90%;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    position: relative;
    margin-top: 2.5rem; /* Make room for the buttons above */
}

.card-actions {
    position: absolute;
    bottom: 100%; /* Places the container right at the top edge of the card */
    left: 0;
    width: 100%;
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    gap: 0.5rem;
    flex-wrap: nowrap; /* Ensures buttons never wrap to a second line */
    padding-bottom: 0.5rem; /* Small gap between buttons and the card */
    z-index: 1600; /* Ensure it stays clickable above the table overlay */
}

/* Guarantee the single-line layout fits on extremely narrow mobile screens */
@media screen and (max-width: 400px) {
    .card-actions {
        gap: 0.25rem;
    }
    .view-toggle-btn, .fullscreen-btn {
        padding: 0.4rem 0.5rem;
        font-size: 0.75rem;
    }
}

.card-actions .help-btn {
    margin-right: auto; /* Pushes the other buttons to the right */
}

.info-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.info-form input {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-size: 1rem;
    font-family: inherit;
}

.form-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.scan-btn {
    flex-grow: 1; /* Allow scan button to take up space */
    background-color: #4299e1; /* A blue color */
}

.submit-btn {
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 8px;
    background-color: #2d3748;
    color: white;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
    flex-grow: 2; /* Make OK button bigger */
}

.scan-btn, .scanner-cancel-btn {
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.submit-btn:hover {
    background-color: #4a5568;
}

.scan-btn:hover {
    background-color: #2b6cb0;
}

.table-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.export-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    background-color: #38a169; /* Green for a 'save' action */
    color: white;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.export-btn:hover {
    background-color: #2f855a;
}

.clear-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    background-color: #e53e3e; /* Red for a destructive action */
    color: white;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.clear-btn:hover {
    background-color: #c53030;
}

.table-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 1500;
    display: none; /* hidden by default */
    justify-content: center;
    align-items: center;
}

.table-overlay.active {
    display: flex; /* Becomes visible when active class is added */
}

.table-container {
    background-color: rgba(255, 255, 255, 0.9);
    padding: 1.5rem;
    border-radius: 15px;
    width: 90%;
    max-width: 1000px; /* Allow table to be wider than form */
    max-height: 90vh; /* Don't overflow the height of the screen */
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    overflow: auto; /* Allow both horizontal and vertical scrolling */
    position: relative; /* Added to contain the absolute positioned SVG */
}

.table-container h2 {
    margin-bottom: 1rem;
    text-align: center;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th, td {
    padding: 0.75rem;
    border-bottom: 1px solid #ddd;
}

thead th {
    background-color: #f2f2f2;
    font-weight: bold;
}

tbody tr:last-child td {
    border-bottom: none;
}

/* Scanner Modal Styles */
.scanner-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 2000;
    overflow-y: auto; /* Ensures content is scrollable on small screens */
    padding: 1rem 0; /* Adds some vertical padding */
}

.scanner-container.active {
    display: flex; /* Becomes visible when active class is added */
}

#scanner-video {
    width: 90%;
    max-width: 640px;
    height: auto;
    border: 3px solid rgba(255, 255, 255, 0.5);
    border-radius: 8px;
}

.scanner-cancel-btn {
    margin-top: 20px;
    background-color: #e53e3e; /* Red color */
}

.scanner-cancel-btn:hover {
    background-color: #c53030;
}

.password-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid #ccc;
    font-size: 1.5rem;
    font-family: inherit;
    text-align: center;
    letter-spacing: 0.5rem;
    margin: 1.5rem 0;
}

.password-error {
    color: #e53e3e;
    font-weight: bold;
    margin-bottom: 1rem;
    display: none;
}