/* Reset some basic defaults */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Base Body Styles */
body {
  font-family: 'Inter', sans-serif; /* Consistent font with index.php */
  background-color: #f3f4f6; /* Light gray background, consistent with index.php */
  color: #333;
  padding: 20px; /* Reduced padding for better mobile fit */
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh; /* Ensure body takes full viewport height */
}

/* Headings */
h1, h2 {
  color: #1f2937; /* Darker gray for better contrast, closer to Tailwind default */
  margin-bottom: 20px;
  font-weight: 700; /* Ensure headings are bold */
}

/* Form Inputs - General */
input[type="text"],
input[type="password"],
input[type="number"], /* If you add number inputs */
textarea {
  padding: 12px 16px;
  margin: 8px 0; /* Adjust margin for consistency */
  border: 1px solid #d1d5db; /* Lighter border color */
  border-radius: 8px; /* Slightly less rounded than 10px */
  width: 100%;
  max-width: 380px; /* Slightly increased max-width for inputs */
  font-size: 16px;
  background-color: #ffffff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08); /* Softer shadow */
  transition: all 0.3s ease-in-out; /* Smooth transitions */
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
textarea:focus {
  border-color: #2563eb; /* Blue focus color */
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3); /* Blue ring focus */
}

input::placeholder,
textarea::placeholder {
  color: #9ca3af; /* Lighter placeholder color */
}

/* Buttons - General Style */
button {
  padding: 12px 20px;
  margin-top: 10px;
  background-color: #2563eb; /* Primary blue, consistent with Tailwind's default blue-600 */
  color: #fff;
  border: none;
  border-radius: 8px; /* Consistent border-radius */
  cursor: pointer;
  font-size: 16px;
  font-weight: 600; /* Make text bolder */
  box-shadow: 0 4px 8px rgba(37,99,235,0.2); /* Shadow matching primary color */
  transition: all 0.3s ease-in-out;
  display: inline-block; /* Ensure consistency for single buttons */
}

button:hover {
  background-color: #1d4ed8; /* Darker blue on hover */
  transform: translateY(-1px); /* Subtle lift effect */
  box-shadow: 0 6px 12px rgba(37,99,235,0.25); /* Enhanced shadow on hover */
}

button:active {
  transform: translateY(0); /* Return to normal on click */
}

/* Specific Button Styles */
.edit-btn {
  background-color: #f59e0b; /* Yellow/orange for edit */
  color: #fff;
}
.edit-btn:hover {
  background-color: #d97706;
}

.delete-btn {
  background-color: #ef4444; /* Red for delete */
  color: #fff;
}
.delete-btn:hover {
  background-color: #dc2626;
}

.logout-btn {
  background-color: #dc2626; /* Specific red for logout */
  margin-right: 10px; /* Kept existing margin */
}
.logout-btn:hover {
  background-color: #b91c1c;
}

.cancel-btn {
  background-color: #6b7280; /* Gray for cancel */
  color: #fff;
  box-shadow: 0 4px 8px rgba(107,114,128,0.2); /* Shadow for gray button */
}
.cancel-btn:hover {
  background-color: #4b5563;
  box-shadow: 0 6px 12px rgba(107,114,128,0.25);
}

/* Auth Container (for login/register pages) */
.auth-container {
    background-color: #ffffff;
    padding: 40px; /* Increased padding */
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1); /* Stronger shadow */
    text-align: center;
    width: 100%;
    max-width: 450px; /* Slightly wider */
    margin: 40px auto; /* More vertical margin */
    animation: fadeIn 0.8s ease-out; /* Added fade-in animation */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.auth-container h1 {
    color: #1a202c; /* Darker heading color */
    margin-bottom: 30px;
    font-size: 2.2rem;
    font-weight: 700;
    position: relative;
    padding-bottom: 15px;
}

.auth-container h1::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background: #2563eb; /* Accent color matching primary blue */
    margin: 10px auto 0;
    border-radius: 2px;
}

.form-group { /* If you add div wrappers for labels/inputs */
    margin-bottom: 20px; /* Increased margin */
    text-align: left;
}

/* Message Styles (Error/Success) - Centralized */
.message {
    padding: 12px;
    margin-bottom: 20px;
    border-radius: 8px;
    font-weight: 500;
    animation: slideIn 0.5s ease-out;
    text-align: center; /* Ensure messages are centered */
}

