/* Define generic color variables first */
:root {
  /* Light Theme Defaults - New Light Palette based on green/yellow gradient */
  --primary-color: #4CAF50; /* Primary Green */
  --primary-dark-color: #388E3C; /* Darker Green */
  --accent-color: #FFD700; /* Gold/Yellow accent */

  --text-color-primary: #2C3E50; /* Dark blue-grey for main text */
  --text-color-secondary: #55606B; /* Muted dark grey */
  --text-color-light: #7F8C8D; /* Light grey for placeholders/subtle text */

  /* Solid background colors for the logged-in app sections */
  --bg-color-body: #F0F8F0; /* Main app background */
  --bg-color-sidebar: #FFFFFF; /* Sidebar background */
  --bg-color-topbar: #FFFFFF; /* Topbar background */
  --bg-color-card: #FFFFFF; /* Cards/panels background */
  --bg-color-input: #EBF2E8; /* Input background */
  --bg-color-button-secondary: #D9EAD3; /* Lighter green button */
  --bg-color-hover: #E6F3E6; /* Light green hover for light theme */
  --bg-color-delete-light: #FFEBEE; /* Light red for delete background */

  --border-color-main: #DDE2E6; /* Light border */
  --border-color-delete: #FFCDD2; /* Light red border */

  --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-medium: 0 4px 10px rgba(0, 0, 0, 0.12);

  /* Sizing Variables */
  --spacing-unit: 0.8rem;
  --font-size-base: 0.9rem;
  --font-size-lg: 1.2rem;
  --font-size-xl: 1.5rem;
  --icon-size-base: 18px;
  --icon-size-lg: 24px;
}

/* Dark Theme Overrides (using green, yellow, white, black palette) */
html[data-theme='dark'] {
  --primary-color: #A2CF6E; /* Muted light green for accents like stars, icons */
  --primary-dark-color: #8BC34A; /* Green for hover states, active elements */
  --accent-color: #FFEB3B; /* Vibrant Yellow accent */

  --text-color-primary: #F0F0F0; /* Off-white for main text */
  --text-color-secondary: #C0C0C0; /* Light grey for secondary text */
  --text-color-light: #888888; /* Darker grey for placeholders/subtle text */

  /* Solid background colors for the logged-in app sections in dark mode */
  --bg-color-body: #1E1E1E; /* Main app background */
  --bg-color-sidebar: #282828; /* Sidebar background */
  --bg-color-topbar: #282828; /* Topbar background */
  --bg-color-card: #383838; /* Cards/panels background */
  --bg-color-input: #4A4A4A; /* Input background */
  --bg-color-button-secondary: #607D8B; /* Slate grey for secondary buttons */
  --bg-color-hover: rgba(162, 207, 110, 0.2); /* Transparent primary green for hover */
  --bg-color-delete-light: #D32F2F30; /* Red for delete background (unchanged) */

  --border-color-main: #555555; /* Medium grey border */
  --border-color-delete: #EF9A9A; /* Light red border (unchanged) */

  --shadow-light: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-medium: 0 4px 15px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: 'Inter', sans-serif;
  color: var(--text-color-primary); /* Use generic text color */
  line-height: 1.5;
  font-size: var(--font-size-base);
  
  /* Base background color for the entire page, covered by login or app-container */
  background-color: var(--bg-color-body); 
  
  transition: color 0.3s ease; /* Smooth theme transition for text colors */
}

.hidden {
  display: none !important;
}

/* --- Login Page --- */
.login-page {
  display: flex;
  justify-content: flex-start; /* Place login box on the left */
  align-items: center;
  height: 100vh;
  /* Background image specific to the login page */
  background-image: url("login-page.png");
  background-size: cover;
  background-position: center center;
  background-attachment: fixed; /* Ensures background stays fixed while scrolling */
  background-repeat: no-repeat;
  
  color: #333; /* Default text color for login, will be overridden by login-box */
  overflow: hidden;
  position: relative;
  padding-left: 5%; /* Push login box slightly from the left edge */
  box-sizing: border-box; /* Include padding in element's total width and height */
}

