/* ============================================
   CONSOLIDATED MASTER CSS - Fixed & Rebuilt
   ============================================ */

/* NOTE: Tailwind is loaded via <script> tag in header, not @import */

:root {
  /* Site Theme Colors - Dark Mode Primary */
  --theme-bg-primary: #111827;        /* gray-900 */
  --theme-bg-secondary: #1f2937;      /* gray-800 */
  --theme-bg-tertiary: #374151;       /* gray-700 */
  --theme-border: #4b5563;            /* gray-600 */
  --theme-border-light: #6b7280;      /* gray-500 */
  
  /* Text Colors */
  --theme-text-primary: #f9fafb;      /* gray-50 */
  --theme-text-secondary: #e5e7eb;    /* gray-200 */
  --theme-text-tertiary: #d1d5db;     /* gray-300 */
  --theme-text-muted: #9ca3af;        /* gray-400 */
  
  /* Accent Colors - Match site gradients */
  --theme-accent-primary: #6366f1;    /* indigo-500 */
  --theme-accent-secondary: #a855f7;  /* purple-500 */
  --theme-accent-tertiary: #3b82f6;   /* blue-500 */
  --theme-accent-success: #10b981;    /* green-500 */
  
  /* Focus & Interactive States */
  --theme-focus: #8b5cf6;             /* purple-500 */
  --theme-focus-ring: rgba(139, 92, 246, 0.5);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  width: 100%;
}

body {
  display: flex;
  flex-direction: column;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #111827;
  line-height: 1.6;
}

body.dark {
  background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
  color: #f9fafb;
}

/* ============================================
   HEADER - Fixed & Properly Spaced
   ============================================ */

header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  margin: 0;
  padding: 0;
}

header .container {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 0.75rem 1rem;
}

@media (min-width: 768px) {
  header .container {
    padding: 0.75rem 1.5rem;
  }
}

@media (min-width: 1024px) {
  header .container {
    padding: 0.75rem 2rem;
  }
}

/* Header top-row flex layout only */
header .container > .flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 0.5rem 0;
  margin: 0;
}

@media (max-width: 640px) {
  header .container > .flex {
    gap: 0.5rem;
  }
}

/* Logo section */
header .container > .flex > .flex:first-child {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
}

@media (max-width: 640px) {
  header .container > .flex > .flex:first-child {
    gap: 0.5rem;
  }
}

header img {
  height: 2.5rem;
  width: 2.5rem;
  border-radius: 9999px;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
}

header a[href="/"] {
  text-decoration: none;
  font-weight: 700;
  font-size: 1.25rem;
  background: linear-gradient(to right, #818cf8, #c084fc, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.05em;
  margin: 0;
  padding: 0;
}

@media (max-width: 640px) {
  header a[href="/"] {
    font-size: 1rem;
    display: none;
  }
}

/* Search bar section */
header .container > .flex > .flex:nth-child(2) {
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 32rem;
  margin: 0 0.75rem;
  padding: 0;
  gap: 0.5rem;
}

@media (max-width: 640px) {
  header .container > .flex > .flex:nth-child(2) {
    max-width: 100%;
    margin: 0 0.5rem;
    flex: 1;
    min-width: 0;
  }
}

header .container > .flex > .flex:nth-child(2) .relative {
  width: 100%;
  position: relative;
  margin: 0;
  padding: 0;
}

/* Search input */
#search-input {
  width: 100%;
  padding: 0.625rem 1rem 0.625rem 2.5rem !important;
  margin: 0 !important;
  background: rgba(31, 41, 55, 0.9) !important;
  border: 1px solid rgba(107, 114, 128, 0.5) !important;
  border-radius: 0.75rem;
  color: white;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

@media (max-width: 640px) {
  #search-input {
    font-size: 0.75rem;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem !important;
  }
}

#search-input:focus {
  border-color: #6366f1 !important;
  outline: none;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1) !important;
}

#search-input::placeholder {
  color: rgba(156, 163, 175, 0.7);
}

/* Search button */
#search-btn {
  padding: 0.5rem 1rem !important;
  margin: 0 0.25rem !important;
  height: auto !important;
  font-size: 0.875rem !important;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  #search-btn {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.75rem !important;
  }
}

/* Right nav section */
header .container > .flex > .flex:last-child {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
}

@media (max-width: 640px) {
  header .container > .flex > .flex:last-child {
    gap: 0.5rem;
  }
}

/* Navigation links */
header nav {
  display: flex;
  gap: 0;
  margin: 0;
  padding: 0;
}

