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

:root {
  /* Define CSS variables for colors */
  --bg-color: #e0e5ec; /* Neumorphism background */
  --text-color: #333;
  --heading-color: #2e3a59;
  --primary-color: #007bff; /* Blue for buttons, links, spinner */
  --primary-dark: #0056b3;
  --primary-light: #00c6ff;
  --accent-green: #28a745; /* Green for received amounts */
  --accent-red: #dc3545; /* Red for sent amounts */
  --neutral-gray: #888;
  --light-gray: #ccc;
  --dark-shadow: #bec4d0; /* Neumorphism dark shadow */
  --light-shadow: #ffffff; /* Neumorphism light shadow */
}

body {
  font-family: 'Segoe UI', 'Roboto', sans-serif;
  background: var(--bg-color);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  color: var(--text-color);
  /* Remove duplicate box-sizing, margin, padding here as it's in universal reset */
}

/* --- SweetAlert2 Customization --- */
.swal-popup-custom {

  border-radius: 25px;
  background: var(--bg-color); /* Match neumorphism background */
 
  color: var(--text-color);
}
.swal2-title, .swal2-html-container { /* Style Swal text to match app */
  color: var(--heading-color);
}

/* --- Connect Only Section --- */
#connect-only {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;

 
}

/* --- Main Container --- */
.container {
  display: none; /* Controlled by JS */
  background: var(--bg-color);
  border-radius: 20px;
  box-shadow: 10px 10px 25px var(--dark-shadow), -10px -10px 25px var(--light-shadow);
  padding: 30px;
  width: 95%; /* Make it responsive by default */
  max-width: 500px; /* Limit max width for desktop */
  text-align: center;
  overflow-y: auto;
  max-height: 90vh;

  margin-bottom: 20px;
  position: relative; /* For proper positioning of fixed elements inside */
}

/* --- Headings & Info --- */
h2 {
  font-size: 22px;
  margin-bottom: 18px;
  color: var(--heading-color);
}

.info {
  font-size: 15px;
  color: var(--text-color);
  margin-bottom: 6px;
}

.balance {
  font-size: 18px;
  color: var(--accent-green); /* Example: green for balance */
  font-weight: 700;
  margin-bottom: 4px;
}

#wallet-address {
  font-weight: 600;
  color: var(--primary-color);
  font-size: 20px;
  word-break: break-word;
  padding: 0 10px; /* Add padding to prevent text touching edges on small screens */
}

/* --- Transactions List --- */
ul#transactions-list {
  list-style: none;
  margin-top: 20px;
  padding: 0;
}

.transaction-item {
  background: var(--bg-color);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: inset 2px 2px 6px var(--dark-shadow), inset -2px -2px 6px var(--light-shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer; /* Indicate clickability for popup */
  display: flex; /* Use flexbox for internal layout */
  flex-direction: column;
}

.transaction-item:hover {
  transform: translateY(-2px);
  box-shadow: inset 2px 2px 8px var(--dark-shadow), inset -2px -2px 8px var(--light-shadow);
}

.transaction-item .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: var(--heading-color);
  margin-bottom: 6px;
}

.icon-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--primary-dark);
}

.icon img {
  width: 25px;
  height: 25px;
  border-radius: 50%; /* Make Jetton icons round */
  object-fit: cover;
  margin-top: 5px;
}

.amount {
  font-weight: 600;
  /* Colors for .amount are handled by JS inline style or classes .red, .green */
  /* If using classes, remove inline style in JS and uncomment these: */
  /* &.red { color: var(--accent-red); } */
  /* &.green { color: var(--accent-green); } */
  /* If no specific color class, it will use default text color or its own default */
}

.amount.red {
  color: var(--accent-red);
}

.amount.green {
  color: var(--accent-green);
}

/* This .black class is likely redundant if the default is dark text and specific colors are used */
.amount.black {
  color: var(--text-color); /* Or specific black if needed */
}

.address {
  font-size: 13px;
  color: var(--neutral-gray);
  word-break: break-word;
  padding-left: 24px; /* Align with icon-label indentation */
}

.time {
  font-size: 12px;
  color: var(--neutral-gray);
  text-align: right;
}

a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
}

