/* Panel Base Styles */
.panel {
  position: fixed;
  background: var(--panel-bg);
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  z-index: 150;
  color: var(--text-dark);
  animation: panelOpen 0.3s ease-out;
}

@keyframes panelOpen {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid #eee;
}

.panel-header h3 {
  font-size: 18px;
  margin: 0;
}

.panel-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
  transition: color 0.2s;
}

.panel-close:hover {
  color: var(--danger-color);
}

.panel-content {
  padding: 20px;
  max-height: 400px;
  overflow-y: auto;
}

/* Inventory Panel */
#inventory-panel {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 350px;
  max-width: 90%;
}

#inventory-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 10px;
  margin-bottom: 15px;
}

.inventory-item {
  background: #f5f5f5;
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.inventory-item:hover {
  background: #e0e0e0;
  transform: scale(1.05);
}

.inventory-item .item-icon {
  font-size: 32px;
  display: block;
  margin-bottom: 5px;
}

.inventory-item .item-name {
  font-size: 12px;
  color: #666;
}

.inventory-item .item-quantity {
  font-size: 14px;
  font-weight: bold;
  color: var(--primary-dark);
}

.inventory-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 15px;
  border-top: 1px solid #eee;
}

#inventory-usage {
  font-size: 14px;
  color: #666;
}

/* Shop Panel */
#shop-panel {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 500px;
  max-width: 95%;
}

.shop-tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 20px;
  border-bottom: 2px solid #eee;
  padding-bottom: 10px;
}

.shop-tab {
  flex: 1;
  padding: 10px 15px;
  border: none;
  background: #f5f5f5;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.shop-tab:hover {
  background: #e0e0e0;
}

.shop-tab.active {
  background: var(--primary-color);
  color: white;
}

#shop-content {
  max-height: 350px;
  overflow-y: auto;
}

.shop-item {
  display: flex;
  align-items: center;
  padding: 15px;
  background: #f9f9f9;
  border-radius: 10px;
  margin-bottom: 10px;
  transition: all 0.2s;
}

.shop-item:hover {
  background: #f0f0f0;
  transform: translateX(5px);
}

.shop-item-icon {
  font-size: 36px;
  margin-right: 15px;
}

.shop-item-info {
  flex: 1;
}

.shop-item-name {
  font-weight: bold;
  font-size: 16px;
  margin-bottom: 3px;
}

.shop-item-desc {
  font-size: 12px;
  color: #666;
}

.shop-item-stats {
  font-size: 11px;
  color: #888;
  margin-top: 3px;
}

.shop-item-price {
  font-weight: bold;
  font-size: 16px;
  color: var(--primary-dark);
  margin-right: 15px;
}

.shop-item-price.cannot-afford {
  color: var(--danger-color);
}

.shop-item-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  background: var(--primary-color);
  color: white;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.2s;
}

.shop-item-btn:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: scale(1.05);
}

.shop-item-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.shop-item-btn.unlock {
  background: var(--accent-color);
  color: var(--text-dark);
}

.shop-item.locked {
  opacity: 0.6;
}

.shop-item.locked .lock-icon {
  margin-left: 5px;
}

/* Upgrade styles */
.upgrade-item {
  display: flex;
  align-items: center;
  padding: 15px;
  background: #f9f9f9;
  border-radius: 10px;
  margin-bottom: 10px;
}

.upgrade-level-bar {
  display: flex;
  gap: 3px;
  margin-top: 5px;
}

.upgrade-level-pip {
  width: 20px;
  height: 6px;
  border-radius: 3px;
  background: #ddd;
}

.upgrade-level-pip.filled {
  background: var(--primary-color);
}

.upgrade-level-pip.current {
  background: var(--accent-color);
}

/* Machine styles */
.machine-item {
  display: flex;
  align-items: flex-start;
  padding: 15px;
  background: linear-gradient(135deg, #f9f9f9, #f0f0f0);
  border-radius: 10px;
  margin-bottom: 10px;
  border-left: 4px solid;
}

.machine-item.tier-1 {
  border-color: #8BC34A;
}

.machine-item.tier-2 {
  border-color: #2196F3;
}

.machine-item.tier-3 {
  border-color: #9C27B0;
}

.machine-tier-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  color: white;
  margin-left: 8px;
}

