/* Public Pages - Responsive Black & White Design System */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --color-primary: #222222;
  --color-bg: #ffffff;
  --color-text: #333333;
  --color-accent: #222222;
  --color-alt-bg: #f9f9f9;
  --color-border: #e0e0e0;
  --color-light-border: #f0f0f0;
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Container */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Typography */
h1 {
  font-size: 2.5rem;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

h2 {
  font-size: 1.5rem;
  color: var(--color-primary);
  margin-bottom: 0.75rem;
  font-weight: 600;
}

h3 {
  font-size: 1.2rem;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

p {
  margin-bottom: 1rem;
  color: #666;
}

/* Cards */
.card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: all 0.2s ease;
}

.card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border-color: #d0d0d0;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

/* Forms */
form {
  margin-bottom: 2rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--color-text);
  font-weight: 500;
  font-size: 0.95rem;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-primary);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

/* Buttons */
button,
.btn {
  padding: 0.75rem 1.5rem;
  background-color: var(--color-accent);
  color: #fff;
  border: 1px solid var(--color-accent);
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-block;
  text-decoration: none;
}

button:hover,
.btn:hover {
  background-color: #000;
  border-color: #000;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background-color: white;
  color: var(--color-primary);
  border: 1px solid #ccc;
}

.btn-secondary:hover {
  background-color: #f5f5f5;
  border-color: #999;
}

.btn-group {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Tables */
.table-output {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1.5rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  overflow: hidden;
}

.table-output th,
.table-output td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--color-light-border);
}

.table-output th {
  background-color: #f9f9f9;
  color: var(--color-primary);
  font-weight: 600;
  font-size: 0.9rem;
}

.table-output tr:hover {
  background-color: #fafafa;
}

.table-output tr:last-child td {
  border-bottom: none;
}

/* Index Page */
.index-page {
  text-align: center;
  padding-top: 2rem;
}

.index-page h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.index-page .subtitle {
  color: #666;
  margin-bottom: 2.5rem;
  font-size: 1.1rem;
}

.index-page .card-grid {
  text-align: left;
}

.index-page .card button {
  width: auto;
}

.admin-link {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

.admin-link a {
  color: var(--color-primary);
  text-decoration: none;
  font-size: 0.95rem;
}

.admin-link a:hover {
  text-decoration: underline;
}

/* Submit & Search Pages */
.submit-page,
.search-page {
  max-width: 600px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.submit-page h1,
.search-page h1 {
  margin-bottom: 2rem;
  text-align: center;
}

.submit-page .card,
.search-page .card {
  background: #fff;
  padding: 2rem;
}

/* Search Section */
#searchSection {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

#result {
  margin-top: 1.5rem;
}

.result-card {
  background: #f9f9f9;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 1.5rem;
  margin-top: 1rem;
}

.result-empty {
  text-align: center;
  padding: 2rem;
  color: #999;
}

/* Admin Login */
.admin-login {
  max-width: 450px;
  margin: 3rem auto;
  padding: 0 1.5rem;
}

.admin-login h1 {
  text-align: center;
  margin-bottom: 2rem;
}

.admin-login .card {
  padding: 2.5rem;
}

/* Messages */
.message,
.error-message,
.success-message {
  padding: 1rem 1.5rem;
  border-radius: 4px;
  margin-bottom: 1.5rem;
  border: 1px solid;
}

.error-message {
  background-color: #fef5f5;
  color: #c33;
  border-color: #fcc;
}

.success-message {
  background-color: #f5fef5;
  color: #3c3;
  border-color: #cfc;
}

.message {
  background-color: #f9f9f9;
  color: #333;
  border-color: #ddd;
}

/* Loading State */
.loading {
  text-align: center;
  padding: 2rem;
  color: #999;
}

.spinner {
  border: 3px solid #f0f0f0;
  border-top: 3px solid var(--color-primary);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 1.5rem 1rem;
  }

  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.3rem;
  }

  .card {
    padding: 1.5rem;
  }

  .card-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .btn-group {
    flex-direction: column;
  }

  .btn-group button,
  .btn-group .btn {
    width: 100%;
  }

  .table-output {
    font-size: 0.9rem;
  }

  .table-output th,
  .table-output td {
    padding: 0.5rem;
  }

  /* Stack table on very small screens */
  @media (max-width: 480px) {
    .table-output thead {
      display: none;
    }

    .table-output tr {
      display: block;
      margin-bottom: 1rem;
      border: 1px solid var(--color-border);
      border-radius: 4px;
    }

    .table-output td {
      display: block;
      text-align: right;
      padding-left: 50%;
      position: relative;
      border-bottom: 1px solid var(--color-light-border);
    }

    .table-output td:before {
      content: attr(data-label);
      position: absolute;
      left: 0.5rem;
      width: 45%;
      text-align: left;
      font-weight: 600;
      color: var(--color-primary);
    }

    .table-output td:last-child {
      border-bottom: none;
    }
  }
}

@media (max-width: 480px) {
  .container {
    padding: 1rem 0.75rem;
  }

  h1 {
    font-size: 1.75rem;
  }

  .index-page {
    padding-top: 1rem;
  }

  .admin-login .card {
    padding: 1.5rem;
  }
}