a:hover {
  text-decoration: underline;
}

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

.container::-webkit-scrollbar-thumb {
  background: var(--light-gray);
  border-radius: 4px;
}

.container::-webkit-scrollbar-thumb:hover {
  background: var(--neutral-gray);
}

/* --- Disconnect Button (part of button-row now) --- */
#disconnect {
  font-size: 16px;
  cursor: pointer;
  color: white; /* Text color is white */
  background: var(--accent-red); /* Red for disconnect */
  transition: transform 0.2s ease, background-color 0.2s ease;
  display: none; /* Controlled by JS */
}
#disconnect:hover {
    background: #c21a2c; /* Darker red on hover */
    transform: translateY(-2px);
}

/* --- Memo Toggle --- */
.memo {
  font-size: 13px;
  color: var(--text-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  width: 100%;
  cursor: pointer;
  text-align: left;
  transition: max-height 0.3s ease;
  max-height: 20px;
  margin-bottom: 6px;
  padding-left: 24px; /* Align with icon-label indentation */
}

.memo.expanded {
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  max-height: 300px; /* Sufficient height for expanded memo */
}

/* --- Send Form --- */
.form-send {
  margin-top: 20px; /* Increased margin for better separation */
  text-align: left;
}

.form-send input,
.form-send button {
  width: 100%;
  padding: 12px 15px; /* Increased padding */
  margin: 8px 0; /* Consistent margin */
  border-radius: 25px;
  border: none;
  font-size: 16px;
  box-shadow: inset 2px 2px 5px var(--dark-shadow), inset -2px -2px 5px var(--light-shadow);
  background: var(--bg-color); /* Match background */
  color: var(--text-color);
  outline: none; /* Remove outline on focus */
}

.form-send input:focus {
    box-shadow: inset 2px 2px 5px var(--dark-shadow), inset -2px -2px 5px var(--light-shadow), 0 0 0 2px var(--primary-color); /* Add focus ring */
}

.form-send button {
  background: var(--primary-color); /* Use primary color for main button */
  color: white;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.1); /* Subtle shadow for clickability */
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.form-send button:hover {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.2);
}

#memo-text:disabled {
  background-color: #f0f0f0;
  color: #999;
  cursor: not-allowed;
  box-shadow: inset 1px 1px 3px var(--dark-shadow); /* Less prominent shadow when disabled */
}

/* --- Transaction Link Row (Consider integrating this into .transaction-item) --- */
/* The current implementation using `position: absolute` within `li` might cause issues
   if `li` content varies significantly or if `padding-bottom` isn't enough.
   A better approach might be to add it as a new flex item at the bottom of .transaction-item.
   I'll keep your original structure for minimal disruption, but recommend refactoring. */
.transaction-item .tx-link-row {
  /* This rule was inside `li` which made it absolute.
     If you move it to a div inside `.transaction-item`,
     it can be a flex item or block element at the end. */
  text-align: right; /* Align link to the right */
  margin-top: 10px; /* Space from memo */
  padding-right: 0; /* Remove padding if not needed */
  padding-left: 0;
}

.transaction-item .tx-link-row a {
  font-size: 13px; /* Slightly smaller for detailed info */
}


/* --- Floating Buttons (Paste, Max) --- */
.input-icon {
  position: relative;
  margin: 10px 0; /* Add margin */
}

.input-icon .icon {
  position: absolute;
  top: 50%;
  left: 15px;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 18px;
  color: var(--neutral-gray);
}

.input-icon input {
  padding-left: 45px !important; /* Ensure enough space for icon */
}

.input-logo { /* For image icons in inputs */
  position: absolute;
  left: 15px;
  top: 50%;
  border-radius: 50%; /* Ensure round logo */
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  pointer-events: none;
}

/* Renamed 'dan' to 'paste-btn' for clarity and consistency */
.paste-btn,
.max-btn {
  position: absolute;
  right: 15px; /* Consistent right padding */
  top: 50%;
  transform: translateY(-50%);
  background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
  color: white;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 20px;
  box-shadow: 0 4px 8px rgba(var(--primary-color), 0.2); /* Use RGBA for primary color */
  cursor: pointer;
  user-select: none;
  transition: all 0.3s ease;
  animation: popIn 0.4s ease;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 10; /* Ensure it's above the input field */
}

