/* Layout Structure */
.app-container {
  display: flex;
  width: 100%;
  height: 100vh;
  overflow: hidden;
}

.main-content {
  flex: 1 1 auto; /* Allow growth but prevent sidebar squeeze */
  display: flex;
  flex-direction: column;
  min-width: 0; /* Prevent text from breaking layout */
  overflow: hidden;
  background-color: var(--bg-primary);
}

/* Inner Content */
.content-wrapper {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden; /* Stop horizontal scroll */
  padding: 20px;
}

/* Sidebar Styles */
.sidebar {
  flex-shrink: 0; /* Prevent shrinking */
  width: 80px; /* Default collapsed width */
  background-color: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  border-right: 1px solid var(--border-color);
  transition: width 0.3s ease;
  z-index: 100;
}

.sidebar.expanded {
  width: 250px;
}

.sidebar-logo {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 15px 0;
}

.sidebar-logo img {
  max-width: 50px;
  max-height: 50px;
}

.sidebar-toggle {
  cursor: pointer;
  color: var(--text-primary);
  padding: 15px;
  width: 100%;
  text-align: center;
}

.sidebar-menu {
  width: 100%;
  list-style-type: none;
  padding: 0;
  margin: 0;
}

.sidebar-link {
  display: flex;
  align-items: center;
  padding: 12px 15px;
  color: var(--text-primary);
  text-decoration: none;
  transition: background-color 0.3s, color 0.3s;
}

.menu-item {
  position: relative;
  width: 100%;
}

.menu-item i {
  font-size: 18px;
  width: 25px;
  text-align: center;
  color: var(--text-secondary);
  margin-right: 10px;
  /* Reduced margin */
}

.menu-item span {
  white-space: nowrap;
  opacity: 0;
  width: 0;
  overflow: hidden;
  transition: opacity 0.3s, width 0.3s;
}

.sidebar.expanded .menu-item span {
  opacity: 1;
  width: auto;
}

/* Submenu Styles */
.submenu {
  list-style-type: none;
  padding: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out, opacity 0.3s;
  background-color: var(--bg-secondary);
  opacity: 0;
}

.sidebar.expanded .has-submenu:hover .submenu {
  max-height: 300px;
  opacity: 1;
}

.submenu a {
  display: block;
  padding: 8px 15px;
  color: var(--text-primary);
  text-decoration: none;
  transition: background-color 0.3s;
}

.submenu a:hover {
  background-color: var(--hover-bg);
}

.sidebar.expanded .submenu {
  position: static;
  background-color: transparent;
  box-shadow: none;
  margin-top: 0;
  padding-left: 50px;
  /* Indent submenu items */
}

/* Logout Item */
.logout-item .sidebar-link {
  color: #dc2626 !important;
}

.logout-item .sidebar-link i {
  color: #dc2626 !important;
}

/* Login Item */
.login-item .sidebar-link {
  color: #22c55e !important;
}

.login-item .sidebar-link i {
  color: #22c55e  !important;
}

/* Hover Effects */
.sidebar-link:hover,
.menu-item:hover {
  background-color: var(--hover-bg);
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .sidebar {
    width: 60px;
  }

  .sidebar.expanded {
    width: 250px;
  }

  .submenu {
    position: absolute;
    left: 100%;
    top: 0;
    width: 200px;
    background-color: var(--bg-secondary);
    box-shadow: var(--box-shadow);
    z-index: 1000;
    max-height: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
  }

  .menu-item:hover .submenu {
    opacity: 1;
    visibility: visible;
  }
}

/* Main Content Styles */
.main-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-primary);
}

/* Base header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 20px 15px;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: nowrap; /* Prevent stacking */
  overflow: hidden;
}

/* User profile section */
.header .user-profile {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.header .user-profile img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
}

.header .username {
  font-size: 0.95rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Page title */
.header .page-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0 auto; /* Center title between items */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Theme toggle */
.header .header-theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

/* Theme toggle switch styling */
.theme-toggle {
  position: relative;
  width: 45px;
  height: 22px;
  background-color: var(--gray-200);
  border-radius: 25px;
  cursor: pointer;
  flex-shrink: 0;
}

.theme-toggle-input {
  opacity: 0;
  position: absolute;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.theme-toggle-label {
  position: absolute;
  width: 19px;
  height: 19px;
  background-color: var(--gray-700);
  border-radius: 50%;
  top: 1.5px;
  left: 2px;
  transition: transform 0.3s;
}

.theme-toggle-input:checked + .theme-toggle-label {
  transform: translateX(23px);
  background-color: var(--gray-50);
}

/* Sidebar toggle button */
.mobile-sidebar-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: var(--text-primary);
  cursor: pointer;
  padding: 5px;
  flex-shrink: 0;
}

/* Login / Logout buttons */
.header a.logout-item,
.header a.login-item {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px 8px;
  font-size: 0.95rem;
  text-decoration: none;
  color: var(--text-primary);
  transition: background-color 0.3s ease;
  flex-shrink: 0;
}

.header a.logout-item:hover,
.header a.login-item:hover {
  background-color: var(--hover-bg);
  border-radius: 4px;
}

.header a.logout-item i,
.header a.login-item i {
  font-size: 1.1rem;
}

/* Responsive tweaks */
@media (max-width: 480px) {
  .header {
    gap: 5px;
    padding: 8px 10px;
  }

  .header .page-title {
    font-size: 1rem;
  }

  .header .user-profile .username {
    font-size: 0.85rem;
  }

  .header a.logout-item,
  .header a.login-item {
    font-size: 0.85rem;
    padding: 4px 6px;
  }
}



/* Footer Styles */
.footer {
  height: 50px;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 30px;
  border-top: 1px solid var(--border-color);
}

* Logout Styles / .logout-item {
  color: #dc2626 !important;
  transition: color 0.3s, background-color 0.3s;
}

.logout-item:hover {
  color: #ef4444 !important;
  /* Tailwind's red-500 */
  background-color: rgba(220, 38, 38, 0.1) !important;
}

.logout-item i {
  color: #dc2626 !important;
}

/* Floating Voter Button */
.floating-voter-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background-color: var(--blue-600);
  /* Fallback to blue */
  color: white;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  z-index: 1000;
  transition: transform 0.3s, box-shadow 0.3s;
}

.floating-voter-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 15px 20px -5px rgba(0, 0, 0, 0.15), 0 5px 8px -3px rgba(0, 0, 0, 0.08);
}

.floating-voter-btn i {
  font-size: 24px;
}

/* Mobile Sidebar Toggle Button */
.mobile-sidebar-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-primary);
  cursor: pointer;
}

@media (max-width: 768px) {
  .mobile-sidebar-btn {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: -250px; /* hidden by default */
    height: 100%;
    z-index: 999;
    transition: left 0.3s ease;
  }

  .sidebar.mobile-visible {
    left: 0; /* slide in */
  }

  .main-content {
    margin-left: 0; /* Prevent shift on mobile */
  }
}


/* Footer Responsive */
.footer {
	text-align: center;
	padding: 10px 15px;
	font-size: 0.9rem;
}

@media (max-width: 768px) {
	.footer {
		font-size: 0.8rem;
		line-height: 1.4;
		padding: 8px;
	}
}
