/* Reset & basics */
* {
  box-sizing: border-box;
  transition: background-color 0.5s ease, color 0.5s ease;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0; padding: 0;
  min-height: 100vh;
  background-color: #f9f9f9;
  color: #222;
  display: flex;
  flex-direction: column;
  align-items: center;
}

h1 {
  text-align: center;
  margin-bottom: 1rem;
}

/* Topbar */
#topbar {
  position: sticky;
  top: 0; left: 0; right: 0;
  background: rgba(255 255 255 / 0.95);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 0.7rem 1rem;
  z-index: 100;
  align-items: center;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  background-color: #4CAF50;
  border: none;
  padding: 0.5rem 1rem;
  color: white;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
  box-shadow: 0 3px 5px rgba(0,128,0,0.4);
  transition: background-color 0.3s ease, transform 0.2s ease;
  user-select: none;
}

.btn:hover {
  background-color: #3a8a35;
  transform: scale(1.05);
}

.add-subject {
  margin-top: 1rem;
  background-color: #2196F3;
  box-shadow: 0 3px 5px rgba(33,150,243,0.5);
}

.add-subject:hover {
  background-color: #1769aa;
}

/* Theme buttons */
#themeSwitcher {
  display: flex;
  gap: 0.5rem;
}

.theme-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: #555;
  transition: color 0.3s ease;
  user-select: none;
}

.theme-btn:hover {
  color: #000;
}

/* Form */
form {
  max-width: 480px;
  width: 90vw;
  background: #fff;
  padding: 1.5rem 2rem;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  margin: 2rem 0;
}

label {
  font-weight: 600;
  display: block;
  margin-top: 1rem;
  margin-bottom: 0.3rem;
}

input[type="text"], input[type="number"] {
  width: 100%;
  padding: 0.5rem 0.7rem;
  font-size: 1rem;
  border: 2px solid #ccc;
  border-radius: 6px;
  transition: border-color 0.3s ease;
}

input[type="text"]:focus, input[type="number"]:focus {
  border-color: #4CAF50;
  outline: none;
}

/* Subject rows */
.subject-row {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

.subject-row input[type="text"] {
  flex: 3;
}

.subject-row input[type="number"] {
  flex: 1;
}

/* Preview section */
#reportPreview {
  max-width: 480px;
  width: 90vw;
  background: #fff;
  padding: 1.5rem 2rem;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  margin-bottom: 3rem;
  user-select: text;
  overflow-x: auto;
}

#reportPreview.hidden {
  display: none;
}

#reportPreview h2 {
  text-align: center;
  margin-bottom: 1rem;
}

#reportPreview table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

#reportPreview th, #reportPreview td {
  border: 1px solid #666;
  padding: 0.6rem;
  text-align: center;
  font-weight: 600;
}

/* Dark Theme */
.dark-theme {
  background-color: #121212;
  color: #eee;
}

.dark-theme form, 
.dark-theme #reportPreview {
  background-color: #222;
  box-shadow: 0 10px 30px rgba(0,0,0,0.8);
}

.dark-theme input[type="text"],
.dark-theme input[type="number"] {
  background-color: #333;
  border-color: #555;
  color: #eee;
}

.dark-theme input[type="text"]:focus,
.dark-theme input[type="number"]:focus {
  border-color: #80c080;
}

.dark-theme #topbar {
  background: rgba(20 20 20 / 0.95);
  box-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

.dark-theme .btn {
  background-color: #388e3c;
  box-shadow: 0 3px 5px rgba(56,142,60,0.7);
}

.dark-theme .btn:hover {
  background-color: #2e7030;
}

/* Gray Theme */
.gray-theme {
  background-color: #b2b2b2;
  color: #222;
}

.gray-theme form, 
.gray-theme #reportPreview {
  background-color: #ddd;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.gray-theme input[type="text"],
.gray-theme input[type="number"] {
  background-color: #eee;
  border-color: #999;
  color: #222;
}

.gray-theme input[type="text"]:focus,
.gray-theme input[type="number"]:focus {
  border-color: #666;
}

.gray-theme #topbar {
  background: rgba(180 180 180 / 0.95);
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.gray-theme .btn {
  background-color: #666;
  box-shadow: 0 3px 5px rgba(102,102,102,0.6);
}

.gray-theme .btn:hover {
  background-color: #4d4d4d;
}

/* Responsive */
@media (max-width: 600px) {
  .subject-row {
    flex-direction: column;
  }

  #topbar {
    gap: 0.6rem;
  }
}
