/* ==========================================================================
   Component Styles for Vega AI
   ========================================================================== */

/* ==========================================================================
   CSS Custom Properties (Design Tokens)
   ========================================================================== */
:root {
  --color-primary: #0D9488;
  --color-primary-dark: #0B7A70;
  --color-secondary: #F59E0B;
  
  --color-slate-900: #0f172a;
  --color-slate-800: #1e293b;
  --color-slate-700: #334155;
  --color-slate-600: #475569;
  --color-slate-500: #64748b;
  --color-slate-400: #94a3b8;
  
  --color-success-bg: rgba(5, 150, 105, 0.8);
  --color-success-border: #047857;
  --color-success-text: #d1fae5;
  
  --color-error-bg: rgba(127, 29, 29, 0.8);
  --color-error-border: #b91c1c;
  --color-error-text: #fee2e2;
  
  --color-warning-bg: rgba(113, 63, 18, 0.8);
  --color-warning-border: #a16207;
  --color-warning-text: #fef3c7;
  
  --color-info-bg: rgba(30, 58, 138, 0.8);
  --color-info-border: #1d4ed8;
  --color-info-text: #dbeafe;
  
  --font-family-heading: 'Space Grotesk', 'DM Sans', ui-sans-serif, system-ui, sans-serif;
  --font-family-body: 'DM Sans', 'Inter', ui-sans-serif, system-ui, sans-serif;
  
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;
  
  --transition-fast: 300ms ease;
  --transition-normal: 300ms ease;
  
  --focus-color: var(--color-slate-500);
  --focus-outline-width: 2px;
  --focus-outline-offset: 2px;
  --focus-ring-shadow: 0 0 0 4px rgba(100, 116, 139, 0.1);
  
  --shadow-toast: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* ==========================================================================
   Base Typography
   ========================================================================== */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family-heading);
  font-weight: 600;
  letter-spacing: -0.025em;
}

body {
  font-family: var(--font-family-body);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   HTMX Indicator Component
   ========================================================================== */
.htmx-indicator {
  display: none !important;
  pointer-events: none !important;
}

.htmx-request .htmx-indicator {
  display: flex !important;
  pointer-events: auto !important;
}

.htmx-request.htmx-indicator {
  display: flex !important;
  pointer-events: auto !important;
}

/* ==========================================================================
   Toast Notification Component
   ========================================================================== */
.toast-notification {
  max-width: 100%;
  word-wrap: break-word;
}

@keyframes fade-in {
  from { 
    opacity: 0; 
    transform: translateY(-10px); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0); 
  }
}

