* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #fdfeff;
  color: #333;
}

/* ===== MAIN WRAPPER (for push effect) ===== */
#mainWrapper {
  transition: margin-left 0.4s ease;
  margin-left: 0;
  position: relative;
}

#mainWrapper.pushed {
  margin-left: 280px;
}

/* ===== SIDEBAR ===== */
.sidebar {
  height: 100%;
  width: 0;
  position: fixed;
  z-index: 1001;
  top: 0;
  left: 0;
  background: linear-gradient(180deg, #2c3e50 0%, #34495e 100%);
  overflow-x: hidden;
  overflow-y: auto;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3);
}

/* Sidebar header with close button */
.sidebar-header {
  position: sticky;
  top: 0;
  background: #1a252f;
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
}

.sidebar-title {
  color: white;
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0;
}

.closebtn {
  font-size: 28px;
  color: #e5e7eb;
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px 10px;
  transition: all 0.3s ease;
  border-radius: 4px;
  line-height: 1;
}

.closebtn:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
  transform: rotate(90deg);
}

/* Sidebar navigation */
.sidebar-nav {
  padding: 10px 0;
}

.sidebar a {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  text-decoration: none;
  font-size: 15px;
  color: #e5e7eb;
  border-left: 4px solid transparent;
  transition: all 0.3s ease;
  font-weight: 500;
  margin: 2px 0;
  gap: 12px;
}

.sidebar a .icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar a:hover {
  background-color: rgba(255, 255, 255, 0.15);
  border-left: 4px solid #3b82f6;
  color: white;
  padding-left: 24px;
}

.sidebar a:active {
  background-color: rgba(255, 255, 255, 0.2);
}

/* Divider in sidebar */
.sidebar-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 15px 0;
}

/* Logout link styling */
.sidebar a.logout-link {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 20px;
  margin-top: 20px;
  color: #ff6b6b;
}

.sidebar a.logout-link:hover {
  background-color: rgba(255, 107, 107, 0.1);
  border-left: 4px solid #ff6b6b;
  color: #ff8787;
}

/* Sidebar overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ===== NAVBAR ===== */
.navbar {
  background: linear-gradient(90deg, #2c3e50, #34495e);
  color: white;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 999;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.openbtn {
  font-size: 24px;
  cursor: pointer;
  background: none;
  color: white;
  padding: 8px 12px;
  border: none;
  transition: all 0.3s ease;
  border-radius: 4px;
  margin-right: 15px;
}

.openbtn:hover {
  background-color: rgba(255, 255, 255, 0.1);
  transform: scale(1.1);
}

.navbar h3 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

/* ===== MAIN CONTENT ===== */
.content {
  padding: 30px 20px;
  max-width: 1000px;
  margin: 0 auto;
  min-height: calc(100vh - 80px);
}

#pageTitle {
  color: #2c3e50;
  font-size: 2rem;
  margin-bottom: 30px;
  text-align: center;
  font-weight: 600;
  padding-bottom: 15px;
  border-bottom: 3px solid #2c3e50;
}

/* ===== SECTIONS ===== */
.section {
  background: white;
  padding: 25px;
  margin-bottom: 25px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  border: 1px solid #e0e0e0;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.section:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.12);
}

.section h3 {
  color: #2c3e50;
  font-size: 1.3rem;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid #e0e0e0;
  font-weight: 600;
}

/* ===== FORM ELEMENTS ===== */
.form-group {
  margin-bottom: 20px;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: #555;
  font-size: 0.95rem;
}

/* Style for labels of locked/disabled fields - only in edit mode */
.edit-mode .locked-field label::after {
  content: " 🔒";
  font-size: 0.85em;
  color: #6c757d;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 15px;
  font-size: 16px;
  border-radius: 6px;
  border: 1px solid #ddd;
  font-family: 'Segoe UI', sans-serif;
  transition: border-color 0.3s, box-shadow 0.3s;
  background-color: #fff;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #2c3e50;
  box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.1);
}