header nav a {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: rgba(209, 213, 219, 0.9);
  text-decoration: none;
  transition: color 0.2s ease;
  cursor: pointer;
  position: relative;
  margin: 0;
  white-space: nowrap;
}

header nav a:hover {
  color: white;
}

header nav a::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, #6366f1, #a855f7);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.3s ease;
}

header nav a:hover::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* Mobile menu toggle */
#menu-toggle {
  display: none;
  padding: 0.5rem !important;
  margin: 0 !important;
  background: transparent;
  border: none;
  color: rgba(209, 213, 219, 0.8);
  cursor: pointer;
  font-size: 1rem;
  height: 2.5rem;
  width: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
}

#menu-toggle:hover {
  color: white;
  background: rgba(31, 41, 55, 0.5);
}

@media (min-width: 1024px) {
  #menu-toggle {
    display: none !important;
  }
  
  header nav {
    display: flex !important;
  }
}

/* Language selector */
#lang-select {
  display: none;
  padding: 0.5rem 0.75rem !important;
  margin: 0 !important;
  font-size: 0.875rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(107, 114, 128, 0.5);
  background: rgba(31, 41, 55, 0.7);
  color: rgba(209, 213, 219, 0.9);
  cursor: pointer;
}

@media (min-width: 768px) {
  #lang-select {
    display: block !important;
  }
}

/* ============================================
   LAYOUT & CONTENT
   ============================================ */

main {
  flex: 1;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/* Only reset flex on specific elements, not globally */
main > .flex,
.flex-col-reset {
  display: flex;
  margin: 0;
  padding: 0;
  gap: 0;
}

.flex-col {
  flex-direction: column;
}

.flex-1 {
  flex: 1;
  margin: 0;
  padding: 0;
}

/* Sidebar spacing for desktop */
@media (min-width: 1024px) {
  .flex-1.lg\:ml-6 {
    margin-left: 1.5rem;
  }
  
  .flex-1.lg\:mr-6 {
    margin-right: 1.5rem;
  }
}

/* Section proper spacing */
section {
  margin: 0;
  padding: 1rem 0.75rem;
}

@media (min-width: 768px) {
  section {
    padding: 1.5rem 1rem;
  }
}

@media (min-width: 1024px) {
  section {
    padding: 2rem 1.5rem;
  }
}

/* ============================================
   SIDEBAR - Proper Layout
   ============================================ */

aside {
  display: none;
  width: 16rem;
  padding: 1.5rem;
  border-radius: 1.5rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.95) 0%, rgba(31, 41, 55, 0.95) 100%);
  border-right: 1px solid rgba(107, 114, 128, 0.3);
  gap: 1rem;
  flex-direction: column;
  position: sticky;
  top: 5rem;
  height: calc(100vh - 5rem);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.5) transparent;
  margin: 0;
  margin-left: 1.5rem;
}

@media (min-width: 1024px) {
  aside {
    display: flex;
  }
}

aside::-webkit-scrollbar {
  width: 6px;
}

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

aside::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #6366f1 0%, #a855f7 100%);
  border-radius: 3px;
}

/* Navigation items */
aside > div {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
}

aside .text-xs {
  font-size: 0.75rem !important;
  color: rgba(107, 114, 128, 0.8) !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin: 1rem 0 0.5rem 0 !important;
  padding: 0 !important;
}

aside a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  color: rgba(209, 213, 219, 0.9);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin: 0;
}

aside a:hover {
  background: rgba(31, 41, 55, 0.7);
  color: white;
  padding-left: 1.25rem;
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.1) 0%, transparent 100%);
}

aside a svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  color: #6366f1;
}

/* ============================================
   CONTAINERS & SPACING
   ============================================ */

.container {
  width: 100%;
  margin-left: auto;
  margin-right: auto;
  padding-left: 1rem;
  padding-right: 1rem;
}

@media (min-width: 768px) {
  .container {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }
}

