/* frontend/css/global.css */

/* ========================================
   Global Variables
======================================== */
:root {
  /* Colors */
  --primary: #4caf50;
  --primary-dark: #388e3c;
  --secondary: #1a1a2e;
  --accent: #2196f3;
  --danger: #f44336;
  --warning: #ff9800;
  --success: #4caf50;

  --bg-body: #f8f9fa;
  --bg-card: #fff;
  --bg-input: #fafafa;

  --text-main: #1a1a2e;
  --text-muted: #666;
  --text-light: #767676;
  --border-color: #e0e0e0;

  /* Typography */
  --font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, sans-serif;
  --font-size-base: 16px;
  --line-height: 1.6;

  /* Spacing */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;

  /* Borders & Shadows */
  --border-radius: 8px;
  --border-radius-lg: 12px;
  --shadow-sm: 0 2px 4px rgb(0 0 0 / 5%);
  --shadow-md: 0 4px 8px rgb(0 0 0 / 10%);
  --shadow-lg: 0 8px 16px rgb(0 0 0 / 15%);

  /* Layout */
  --container-width: 1200px;
  --focus-ring: 0 0 0 3px rgb(76 175 80 / 25%);
}

/* ========================================
   Reset & Base
======================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: var(--line-height);
  color: var(--text-main);
  background-color: var(--bg-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

button,
[type="button"],
[type="submit"],
[type="reset"] {
  cursor: pointer;
}

button:disabled,
[type="button"]:disabled,
[type="submit"]:disabled,
[type="reset"]:disabled {
  cursor: not-allowed;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

img,
video {
  height: auto;
}

iframe {
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
}

input,
select,
textarea {
  max-width: 100%;
}

textarea {
  resize: vertical;
}

[hidden] {
  display: none !important;
}

/* ========================================
   Links & Accessibility
======================================== */
a {
  color: var(--primary-dark);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

:focus-visible {
  outline: 3px solid var(--primary-dark);
  outline-offset: 3px;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-radius: 3px;
}

::selection {
  background-color: rgb(76 175 80 / 20%);
  color: var(--text-main);
}

/* ========================================
   Typography
======================================== */
h1,
h2,
h3,
h4,
h5,
h6 {
  margin: 0 0 var(--spacing-sm);
  color: var(--secondary);
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

h1 {
  font-size: clamp(2rem, 5vw, 2.5rem);
}

h2 {
  font-size: clamp(1.65rem, 4vw, 2rem);
}

h3 {
  font-size: clamp(1.25rem, 3vw, 1.5rem);
}

h4 {
  font-size: 1.25rem;
}

h5 {
  font-size: 1.1rem;
}

h6 {
  font-size: 1rem;
}

p {
  margin: 0 0 var(--spacing-sm);
  color: var(--text-muted);
}

p:last-child {
  margin-bottom: 0;
}

small {
  font-size: 0.875em;
}

strong,
b {
  font-weight: 700;
}

hr {
  height: 0;
  margin: var(--spacing-md) 0;
  border: 0;
  border-top: 1px solid var(--border-color);
}

/* ========================================
   Layout Utilities
======================================== */
.container {
  width: 100%;
  max-width: var(--container-width);
  margin-inline: auto;
  padding-inline: var(--spacing-md);
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

.items-center {
  align-items: center;
}

.items-start {
  align-items: flex-start;
}

.justify-between {
  justify-content: space-between;
}

.justify-center {
  justify-content: center;
}

.gap-sm {
  gap: var(--spacing-sm);
}

.gap-md {
  gap: var(--spacing-md);
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-muted {
  color: var(--text-muted);
}

.text-primary {
  color: var(--primary-dark);
}

.text-danger {
  color: var(--danger);
}

.mt-sm {
  margin-top: var(--spacing-sm);
}

.mt-md {
  margin-top: var(--spacing-md);
}

.mb-sm {
  margin-bottom: var(--spacing-sm);
}

.mb-md {
  margin-bottom: var(--spacing-md);
}

.w-full {
  width: 100%;
}

.min-w-0 {
  min-width: 0;
}

/* ========================================
   Loading Spinner
======================================== */
.spinner {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border: 4px solid var(--border-color);
  border-top-color: var(--primary-dark);
  border-radius: 50%;
  animation: vaultbar-spin 0.8s linear infinite;
}

@keyframes vaultbar-spin {
  to {
    transform: rotate(360deg);
  }
}

/* Optional centered loading layout */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  min-height: 160px;
  padding: var(--spacing-lg);
  text-align: center;
}

/* ========================================
   Responsive Adjustments
======================================== */
@media (max-width: 768px) {
  .container {
    padding-inline: var(--spacing-sm);
  }
}

@media (max-width: 480px) {
  :root {
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
  }

  .text-right-mobile-left {
    text-align: left;
  }
}

/* ========================================
   Reduced Motion
======================================== */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}