/* Gray out disabled/readonly fields only in edit mode */
.edit-mode input:disabled,
.edit-mode select:disabled,
.edit-mode textarea:disabled,
.edit-mode input:read-only,
.edit-mode select:read-only,
.edit-mode textarea:read-only {
  background-color: #f5f5f5;
  background-image: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 10px,
    rgba(108, 117, 125, 0.03) 10px,
    rgba(108, 117, 125, 0.03) 20px
  );
  color: #6c757d;
  cursor: not-allowed;
  border: 1px solid #e0e0e0;
  font-style: italic;
}

textarea {
  min-height: 100px;
  resize: vertical;
  line-height: 1.5;
}

/* ===== BUTTONS ===== */
button {
  background-color: #2c3e50;
  color: white;
  border: none;
  padding: 12px 25px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  transition: all 0.3s ease;
  font-family: 'Segoe UI', sans-serif;
}

button:hover {
  background-color: #34495e;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(44, 62, 80, 0.3);
}

button:active {
  transform: translateY(0);
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
}

/* ===== VIEW MODE ===== */
.view-mode {
  background: linear-gradient(135deg, #e8f5e9 0%, #f1f8e9 100%) !important;
  border-left: 4px solid #4caf50;
}

.view-mode input,
.view-mode select,
.view-mode textarea {
  background-color: #fafafa;
  cursor: not-allowed;
  color: #555;
}

/* ===== SPECIFIC BUTTON STYLES ===== */
.back-btn {
  background-color: #6c757d;
}

.back-btn:hover {
  background-color: #5a6268;
}

#submitBtn {
  background-color: #2c3e50;
}

#submitBtn:hover {
  background-color: #34495e;
}

/* Success button (for updates) */
button[style*="background-color: #28a745"],
button[style*="background-color:#28a745"] {
  background-color: #27ae60 !important;
}

button[style*="background-color: #28a745"]:hover,
button[style*="background-color:#28a745"]:hover {
  background-color: #229954 !important;
}

/* Green button */
button[style*="background-color: #34a853"],
button[style*="background-color:#34a853"] {
  background-color: #27ae60 !important;
}

button[style*="background-color: #34a853"]:hover,
button[style*="background-color:#34a853"]:hover {
  background-color: #229954 !important;
}

/* ===== NOTICE BOXES ===== */
.notice-box {
  background: #d4edda;
  color: #155724;
  padding: 15px 20px;
  border-radius: 6px;
  margin-bottom: 25px;
  border: 1px solid #c3e6cb;
  text-align: center;
  font-weight: 600;
  font-size: 1rem;
}

.notice-box.warning {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffeaa7;
}

/* ===== RESPONSIVE DESIGN ===== */

/* ========== TABLET RESPONSIVE (769px - 1024px) ========== */
@media (max-width: 1024px) and (min-width: 769px) {
  /* Disable push effect on tablet - overlay instead */
  #mainWrapper.pushed {
    margin-left: 0 !important;
  }

  .navbar {
    padding: 14px 18px;
  }

  .navbar h3 {
    font-size: 1.2rem;
  }

  .openbtn {
    font-size: 22px;
    padding: 8px 12px;
    min-height: 44px;
    min-width: 44px;
  }

  .content {
    padding: 25px 30px;
    max-width: 700px;
    margin: 0 auto;
  }

  #pageTitle {
    font-size: 1.8rem;
    margin-bottom: 28px;
  }

  .section {
    padding: 24px 22px;
    margin-bottom: 24px;
  }

  .section h3 {
    font-size: 1.3rem;
    margin-bottom: 18px;
  }

  .form-group {
    margin-bottom: 18px;
  }

  label {
    font-size: 0.95rem;
    margin-bottom: 8px;
  }

  input,
  select,
  textarea {
    font-size: 16px;
    padding: 12px 14px;
    border-radius: 6px;
  }

  textarea {
    min-height: 110px;
  }

  button {
    padding: 13px 22px;
    font-size: 16px;
    min-height: 44px;
  }

  .button-group {
    gap: 12px;
  }

  .notice-box {
    padding: 16px 20px;
    font-size: 1rem;
  }

  /* Sidebar tablet */
  .sidebar {
    width: 0 !important;
  }

  .sidebar-header {
    padding: 20px;
  }

  .sidebar-title {
    font-size: 1.15rem;
  }

  .closebtn {
    font-size: 26px;
  }

  .sidebar a {
    font-size: 15px;
    padding: 13px 20px;
  }

  .sidebar a .icon {
    font-size: 17px;
    width: 24px;
  }
}