@media (min-width: 1024px) {
  .container {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

.max-w-6xl {
  max-width: 72rem;
  margin-left: auto;
  margin-right: auto;
}

.max-w-4xl {
  max-width: 56rem;
  margin-left: auto;
  margin-right: auto;
}

.max-w-xl {
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
}

/* ============================================
   GRID & GAP UTILITIES
   ============================================ */

.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-cols-1 {
  grid-template-columns: 1fr;
}

.grid-cols-2 {
  grid-template-columns: 1fr;
}

.grid-cols-3 {
  grid-template-columns: 1fr;
}

.grid-cols-4 {
  grid-template-columns: 1fr;
}

@media (min-width: 768px) {
  .grid {
    gap: 1.5rem;
  }
  
  .grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  
  .grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  
  .grid-cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .grid {
    gap: 0.75rem;
  }
}

.gap-6 { gap: 1.5rem !important; }
.gap-5 { gap: 1.25rem !important; }
.gap-4 { gap: 1rem !important; }
.gap-3 { gap: 0.75rem !important; }
.gap-2 { gap: 0.5rem !important; }

/* Mobile: smaller gaps */
@media (max-width: 640px) {
  .gap-6 { gap: 1rem !important; }
  .gap-5 { gap: 0.75rem !important; }
  .gap-4 { gap: 0.5rem !important; }
  .gap-3 { gap: 0.375rem !important; }
}

/* ============================================
   PADDING & MARGIN - Proper Scale
   ============================================ */

.py-8 {
  padding-top: 2rem !important;
  padding-bottom: 2rem !important;
}

.py-6 {
  padding-top: 1.5rem !important;
  padding-bottom: 1.5rem !important;
}

.py-4 {
  padding-top: 1rem !important;
  padding-bottom: 1rem !important;
}

.py-3 {
  padding-top: 0.75rem !important;
  padding-bottom: 0.75rem !important;
}

.py-2 {
  padding-top: 0.5rem !important;
  padding-bottom: 0.5rem !important;
}

.px-8 {
  padding-left: 2rem !important;
  padding-right: 2rem !important;
}

.px-6 {
  padding-left: 1.5rem !important;
  padding-right: 1.5rem !important;
}

.px-4 {
  padding-left: 1rem !important;
  padding-right: 1rem !important;
}

.px-3 {
  padding-left: 0.75rem !important;
  padding-right: 0.75rem !important;
}

/* Margin utilities */
.mb-8 { margin-bottom: 2rem !important; }
.mb-6 { margin-bottom: 1.5rem !important; }
.mb-4 { margin-bottom: 1rem !important; }
.mb-3 { margin-bottom: 0.75rem !important; }

.mt-8 { margin-top: 2rem !important; }
.mt-6 { margin-top: 1.5rem !important; }
.mt-4 { margin-top: 1rem !important; }
.mt-3 { margin-top: 0.75rem !important; }

.pt-12 {
  padding-top: 3rem !important;
}

.pt-8 {
  padding-top: 2rem !important;
}

.pt-6 {
  padding-top: 1.5rem !important;
}

/* Mobile responsive margins */
@media (max-width: 640px) {
  .py-8 {
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
  }
  
  .py-6 {
    padding-top: 0.75rem !important;
    padding-bottom: 0.75rem !important;
  }
  
  .px-8 {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
  }
}

/* ============================================
   TEXT & TYPOGRAPHY
   ============================================ */

h1, h2, h3, h4, h5, h6 {
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1.2;
}

h1 {
  font-size: 2rem;
  font-weight: 700;
}

@media (max-width: 768px) {
  h1 {
    font-size: 1.5rem;
  }
}

h2 {
  font-size: 1.5rem;
  font-weight: 600;
}

h3, h4, h5, h6 {
  font-size: 1.125rem;
  font-weight: 600;
}

p {
  margin: 0 !important;
  padding: 0 !important;
}

/* ============================================
   BUTTONS
   ============================================ */

button,
[role="button"],
[type="button"],
[type="submit"],
[type="reset"] {
  padding: 0.625rem 1rem !important;
  margin: 0 !important;
  border: none;
  border-radius: 0.5rem;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 36px;
}

@media (pointer: coarse) {
  button,
  [role="button"],
  [type="button"],
  [type="submit"],
  [type="reset"] {
    min-height: 44px;
  }
}

button:hover:not(:disabled),
[role="button"]:hover:not([aria-disabled="true"]) {
  filter: brightness(1.15);
}

button:active:not(:disabled),
[role="button"]:active:not([aria-disabled="true"]) {
  transform: scale(0.98);
  opacity: 0.9;
}

button:disabled,
button[disabled],
[aria-disabled="true"] {
  cursor: not-allowed !important;
  opacity: 0.5 !important;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */

input:not([type="checkbox"]):not([type="radio"]),
textarea,
select {
  width: 100%;
  padding: 0.625rem 0.875rem !important;
  margin: 0 !important;
  border: 1px solid var(--theme-border);
  background-color: var(--theme-bg-secondary);
  color: var(--theme-text-primary);
  border-radius: 0.5rem;
  font-family: inherit;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

input:not([type="checkbox"]):not([type="radio"]):hover,
textarea:hover,
select:hover {
  border-color: var(--theme-border-light);
}

input:not([type="checkbox"]):not([type="radio"]):focus,
textarea:focus,
select:focus {
  border-color: var(--theme-accent-primary);
  outline: 2px solid transparent;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

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

/* ============================================
   INTERACTIVE ELEMENTS
   ============================================ */

a,
button,
[role="button"],
[onclick],
[x-on\:click] {
  cursor: pointer !important;
}

:disabled,
[disabled],
[aria-disabled="true"] {
  cursor: not-allowed !important;
  opacity: 0.5 !important;
}

/* Links */
a {
  color: #6366f1;
  text-decoration: none;
}

a:hover {
  color: #a855f7;
  text-decoration: underline;
}

/* Navigation active states */
nav a[aria-current="page"],
nav a.active {
  background-color: rgba(99, 102, 241, 0.15);
  border-left: 3px solid var(--theme-accent-primary);
}

/* ============================================
   RESPONSIVE DESIGN - Mobile First
   ============================================ */

/* Mobile - Base styles */
@media (max-width: 640px) {
  #menu-toggle {
    display: flex !important;
  }
  
  header nav {
    display: none;
  }
  
  header nav.active {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(17, 24, 39, 0.98);
    padding: 1rem;
    gap: 0.5rem;
    z-index: 40;
  }
  
  .grid-cols-2 {
    grid-template-columns: 1fr !important;
  }
  
  .grid-cols-3 {
    grid-template-columns: 1fr !important;
  }
  
  .hidden.lg\:flex {
    display: none !important;
  }
}

/* Tablet */
@media (min-width: 641px) and (max-width: 1024px) {
  .hidden.md\:flex {
    display: flex !important;
  }
  
  .hidden.lg\:flex {
    display: none !important;
  }
  
  .grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* Desktop */
@media (min-width: 1025px) {
  .hidden.lg\:flex {
    display: flex !important;
  }
}

/* ============================================
   STICKY ELEMENTS
   ============================================ */

.sticky {
  position: sticky !important;
  z-index: 40;
}

.top-0 {
  top: 0;
}

header.sticky.top-0 {
  top: 0 !important;
}

@media (max-width: 640px) {
  .sticky.top-0 {
    top: 3.5rem;
  }
}

@media (min-width: 641px) {
  .sticky.top-0 {
    top: 3.75rem;
  }
}

/* ============================================
   FOCUS & ACCESSIBILITY
   ============================================ */

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

/* ============================================
   ANIMATIONS - Allow selective animations
   ============================================ */

* {
  animation: none !important;
}

/* Allow header nav underline animation */
header nav a::after {
  transition: transform 0.3s ease !important;
}

/* Allow sidebar hover animation */
aside a {
  transition: all 0.2s ease !important;
}

/* Disable other transitions */
.transition,
.transition-all,
.transition-colors,
.transition-shadow,
.transition-transform,
.transition-opacity {
  transition: none !important;
}

.duration-200,
.duration-300,
.duration-500,
.duration-700 {
  transition-duration: 0s !important;
}

/* ============================================
   DARK MODE DEFAULTS
   ============================================ */

body {
  background: linear-gradient(135deg, #111827 0%, #1f2937 100%);
  color: #f9fafb;
}

header {
  background: rgba(17, 24, 39, 0.95);
  border-bottom-color: rgba(255, 255, 255, 0.1);
}

.text-gray-300 {
  color: rgba(209, 213, 219, 0.9) !important;
}

.text-gray-400 {
  color: rgba(156, 163, 175, 0.8) !important;
}

.text-gray-200 {
  color: rgba(229, 231, 235, 0.9) !important;
}

.bg-gray-900 {
  background-color: #111827 !important;
}

.bg-gray-800 {
  background-color: #1f2937 !important;
}

.bg-gray-700 {
  background-color: #374151 !important;
}

/* ============================================
   CARD & CONTENT AREAS
   ============================================ */

.card,
[class*="card"] {
  padding: 1rem !important;
  margin: 0 !important;
  border-radius: 0.75rem;
  background: rgba(31, 41, 55, 0.5);
  border: 1px solid rgba(107, 114, 128, 0.2);
  transition: all 0.2s ease;
}

.card:hover,
[class*="card"]:hover {
  background: rgba(31, 41, 55, 0.8);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  * {
    animation: none !important;
    transition: none !important;
  }
}