.tier-1 .machine-tier-badge { background: #8BC34A; }
.tier-2 .machine-tier-badge { background: #2196F3; }
.tier-3 .machine-tier-badge { background: #9C27B0; }

/* Action Buttons */
.action-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  background: var(--primary-color);
  color: white;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
}

.action-btn.secondary {
  background: #757575;
}

.action-btn.danger {
  background: var(--danger-color);
}

/* Tooltip */
.tooltip {
  position: fixed;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 10px 15px;
  border-radius: 8px;
  font-size: 14px;
  max-width: 250px;
  z-index: 300;
  pointer-events: none;
  animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.tooltip-title {
  font-weight: bold;
  margin-bottom: 5px;
}

.tooltip-desc {
  font-size: 12px;
  color: #ccc;
}

/* Progress bars */
.progress-bar {
  width: 100%;
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary-color);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* Modal overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 140;
  animation: fadeIn 0.2s ease-out;
}

/* Scrollbar styling */
.panel-content::-webkit-scrollbar {
  width: 8px;
}

.panel-content::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

.panel-content::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

.panel-content::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px;
  color: #999;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 10px;
}

.empty-state-text {
  font-size: 14px;
}

/* Auth Forms */
.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
}

.auth-tab {
  flex: 1;
  padding: 12px 20px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  font-size: 16px;
  font-weight: 500;
  transition: all 0.2s;
}

.auth-tab:hover {
  background: rgba(255, 255, 255, 0.1);
}

.auth-tab.active {
  background: var(--primary-color);
  color: white;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.auth-form input {
  padding: 14px 18px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.95);
  font-size: 16px;
  color: #333;
  transition: all 0.2s;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

.auth-form input::placeholder {
  color: #999;
}

.auth-error {
  color: #ff6b6b;
  font-size: 14px;
  text-align: center;
  min-height: 20px;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 15px;
  margin: 20px 0;
  color: rgba(255, 255, 255, 0.5);
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.2);
}

.quick-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.menu-btn.secondary {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.menu-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
}

.menu-btn.telegram {
  background: #0088cc;
  color: white;
}

.menu-btn.telegram:hover {
  background: #0077b5;
}

.tg-icon {
  margin-right: 8px;
}

/* Achievements Panel */
#achievements-panel {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 450px;
  max-width: 95%;
}

.achievements-summary {
  text-align: center;
  padding: 10px;
  background: linear-gradient(135deg, #f5f5f5, #e0e0e0);
  border-radius: 8px;
  margin-bottom: 15px;
  font-weight: bold;
  color: var(--primary-dark);
}

.achievement-item {
  display: flex;
  align-items: center;
  padding: 12px;
  background: #f9f9f9;
  border-radius: 10px;
  margin-bottom: 8px;
  transition: all 0.2s;
  border-left: 4px solid #ddd;
}

.achievement-item.completed {
  border-left-color: var(--primary-color);
  background: linear-gradient(135deg, #e8f5e9, #f9f9f9);
}

.achievement-item:hover {
  transform: translateX(3px);
}

.achievement-icon {
  font-size: 32px;
  margin-right: 12px;
}

.achievement-info {
  flex: 1;
}

.achievement-name {
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 2px;
}

.achievement-desc {
  font-size: 12px;
  color: #666;
}

.achievement-progress {
  margin-top: 6px;
}

.achievement-reward {
  text-align: right;
  font-size: 12px;
  color: var(--accent-color);
}

.achievement-claim-btn {
  padding: 6px 12px;
  font-size: 12px;
  margin-top: 4px;
}

/* Stats Panel */
#stats-panel {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 500px;
  max-width: 95%;
}

.stats-tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 15px;
}

.stats-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: #f5f5f5;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.stats-tab.active {
  background: var(--primary-color);
  color: white;
}

.stats-section {
  min-height: 200px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: #f9f9f9;
  border-radius: 8px;
  margin-bottom: 8px;
}

.stat-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.stat-label .icon {
  font-size: 20px;
}

.stat-value {
  font-weight: bold;
  font-size: 16px;
  color: var(--primary-dark);
}

/* Leaderboard */
.leaderboard-category-select {
  margin-bottom: 15px;
}