.paste-btn:hover,
.max-btn:hover {
  transform: translateY(-50%) scale(1.05);
  box-shadow: 0 6px 12px rgba(var(--primary-dark), 0.3);
  background: linear-gradient(135deg, var(--primary-dark), #00a2ff);
}

@keyframes popIn {
  0% {
    transform: translateY(-50%) scale(0.8);
    opacity: 0;
  }
  100% {
    transform: translateY(-50%) scale(1);
    opacity: 1;
  }
}

/* --- Modals (QR and Popups) --- */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(3px); /* Add blur for modern effect */
}

.modal-content {
  background: var(--bg-color); /* Match neumorphism background */
  padding: 30px; /* Increased padding */
  border-radius: 25px;
  text-align: center;
  width: 90%;
  max-width: 400px; /* Slightly increased max width */
  position: relative;
  box-shadow: 15px 15px 30px var(--dark-shadow), -15px -15px 30px var(--light-shadow); /* More prominent shadow */
  animation: popupFadeIn 0.3s ease-out; /* Apply consistent animation */
  color: var(--text-color);
}

.close-btn { /* For QR Modal */
  position: absolute;
  top: 15px;
  right: 15px;
  font-size: 24px; /* Slightly larger */
  cursor: pointer;
  color: var(--neutral-gray);
  background: transparent;
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
.close-btn:hover {
    color: var(--accent-red);
    background-color: rgba(var(--accent-red), 0.1);
}


.qr-canvas {
  margin: 20px auto; /* Increased margin */
  width: 250px;
  height: 250px;
  background: white; /* Ensure white background for QR code */
  padding: 10px; /* Small padding around QR */
  border-radius: 10px; /* Soften edges */
  box-shadow: inset 2px 2px 5px #c3c8d3, inset -2px -2px 5px #ffffff;
}

.qr-address {
  word-break: break-all; /* Allow breaking words for long addresses */
  font-size: 14px; /* Slightly smaller for address */
  color: var(--heading-color);
}

/* --- Copy Button --- */
.copy-btn {
  width: 100%;
  max-width: 250px; /* Adjusted max-width */
  margin: 20px auto 0; /* Centered with top margin */
  padding: 12px 20px; /* Increased padding */
  border: none;
  border-radius: 25px;
  background: var(--primary-color);
  color: white;
  font-weight: bold;
  cursor: pointer;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.1);
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.copy-btn i {
  margin-right: 8px;
}

.copy-btn:hover {
  background-color: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.2);
}

/* --- General Button Styling --- */
.button-container {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  padding-top: 20px; /* Add padding to the top of button container */
  box-sizing: border-box;
}

button {
  width: 100%;
  max-width: 100%;
  padding: 12px; /* Consistent padding for all buttons */
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  outline: none;
  background: var(--bg-color); /* Default neumorphism button background */
  color: var(--heading-color); /* Default text color */
  font-weight: 600; /* Make text bolder */
  border-radius: 25px;
  margin: 8px 0; /* Consistent margin */
  cursor: pointer;
  box-sizing: border-box;
  box-shadow: 4px 4px 8px var(--dark-shadow), -4px -4px 8px var(--light-shadow); /* Neumorphism shadow for buttons */
  transition: all 0.2s ease;
}
button:hover {
    box-shadow: 2px 2px 5px var(--dark-shadow), -2px -2px 5px var(--light-shadow); /* Inset shadow on hover */
    transform: translateY(1px); /* Slight press effect */
}
button:active {
    box-shadow: inset 2px 2px 5px var(--dark-shadow), inset -2px -2px 5px var(--light-shadow); /* Deeper inset on active */
    transform: translateY(0);
}

button i {
  margin-right: 8px;
}

/* Specific button styles */
#send-ton-btn {
  background: var(--primary-color);
  color: white;
  margin-bottom: 20px; /* Space above the row of buttons */
}
#send-ton-btn:hover {
    background: var(--primary-dark);
    box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

.button-row {
  display: flex;
  justify-content: space-between;
  width: 100%;
  gap: 10px;
  flex-wrap: wrap; /* Allows wrapping on smaller screens */
}

