:root {
  --bg-color: #121212;
  --surface-color: #1e1e1e;
  --primary-color: #9a67ea;
  --text-color: #e0e0e0;
  --positive: #4caf50;
  --negative: #f44336;
}

[data-theme="light"] {
  --bg-color: #f5f5f5;
  --surface-color: #ffffff;
  --text-color: #333333;
  --primary-color: #7e57c2;
}

[data-theme="high-contrast"] {
  --bg-color: #000000;
  --surface-color: #1a1a1a;
  --primary-color: #ffd700;
  --text-color: #ffffff;
  --positive: #00ff00;
  --negative: #ff0000;
}

[data-theme="solarized"] {
  --bg-color: #002b36;
  --surface-color: #073642;
  --primary-color: #268bd2;
  --text-color: #839496;
  --positive: #859900;
  --negative: #dc322f;
}

[data-theme="ocean"] {
  --bg-color: #0a192f;
  --surface-color: #172a45;
  --primary-color: #64ffda;
  --text-color: #ccd6f6;
  --positive: #64ffda;
  --negative: #ff6489;
}

[data-theme="forest"] {
  --bg-color: #2e442d;         
  --surface-color: #364d3d;      
  --primary-color: #a3d39c;     
  --text-color: #e0f7e9;         
  --positive: #4caf50;          
  --negative: #f44336;
}

[data-theme="cyberpunk"] {
  --bg-color: #0d0d0d;         
  --surface-color: #1b1b1b;     
  --primary-color: #ff0080;     
  --text-color: #e0e0e0;         
  --positive: #00ff00;
  --negative: #ff0000;
}

[data-theme="pastel"] {
  --bg-color: #fdf6e3;         
  --surface-color: #fff7ed;    
  --primary-color: #ffa07a;   
  --text-color: #333333;       
  --positive: #90ee90;         
  --negative: #ff6f61;         
}

[data-theme="vintage"] {
  --bg-color: #f5f5dc;         
  --surface-color: #e8e2d9;      
  --primary-color: #b5651d;     
  --text-color: #5b4636;        
  --positive: #6aa84f;         
  --negative: #cc4125;        
}

[data-theme="monochrome"] {
  --bg-color: #ffffff;        
  --surface-color: #f2f2f2;      
  --primary-color: #333333;     
  --text-color: #000000;        
  --positive: #777777;         
  --negative: #555555;         
}

body {
  margin: 0;
  padding: 0;
  font-family: 'Poppins', sans-serif;
  background: var(--bg-color);
  color: var(--text-color);
  transition: background 0.3s ease, color 0.3s ease;
}

header {
  background: linear-gradient(135deg, var(--surface-color), #272727);
  color: #fff;
  text-align: center;
  padding: 20px 0;
  position: relative;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

header .logo {
  position: absolute;
  top: -20px;
  left: 20px;
  width: 60px;
  height: 60px;
}

#coin-svg {
  width: 60px;
  height: 60px;
  animation: rotate 5s linear infinite;
}

@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

h1 {
  margin: 0;
  font-size: 2em;
  font-weight: 500;
}
#theme-toggle {
  position: absolute;
  right: 20px;
  top: 20px;
  background: var(--surface-color);
  border: 1px solid var(--text-color);
  border-radius: 20px;
  padding: 8px 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.3s ease;
}

#theme-select {
  background: transparent;
  border: none;
  color: var(--text-color);
  font-family: 'Poppins', sans-serif;
  font-size: 1em;
  cursor: pointer;
  appearance: none;
  padding-right: 20px;
}

#theme-select option {
  background: var(--surface-color);
  color: var(--text-color);
}

#theme-toggle svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin: 20px 0;
}

.controls input[type="text"],
.controls select,
#refresh-btn {
  padding: 10px;
  font-size: 1em;
  border: 1px solid #333;
  border-radius: 4px;
  background: var(--surface-color);
  color: var(--text-color);
}

.controls input[type="text"]::placeholder {
  color: #bbb;
}

#refresh-btn {
  cursor: pointer;
  transition: background 0.3s ease, transform 0.2s;
}

#refresh-btn:hover {
  background: var(--primary-color);
  transform: scale(1.05);
}

.controls label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.9em;
}

#last-updated {
  font-size: 0.9em;
  color: #bbb;
}

main {
  width: 90%;
  max-width: 1200px;
  margin: 20px auto 40px;
}

.coin-box {
  background: var(--surface-color);
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  padding: 15px;
  cursor: pointer;
}