.leaderboard-category-select select {
  width: 100%;
  padding: 10px;
  border: 2px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  background: white;
}

.leaderboard-entry {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: #f9f9f9;
  border-radius: 8px;
  margin-bottom: 6px;
  transition: all 0.2s;
}

.leaderboard-entry:hover {
  background: #f0f0f0;
}

.leaderboard-entry.current-player {
  background: linear-gradient(135deg, #e8f5e9, #f0f0f0);
  border: 2px solid var(--primary-color);
}

.leaderboard-rank {
  width: 40px;
  font-weight: bold;
  font-size: 16px;
  color: #666;
}

.leaderboard-rank.top-1 { color: #FFD700; }
.leaderboard-rank.top-2 { color: #C0C0C0; }
.leaderboard-rank.top-3 { color: #CD7F32; }

.leaderboard-player {
  flex: 1;
  font-size: 14px;
}

.leaderboard-player-name {
  font-weight: 500;
}

.leaderboard-player-level {
  font-size: 12px;
  color: #888;
}

.leaderboard-score {
  font-weight: bold;
  color: var(--primary-dark);
}

/* Prestige */
.prestige-info {
  text-align: center;
  padding: 20px;
  background: linear-gradient(135deg, #9c27b0, #7b1fa2);
  border-radius: 12px;
  color: white;
  margin-bottom: 15px;
}

.prestige-level {
  font-size: 18px;
  margin-bottom: 5px;
}

.prestige-multiplier {
  font-size: 24px;
  font-weight: bold;
}

.prestige-perks {
  margin-bottom: 15px;
}

.prestige-perk {
  display: flex;
  justify-content: space-between;
  padding: 10px;
  background: #f5f5f5;
  border-radius: 8px;
  margin-bottom: 6px;
}

.prestige-btn {
  width: 100%;
  background: linear-gradient(135deg, #9c27b0, #7b1fa2);
}

.prestige-btn:disabled {
  background: #ccc;
}

.prestige-requirements {
  margin-top: 10px;
  font-size: 12px;
  color: #666;
  text-align: center;
}

/* Animals Panel */
#animals-panel {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 450px;
  max-width: 95%;
}

.animal-item {
  display: flex;
  align-items: center;
  padding: 15px;
  background: #f9f9f9;
  border-radius: 10px;
  margin-bottom: 10px;
}

.animal-icon {
  font-size: 40px;
  margin-right: 15px;
}

.animal-info {
  flex: 1;
}

.animal-name {
  font-weight: bold;
  font-size: 14px;
}

.animal-happiness {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
}

.happiness-bar {
  width: 100px;
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
}

.happiness-fill {
  height: 100%;
  background: linear-gradient(90deg, #f44336, #ffeb3b, #4caf50);
  transition: width 0.3s;
}

.animal-actions {
  display: flex;
  gap: 5px;
}

.animal-btn {
  padding: 6px 10px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 16px;
  transition: transform 0.2s;
}

.animal-btn:hover {
  transform: scale(1.1);
}

.animal-btn.feed { background: #e8f5e9; }
.animal-btn.collect { background: #fff3e0; }
.animal-btn.collect:disabled { opacity: 0.5; cursor: not-allowed; }

/* Crafting Panel */
#crafting-panel {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 500px;
  max-width: 95%;
}

.crafting-tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 15px;
}

.crafting-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: #f5f5f5;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.crafting-tab.active {
  background: var(--primary-color);
  color: white;
}

.recipe-item {
  display: flex;
  align-items: center;
  padding: 15px;
  background: #f9f9f9;
  border-radius: 10px;
  margin-bottom: 10px;
}

.recipe-icon {
  font-size: 36px;
  margin-right: 15px;
}

.recipe-info {
  flex: 1;
}

.recipe-name {
  font-weight: bold;
  font-size: 14px;
}

.recipe-ingredients {
  font-size: 12px;
  color: #666;
  margin-top: 4px;
}

.recipe-time {
  font-size: 11px;
  color: #888;
  margin-top: 2px;
}

.recipe-btn {
  padding: 8px 16px;
}

.recipe-btn:disabled {
  background: #ccc;
}

.crafting-queue-item {
  display: flex;
  align-items: center;
  padding: 12px;
  background: linear-gradient(135deg, #f9f9f9, #f0f0f0);
  border-radius: 10px;
  margin-bottom: 8px;
}

.queue-progress {
  margin-top: 8px;
}

.queue-time {
  font-size: 12px;
  color: #666;
  margin-top: 4px;
}

/* Machines Panel */
#machines-panel {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 450px;
  max-width: 95%;
}

.machines-footer {
  padding-top: 15px;
  border-top: 1px solid #eee;
  text-align: center;
}

/* Settings Panel */
#settings-panel {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 350px;
  max-width: 95%;
}

.settings-group {
  margin-bottom: 20px;
}

.settings-label {
  display: block;
  font-size: 14px;
  margin-bottom: 8px;
  color: #333;
}

.settings-group input[type="range"] {
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  background: #e0e0e0;
  border-radius: 4px;
  outline: none;
}

.settings-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary-color);
  cursor: pointer;
}

.settings-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-right: 10px;
  vertical-align: middle;
}

.settings-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #eee;
}