.login-box {
  /* Fixed semi-transparent background for login box, not tied to theme */
  background-color: rgba(0, 0, 0, 0); /* Semi-transparent black for better contrast */
  padding: 40px; /* Increased padding for more space */
  border-radius: 12px; /* More rounded corners */
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4); /* Stronger shadow for contrast */
  text-align: center;
  width: 100%;
  max-width: 400px; /* Adjusted max width */
  min-height: 380px; /* Adjusted min height to fit content */
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative; /* Ensure it's above shapes */
  z-index: 1; /* Keep it above background elements */
  border: 1px solid rgba(255, 255, 255, 0.1); /* Subtle border */
  color: white; /* Default text color for login box content */
  margin-left: 80px;
  margin-top:40px;
}

.login-box .app-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-color); /* Use accent color for app title on login */
    margin-bottom: 20px;
    letter-spacing: 1px;
    display: flex; /* For aligning logo and text */
    align-items: center;
    justify-content: center;
}

.login-box .app-title img {
    height: 30px; /* Adjust logo size */
    margin-right: 10px;
}

.login-box h2 {
  font-size: var(--font-size-xl);
  margin-bottom: 25px; /* More space below Login heading */
  color: #F0F8F0;
  font-weight: 600;
}

.input-group {
    text-align: left;
    margin-bottom: 20px; /* Increased margin for input groups */
}

.input-group label {
    display: block;
    font-size: calc(var(--font-size-base) * 0.9);
    color: white; /* White for labels on dark background */
    margin-bottom: 8px; /* Space between label and input */
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.login-box input {
  display: block;
  width: 100%;
  padding: 12px 15px; /* Increased padding */
  border: 1px solid rgba(255, 255, 255, 0.2); /* Lighter border for dark input */
  border-radius: 8px; /* Slightly more rounded */
  font-size: var(--font-size-base);
  transition: all 0.3s ease;
  background-color: rgba(255, 255, 255, 0.1); /* Semi-transparent white for input background */
  color: white; /* White text for input */
  padding-right: 40px; /* Space for icon */
}

.login-box input::placeholder {
  color: rgba(255, 255, 255, 0.7); /* Lighter placeholder on dark input */
  opacity: 0.7;
}

.login-box input:focus {
  outline: none;
  border-color: var(--primary-color); /* Green focus border */
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3); /* Green shadow */
}

.password-toggle-icon {
    position: absolute;
    right: 12px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.7); /* Light icon on dark background */
    font-size: var(--icon-size-base);
    transition: color 0.2s ease;
}

.password-toggle-icon:hover {
    color: var(--primary-color); /* Green hover for icon */
}

.login-options-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: calc(var(--font-size-base) * 0.9);
    color: white; /* White text for options */
}

.remember-me {
    display: flex;
    align-items: center;
    color: white; /* White color */
}

.remember-me input[type="checkbox"] {
    margin-right: 5px;
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color); /* Green accent for checkbox */
}

#forgot-password-link {
    color: white; /* White link */
    text-decoration: none;
    transition: color 0.2s ease;
}
#forgot-password-link:hover {
    color: var(--primary-color); /* Green hover for link */
    text-decoration: underline;
}

.login-box .main-sign-in-btn {
  width: 100%;
  padding: 14px 15px; /* Increased padding for main button */
  background: var(--primary-color); /* Primary Green */
  color: white;
  border: none;
  border-radius: 8px;
  font-size: var(--font-size-base);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s ease, transform 0.2s ease;
  margin-top: 25px; /* Increased margin */
  box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4); /* Green shadow */
}

.login-box .main-sign-in-btn:hover {
  background: var(--primary-dark-color);
  transform: translateY(-2px);
}

.login-with-google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 15px; /* Reverted to match main button padding */
    background: #FFFFFF; /* White background for the button */
    color: #333; /* Dark text for button */
    border: 1px solid #DDD; /* Light grey border */
    border-radius: 8px;
    font-size: var(--font-size-base);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
    margin-top: 20px; /* Space between email login and Google login */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); /* Subtle shadow for button */
}

.login-with-google-btn img {
    width: 24px; /* Icon size */
    height: 24px;
    margin-right: 10px;
}

.login-with-google-btn:hover {
    background: #F0F0F0; /* Light hover effect */
    border-color: #CCC;
    transform: translateY(-2px);
}

#login-msg {
  color: #FF6347; /* Error message color */
  margin-top: var(--spacing-unit);
  font-size: calc(var(--font-size-base) * 0.9);
  font-weight: 500;
}