/* ========== MOBILE RESPONSIVE (481px - 768px) ========== */
@media (max-width: 768px) {
  /* Disable push effect on mobile/tablet - overlay instead */
  #mainWrapper.pushed {
    margin-left: 0 !important;
  }
  
  .navbar {
    padding: 12px 16px;
  }

  .navbar h3 {
    font-size: 1.15rem;
  }

  .openbtn {
    font-size: 22px;
    padding: 8px 12px;
    min-height: 44px;
    min-width: 44px;
  }

  .content {
    padding: 22px 18px;
  }

  #pageTitle {
    font-size: 1.65rem;
    margin-bottom: 24px;
    line-height: 1.3;
  }

  .section {
    padding: 22px 18px;
    margin-bottom: 22px;
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.08);
  }

  .section h3 {
    font-size: 1.25rem;
    margin-bottom: 16px;
  }

  .form-group {
    margin-bottom: 18px;
  }

  label {
    font-size: 0.93rem;
    margin-bottom: 8px;
  }

  input,
  select,
  textarea {
    font-size: 16px;
    padding: 13px;
    border-radius: 6px;
  }

  textarea {
    min-height: 100px;
  }

  .button-group {
    flex-direction: column;
    gap: 10px;
  }

  button {
    width: 100%;
    padding: 14px 20px;
    font-size: 15px;
    min-height: 48px;
  }

  .notice-box {
    padding: 14px 18px;
    font-size: 0.95rem;
  }

  /* Sidebar adjustments for tablets */
  .sidebar {
    width: 0 !important;
  }
  
  .sidebar-header {
    padding: 18px;
  }
  
  .sidebar-title {
    font-size: 1.1rem;
  }

  .closebtn {
    font-size: 26px;
  }
  
  .sidebar a {
    font-size: 14px;
    padding: 13px 18px;
  }
  
  .sidebar a .icon {
    font-size: 16px;
    width: 22px;
  }
}

/* ========== SMALL MOBILE (320px - 480px) ========== */
@media (max-width: 480px) {
  /* Disable push effect on mobile - overlay instead */
  #mainWrapper.pushed {
    margin-left: 0 !important;
  }
  
  .navbar {
    padding: 10px 14px;
  }

  .navbar h3 {
    font-size: 1.05rem;
    line-height: 1.3;
  }

  .openbtn {
    font-size: 20px;
    padding: 8px 10px;
    min-height: 44px;
    min-width: 44px;
  }

  .content {
    padding: 18px 14px;
  }

  #pageTitle {
    font-size: 1.5rem;
    margin-bottom: 20px;
    line-height: 1.3;
  }

  .section {
    padding: 18px 15px;
    margin-bottom: 20px;
    border-radius: 8px;
  }

  .section h3 {
    font-size: 1.15rem;
    margin-bottom: 14px;
  }

  .form-group {
    margin-bottom: 16px;
  }

  label {
    font-size: 0.9rem;
    margin-bottom: 7px;
  }

  input,
  select,
  textarea {
    font-size: 16px;
    padding: 12px;
    border-radius: 6px;
  }

  textarea {
    min-height: 90px;
  }

  button {
    font-size: 15px;
    padding: 13px 18px;
    min-height: 48px;
  }

  .button-group {
    gap: 10px;
  }

  .notice-box {
    padding: 12px 15px;
    font-size: 0.9rem;
    line-height: 1.5;
  }

  /* Sidebar mobile optimization */
  .sidebar {
    width: 0 !important;
  }
  
  .sidebar-header {
    padding: 16px;
  }
  
  .sidebar-title {
    font-size: 1.05rem;
  }
  
  .closebtn {
    font-size: 24px;
    padding: 6px 10px;
  }
  
  .sidebar a {
    font-size: 14px;
    padding: 12px 16px;
  }
  
  .sidebar a .icon {
    font-size: 16px;
    width: 20px;
  }

  .button-group {
    gap: 10px;
  }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section {
  animation: fadeIn 0.5s ease;
}