.coin-box::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, 
    transparent 20%, 
    rgba(255, 255, 255, 0.05) 50%, 
    transparent 80%
  );
  transform: rotate(45deg);
  pointer-events: none;
  transition: all 0.5s ease;
}

.coin-box:hover::before {
  animation: shine 1.5s forwards;
}

@keyframes shine {
  to {
    top: 50%;
    left: 50%;
  }
}

.coin-box:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.7);
}

.coin-box.highlight {
  border-color: #ff5555;
}

.coin-icon-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 10px;
}

.coin-icon {
  width: 50px;
  height: 50px;
}

.coin-icon-img {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
}

.coin-info h2 {
  text-align: center;
  margin: 10px 0;
  font-size: 1.5em;
}

.coin-info p {
  margin: 5px 0;
  font-size: 1em;
  text-align: center;
}

.market-cap-rank {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--primary-color);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.8em;
  font-weight: 500;
}

#loader {
  border: 4px solid var(--surface-color);
  border-top: 4px solid var(--positive);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 20px auto;
  display: none;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

#crypto-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  padding: 20px 0;
}

.notification {
  position: fixed;
  bottom: -50px;
  right: 20px;
  background: var(--surface-color);
  color: var(--text-color);
  padding: 15px 25px;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  opacity: 0;
  transform: translateY(100%);
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.notification.show {
  opacity: 1;
  transform: translateY(0);
}

.favorite-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  z-index: 10;
}
.favorite-btn svg {
  width: 24px;
  height: 24px;
  fill: #bbb;
  transition: fill 0.3s ease;
}
.favorite-btn.favorited svg {
  fill: #ffdd57;
}

footer {
  text-align: center;
  padding: 20px 0;
  background: var(--surface-color);
  font-size: 0.9em;
  color: #bbb;
  border-top: 1px solid #333;
}

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.7);
}

.modal-content {
  background: var(--surface-color);
  margin: 10% auto;
  padding: 20px;
  border: 1px solid #333;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  animation: fadeIn 0.5s;
  color: var(--text-color);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.close-modal {
  color: #bbb;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.close-modal:hover,
.close-modal:focus {
  color: #fff;
  text-decoration: none;
  cursor: pointer;
}

/* Enhanced modal */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
}

.modal-column p {
  display: flex;
  justify-content: space-between;
  margin: 12px 0;
  padding: 8px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
}

.label {
  color: #bbb;
  font-weight: 300;
}

.sparkline-container {
  height: 100px;
  margin: 15px 0;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 10px;
}

.sparkline {
  width: 100%;
  height: 100%;
}

.modal-favorite {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.modal-favorite svg {
  width: 28px;
  height: 28px;
  transition: transform 0.2s ease;
}

.modal-favorite:hover svg {
  transform: scale(1.2);
}

@media (max-width: 768px) {
  header {
    padding: 15px 0;
  }

  header .logo {
    position: static;
    margin: 0 auto;
    width: 50px;
    height: 50px;
  }

  h1 {
    font-size: 1.5em;
    margin-top: 10px;
  }

  #theme-toggle {
    position: static;
    margin: 10px auto 0;
    width: 90%;
    justify-content: center;
    background: none;
    border: none;
  }

  .controls {
    flex-direction: column;
    gap: 10px;
    margin: 15px 0;
  }

  .controls input[type="text"],
  .controls select,
  #refresh-btn {
    width: 100%;
    margin: 0;
  }

  .controls label {
    width: 100%;
    justify-content: space-between;
  }

  #crypto-container {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
  }

  .coin-box {
    min-width: unset;
  }

  .modal-content {
    width: 95%;
    margin: 20% auto;
    padding: 15px;
  }

  .modal-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

@media (max-width: 480px) {
  header {
    padding: 10px 0;
  }

  h1 {
    font-size: 1.3em;
  }

  #coin-svg {
    width: 45px;
    height: 45px;
  }

  #theme-select {
    font-size: 0.9em;
  }

  .coin-info h2 {
    font-size: 1.3em;
  }

  .coin-info p {
    font-size: 0.9em;
  }

  .coin-icon {
    width: 40px;
    height: 40px;
  }

  .market-cap-rank {
    font-size: 0.7em;
    padding: 3px 6px;
  }

  .modal-content {
    margin: 10px auto;
    max-width: 100%;
    border-radius: 0;
  }

  .sparkline-container {
    height: 80px;
  }
}

@media screen and (max-width: 768px) {
  input[type="text"],
  select,
  button {
    font-size: 16px;
  }
}