/* Reset & Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
  width: 100%;
}

/* Container */
.container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  overflow-x: hidden;
}

/* Header */
header {
  text-align: center;
  color: white;
  margin-bottom: 30px;
}

header h1 {
  font-size: 2.5em;
  margin-bottom: 10px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

header p {
  font-size: 1.1em;
  opacity: 0.9;
}

/* Main Layout */
.main-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 30px;
}

/* Card Component */
.card {
  background: white;
  border-radius: 15px;
  padding: 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  width: 100%;
  overflow: hidden;
}

.card h2 {
  color: #667eea;
  margin-bottom: 20px;
  font-size: 1.5em;
}

/* Category Grid */
.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.category-btn {
  padding: 15px;
  border: 2px solid #667eea;
  background: white;
  color: #667eea;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1em;
  font-weight: 600;
  transition: all 0.3s ease;
  text-align: left;
}

.category-btn:hover {
  background: #667eea;
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.category-btn.active {
  background: #667eea;
  color: white;
}

.category-count {
  display: block;
  font-size: 0.85em;
  opacity: 0.8;
  margin-top: 5px;
}

/* Random Button */
.random-btn {
  width: 100%;
  padding: 20px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1.3em;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.random-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.5);
}

.random-btn:active {
  transform: translateY(-1px);
}

/* Result Box */
.result-box {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
  padding: 30px;
  border-radius: 15px;
  text-align: center;
  min-height: 150px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-bottom: 20px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
  width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.result-box h3 {
  font-size: 1.8em;
  margin-bottom: 10px;
  animation: fadeIn 0.5s ease;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.result-box p {
  font-size: 1.1em;
  opacity: 0.9;
  animation: fadeIn 0.5s ease 0.2s backwards;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.result-box.empty {
  background: #f0f0f0;
  color: #999;
}

.result-box a,
.item-name a {
  color: inherit;
  text-decoration: none;
  border-bottom: 2px solid rgba(255, 255, 255, 0.3);
  transition: all 0.3s ease;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.result-box a {
  color: white;
}

.item-name a {
  color: #667eea;
  border-bottom-color: rgba(102, 126, 234, 0.3);
}

.item-name a:hover,
.result-box a:hover {
  border-bottom-color: currentColor;
  opacity: 0.8;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Manage Section */
.manage-section {
  grid-column: 1 / -1;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  border-bottom: 2px solid #e0e0e0;
}

.tab {
  padding: 10px 20px;
  background: none;
  border: none;
  color: #666;
  font-size: 1em;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.3s ease;
}

.tab:hover {
  color: #667eea;
}

.tab.active {
  color: #667eea;
  border-bottom-color: #667eea;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  color: #333;
  font-weight: 600;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 12px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 1em;
  transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: #667eea;
}

/* Buttons */
.btn {
  padding: 12px 30px;
  border: none;
  border-radius: 8px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary {
  background: #667eea;
  color: white;
}

.btn-primary:hover {
  background: #5568d3;
  transform: translateY(-2px);
}

.btn-danger {
  background: #f5576c;
  color: white;
}

.btn-danger:hover {
  background: #e04556;
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.9em;
}

/* Items List */
.items-list {
  max-height: 500px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.items-list::-webkit-scrollbar {
  width: 6px;
}

.items-list::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

.items-list::-webkit-scrollbar-thumb {
  background: #667eea;
  border-radius: 10px;
}

.items-list::-webkit-scrollbar-thumb:hover {
  background: #5568d3;
}

.item-group {
  margin-bottom: 0;
}

.item-group:not(:first-child) {
  margin-top: 20px;
}

.item-group h3 {
  color: #667eea;
  margin: 0 0 15px 0;
  padding: 12px 0;
  border-bottom: 2px solid #e0e0e0;
  position: sticky;
  top: 0;
  background: white;
  z-index: 10;
}

.item-group:not(:last-child) .item:last-child {
  margin-bottom: 5px;
}

.item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: #f8f9fa;
  margin-bottom: 8px;
  border-radius: 8px;
  transition: all 0.3s ease;
  width: 100%;
  max-width: 100%;
}

.item:hover {
  background: #e9ecef;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.item-content {
  flex: 1;
  min-width: 0;
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
}

.item-name {
  font-weight: 600;
  color: #333;
  margin-bottom: 3px;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.item-desc {
  font-size: 0.9em;
  color: #666;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

.item-actions {
  display: flex;
  gap: 8px;
}

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

.empty-state svg {
  width: 80px;
  height: 80px;
  margin-bottom: 15px;
  opacity: 0.5;
}

/* Notification */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 15px 25px;
  background: #4caf50;
  color: white;
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  animation: slideIn 0.3s ease;
  z-index: 1000;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Tablet & Mobile Responsive */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }

  .main-content {
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 20px;
  }

  .category-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  header {
    margin-bottom: 20px;
  }

  header h1 {
    font-size: 1.8em;
  }

  header p {
    font-size: 1em;
  }

  .card {
    padding: 20px;
    border-radius: 12px;
  }

  .card h2 {
    font-size: 1.3em;
    margin-bottom: 15px;
  }

  .category-btn {
    padding: 12px;
    font-size: 0.95em;
  }

  .random-btn {
    padding: 16px;
    font-size: 1.1em;
  }

  .result-box {
    padding: 20px;
    min-height: 120px;
  }

  .result-box h3 {
    font-size: 1.4em;
  }

  .result-box p {
    font-size: 1em;
  }

  .tabs {
    flex-wrap: wrap;
    gap: 5px;
  }

  .tab {
    padding: 8px 15px;
    font-size: 0.95em;
    flex: 1;
    min-width: calc(33.33% - 5px);
  }

  .form-group input,
  .form-group textarea,
  .form-group select {
    padding: 10px;
    font-size: 16px; /* Prevents zoom on iOS */
  }

  .items-list {
    max-height: 400px;
  }

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

  .item-group h3 {
    font-size: 1.1em;
    margin-bottom: 12px;
    padding-bottom: 8px;
  }

  .item {
    padding: 12px;
    margin-bottom: 10px;
    gap: 12px;
  }

  .item:hover {
    transform: translateX(0);
  }

  .item-name {
    font-size: 0.95em;
    margin-bottom: 4px;
  }

  .item-desc {
    font-size: 0.85em;
    line-height: 1.4;
  }

  .item-actions {
    flex-shrink: 0;
  }

  .item-actions .btn-small {
    padding: 8px 16px;
    white-space: nowrap;
  }

  .notification {
    right: 10px;
    left: 10px;
    top: 10px;
    padding: 12px 15px;
    font-size: 0.9em;
  }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
  header h1 {
    font-size: 1.5em;
  }

  header p {
    font-size: 0.9em;
  }

  .card {
    padding: 15px;
  }

  .card h2 {
    font-size: 1.2em;
  }

  .category-btn {
    padding: 10px;
  }

  .random-btn {
    padding: 14px;
    font-size: 1em;
  }

  .result-box h3 {
    font-size: 1.2em;
  }

  .result-box p {
    font-size: 0.9em;
  }

  .btn {
    padding: 10px 20px;
    font-size: 0.95em;
  }

  .item-group h3 {
    font-size: 1em;
  }

  .item {
    padding: 12px;
    gap: 10px;
  }

  .item-name {
    font-size: 0.95em;
  }

  .item-desc {
    font-size: 0.85em;
    line-height: 1.3;
  }

  .item-actions .btn-small {
    padding: 8px 12px;
    font-size: 0.85em;
  }

  .empty-state {
    padding: 30px 20px;
  }

  .empty-state svg {
    width: 60px;
    height: 60px;
  }
}
