/* --- Global Reset & Typography --- */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  background: #f8f9fa;
  color: #333;
  line-height: 1.5;
}

/* --- Navigation --- */
nav {
  background: #2c3e50;
  padding: 15px 25px;
  color: white;
  margin-bottom: 30px;
  overflow: hidden;
}

nav a {
  color: white;
  margin-right: 20px;
  text-decoration: none;
  font-weight: bold;
}

nav a:hover {
  text-decoration: underline;
}

/* Automatically push logout or specific links to the right if desired */
nav a:last-child:not(:first-child) {
  float: right;
  color: #e74c3c;
}

/* --- Main Content Containers --- */
main {
  max-width: 800px;
  margin: 40px auto;
  background: white;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Optional modifier if a page needs to be narrower (like login) */
main.narrow {
  max-width: 420px;
}

/* --- Headings & Text --- */
h1,
h2,
h3 {
  margin-top: 0;
  color: #2c3e50;
}

h3 {
  margin-bottom: 0;
}

p {
  margin-bottom: 20px;
}

/* --- Form Elements --- */
form {
  margin: 0;
}

label {
  font-weight: 600;
  display: block;
  margin-bottom: 5px;
  margin-top: 15px;
}

input[type="text"],
input[type="password"],
input[type="number"] {
  width: 100%;
  padding: 10px;
  margin-bottom: 15px;
  box-sizing: border-box;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1em;
}

/* Special case for horizontal inline forms (like Search or Add Product) */
form[action*="search"],
form[action*="add"] {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

form[action*="search"] input,
form[action*="add"] input {
  margin-bottom: 0;
  flex: 1;
}

/* --- Buttons --- */
button {
  background: #3498db;
  color: white;
  border: none;
  padding: 10px 18px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  font-size: 1em;
}

button:hover {
  opacity: 0.9;
}

/* Contextual button styling without classes */
form[action*="add"] button {
  background: #27ae60;
}

form[action*="delete"] button {
  background: #c0392b;
  padding: 5px 10px;
  font-size: 0.9em;
}

/* --- Tables --- */
table {
  width: 100%;
  margin-top: 5px;
  border-collapse: collapse;
  background: white;
}

th,
td {
  padding: 12px;
  border: 1px solid #ddd;
  text-align: left;
}

th {
  background: #f1f3f5;
  font-weight: 600;
}

tr:nth-child(even) {
  background: #fcfcfc;
}

/* --- Alerts & Messages --- */
div[th\:if*="message"],
div[th\:if*="error"] {
  margin-top: 15px;
  padding: 12px;
  border-radius: 4px;
}

code {
  background: #f1f3f5;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  color: #d63384;
}

pre {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  padding: 12px;
  border-radius: 4px;
  overflow-x: auto;
}

/* Fallback generic alert classes if used dynamically */
.alert-success {
  background: #d4edda;
  color: #155724;
  padding: 10px;
  border-radius: 4px;
  margin-top: 15px;
}

.alert-error {
  background: #f8d7da;
  color: #721c24;
  padding: 10px;
  border-radius: 4px;
  margin-top: 15px;
}