/* --- App Container --- */
.app-container {
  display: flex;
  height: 100vh;
  background-color: var(--bg-color-body); /* This will cover the global background image */
  overflow: hidden;
  transition: background-color 0.3s ease; /* For theme change */
}

/* --- Sidebar --- */
.sidebar {
  width: 240px;
  background: var(--bg-color-sidebar); /* Use solid variable */
  border-right: 1px solid var(--border-color-main);
  padding: calc(var(--spacing-unit) * 1.2);
  overflow-y: auto;
  box-shadow: 1px 0 6px rgba(0, 0, 0, 0.05);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  left: 0;
  transition: left 0.3s ease-in-out, background-color 0.3s ease; /* Added transition */
}

.sidebar.active {
  left: 0;
}

.sidebar h2 {
  font-size: var(--font-size-xl);
  margin-bottom: calc(var(--spacing-unit) * 2);
  color: var(--primary-color);
  text-align: center;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.sidebar .section-label {
  margin-top: var(--spacing-unit); /* Adjusted */
  font-size: var(--font-size-base); /* Adjusted */
  color: var(--text-color-secondary);
  margin-bottom: calc(var(--spacing-unit) * 0.2); /* Adjusted */
  font-weight: 600;
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 0.3rem 0.6rem; /* Adjusted */
  border-radius: 5px;
  transition: background-color 0.2s ease;
}

.sidebar .section-label:hover {
  background-color: var(--bg-color-hover);
}

.sidebar .section-label span {
  margin-left: auto;
  font-size: calc(var(--font-size-base) * 0.8);
  color: var(--text-color-light);
  transition: transform 0.2s ease;
}

.sidebar .section-label.expanded span {
  transform: rotate(90deg);
}

.sidebar .menu-item {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.8rem; /* Adjusted */
  font-size: calc(var(--font-size-base) * 0.9); /* Adjusted */
  cursor: pointer;
  color: var(--text-color-secondary);
  border-radius: 6px;
  margin-bottom: 0.1rem; /* Adjusted */
  transition: background-color 0.2s ease, color 0.2s ease;

  /* Added for text truncation in sidebar */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar .menu-item:hover {
  background-color: var(--bg-color-hover);
  color: var(--primary-dark-color);
}

.sidebar .menu-item i {
  font-size: calc(var(--icon-size-base) * 0.9) !important; /* Adjusted */
  margin-right: 0.6rem; /* Adjusted */
  color: var(--text-color-light);
  transition: color 0.2s ease;
  flex-shrink: 0; /* Prevent icon from shrinking */
}

.sidebar .menu-item:hover i {
  color: var(--primary-color);
}

/* Mode Selector Styles */
.mode-selector {
  margin-top: auto;
  padding-top: var(--spacing-unit);
  border-top: 1px solid var(--border-color-main);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mode-selector label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: calc(var(--font-size-base) * 0.9);
  color: var(--text-color-secondary);
  cursor: pointer;
  padding: 0.3rem 0;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.mode-selector label:hover {
    background-color: var(--bg-color-hover);
}

.mode-selector input[type="radio"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid var(--primary-color);
  border-radius: 50%;
  position: relative;
  cursor: pointer;
  display: inline-block;
  flex-shrink: 0;
}

.mode-selector input[type="radio"]:checked {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

.mode-selector input[type="radio"]:checked::after {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  background: white;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* --- Main Content Area --- */
.main {
  flex-grow: 1;
  padding: 0;
  background: transparent; /* Explicitly transparent to show app-container background */
  overflow: auto; /* Changed from overflow-y to auto for overall content */
  position: relative;
  width: 100%;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
  background-color: var(--bg-color-topbar); /* Use solid variable */
  padding: var(--spacing-unit);
  border-radius: 0;
  box-shadow: var(--shadow-light);
  position: sticky;
  top: 0;
  z-index: 10;
  flex-wrap: wrap; /* Allow wrapping on small screens */
  transition: background-color 0.3s ease; /* Added transition */
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: var(--font-size-lg);
  cursor: pointer;
  color: var(--text-color-primary);
  margin-right: var(--spacing-unit);
}

/* Search Bar Styles */
.search-bar {
  display: flex;
  align-items: center;
  background-color: var(--bg-color-input);
  border: 1px solid var(--border-color-main);
  border-radius: 8px;
  padding: 0.3rem 0.6rem;
  flex-grow: 1; /* Allows it to take available space */
  max-width: 300px; /* Limit width */
  margin: 0 var(--spacing-unit); /* Center it or give horizontal margin */
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.search-bar:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

.search-bar input {
  border: none;
  background: transparent;
  outline: none;
  flex-grow: 1;
  padding: 0.3rem 0.5rem;
  font-size: var(--font-size-base);
  color: var(--text-color-primary);
}

.search-bar i {
  color: var(--text-color-secondary);
  font-size: var(--icon-size-base);
}


.user-box {
  display: flex;
  align-items: center;
  gap: var(--spacing-unit);
  margin-left: auto; /* Push to the right */
  position: relative; /* For dropdown positioning */
}

.filter-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-right: var(--spacing-unit); /* Add some spacing */
}

.custom-select {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border-color-main);
  border-radius: 6px;
  background-color: var(--bg-color-input);
  color: var(--text-color-primary);
  font-size: var(--font-size-base);
  cursor: pointer;
  outline: none;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.custom-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

.user-name {
  font-size: var(--font-size-base);
  color: var(--text-color-primary);
  font-weight: 500;
}

.profile {
  background: var(--primary-color);
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: calc(var(--font-size-base) * 0.9);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  cursor: pointer; /* Make it clickable */
}

.logout-btn {
  padding: 0.5rem 1rem;
  background: var(--bg-color-button-secondary);
  border: 1px solid var(--border-color-main);
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-color-secondary);
  transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
  font-size: calc(var(--font-size-base) * 0.9);
}

.logout-btn:hover {
  background: #D32F2F;
  color: white;
  border-color: #D32F2F;
}

/* User Profile Dropdown */
.profile-dropdown {
    position: absolute;
    top: calc(100% + 10px); /* Position below the profile circle */
    right: 0;
    background-color: var(--bg-color-card); /* Use solid variable */
    border: 1px solid var(--border-color-main);
    border-radius: 8px;
    box-shadow: var(--shadow-medium);
    z-index: 100;
    min-width: 200px;
    padding: 15px;
    display: none; /* Hidden by default */
    flex-direction: column;
    gap: 10px;
    transform-origin: top right;
    animation: fadeInScale 0.2s ease-out;
    transition: background-color 0.3s ease; /* Added transition */
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.profile-dropdown.active {
    display: flex;
}

.profile-dropdown p {
    margin: 0;
    color: var(--text-color-primary);
    font-size: var(--font-size-base);
}
.profile-dropdown p.email {
    font-size: calc(var(--font-size-base) * 0.9);
    color: var(--text-color-secondary);
    word-break: break-all; /* Ensures long emails wrap */
}
.profile-dropdown .dropdown-logout-btn {
    width: 100%;
    padding: 8px 12px;
    background-color: #D32F2F; /* Red color for logout */
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s ease;
}
.profile-dropdown .dropdown-logout-btn:hover {
    background-color: #C62828;
}


/* --- Cards --- */
.cards {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-unit);
  justify-content: flex-start;
  padding: var(--spacing-unit) calc(var(--spacing-unit) * 2);
  background-color: var(--bg-color-body); /* Should be solid, consistent with app-container */
  transition: background-color 0.3s ease;
}

.card {
  width: 220px;
  padding: var(--spacing-unit);
  border-radius: 12px;
  background: var(--bg-color-card); /* Use solid variable */
  box-shadow: var(--shadow-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.3s ease; /* Added transition */
  text-align: center;
  flex-shrink: 0;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-medium);
}

.card-icon {
  background: var(--primary-color);
  color: white;
  border-radius: 10px;
  padding: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--icon-size-lg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.card-icon i {
  font-size: var(--icon-size-lg) !important;
}

.card-content {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-color-primary);
}

/* --- Iframe and Back Button --- */
iframe {
  width: 100%;
  height: calc(100vh - 60px);
  border: none;
  border-radius: 0;
  background-color: var(--bg-color-card); /* Use solid variable */
  box-shadow: none;
  transition: background-color 0.3s ease; /* Added transition */
}

#back-btn {
  display: none !important;
}

/* --- Admin Panel --- */
#admin-panel {
  background: var(--bg-color-card); /* Use solid variable */
  padding: calc(var(--spacing-unit) * 1.5);
  border-radius: 12px;
  box-shadow: var(--shadow-light);
  margin-bottom: calc(var(--spacing-unit) * 1.5);
  margin-top: calc(var(--spacing-unit) * 1.5);
  margin-left: calc(var(--spacing-unit) * 2);
  margin-right: calc(var(--spacing-unit) * 2);
  transition: background-color 0.3s ease; /* Added transition */
}

#admin-panel h3 {
  font-size: var(--font-size-lg);
  margin-bottom: var(--spacing-unit);
  color: var(--primary-color);
  font-weight: 600;
}

/* Make admin panel inputs responsive */
#admin-panel .input-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

#admin-panel .input-row input,
#admin-panel .input-row select {
    flex-grow: 1; /* Allow inputs to grow and shrink */
    min-width: 150px; /* Minimum width before wrapping */
    width: auto; /* Override fixed width */
    margin: 0; /* Remove default margin from general input styles */
}

