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

:root[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f5;
  --text-primary: #1a1a1a;
  --text-secondary: #666666;
  --border-color: #e0e0e0;
  --accent: #007bff;
  --accent-hover: #0056b3;
  --nav-bg: #ffffff;
  --nav-shadow: rgba(0, 0, 0, 0.1);
  --card-bg: #ffffff;
  --input-bg: #ffffff;
  --input-border: #d0d0d0;
}

:root[data-theme="dark"] {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2a2a2a;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0a0;
  --border-color: #404040;
  --accent: #4a9eff;
  --accent-hover: #6bb0ff;
  --nav-bg: #242424;
  --nav-shadow: rgba(0, 0, 0, 0.5);
  --card-bg: #2a2a2a;
  --input-bg: #333333;
  --input-border: #505050;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Navigation */
nav {
  position: sticky;
  top: 0;
  background-color: var(--nav-bg);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 2px 8px var(--nav-shadow);
  z-index: 1000;
  transition: background-color 0.3s ease;
}

.nav-container {
  padding: 0.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav-logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.nav-block {
  display: contents;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}

.nav-links a {
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: color 0.3s ease;
  position: relative;
}

.nav-links a:hover {
  color: var(--accent);
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--accent);
  transition: width 0.3s ease;
}

.nav-links a:hover::after {
  width: 100%;
}

/* Theme Toggle */
.theme-toggle {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 0.35rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
}

.theme-toggle:hover {
  background: var(--border-color);
}

.theme-icon {
  width: 18px;
  height: 18px;
}

/* User Auth Section */
.user-section {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-name {
  color: var(--text-primary);
  font-weight: 500;
}

/* Login Form */
.login-form {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  position: relative;
}

.login-fields {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 0;
  overflow: visible;
  opacity: 0;
  transition: all 0.4s ease;
  pointer-events: none;
}

.login-fields.active {
  max-width: 400px;
  opacity: 1;
  pointer-events: auto;
}

.login-inputs {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  white-space: nowrap;
}

.login-fields input {
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  background-color: var(--input-bg);
  color: var(--text-primary);
  font-size: 0.9rem;
  line-height: 1.5;
  height: 34px;
  transition: all 0.3s ease;
  min-width: 110px;
  width: auto;
  box-sizing: border-box;
}

.login-fields input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.1);
}

/* Error Tooltip */
.login-error-tooltip {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  background-color: #ff4444;
  color: white;
  padding: 0.5rem 0.875rem;
  border-radius: 6px;
  font-size: 0.85rem;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(255, 68, 68, 0.3);
  z-index: 1001;
  animation: slideDown 0.3s ease;
}

.tooltip-arrow {
  position: absolute;
  top: -5px;
  left: 20px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 6px solid #ff4444;
}

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

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

.btn {
  padding: 0.4rem 1rem;
  background-color: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  line-height: 1.5;
  height: 34px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  white-space: nowrap;
  position: relative;
  z-index: 10;
  box-sizing: border-box;
}

.btn:hover {
  background-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(74, 158, 255, 0.3);
}

.btn-outline {
  background-color: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
}

.btn-outline:hover {
  background-color: var(--accent);
  color: white;
}

/* Main Content */
.container {
  padding: 3rem 2rem;
}

.card {
  background-color: var(--card-bg);
  border-radius: 12px;
  padding: 2.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  max-width: 500px;
  margin: 0 auto;
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

.card:hover {
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

h1 {
  font-size: 2rem;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

input[type="text"],
input[type="password"],
input[type="email"] {
  padding: 0.875rem;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  background-color: var(--input-bg);
  color: var(--text-primary);
  font-size: 1rem;
  transition: all 0.3s ease;
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.1);
}

label {
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
}

.mobile-controls {
  display: none;
  align-items: center;
  gap: 0.75rem;
}

.mobile-theme-toggle {
  display: none;
}

.desktop-theme-toggle {
  display: flex;
}

/* Responsive Design */
@media (max-width: 768px) {
  .nav-container {
    flex-wrap: wrap;
    padding: 0.5rem 1rem;
  }

  .container {
    padding: 2rem 1rem;
  }

  .mobile-controls {
    display: flex;
  }

  .mobile-theme-toggle {
    display: flex;
  }

  .desktop-theme-toggle {
    display: none;
  }

  .mobile-menu-toggle {
    display: block;
  }

  .nav-right {
    flex-basis: 100%;
    flex-direction: row;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1rem;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.3s ease;
  }

  .nav-right.active {
    display: flex;
    max-height: 500px;
    opacity: 1;
  }

  .nav-block {
    flex: 1;
    display: block;
  }

  .nav-links-block {
    display: flex;
    align-items: flex-start;
  }

  .nav-auth-block {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
  }

  .nav-links {
    flex-direction: column;
    width: 100%;
    gap: 0.75rem;
  }

  .user-section {
    flex-direction: column;
    align-items: flex-end;
    width: 100%;
  }

  .login-form {
    width: 100%;
  }

  .card {
    padding: 1.5rem;
  }

  h1 {
    font-size: 1.5rem;
  }
}

@media (max-width: 480px) {
  .nav-container {
    padding: 0.5rem 0.75rem;
  }

  .container {
    padding: 1.5rem 0.75rem;
  }

  .card {
    padding: 1.25rem;
  }

  .login-form {
    flex-direction: column;
    width: 100%;
    align-items: stretch;
  }

  .login-inputs {
    flex-direction: column;
    width: 100%;
  }

  .login-fields {
    width: 100%;
  }

  .login-fields.active {
    max-width: 100%;
  }

  .login-fields input {
    width: 100%;
  }
}
