/* ==========================================================================
   ChainVault - Base Styles & Reset
   Dark Theme Foundation | Google Fonts Import
   ========================================================================== */

/* -----------------------------------------------------------------------
   GOOGLE FONTS
   Space Grotesk (headings): 500, 600, 700
   Inter (body): 400, 500, 600
   ----------------------------------------------------------------------- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Space+Grotesk:wght@500;600;700&display=swap');

/* -----------------------------------------------------------------------
   CSS RESET - Modern Minimal
   ----------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -moz-tab-size: 4;
  tab-size: 4;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100%;
  overflow: hidden;
}

body {
  height: 100%;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);
  overflow: hidden;
}

/* Remove default margin */
h1, h2, h3, h4, h5, h6,
p, figure, blockquote, dl, dd {
  margin: 0;
}

/* Remove list styles */
ul, ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Headings use Space Grotesk */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text-primary);
}

h1 { font-size: var(--text-4xl); }
h2 { font-size: var(--text-3xl); }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5 { font-size: var(--text-lg); }
h6 { font-size: var(--text-base); font-weight: var(--weight-medium); }

p {
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
}

small {
  font-size: var(--text-sm);
}

strong, b {
  font-weight: var(--weight-semibold);
}

/* -----------------------------------------------------------------------
   LINKS
   ----------------------------------------------------------------------- */
a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-light);
}

a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}

/* -----------------------------------------------------------------------
   MEDIA
   ----------------------------------------------------------------------- */
img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

svg {
  fill: currentColor;
}

/* Global SVG size constraints - prevent inline SVGs from blowing up.
   SVGs without explicit width/height attributes default to 20px.
   Specific containers (qr-placeholder, allocation pie) override as needed. */
svg:not([width]):not([class*="allocation"]) {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Let the QR placeholder SVG fill its container */
.qr-placeholder svg,
.wallet-receive__qr svg {
  width: 160px;
  height: 160px;
}

/* -----------------------------------------------------------------------
   FORM ELEMENTS - Dark Theme Defaults
   ----------------------------------------------------------------------- */
input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

button {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

input::placeholder,
textarea::placeholder {
  color: var(--color-text-muted);
  opacity: 1;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="tel"],
textarea,
select {
  display: block;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-primary);
  background-color: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast),
              box-shadow var(--transition-fast),
              background-color var(--transition-fast);
}

input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="number"]:hover,
input[type="search"]:hover,
input[type="url"]:hover,
input[type="tel"]:hover,
textarea:hover,
select:hover {
  border-color: var(--color-border-strong);
  background-color: var(--color-bg-elevated);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
input[type="tel"]:focus,
textarea:focus,
select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-subtle),
              var(--glow-green-sm);
  background-color: var(--color-bg-elevated);
}

input:disabled,
textarea:disabled,
select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%239ca3b4'%3e%3cpath d='M4.427 6.427l3.396 3.396a.25.25 0 00.354 0l3.396-3.396A.25.25 0 0011.396 6H4.604a.25.25 0 00-.177.427z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  padding-right: 2.5rem;
}

textarea {
  resize: vertical;
  min-height: 100px;
}

label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

/* -----------------------------------------------------------------------
   TABLE DEFAULTS
   ----------------------------------------------------------------------- */
table {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
}

/* -----------------------------------------------------------------------
   SCROLLBAR STYLING (Webkit + Firefox)
   ----------------------------------------------------------------------- */

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-gray-700) transparent;
}

/* Webkit (Chrome, Safari, Edge) */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: var(--color-gray-700);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-gray-600);
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* -----------------------------------------------------------------------
   TEXT SELECTION
   ----------------------------------------------------------------------- */
::selection {
  background-color: var(--color-primary-subtle);
  color: var(--color-primary);
}

::-moz-selection {
  background-color: var(--color-primary-subtle);
  color: var(--color-primary);
}

/* -----------------------------------------------------------------------
   FOCUS VISIBLE (keyboard users only)
   ----------------------------------------------------------------------- */
:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* -----------------------------------------------------------------------
   UTILITY CLASSES
   ----------------------------------------------------------------------- */

/* Monospace for addresses, hashes, keys */
.mono {
  font-family: var(--font-mono);
  letter-spacing: 0;
}

/* Truncation */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Screen reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Color utilities */
.text-green  { color: var(--color-success); }
.text-red    { color: var(--color-danger); }
.text-amber  { color: var(--color-warning); }
.text-muted  { color: var(--color-text-tertiary); }

/* -----------------------------------------------------------------------
   REDUCED MOTION
   ----------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