#admin-panel input,
#admin-panel select { /* General styles for inputs/selects within admin panel */
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border-color-main);
  border-radius: 6px;
  font-size: calc(var(--font-size-base) * 0.95);
  transition: border-color 0.3s ease;
  background-color: var(--bg-color-input);
  color: var(--text-color-primary);
}

#admin-panel input::placeholder {
  color: var(--text-color-light);
  opacity: 0.8;
}

#admin-panel input:focus,
#admin-panel select:focus { /* Added select for roles input */
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
}

#admin-panel button {
  padding: 0.6rem 1.2rem;
  background: var(--primary-color);
  color: white;
  border: none;
  cursor: pointer;
  border-radius: 6px;
  font-weight: 600;
  transition: background 0.3s ease, transform 0.2s ease;
  font-size: var(--font-size-base);
}

#admin-panel button:hover {
  background: var(--primary-dark-color);
  transform: translateY(-1px);
}

#admin-menu-list,
#admin-user-list { /* Added user list styling */
  margin-top: var(--spacing-unit);
  list-style: none;
  padding: 0;
}

#admin-menu-list li,
#admin-user-list li { /* Adjusted for better wrapping and alignment */
  display: flex;
  flex-wrap: wrap; /* Allow items to wrap */
  align-items: flex-start; /* Align text to the top if it wraps */
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px dashed var(--border-color-main);
  color: var(--text-color-secondary);
  font-size: calc(var(--font-size-base) * 0.95);
}

