/* ==========================================================
   UTILITIES.CSS – Clase ajutătoare, accessibility & responsive helpers
   ========================================================== */

/* ----------------------------------------------------------
   1. ACCESSIBILITY
   ---------------------------------------------------------- */

/* Skip-link pentru navigare cu tastatura */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--accent1);
  color: #fff;
  padding: 0.5em 1em;
  border-radius: 0 0 4px 0;
  z-index: 1000;
  font-weight: 600;
  transition: top 0.3s;
}

.skip-link:focus {
  top: 0;
}

/* Ascundere vizuală, dar lăsat în DOM pentru screen-readers */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Focus vizibil îmbunătățit */
:focus-visible {
  outline: 3px solid var(--accent2);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(46, 230, 214, 0.3);
}

/* Eliminăm focus-ul implicit pe mouse, păstrăm pe tastatură */
:focus:not(:focus-visible) {
  outline: none;
}

/* Indici vizibili pentru tab navigation */
[tabindex]:focus-visible {
  transform: scale(1.02);
  z-index: 1;
}

/* Suport pentru preferință „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;
  }
}

/* High-contrast mode (Windows / Firefox) */
@media (forced-colors: active) {
  button,
  .main-btn,
  .secondary-btn,
  .delete-btn {
    border: 2px solid;
  }

  .color-option {
    border: 2px solid CanvasText;
  }
}

/* ----------------------------------------------------------
   2. UTILITĂȚI TEXT & ALIGNMENT
   ---------------------------------------------------------- */

.text-center { text-align: center !important; }
.text-left   { text-align: left !important; }
.text-right  { text-align: right !important; }

.font-mono   { font-family: 'Digital-7', 'Courier New', monospace !important; }
.font-main   { font-family: var(--font-main) !important; }

.truncate {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ----------------------------------------------------------
   3. DISPLAY & SPACING HELPERS
   ---------------------------------------------------------- */

.d-none        { display: none !important; }
.d-block       { display: block !important; }
.d-flex        { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }

.flex-center   { display: flex; align-items: center; justify-content: center; }
.flex-between  { display: flex; align-items: center; justify-content: space-between; }
.flex-column   { display: flex; flex-direction: column; }
.flex-wrap     { flex-wrap: wrap; }

.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

/* Margin rapid */
.m-0  { margin: 0 !important; }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.5rem !important; }
.mt-2 { margin-top: 1rem !important; }
.mt-3 { margin-top: 1.5rem !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.5rem !important; }
.mb-2 { margin-bottom: 1rem !important; }
.mb-3 { margin-bottom: 1.5rem !important; }

.ml-auto { margin-left: auto !important; }
.mr-auto { margin-right: auto !important; }
.mx-auto { margin-left: auto !important; margin-right: auto !important; }

/* Padding rapid */
.p-0  { padding: 0 !important; }
.p-1  { padding: 0.5rem !important; }
.p-2  { padding: 1rem !important; }
.p-3  { padding: 1.5rem !important; }

/* ----------------------------------------------------------
   4. RESPONSIVE UTILITIES
   ---------------------------------------------------------- */

/* Hidden only on mobile */
@media (max-width: 600px) {
  .hide-mobile { display: none !important; }
}

/* Hidden only on desktop */
@media (min-width: 601px) {
  .hide-desktop { display: none !important; }
}

/* Scrollbar utilitar */
.scroll-y-auto {
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--accent3) var(--bg);
}

.scroll-y-auto::-webkit-scrollbar {
  width: 6px;
}

.scroll-y-auto::-webkit-scrollbar-thumb {
  background: var(--accent3);
  border-radius: 3px;
}

/* ----------------------------------------------------------
   5. ANIMATION UTILITIES
   ---------------------------------------------------------- */

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ----------------------------------------------------------
   6. STATES & ARIA
   ---------------------------------------------------------- */

/* Busy / loading */
[aria-busy="true"] {
  cursor: progress;
  opacity: 0.7;
  pointer-events: none;
}

/* Disabled */
[aria-disabled="true"],
[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Read-only */
[aria-readonly="true"] {
  opacity: 0.85;
  cursor: default;
}

/* Live-regions */
[role="alert"] {
  border-left: 4px solid var(--error-color);
  padding: 1rem;
  background-color: rgba(211, 47, 47, 0.08);
  color: var(--text);
}

[role="status"] {
  border-left: 4px solid var(--success-color);
  padding: 1rem;
  background-color: rgba(56, 142, 60, 0.08);
  color: var(--text);
}

/* ----------------------------------------------------------
   7. PRINT STYLES
   ---------------------------------------------------------- */
@media print {
  * {
    background: transparent !important;
    color: black !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }

  .topbar,
  .adsense-placeholder,
  .tool-cards-row,
  .back-to-tools,
  .card-controls {
    display: none !important;
  }

  .main-content {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}