.section:nth-child(1) {
  animation-delay: 0.1s;
}

.section:nth-child(2) {
  animation-delay: 0.2s;
}

.section:nth-child(3) {
  animation-delay: 0.3s;
}

.section:nth-child(4) {
  animation-delay: 0.4s;
}

/* ===== LOADING STATE ===== */
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* ===== ACCESSIBILITY ===== */
*:focus-visible {
  outline: 3px solid #2c3e50;
  outline-offset: 2px;
  border-radius: 2px;
}

/* Better focus for interactive elements */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.openbtn:focus-visible,
.closebtn:focus-visible {
  outline: 3px solid #2c3e50;
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .section {
    border: 2px solid #333;
  }

  button {
    border: 2px solid currentColor;
  }

  input,
  select,
  textarea {
    border: 2px solid #333;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .section {
    animation: none !important;
  }
}

/* ===== SMOOTH SCROLLING ===== */
html {
  scroll-behavior: smooth;
}

/* ===== FOOTER ===== */
.footer {
  background-color: #2c3e50;
  color: white;
  text-align: center;
  padding: 15px 10px;
  font-size: 0.85em;
  margin-top: auto;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.footer p {
  margin: 5px 0;
}

.footer strong {
  font-weight: 600;
}
/* ===== TOUCH RESPONSIVENESS ===== */
@media (hover: none) and (pointer: coarse) {
  button:active {
    transform: scale(0.98);
    opacity: 0.9;
  }

  .openbtn:active,
  .closebtn:active {
    transform: scale(0.95);
    background-color: rgba(255, 255, 255, 0.2);
  }

  .sidebar a:active {
    background-color: rgba(255, 255, 255, 0.25);
  }

  /* Larger tap targets for mobile */
  button,
  .openbtn,
  .closebtn,
  input,
  select,
  textarea {
    min-height: 48px;
  }

  /* Better touch feedback */
  button:active {
    background-color: #1a2734;
  }

  input:focus,
  select:focus,
  textarea:focus {
    transform: scale(1.01);
  }
}

/* ===== EXTRA SMALL MOBILE (< 360px) ===== */
@media (max-width: 360px) {
  .navbar {
    padding: 8px 12px;
  }

  .navbar h3 {
    font-size: 1rem;
  }

  .openbtn {
    font-size: 18px;
    padding: 6px 8px;
  }

  .content {
    padding: 15px 12px;
  }

  #pageTitle {
    font-size: 1.35rem;
    margin-bottom: 18px;
  }

  .section {
    padding: 16px 13px;
    margin-bottom: 18px;
  }

  .section h3 {
    font-size: 1.1rem;
    margin-bottom: 12px;
  }

  .form-group {
    margin-bottom: 14px;
  }

  label {
    font-size: 0.88rem;
  }

  input,
  select,
  textarea {
    padding: 11px;
  }

  textarea {
    min-height: 85px;
  }

  button {
    padding: 12px 16px;
    font-size: 14px;
  }

  .notice-box {
    padding: 11px 13px;
    font-size: 0.88rem;
  }
}

/* ===== LANDSCAPE MOBILE OPTIMIZATION ===== */
@media (max-width: 896px) and (max-height: 414px) and (orientation: landscape) {
  .navbar {
    padding: 8px 15px;
  }

  .navbar h3 {
    font-size: 1rem;
  }

  .content {
    padding: 15px 20px;
  }

  #pageTitle {
    font-size: 1.3rem;
    margin-bottom: 15px;
  }

  .section {
    padding: 15px;
    margin-bottom: 15px;
  }

  .section h3 {
    font-size: 1.1rem;
    margin-bottom: 12px;
  }

  .form-group {
    margin-bottom: 12px;
  }

  textarea {
    min-height: 70px;
  }

  button {
    padding: 10px 18px;
  }
}