/* Styles for the text content within the list item */
#admin-menu-list li .item-display-info,
#admin-user-list li .user-display-info {
  flex-grow: 1; /* Allows text to take all available space */
  min-width: 0; /* Allows text to shrink below its content size if needed (important for long words) */
  word-wrap: break-word; /* Ensure long words break and wrap */
  white-space: normal; /* Allow normal white-space handling (wrapping) */
  margin-right: 10px; /* Space between text and buttons */
}

/* Styles for the button container within the list item */
#admin-menu-list li .item-actions,
#admin-user-list li .user-actions {
  display: flex;
  flex-shrink: 0; /* Prevent buttons from shrinking */
  gap: 5px; /* Space between buttons */
  align-items: center; /* Vertically align buttons within their container */
  margin-left: auto; /* Push buttons to the right */
}

/* Styling for the inline edit form */
#admin-user-list li .user-edit-form,
#admin-menu-list li .menu-edit-form { /* Added for menu items */
    flex-grow: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
    min-width: 0; /* Important for flex items */
}

#admin-user-list li .user-edit-form input,
#admin-menu-list li .menu-edit-form input { /* Added for menu items */
    flex-grow: 1;
    min-width: 120px; /* Ensure inputs are not too small */
    width: auto; /* Override fixed width from general input style */
    margin: 0; /* Remove extra margin from general input style */
}


#admin-menu-list li:last-child,
#admin-user-list li:last-child { /* Added user list styling */
  border-bottom: none;
}

.delete-btn { /* Combined for shared styles */
  background: var(--bg-color-delete-light);
  color: #D32F2F;
  border: 1px solid var(--border-color-delete);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  font-size: calc(var(--font-size-base) * 0.9);
}

.delete-btn:hover {
  background: #D32F2F;
  color: white;
  border-color: #D32F2F;
}