#show-qr-btn, #disconnect {
  flex: 1 1 48%; /* Adjust to ensure better wrapping on small screens, allowing for 2 buttons per row */
  max-width: calc(50% - 5px); /* Account for gap */
}
/* Re-apply specific hover for disconnect button as it's a different color */
#disconnect:hover {
    background: #c21a2c; /* Darker red on hover */
    box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

/* --- Loading Spinner --- */
#list { /* This ID seems to be misplaced, should be a parent of transactions-list */
  min-height: 100px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 20px; /* Ensure space for spinner */
}

.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--neutral-gray);
  font-size: 16px;
  gap: 10px;
  padding: 20px 0; /* Add padding */
}

.spinner {
  width: 30px;
  height: 30px;
  border: 4px solid var(--light-gray);
  border-top: 4px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --- Popup Overlay & Content --- */
.popup-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.35);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
  cursor: pointer;
}

.popup-content {
  background: var(--bg-color);
  border-radius: 16px;
  padding: 30px 25px;
  max-width: 480px;
  width: 95%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  position: relative;
  animation: popupFadeIn 0.3s ease-out;
  font-family: 'Segoe UI', sans-serif;
  color: var(--text-color);
  cursor: default;
}

.popup-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: none;
  font-size: 22px;
  color: var(--neutral-gray);
  cursor: pointer;
  transition: 0.2s;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
}

.popup-close:before {
  content: "×";
  font-size: 22px;
  color: var(--neutral-gray);
}

.popup-close:hover {
  color: #fff;
  background-color: var(--accent-red);
  transform: scale(1.1);
}

.popup-content h2 {
  margin: 0 0 16px;
  font-size: 22px;
  font-weight: 600;
  color: var(--heading-color);
}

.popup-content p {
  margin: 10px 0;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
  color: var(--text-color);
}

.popup-content strong {
    color: var(--heading-color); /* Make strong text more prominent */
}

.popup-content a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
}

.popup-content a:hover {
  text-decoration: underline;
}

@keyframes popupFadeIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
    .container {
        padding: 20px;
        width: 95%; /* Adjust width for slightly larger mobile screens */
        margin-top: 15px;
        margin-bottom: 15px;
    }
    .modal-content {
        max-width: 350px;
        padding: 25px;
    }
    .qr-canvas {
        width: 200px;
        height: 200px;
    }
    .copy-btn {
        max-width: 200px;
    }
}

@media (max-width: 480px) {
  .container {
    padding: 15px;
    width: 100%; /* Take full width on very small screens */
    border-radius: 0; /* No border-radius on very small screens for full edge-to-edge feel */
    box-shadow: none; /* No shadow on very small screens */
    margin: 0; /* Remove margins */
    min-height: 100vh; /* Fill entire screen height */
    max-height: unset; /* Remove max-height */
  }

  body {
    align-items: flex-start; /* Align to top on small screens */
  }

  h2 {
    font-size: 20px;
  }

  .info,
  .balance,
  .row,
  .address,
  .time,
  .memo {
    font-size: 14px; /* Slightly smaller font for better fit */
  }
  #wallet-address {
    font-size: 16px;
  }

  .transaction-item {
    padding: 12px;
  }

  .icon img {
    width: 16px;
    height: 16px;
  }
  .memo {
    padding-left: 20px; /* Adjust alignment for smaller icons */
  }

  .form-send input,
  .form-send button,
  .copy-btn,
  button {
    font-size: 15px;
    padding: 10px; /* Reduced padding */
  }

  .input-icon .icon,
  .input-logo {
    left: 10px; /* Adjust icon position */
  }
  .input-icon input {
      padding-left: 40px !important;
  }
  .paste-btn, .max-btn {
      right: 10px;
      font-size: 12px;
      padding: 3px 8px;
  }
  
  .button-row {
    flex-direction: column; /* Stack buttons vertically on very small screens */
    gap: 5px; /* Smaller gap */
  }
  #show-qr-btn, #disconnect {
    max-width: 100%; /* Take full width when stacked */
    flex: none; /* Disable flex shrinking/growing */
  }

  .modal-content {
    width: 95%;
    padding: 20px;
    border-radius: 15px;
  }
}