/* ===== IMPROVED SCROLLBAR ===== */
@media (max-width: 768px) {
  ::-webkit-scrollbar {
    width: 8px;
  }

  ::-webkit-scrollbar-track {
    background: #f1f1f1;
  }

  ::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
  }

  ::-webkit-scrollbar-thumb:hover {
    background: #555;
  }

  /* For sidebar */
  .sidebar::-webkit-scrollbar {
    width: 6px;
  }

  .sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
  }

  .sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  .sidebar,
  .sidebar-overlay,
  .navbar,
  .button-group,
  .openbtn,
  .closebtn {
    display: none !important;
  }

  #mainWrapper {
    margin-left: 0 !important;
  }

  .content {
    max-width: 100%;
    padding: 0;
    margin: 0;
  }

  .section {
    box-shadow: none;
    border: 1px solid #ddd;
    page-break-inside: avoid;
    margin-bottom: 20px;
    padding: 15px;
  }

  #pageTitle {
    page-break-after: avoid;
  }

  input,
  select,
  textarea {
    border: 1px solid #000;
    background: none;
  }

  * {
    color: #000 !important;
  }
}

/* ===== REQUIRED FIELD INDICATOR ENHANCEMENT ===== */
label::after {
  content: none;
}

/* No special styling for required fields - they look like normal fields */
/* The asterisk (*) in the label is the only visual indicator */

/* Add visual indicator for required labels */
label:has(+ input:required)::after,
label:has(+ select:required)::after,
label:has(+ textarea:required)::after {
  content: " *";
  color: #e74c3c;
  font-weight: bold;
}

/* Alternative for browsers that don't support :has() */
@supports not (selector(:has(*))) {
  /* Labels with asterisk already handled in HTML */
}

/* Focus states for required fields remain the same as normal fields */
input:required:focus,
select:required:focus,
textarea:required:focus {
  outline: none;
  border-color: #2c3e50;
  box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.1);
}
/* ========== MOBILE/TABLET FIXES ========== */
@media (max-width: 768px) {
  /* Ensure mainWrapper takes full height and footer stays at bottom */
  #mainWrapper {
    min-height: 100vh !important;
    display: flex !important;
    flex-direction: column !important;
    margin-left: 0 !important;
  }

  /* Disable push effect on mobile/tablet */
  #mainWrapper.pushed {
    margin-left: 0 !important;
  }

  /* Make content area flex-grow to push footer down */
  .content {
    flex: 1 !important;
  }

  /* Ensure sidebar overlay works properly */
  .sidebar-overlay.active {
    display: block !important;
    z-index: 1000 !important;
  }

  /* Sidebar should appear on top, not push content */
  .sidebar {
    z-index: 1001 !important;
  }

  /* Prevent body scroll when sidebar is open on mobile */
  body.sidebar-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
  }
}
/* ========== SIDEBAR FIX FOR MOBILE/TABLET ========== */

/* Force sidebar to open properly on all screen sizes */
@media (max-width: 1024px) {
  /* When sidebar is opened, it should be visible */
  .sidebar {
    width: 0 !important;
    transition: width 0.3s ease !important;
  }
  
  /* JavaScript will set inline style width: 280px, ensure it takes effect */
  .sidebar[style*="width: 280px"] {
    width: 280px !important;
  }
  
  /* Alternative: use a class-based approach */
  .sidebar.open {
    width: 280px !important;
  }
  
  /* Ensure sidebar content is visible when open */
  .sidebar-header,
  .sidebar-nav {
    opacity: 1;
    visibility: visible;
  }
  
  /* Disable the push effect - sidebar should overlay */
  #mainWrapper.pushed {
    margin-left: 0 !important;
  }
  
  /* Make sure overlay is clickable and visible */
  .sidebar-overlay.active {
    display: block !important;
    opacity: 1 !important;
    z-index: 1000 !important;
    pointer-events: all !important;
  }
  
  /* Sidebar should be on top */
  .sidebar {
    z-index: 1001 !important;
  }
}

/* Specific fix for tablets */
@media (max-width: 1024px) and (min-width: 769px) {
  .sidebar {
    max-width: 280px;
  }
}

/* Specific fix for mobile phones */
@media (max-width: 768px) {
  .sidebar {
    max-width: 280px;
  }
  
  /* Make sidebar full height */
  .sidebar {
    height: 100vh !important;
    height: 100dvh !important; /* Dynamic viewport height for mobile browsers */
  }
}