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

body {
  font-family: 'Sarabun', 'Prompt', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding-top: 70px;
  position: relative;
}

/* Top Menu Bar */
.top-menu-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 70px;
  background: white;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  z-index: 1000;
}

.top-menu-bar.simple {
  display: flex;
  justify-content: flex-start;
}

.menu-container {
  max-width: 100%;
  height: 100%;
  padding: 0 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.top-menu-bar.simple .menu-container {
  justify-content: flex-start;
}

.menu-logo {
  font-size: 20px;
  font-weight: 700;
  color: #667eea;
  white-space: nowrap;
}

.menu-items {
  display: flex;
  gap: 30px;
  flex: 1;
  margin-left: 40px;
}

.menu-item {
  color: #666;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
  border-bottom: 2px solid transparent;
  padding-bottom: 5px;
}

.menu-item:hover {
  color: #667eea;
  border-bottom-color: #667eea;
}

.menu-actions {
  color: #999;
  font-size: 12px;
  white-space: nowrap;
}

/* System Disabled Overlay */
.system-disabled-overlay {
  position: fixed;
  top: 70px;
  left: 0;
  width: 100%;
  height: calc(100% - 70px);
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  backdrop-filter: blur(10px);
}

.system-disabled-message {
  background: white;
  border-radius: 20px;
  padding: 60px 80px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 600px;
  animation: slideDown 0.5s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.system-disabled-message svg {
  color: #dc3545;
  margin-bottom: 30px;
}

.system-disabled-message h2 {
  color: #333;
  font-size: 32px;
  margin: 0 0 15px 0;
}

.system-disabled-message p {
  color: #666;
  font-size: 18px;
  margin: 0;
}

/* Main Container */
.main-container {
  display: flex;
  gap: 20px;
  max-width: 1800px;
  margin: 0 auto;
  padding: 5%;
  height: calc(100vh - 70px - 10%);
}

.left-panel {
  flex: 0 0 calc(41.67%);
  display: flex;
  flex-direction: column;
}

.form-box {
  background: white;
  border-radius: 15px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  padding: 40px;
  height: 100%;
  overflow-y: auto;
}

.right-panel {
  flex: 0 0 calc(58.33%);
  background: white;
  border-radius: 15px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#pdfContainer {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Typography */
h1 {
  color: #333;
  text-align: center;
  margin-bottom: 8px;
  font-size: 32px;
  font-weight: 600;
}

.subtitle {
  color: #666;
  text-align: center;
  margin-bottom: 15px;
  font-size: 15px;
}

/* Current Exam Badge */
.current-exam-badge {
  margin: 0 auto 25px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
  width: fit-content;
}

.badge-label {
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  font-weight: 500;
}

.badge-value {
  color: white;
  font-size: 14px;
  font-weight: 700;
}

/* Form Styles */
.form-container {
  margin-top: 10px;
}

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

.form-group label {
  display: block;
  color: #444;
  font-weight: 500;
  margin-bottom: 6px;
  font-size: 14px;
}

.form-input {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 15px;
  transition: all 0.3s ease;
  font-family: 'Sarabun', sans-serif;
  background: white;
}

.form-input::placeholder {
  color: #bbb;
}

.form-input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-input:disabled {
  background: #f5f5f5;
  cursor: not-allowed;
  color: #999;
  border-color: #e0e0e0;
}

.btn-submit {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 5px;
  font-family: 'Sarabun', sans-serif;
}

.btn-submit:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn-submit:active:not(:disabled) {
  transform: translateY(0);
}

.btn-submit:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Button Group */
.button-group {
  display: flex;
  gap: 10px;
  margin-top: 5px;
}

.button-group .btn-submit {
  flex: 1;
  width: auto;
  padding: 12px;
  font-size: 14px;
  margin-top: 0;
}

.btn-envelope {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.btn-attendance {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.btn-attendance:hover:not(:disabled) {
  box-shadow: 0 5px 20px rgba(245, 87, 108, 0.4);
}

/* Messages */
.message {
  margin-top: 15px;
  padding: 12px;
  border-radius: 8px;
  text-align: center;
  font-size: 14px;
  display: none;
  animation: slideDown 0.3s ease;
}

.message p {
  margin: 0;
}

.message.success {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
  display: block;
}

.message.error {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
  display: block;
}

/* Loading */
.loading {
  text-align: center;
  margin-top: 15px;
  padding: 15px;
}

.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #667eea;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin: 0 auto 12px;
}

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

.loading p {
  color: #666;
  font-size: 14px;
  margin: 0;
}

/* PDF Styles */
.pdf-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #999;
  padding: 40px;
  text-align: center;
}

.pdf-placeholder svg {
  color: #ddd;
  margin-bottom: 20px;
}

.pdf-placeholder p {
  font-size: 16px;
  margin: 10px 0;
}

.pdf-placeholder .hint {
  font-size: 13px;
  color: #bbb;
}

.pdf-placeholder.error-state svg {
  color: #f8d7da;
}

.pdf-placeholder.error-state p {
  color: #721c24;
}

.pdf-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 25px;
  border-bottom: 2px solid #f0f0f0;
  background: #fafafa;
}

.pdf-header h3 {
  margin: 0;
  color: #333;
  font-size: 18px;
  font-weight: 600;
}

.pdf-actions {
  display: flex;
  gap: 10px;
}

.btn-icon {
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #666;
}

.btn-icon:hover {
  border-color: #667eea;
  color: #667eea;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.btn-icon.btn-delete:hover {
  border-color: #dc3545;
  color: #dc3545;
}

.pdf-viewer {
  flex: 1;
  border: none;
  width: 100%;
  height: 100%;
}

/* Responsive */
@media (max-width: 1200px) {
  .main-container {
    flex-direction: column;
    height: auto;
  }
  
  .left-panel {
    flex: 0 0 auto;
  }
  
  .right-panel {
    min-height: 600px;
  }
}

@media (max-width: 768px) {
  body {
    padding: 3%;
  }
  
  .main-container {
    height: auto;
  }
  
  .form-box {
    padding: 25px;
  }
  
  h1 {
    font-size: 26px;
    margin-bottom: 5px;
  }
  
  .subtitle {
    font-size: 14px;
    margin-bottom: 10px;
  }
  
  .current-exam-badge {
    margin-bottom: 20px;
    font-size: 12px;
  }
  
  .form-group {
    margin-bottom: 15px;
  }
  
  .form-input {
    font-size: 16px;
  }
  
  .btn-submit {
    font-size: 15px;
    padding: 12px;
  }
  
  .pdf-header {
    padding: 15px 20px;
  }
  
  .pdf-header h3 {
    font-size: 16px;
  }
  
  .system-disabled-message {
    padding: 40px 30px;
    max-width: 90%;
    margin: 20px;
  }
  
  .system-disabled-message h2 {
    font-size: 24px;
  }
  
  .system-disabled-message p {
    font-size: 16px;
  }
}
/* Autocomplete styles */
.autocomplete-wrapper {
  position: relative;
  width: 100%;
}

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #e0e0e0;
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.autocomplete-item {
  padding: 12px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid #f0f0f0;
  transition: background-color 0.2s ease;
}

.autocomplete-item:hover {
  background-color: #f5f5f5;
}

.autocomplete-item strong {
  color: #667eea;
  min-width: 100px;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.level-badge {
  background-color: #f0f0f0;
  color: #666;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  margin-left: auto;
  white-space: nowrap;
}