@keyframes fade-out {
  from { 
    opacity: 1; 
  }
  to { 
    opacity: 0; 
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.animate-fade-in {
  animation: fade-in 0.3s ease-in-out;
}

.animate-fade-out {
  animation: fade-out 0.3s ease-in-out forwards;
}

.animate-slide-in-right {
  animation: slideInRight 0.3s ease-out;
}

.animate-slide-out-right {
  animation: slideOutRight 0.3s ease-out forwards;
}

/* ==========================================================================
   Form Components
   ========================================================================== */

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 30px var(--color-slate-700) inset !important;
  -webkit-text-fill-color: white !important;
  border-color: var(--color-slate-600) !important;
}

/* ==========================================================================
   Interactive Elements
   ========================================================================== */

a, 
button, 
input, 
textarea, 
select, 
.hover\:bg-slate-700 {
  transition-property: color, background-color, border-color, box-shadow, transform;
  transition-timing-function: ease;
  transition-duration: var(--transition-normal);
}

/* ==========================================================================
   Focus Management
   ========================================================================== */

*:focus {
  outline: none !important;
  box-shadow: none !important;
  ring: 0 !important;
  --tw-ring-shadow: none !important;
  --tw-ring-offset-shadow: none !important;
}

*:focus-visible {
  outline: var(--focus-outline-width) solid var(--focus-color) !important;
  outline-offset: var(--focus-outline-offset) !important;
  border-radius: 4px !important;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: var(--focus-outline-width) solid var(--focus-color) !important;
  outline-offset: var(--focus-outline-offset) !important;
  box-shadow: var(--focus-ring-shadow) !important;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  border-color: var(--focus-color) !important;
  box-shadow: 0 0 0 3px rgba(100, 116, 139, 0.1) !important;
}

/* ==========================================================================
   Mobile-Specific Components
   ========================================================================== */

@media (max-width: 640px) {
  button:not(.inline-button), 
  a.button, 
  input[type="submit"], 
  input[type="button"] {
    min-height: 44px;
    min-width: 44px;
  }
  
  button, 
  a, 
  input, 
  select, 
  textarea {
    -webkit-tap-highlight-color: rgba(100, 116, 139, 0.2);
  }
}

/* ==========================================================================
   Content Editable Component
   ========================================================================== */
[contenteditable] {
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
  white-space: pre-wrap;
}

/* ==========================================================================
   Table Component
   ========================================================================== */
@media (max-width: 640px) {
  table {
    table-layout: fixed;
    width: 100%;
    word-wrap: break-word;
  }
}

/* ==========================================================================
   Code Block Component
   ========================================================================== */
pre {
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

/* ==========================================================================
   Media Components
   ========================================================================== */
img, 
video, 
iframe, 
object, 
embed {
  max-width: 100%;
  height: auto;
}

@media (max-width: 640px) {
  img, 
  video, 
  iframe, 
  object, 
  embed, 
  table, 
  pre {
    max-width: 100vw;
  }
}

/* ==========================================================================
   Job Details Component
   ========================================================================== */
.htmx-request .analyze-icon,
.htmx-request .cover-letter-icon,
.htmx-request .cv-icon {
  display: none;
}

/* ==========================================================================
   Settings Layout Component
   ========================================================================== */

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

/* Better touch targets for mobile */
@media (max-width: 768px) {
  input, 
  button, 
  select, 
  textarea, 
  label, 
  a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  input[type="checkbox"], 
  input[type="radio"] {
    min-width: 20px;
    min-height: 20px;
    margin: 4px;
  }

  input:focus, 
  textarea:focus, 
  select:focus {
    transform: scale(1.02);
    transition: transform 0.2s ease;
  }

  button:active, 
  .touch-manipulation:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }

  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="url"],
  input[type="password"],
  textarea,
  select {
    font-size: 16px;
  }

  .scroll-container {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
}

.htmx-request {
  opacity: 0.7;
  transition: opacity 0.3s ease;
}

.htmx-request button {
  pointer-events: none;
}

/* ==========================================================================
   Skills Tag Component
   ========================================================================== */
.skill-tag {
  padding: 2px 4px !important;
}

@media (max-width: 768px) {
  .skill-tag {
    padding: 1px 3px !important;
    font-size: 0.6875rem !important;
  }
}

/* ==========================================================================
   CV Generator Button Component
   ========================================================================== */

/* CV generator compact buttons with enhanced touch targets */
.cv-button-compact {
  /* Reset global button styles */
  min-height: auto !important;
  min-width: auto !important;
  height: auto !important;
  
  /* Compact visual size */
  padding: 2px 8px;
  font-size: 0.75rem; /* 12px */
  line-height: 1.25rem; /* 20px */
  
  /* Position relative for pseudo-element */
  position: relative;
  
  /* Ensure button stays above pseudo-element */
  z-index: 1;
}

/* Mobile-specific adjustments */
@media (max-width: 640px) {
  .cv-button-compact {
    /* Even smaller visual size on mobile */
    padding: 0 2px;
    font-size: 0.5625rem; /* 9px */
  }
}

@media (min-width: 640px) and (max-width: 768px) {
  .cv-button-compact {
    /* Small screens */
    padding: 2px 4px;
    font-size: 0.625rem; /* 10px */
  }
}

@media (min-width: 768px) {
  .cv-button-compact {
    /* Medium screens and up */
    padding: 4px 8px;
    font-size: 0.75rem; /* 12px */
  }
}

/* Enhanced touch target for mobile (44x44px minimum) */
@media (max-width: 768px) {
  .cv-button-compact::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: max(100%, 44px);
    height: max(100%, 44px);
    z-index: -1;
    /* Invisible but tappable */
  }
  
  /* Override global mobile button styles for these specific buttons */
  #resume-content .cv-button-compact {
    min-height: auto !important;
    display: inline-flex !important;
  }
}