/* Machines Panel */
.panel-large {
  width: 500px !important;
  max-width: 90vw;
}

.machines-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-radius: 10px;
  overflow: hidden;
  background: #f5f5f5;
}

.machines-tab {
  flex: 1;
  padding: 12px 20px;
  border: none;
  background: transparent;
  color: #666;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.machines-tab:hover {
  background: #eee;
}

.machines-tab.active {
  background: var(--primary-color);
  color: white;
}

.machines-section {
  min-height: 200px;
}

.machines-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.machine-card {
  background: white;
  border: 2px solid #eee;
  border-radius: 12px;
  padding: 15px;
  transition: all 0.2s;
  cursor: pointer;
}

.machine-card:hover {
  border-color: var(--primary-color);
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.machine-card.owned {
  border-color: var(--primary-color);
  background: linear-gradient(135deg, #f0fff0 0%, #fff 100%);
}

.machine-card.locked {
  opacity: 0.6;
  cursor: not-allowed;
}

.machine-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.machine-icon {
  font-size: 28px;
}

.machine-name {
  font-weight: bold;
  font-size: 14px;
}

.machine-tier {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: #eee;
  margin-left: auto;
}

.machine-tier.tier1 { background: #e8f5e9; color: #2e7d32; }
.machine-tier.tier2 { background: #e3f2fd; color: #1565c0; }
.machine-tier.tier3 { background: #fce4ec; color: #c2185b; }

.machine-effect {
  font-size: 12px;
  color: #666;
  margin-bottom: 10px;
  line-height: 1.4;
}

.machine-stats {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: #888;
  margin-bottom: 10px;
}

.machine-stat {
  display: flex;
  align-items: center;
  gap: 4px;
}

.machine-cost {
  font-size: 14px;
  font-weight: bold;
  color: var(--primary-color);
}

.machine-cost.locked {
  color: #999;
}

.machine-unlock {
  font-size: 11px;
  color: #ff9800;
}

.machine-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.machine-btn {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.machine-btn.buy {
  background: var(--primary-color);
  color: white;
}

.machine-btn.buy:hover {
  background: var(--primary-dark);
}

.machine-btn.buy:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.machine-btn.toggle {
  background: #f5f5f5;
}

.machine-btn.toggle.active {
  background: #4CAF50;
  color: white;
}

.machine-btn.remove {
  background: #ffebee;
  color: #c62828;
}

.machine-btn.remove:hover {
  background: #ffcdd2;
}

.machines-empty {
  text-align: center;
  padding: 40px;
  color: #999;
}

.machines-tiers h4 {
  margin: 20px 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #eee;
  color: #333;
}

.machines-tiers h4:first-child {
  margin-top: 0;
}

/* Mobile Responsive */
@media (max-width: 600px) {
  .panel {
    width: 95% !important;
    max-width: none !important;
  }

  .panel-content {
    max-height: 60vh;
  }

  .shop-tabs,
  .stats-tabs,
  .crafting-tabs {
    flex-wrap: wrap;
  }

  .shop-tab,
  .stats-tab,
  .crafting-tab {
    flex-basis: 45%;
  }

  #tool-bar {
    flex-wrap: wrap;
    max-width: 200px;
  }

  .tool-btn {
    width: 45px;
    height: 45px;
    font-size: 20px;
  }
}