.edit-btn { /* Specific style for menu edit button */
    background: var(--primary-color);
    color: white;
    border: 1px solid var(--primary-color);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    font-size: calc(var(--font-size-base) * 0.9);
}

.edit-btn:hover {
    background: var(--primary-dark-color);
    border-color: var(--primary-dark-color);
}

/* Edit/Save/Cancel buttons for both users and menu items */
.save-btn {
  background: var(--primary-color);
  color: white;
  border: 1px solid var(--primary-color);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  font-size: calc(var(--font-size-base) * 0.9);
}
.save-btn:hover {
  background: var(--primary-dark-color);
  border-color: var(--primary-dark-color);
}

.cancel-btn {
  background: var(--bg-color-button-secondary);
  color: var(--text-color-secondary);
  border: 1px solid var(--border-color-main);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  font-size: calc(var(--font-size-base) * 0.9);
}
.cancel-btn:hover {
  background: #CCC;
  color: #555;
}


/* Role selection for multi-role users */
#role-title div {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font-size: calc(var(--font-size-base) * 0.9);
  color: var(--text-color-secondary);
}

#role-title input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid var(--primary-color);
  border-radius: 50%;
  margin-right: 4px;
  position: relative;
  cursor: pointer;
  transition: all 0.2s ease;
}

#role-title input[type="radio"]:checked {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

#role-title input[type="radio"]:checked::before {
  content: '';
  display: block;
  width: 7px;
  height: 7px;
  background-color: white;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

#role-title label {
  cursor: pointer;
}

/* --- Dashboard Specific Styles --- */
#dashboard-content {
  background-color: var(--bg-color-card); /* Use solid variable */
  padding: calc(var(--spacing-unit) * 2);
  min-height: calc(100vh - 60px);
  transition: background-color 0.3s ease; /* Added transition */
}

#dashboard-content h3 {
  font-size: var(--font-size-lg);
  margin-bottom: var(--spacing-unit);
  color: var(--primary-color);
  font-weight: 600;
}

#dashboard-content .dashboard-card {
  background-color: var(--bg-color-card); /* Use solid variable */
  padding: calc(var(--spacing-unit) * 1.5);
  border-radius: 12px;
  box-shadow: var(--shadow-light);
  margin-bottom: calc(var(--spacing-unit) * 1.5);
  transition: background-color 0.3s ease; /* Added transition */
}

#dashboard-content .dashboard-stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-unit);
  margin-bottom: calc(var(--spacing-unit) * 2);
}

#dashboard-content .stat-item {
  flex: 1;
  min-width: 150px;
  background-color: var(--bg-color-card); /* Use solid variable */
  padding: var(--spacing-unit);
  border-radius: 8px;
  box-shadow: var(--shadow-light);
  text-align: center;
  transition: background-color 0.3s ease; /* Added transition */
}

#dashboard-content .stat-item .value {
  font-size: calc(var(--font-size-xl) * 1.2);
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

#dashboard-content .stat-item .label {
  font-size: calc(var(--font-size-base) * 0.9);
  color: var(--text-color-secondary);
}

#dashboard-content table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--spacing-unit);
}

#dashboard-content th, #dashboard-content td {
  border: 1px solid var(--border-color-main);
  padding: 0.8rem;
  text-align: left;
  font-size: calc(var(--font-size-base) * 0.95);
  color: var(--text-color-secondary);
}

#dashboard-content th {
  background-color: var(--bg-color-button-secondary);
  font-weight: 600;
  color: var(--text-color-primary);
  transition: background-color 0.3s ease;
}

#dashboard-content tr:nth-child(even) {
  background-color: rgba(0, 0, 0, 0.03); /* Subtle stripe for light theme */
}
#dashboard-content tr:hover {
  background-color: var(--bg-color-hover);
}

