/* ========================================
   TJ Books - Modern Theme
   ======================================== */

:root {
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial,
    sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", "Roboto Mono", monospace;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --bg: #f1f5f9;
  --bg-card: #ffffff;
  --bg-nav: #0f172a;
  --border: #e2e8f0;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: #eff6ff;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- Links ---- */
a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* ---- Base Inputs ---- */
input, select, textarea, button {
  font-family: inherit;
  font-size: inherit;
}

/* ---- Login / Register ---- */
.login, .register {
  width: 400px;
  max-width: calc(100% - 32px);
  margin: 80px auto;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.login h1, .register h1 {
  margin: 0;
  padding: 28px 24px 20px;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.login .links, .register .links {
  display: flex;
  gap: 4px;
  padding: 0 24px;
  margin-top: 4px;
}

.login .links a, .register .links a {
  padding: 8px 12px 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
}
.login .links a:hover, .register .links a:hover {
  color: var(--text-secondary);
  text-decoration: none;
}
.login .links a.active, .register .links a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.login form, .register form {
  padding: 20px 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login form label:not(.checkbox-label), .register form label:not(.checkbox-label) {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  flex-shrink: 0;
}

.field-group {
  display: flex;
  align-items: stretch;
}

.field-group input[type="text"],
.field-group input[type="password"],
.field-group input[type="email"] {
  flex: 1;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.field-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.15);
}

input[type="text"], input[type="password"], input[type="email"] {
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--bg-card);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.15);
}

.login form .msg, .register form .msg {
  font-size: 14px;
  color: var(--text-secondary);
  padding: 4px 0;
}

.login form > a, .register form > a {
  font-size: 14px;
  color: var(--primary);
  padding: 4px 0;
  width: auto;
  align-self: flex-start;
}
.login form > a:hover, .register form > a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* ---- Buttons ---- */
input[type="submit"], button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 24px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}
input[type="submit"]:hover, button:hover, .btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
input[type="submit"]:active, button:active, .btn:active {
  transform: translateY(0);
}

input[type="reset"], .btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 24px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}
input[type="reset"]:hover, .btn-secondary:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

/* ---- Navbar ---- */
.navtop {
  background: var(--bg-nav);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.3);
}

.navtop div {
  display: flex;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  gap: 8px;
}

.navtop div h1 {
  flex: 1;
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.navtop div a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: #94a3b8;
  border-radius: var(--radius-xs);
  transition: all var(--transition);
}
.navtop div a:hover {
  color: #fff;
  background: rgb(255 255 255 / 0.08);
  text-decoration: none;
}
.navtop div a i {
  font-size: 14px;
}

/* ---- Logged-in Pages ---- */
body.loggedin {
  background: var(--bg);
}

.content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px;
}

.content h2 {
  margin: 0 0 24px;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.content .block {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin-bottom: 24px;
}

.content .block p {
  margin: 0 0 12px;
  color: var(--text-secondary);
  font-size: 15px;
}

.content .block p:last-child {
  margin-bottom: 0;
}

/* ---- Tables ---- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table:not([class]) {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
}

table:not([class]) th,
table:not([class]) td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

table:not([class]) th {
  background: #f8fafc;
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

table:not([class]) tr:last-child td {
  border-bottom: none;
}

table:not([class]) tr:hover td {
  background: #f8fafc;
}

/* table with border="1" — used in home.php */
table[border] {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
table[border] td {
  padding: 10px 14px;
  border: 1px solid var(--border);
}

/* ---- Cards / Misc ---- */
.content form {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  max-width: 720px;
}

.content form h2 {
  margin-top: 0;
}

.content form input[type="text"],
.content form input[type="password"],
.content form input[type="email"],
.content form select {
  width: 100%;
  margin-bottom: 4px;
}

.content form tr td {
  padding: 8px 10px;
  vertical-align: middle;
}

.content form tr td:first-child {
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  padding-right: 16px;
  width: 140px;
}

.content form select {
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.content form select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.15);
}

.content form input[type="submit"],
.content form input[type="reset"] {
  width: auto;
  min-width: 160px;
  margin-top: 20px;
  margin-right: 12px;
}

.content form input[readonly] {
  background: #f8fafc;
  cursor: not-allowed;
  opacity: 0.7;
}

.content form select[readonly] {
  background: #f8fafc;
  cursor: not-allowed;
  opacity: 0.7;
}

/* ---- Edit History ---- */
.content .block + hr,
.content br + hr {
  display: none;
}

/* ---- Messages ---- */
.msg {
  font-size: 14px;
  line-height: 1.5;
}

/* ---- Profile ---- */
.content.profile form label {
  display: block;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.content.profile form input[type="text"],
.content.profile form input[type="password"],
.content.profile form input[type="email"] {
  padding: 10px 14px;
  width: 100%;
  max-width: 360px;
}

.content.profile .profile-btn {
  display: inline-block;
  padding: 10px 24px;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border-radius: var(--radius-sm);
  margin-top: 12px;
  transition: background var(--transition);
}
.content.profile .profile-btn:hover {
  background: var(--primary-hover);
  text-decoration: none;
}

/* ---- Responsive ---- */
@media screen and (max-width: 640px) {
  .login, .register {
    margin: 40px auto;
    border-radius: var(--radius-sm);
  }

  .navtop div {
    flex-wrap: wrap;
    height: auto;
    padding: 12px 16px;
    gap: 4px;
  }
  .navtop div h1 {
    flex-basis: 100%;
    font-size: 16px;
    margin-bottom: 4px;
  }
  .navtop div a {
    padding: 6px 12px;
    font-size: 13px;
  }

  .content {
    padding: 16px;
  }

  .content .block {
    padding: 18px;
  }

  .content form {
    padding: 20px;
  }

  table:not([class]) th,
  table:not([class]) td {
    padding: 8px 10px;
    font-size: 13px;
  }

  .content form input[type="submit"],
  .content form input[type="reset"] {
    width: 100%;
    margin-right: 0;
  }

  .content form tr td:first-child {
    width: auto;
    display: block;
    padding-bottom: 0;
  }
  .content form tr td:last-child {
    display: block;
  }
}

@media screen and (max-width: 400px) {
  .login, .register {
    width: calc(100% - 24px);
    margin: 24px auto;
  }
}
