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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f8f9fa;
  color: #333;
  min-height: 100vh;
}

/* ── Navbar ── */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  border-bottom: 1px solid #ddd;
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-brand {
  font-weight: bold;
  font-size: 18px;
  color: #333;
  text-decoration: none;
}

.nav-link {
  color: #666;
  text-decoration: none;
  font-size: 14px;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.nav-link:hover {
  color: #000;
}

.nav-link.active {
  color: #000;
  border-bottom-color: #007bff;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.nav-user {
  font-size: 14px;
  color: #555;
}

/* ── Container ── */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 30px 20px;
}

.library-container {
  max-width: 1100px;
}

/* ── Page Title ── */
.page-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 24px;
  color: #1a1a1a;
}

/* ── Home Cards ── */
.home-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-top: 10px;
}

.home-card {
  display: block;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 30px 24px;
  text-decoration: none;
  color: #333;
  transition: box-shadow 0.2s, transform 0.2s;
}

.home-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}

.card-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

.home-card h3 {
  font-size: 18px;
  margin-bottom: 6px;
}

.home-card p {
  font-size: 13px;
  color: #777;
}

/* ── Upload Form ── */
.upload-form {
  display: flex;
  align-items: center;
  gap: 30px;
  margin-bottom: 30px;
  padding: 20px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
}

.file-input {
  font-size: 14px;
}

.btn {
  padding: 8px 20px;
  border: 1px solid #ccc;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  border-radius: 4px;
  transition: all 0.2s;
  text-decoration: none;
  color: #333;
  display: inline-block;
}

.btn:hover {
  background: #f5f5f5;
}

.btn-upload {
  padding: 8px 30px;
  background: #007bff;
  color: #fff;
  border-color: #007bff;
}

.btn-upload:hover {
  background: #0056b3;
}

.btn-primary {
  background: #007bff;
  color: #fff;
  border-color: #007bff;
}

.btn-primary:hover {
  background: #0056b3;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-view {
  background: #007bff;
  color: #fff;
  border-color: #007bff;
}

.btn-view:hover {
  background: #0056b3;
  color: #fff;
}

.btn-thumb {
  background: #f0f0f0;
  color: #555;
}

.btn-thumb:hover {
  background: #e0e0e0;
}

.btn-delete {
  color: #dc3545;
  border-color: #dc3545;
  background: #fff;
}

.btn-delete:hover {
  background: #dc3545;
  color: #fff;
}

.inline-form {
  display: inline;
}

/* ── File Table ── */
.file-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
}

.file-table th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #666;
  background: #fafafa;
  border-bottom: 1px solid #e0e0e0;
}

.file-table td {
  padding: 14px 16px;
  vertical-align: middle;
  font-size: 14px;
}

.file-table tbody tr {
  border-bottom: 1px solid #f0f0f0;
}

.file-table tbody tr:last-child {
  border-bottom: none;
}

.file-table a {
  color: #333;
  text-decoration: none;
}

.file-table a:hover {
  text-decoration: underline;
}

.link-highlight {
  color: #007bff !important;
}

.thumb-preview {
  max-width: 70px;
  max-height: 70px;
  border: 1px solid #ddd;
  border-radius: 4px;
  object-fit: cover;
}

.empty-row {
  text-align: center;
  color: #999;
  padding: 40px !important;
}

/* ── Library ── */
.library-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 4px;
}

.file-count {
  font-size: 14px;
  color: #888;
  font-weight: 400;
}

.search-bar {
  position: relative;
  margin-bottom: 24px;
}

.search-input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 15px;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  opacity: 0.5;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.library-card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.15s;
}

.library-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}

.card-thumbnail {
  width: 100%;
  height: 260px;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-bottom: 1px solid #eee;
}

.card-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.card-thumbnail img:hover {
  transform: scale(1.05);
}

.card-placeholder {
  font-size: 64px;
  opacity: 0.3;
}

.card-body {
  padding: 14px;
}

.card-title {
  font-size: 13px;
  font-weight: 500;
  color: #333;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  font-size: 11px;
  color: #999;
  margin-bottom: 8px;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ── Empty states ── */
.empty-library,
.no-results {
  text-align: center;
  padding: 60px 20px;
  color: #888;
}

.empty-library .empty-icon,
.no-results .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-library h3,
.no-results h3 {
  font-size: 18px;
  margin-bottom: 6px;
  color: #666;
}

.empty-library a {
  color: #007bff;
}

/* ── Alerts ── */
.alert {
  padding: 12px 16px;
  margin-bottom: 20px;
  border-radius: 6px;
  font-size: 14px;
}

.alert-error {
  background: #f8d7da;
  color: #842029;
  border: 1px solid #f5c2c7;
}

.alert-success {
  background: #d1e7dd;
  color: #0f5132;
  border: 1px solid #badbcc;
}

/* ── Login ── */
.login-box {
  max-width: 400px;
  margin: 80px auto;
  padding: 30px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
}

.login-box h2 {
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-size: 14px;
  font-weight: 500;
}

.form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
}

.form-group input:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
}

/* ── Pagination ── */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 32px;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  color: #333;
  font-size: 14px;
  text-decoration: none;
  transition: all 0.2s;
}

.page-btn:hover:not(.disabled):not(.active) {
  background: #f0f0f0;
  border-color: #bbb;
}

.page-btn.active {
  background: #007bff;
  color: #fff;
  border-color: #007bff;
  font-weight: 600;
}

.page-btn.disabled {
  color: #ccc;
  cursor: default;
  background: #fafafa;
}

.page-dots {
  padding: 0 4px;
  color: #999;
  font-size: 14px;
}

.pagination-info {
  text-align: center;
  margin-top: 10px;
  font-size: 13px;
  color: #888;
}

/* ── Admin ── */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-admin {
  background: #e8daff;
  color: #6f42c1;
}

.badge-user {
  background: #e2e8f0;
  color: #555;
}

.badge-active {
  background: #d1e7dd;
  color: #0f5132;
}

.badge-inactive {
  background: #f8d7da;
  color: #842029;
}

.btn-edit {
  background: #f0f0f0;
  color: #333;
}

.btn-edit:hover {
  background: #e0e0e0;
}

.actions-cell {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* ── User Form ── */
.form-page {
  max-width: 520px;
  margin: 0 auto;
}

.user-form {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 28px;
}

.user-form .form-group {
  margin-bottom: 18px;
}

.form-row {
  display: flex;
  gap: 24px;
  margin-bottom: 18px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.required {
  color: #dc3545;
}

.hint {
  font-size: 12px;
  color: #999;
  font-weight: 400;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .library-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }

  .card-thumbnail {
    height: 200px;
  }

  .home-cards {
    grid-template-columns: 1fr;
  }

  .upload-form {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
}