html[data-theme='dark'] #dashboard-content tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.03); /* Subtle stripe for dark theme */
}

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }

  .login-page {
    /* On mobile, center the login box instead of pushing left */
    justify-content: center;
    padding-left: 0; /* Remove left padding */
  }

  .login-box {
    width: calc(100% - var(--spacing-unit) * 4); /* Adjust width to have padding */
    max-width: 400px; /* Keep max-width */
    margin: var(--spacing-unit) auto; /* Center with margin */
  }


  .sidebar {
    width: 250px;
    position: fixed; 
    height: 100%;
    z-index: 1000;
    left: -250px;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.2);
  }
  
  .sidebar.active {
    left: 0;
  }

  .main {
    width: 100%;
    padding-bottom: 0;
  }

  .topbar {
    padding: var(--spacing-unit);
    flex-direction: column; /* Stack items vertically on mobile */
    align-items: flex-start; /* Align items to the left */
    gap: 0.5rem; /* Add some space between stacked items */
  }

  .menu-toggle {
    display: block;
    order: 1; /* Place at the top */
  }

  .filter-controls {
    width: 100%; /* Take full width */
    order: 3; /* Place below search */
    justify-content: flex-start;
  }
  
  .search-bar {
    width: 100%; /* Take full width */
    max-width: none; /* Remove max width constraint */
    order: 2; /* Place after menu toggle */
    margin: 0; /* Remove horizontal margin */
  }

  .user-box {
    width: 100%; /* Take full width */
    justify-content: flex-end; /* Push to the right */
    order: 4; /* Place at the bottom */
    margin-top: 0.5rem; /* Space from elements above */
  }

  .cards {
    justify-content: center;
    padding: var(--spacing-unit);
  }

  .card {
    width: calc(50% - var(--spacing-unit) / 2);
    max-width: 180px;
    font-size: calc(var(--font-size-base) * 0.9);
  }

  .card-content {
    font-size: calc(var(--font-size-base) * 0.9);
  }

  iframe {
    height: calc(100vh - 60px);
  }

  #admin-panel, #dashboard-content {
    margin: var(--spacing-unit);
    padding: var(--spacing-unit);
  }

  #admin-panel input,
  #admin-panel select { /* Added select for roles input */
    width: 100%;
    margin-right: 0;
  }
  
  /* Ensure input-row also handles stacking on mobile */
  #admin-panel .input-row {
      flex-direction: column;
      gap: 5px; /* Adjust gap for vertical stacking */
  }


  #admin-panel button {
    width: 100%;
    margin-top: var(--spacing-unit);
  }

  #admin-menu-list li,
  /* Removed #admin-user-list li from here */
  #admin-user-list li { /* Adjusted for better mobile stacking */
    flex-direction: column; /* Stack elements vertically */
    align-items: flex-start; /* Align text to the left */
  }
  
  /* Ensure text spans full width on mobile */
  #admin-menu-list li .item-display-info,
  /* Removed #admin-user-list li .user-display-info from here */
  #admin-user-list li .user-display-info {
      width: 100%; /* Take full width when stacked */
      margin-bottom: 5px; /* Space between text and buttons */
      margin-right: 0; /* Remove right margin when stacked */
  }

  /* Buttons should also take full width on smaller screens */
  #admin-menu-list li .item-actions,
  /* Removed #admin-user-list li .user-actions from here */
  #admin-user-list li .user-actions {
      width: 100%;
      justify-content: flex-end; /* Align buttons to the right on mobile */
      margin-top: 5px; /* Add margin after text */
      margin-left: 0; /* Remove auto margin when stacked */
  }

  /* Adjust inline edit form on mobile */
  /* Removed #admin-user-list li .user-edit-form from here */
  #admin-menu-list li .menu-edit-form { /* Added for menu items */
      width: 100%;
      flex-direction: column; /* Stack inputs vertically */
      align-items: stretch; /* Stretch inputs to full width */
  }
  /* Removed #admin-user-list li .user-edit-form input from here */
  #admin-menu-list li .menu-edit-form input { /* Added for menu items */
      width: 100%; /* Full width for inputs */
  }


  .delete-btn, .edit-btn, .save-btn, .cancel-btn { /* Combined for shared styles */
    margin-left: 0;
    margin-top: 0; /* Remove margin-top as parent div has it */
    width: auto; /* Allow buttons to size based on content */
  }
  .edit-btn {
      margin-right: 5px; /* Space between edit and delete on mobile */
  }

  #dashboard-content .dashboard-stats {
    flex-direction: column;
  }

  #dashboard-content .stat-item {
    width: 100%;
  }
  /* filter-controls already handled above */
}

@media (max-width: 480px) {
  .card {
    width: 95%;
    max-width: 300px;
  }

  .login-box {
    margin: var(--spacing-unit);
  }

  .sidebar {
    width: 80%;
    left: -80%;
  }
}