.message.error {
    background-color: #ffebeb;
    color: #dc2626; /* Darker red */
    border: 1px solid #f87171; /* Red border */
}

.message.success {
    background-color: #ecfdf5;
    color: #10b981; /* Green */
    border: 1px solid #34d399; /* Green border */
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.auth-link {
    margin-top: 25px;
    font-size: 0.95rem;
    color: #555;
}

.auth-link a {
    color: #2563eb; /* Blue link */
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s ease;
}

.auth-link a:hover {
    color: #1d4ed8; /* Darker blue on hover */
    text-decoration: underline;
}

/* Camera Preview */
#preview {
  width: 100%;
  height: 300px; /* Fixed height for consistency */
  border: 2px dashed #d1d5db;
  border-radius: 0.75rem;
  overflow: hidden;
  position: relative;
  background-color: #e5e7eb; /* Placeholder background */
}

#preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 0;
}

#preview canvas.drawingBuffer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}


/* Scan Results Styling (Combined and refined) */
#result {
  margin-top: 25px; /* Consistent margin */
  padding: 20px;
  max-width: 600px; /* Increased max-width */
  width: 90%; /* Responsive width */
  background-color: #ffffff;
  border-left: 5px solid #2563eb; /* Blue accent bar */
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  font-size: 1rem; /* Adjusted font size */
  color: #333;
  transition: all 0.3s ease; /* Smooth transitions for updates */
}

/* NEW STYLES FOR ATTRACTIVE BARCODE RESULT DISPLAY */
.product-result-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 1rem;
}

.product-result-box div {
  /* No special styles needed, just a container */
}

.product-result-box strong {
  font-weight: 700;
  color: #1f2937;
  margin-right: 5px;
}

/* End of NEW STYLES */

.product-found {
    background-color: #e8f5e9; /* Light green */
    border-left-color: #4caf50; /* Green border */
}

.product-not-found, .error {
    background-color: #ffebee; /* Light red */
    border-left-color: #ef4444; /* Red border */
}

.detail-row {
  display: flex;
  flex-wrap: wrap; /* Allow wrapping on small screens */
  margin: 8px 0;
}

.detail-label {
  font-weight: bold;
  min-width: 100px; /* Adjusted min-width */
  margin-right: 10px; /* Space between label and value */
}

.detail-value {
  flex: 1;
  word-break: break-all; /* Prevent long words from breaking layout */
}

.description {
  margin-top: 15px; /* Increased margin */
  padding-top: 15px; /* Increased padding */
  border-top: 1px dashed #e5e7eb; /* Lighter dashed border */
  font-style: italic; /* Emphasize description */
  color: #4b5563;
}


/* Product List Styling */
#productList {
  width: 100%;
  max-width: 1000px; /* Increased max-width for product list */
  margin: 20px auto;
}

.product-item {
  background-color: #ffffff;
  border-radius: 12px; /* More rounded corners */
  padding: 20px; /* Increased padding */
  margin-bottom: 15px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08); /* Stronger, softer shadow */
  display: flex;
  flex-direction: column; /* Stack info and actions on small screens */
  align-items: flex-start; /* Align content to the start */
  transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.product-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

.product-info {
  flex: 1;
  width: 100%; /* Take full width */
  margin-bottom: 15px; /* Space before actions */
}

.product-header {
  display: flex;
  flex-wrap: wrap;
  gap: 15px 25px; /* More horizontal gap */
  margin-bottom: 10px;
}

.product-field {
  white-space: nowrap;
  font-size: 0.95rem;
  color: #374151;
}
.product-field strong {
    color: #1f2937;
    margin-right: 5px;
}


.product-description {
  color: #6b7280;
  margin-top: 8px;
  line-height: 1.5;
  font-size: 0.9rem;
}

.product-actions {
  display: flex;
  gap: 12px; /* Consistent gap for buttons */
  width: 100%; /* Take full width */
  justify-content: flex-end; /* Align buttons to the right */
}
.product-actions button {
    margin-top: 0; /* Remove top margin from general button style */
    padding: 8px 16px; /* Smaller buttons */
    font-size: 0.9rem;
}


