@import url('https://fonts.googleapis.com/css2?family=Quicksand:wght@400;600;700&display=swap');

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

:root {
  --forest-dark: #0d1f0d;
  --forest-deep: #1a3a1a;
  --forest-mid: #2d5a2d;
  --forest-light: #3d7a3d;
  --forest-pale: #5a9a5a;
  --leaf-green: #7bc67b;
  --moss: #4a7a3a;
  --bark: #3e2723;
  --bark-light: #5d4037;
  --cream: #f5f0e8;
  --gold: #d4a847;
  --gold-light: #f0d68a;
  --glow: rgba(122, 198, 122, 0.3);
  --shadow: rgba(0, 0, 0, 0.4);
}

body {
  font-family: 'Quicksand', sans-serif;
  background: var(--forest-dark);
  color: var(--cream);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(45, 90, 45, 0.3) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(61, 122, 61, 0.2) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(30, 60, 30, 0.4) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  text-align: center;
  padding: 30px 0 20px;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.logo-icon {
  font-size: 2.5rem;
  filter: drop-shadow(0 0 10px var(--glow));
  animation: sway 3s ease-in-out infinite;
}

@keyframes sway {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}

.logo h1 {
  font-size: 2.2rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--leaf-green), var(--gold-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  color: var(--forest-pale);
  font-size: 0.9rem;
  margin-top: 6px;
  opacity: 0.8;
}

main {
  flex: 1;
  padding: 20px 0;
}

#cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

#empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  opacity: 0.6;
}

.empty-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  animation: sway 4s ease-in-out infinite;
}

#empty-state h2 {
  font-size: 1.3rem;
  margin-bottom: 8px;
  color: var(--leaf-green);
}

#empty-state p {
  font-size: 0.9rem;
  color: var(--forest-pale);
}

/* Card Item */
.card-item {
  background: linear-gradient(145deg, var(--forest-deep), var(--forest-mid));
  border-radius: 16px;
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  border: 1px solid rgba(122, 198, 122, 0.15);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.card-item::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, var(--glow) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}

.card-item:hover::before,
.card-item:active::before {
  opacity: 1;
}

.card-item:hover,
.card-item:active {
  transform: translateY(-4px);
  border-color: var(--leaf-green);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3), 0 0 20px var(--glow);
}

.card-item .card-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
  display: block;
}

.card-item .card-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--cream);
  word-break: break-word;
}

/* FAB Button */
#add-btn {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--forest-light), var(--moss));
  color: var(--cream);
  font-size: 2rem;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 30px var(--glow);
  transition: all 0.3s ease;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

#add-btn:hover,
#add-btn:active {
  transform: scale(1.1) rotate(90deg);
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.5), 0 0 40px var(--glow);
}

#add-btn span {
  line-height: 1;
}

footer {
  text-align: center;
  padding: 20px 0 10px;
  color: var(--forest-pale);
  font-size: 0.85rem;
  opacity: 0.7;
}

footer strong {
  color: var(--gold);
}

/* Modals */
.hidden {
  display: none !important;
}

#modal-overlay,
#view-overlay,
#confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

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

#modal,
#view-modal,
#confirm-modal {
  background: linear-gradient(145deg, var(--forest-deep), #142814);
  border-radius: 20px;
  padding: 28px;
  width: 100%;
  max-width: 420px;
  border: 1px solid rgba(122, 198, 122, 0.2);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.3s ease;
}

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

.modal-header,
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-header h2,
.view-header h2 {
  font-size: 1.3rem;
  color: var(--leaf-green);
}

.close-btn {
  background: none;
  border: none;
  color: var(--forest-pale);
  font-size: 1.8rem;
  cursor: pointer;
  padding: 0 4px;
  transition: color 0.2s;
}

.close-btn:hover {
  color: var(--cream);
}

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

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--leaf-green);
  font-size: 0.9rem;
}

.form-group input[type="text"] {
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid rgba(122, 198, 122, 0.2);
  background: rgba(0, 0, 0, 0.3);
  color: var(--cream);
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input[type="text"]:focus {
  border-color: var(--leaf-green);
  box-shadow: 0 0 12px var(--glow);
}

.form-group input[type="text"]::placeholder {
  color: rgba(245, 240, 232, 0.3);
}

#upload-area {
  border: 2px dashed rgba(122, 198, 122, 0.3);
  border-radius: 12px;
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}

#upload-area:hover {
  border-color: var(--leaf-green);
  background: rgba(122, 198, 122, 0.05);
}

.upload-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 8px;
}

#upload-placeholder p {
  color: var(--forest-pale);
  font-size: 0.9rem;
}

#image-preview {
  max-width: 100%;
  max-height: 200px;
  border-radius: 8px;
  object-fit: contain;
}

#save-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--forest-light), var(--moss));
  color: var(--cream);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

#save-btn:hover {
  box-shadow: 0 4px 20px var(--glow);
  transform: translateY(-2px);
}

/* View Modal */
#view-image-container {
  text-align: center;
  margin-bottom: 20px;
}

#view-image {
  max-width: 100%;
  max-height: 400px;
  border-radius: 12px;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.2);
}

.view-actions {
  display: flex;
  gap: 12px;
}

.action-btn {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.action-btn.edit {
  background: var(--forest-mid);
  color: var(--cream);
  border: 1px solid rgba(122, 198, 122, 0.3);
}

.action-btn.edit:hover {
  background: var(--forest-light);
}

.action-btn.delete {
  background: rgba(180, 50, 50, 0.6);
  color: #ffb3b3;
  border: 1px solid rgba(180, 50, 50, 0.4);
}

.action-btn.delete:hover {
  background: rgba(200, 50, 50, 0.8);
}

/* Confirm Modal */
#confirm-modal {
  text-align: center;
  max-width: 340px;
}

.confirm-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

#confirm-modal h2 {
  color: var(--cream);
  margin-bottom: 8px;
}

#confirm-card-name {
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 24px;
}

.confirm-actions {
  display: flex;
  gap: 12px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--forest-dark);
}

::-webkit-scrollbar-thumb {
  background: var(--forest-mid);
  border-radius: 3px;
}

/* Responsive */
@media (max-width: 400px) {
  #cards-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .card-item {
    padding: 16px 10px;
  }

  .logo h1 {
    font-size: 1.8rem;
  }
}