/* Status Messages within sections */
.loading, .no-products, .error {
  text-align: center;
  padding: 1rem;
  font-size: 1.125rem;
  color: #6b7280;
  border-radius: 0.75rem;
  margin-top: 1rem;
  background-color: #f8f9fa; /* Light background for these messages */
}
.error {
    color: #ef4444; /* Red */
    font-weight: bold;
    background-color: #ffebeb;
    border: 1px solid #fca5a5;
}
.no-products {
    background-color: #e2e8f0;
    color: #4a5568;
}
.loading {
    color: #2563eb;
    background-color: #e0f2fe;
}


/* Pagination Controls */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center; /* Vertically align items */
    margin: 30px 0;
    gap: 15px; /* Increased gap */
}

.pagination button {
    padding: 8px 16px; /* Slightly larger buttons */
    border: 1px solid #d1d5db;
    background-color: #e5e7eb; /* Light gray background */
    color: #374151; /* Dark gray text */
    font-weight: 600;
    transition: background-color 0.2s ease, transform 0.2s ease;
    box-shadow: none; /* Remove default button shadow for pagination */
}

.pagination button:hover:not(:disabled) {
    background-color: #d1d5db;
    transform: none; /* No lift effect for pagination buttons */
}

.pagination button:disabled {
    background-color: #eff6ff; /* Lighter background for disabled */
    color: #9ca3af; /* Lighter text for disabled */
    cursor: not-allowed;
    opacity: 0.7;
    box-shadow: none;
    transform: none;
}

/* User info bar fixed top-right */
.user-info {
  position: fixed;
  top: 15px; /* Slightly more space from top */
  right: 20px;
  background-color: #ffffff; /* White background */
  padding: 10px 15px; /* More padding */
  border-radius: 8px; /* Consistent border-radius */
  box-shadow: 0 4px 12px rgba(0,0,0,0.1); /* Softer, larger shadow */
  font-family: 'Inter', sans-serif; /* Consistent font */
  font-size: 0.9rem; /* Slightly smaller font */
  color: #4b5563; /* Medium gray color */
  z-index: 1000;
  user-select: none;
  display: flex; /* Use flexbox for alignment */
  align-items: center;
  gap: 8px; /* Space between elements */
}

.user-info .username {
  font-weight: 700; /* Bolder username */
  color: #2563eb; /* Blue color for username */
}

.user-info a {
  text-decoration: none;
  color: #ef4444; /* Red for logout link */
  font-weight: 600;
  transition: color 0.2s ease;
}

.user-info a:hover {
  text-decoration: underline;
  color: #dc2626; /* Darker red on hover */
}


/* Responsive adjustments */
@media screen and (max-width: 768px) {
  body {
    padding: 15px;
  }
  h1 {
    font-size: 2.2rem;
  }
  h2 {
    font-size: 1.8rem;
  }
  input[type="text"],
  input[type="password"],
  textarea {
    max-width: 100%; /* Full width on smaller screens */
    margin: 6px 0;
  }
  button {
    padding: 10px 15px;
    font-size: 15px;
  }

  .auth-container {
      padding: 30px 20px;
      margin: 20px auto;
  }

  .product-item {
    flex-direction: column; /* Stack items vertically */
    align-items: flex-start;
    padding: 15px;
  }

  .product-info {
    margin-bottom: 10px; /* Adjust spacing */
  }

  .product-actions {
    flex-direction: row; /* Keep buttons in a row if space allows */
    justify-content: flex-start; /* Align actions to the left */
    width: auto; /* Allow buttons to size naturally */
    gap: 8px; /* Smaller gap for actions */
  }
  .product-actions button {
      width: auto; /* Prevent buttons from stretching */
      flex-grow: 1; /* Allow buttons to grow evenly */
      font-size: 0.85rem;
  }

  .detail-label {
    min-width: 80px; /* Reduce min-width for labels */
  }

  .user-info {
    top: 10px;
    right: 10px;
    padding: 8px 12px;
    font-size: 0.8rem;
    gap: 5px;
  }
}

@media screen and (max-width: 480px) {
    h1 {
        font-size: 1.8rem;
    }
    h2 {
        font-size: 1.5rem;
    }
    .auth-container {
        padding: 25px 15px;
    }
    .product-actions {
        flex-direction: column; /* Stack buttons vertically on very small screens */
        width: 100%;
    }
    .product-actions button {
        width: 100%; /* Make buttons full width */
    }
}