/* ============================================
   DESIGN SYSTEM & TYPOGRAPHY
   ============================================ */

:root {
  /* Color Palette - Управленческий учёт (Professional Blue) */
  --primary-color: #2563eb;      /* Bright Blue - Professional, trustworthy */
  --primary-light: #3b82f6;      /* Lighter blue for hover states */
  --primary-dark: #1d4ed8;       /* Darker blue for focus states */
  
  --secondary-color: #10b981;    /* Green - Growth, success */
  --accent-color: #f59e0b;       /* Amber - Attention, highlights */
  
  /* Neutral palette */
  --background: #ffffff;
  --surface: #f8f9fa;
  --surface-secondary: #f0f4f9;
  
  /* Text colors */
  --text-primary: #1a1a1a;
  --text-secondary: #6c757d;
  --text-tertiary: #adb5bd;
  --text-inverse: #ffffff;
  
  /* Borders & dividers */
  --border: #e9ecef;
  --border-light: #f1f3f5;
  --border-dark: #dee2e6;
  
  /* States */
  --success: #10b981;
  --warning: #f59e0b;
  --error: #ef4444;
  --info: #3b82f6;
  
  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.16);
  --shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.15);
  
  /* Typography */
  --font-heading: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  --font-mono: 'Courier New', monospace;
  
  /* Spacing System */
  --space-xs: 0.25rem;    /* 4px */
  --space-sm: 0.5rem;     /* 8px */
  --space-md: 1rem;       /* 16px */
  --space-lg: 2rem;       /* 32px */
  --space-xl: 4rem;       /* 64px */
  --space-2xl: 6rem;      /* 96px */
  
  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
  
  /* Z-index scale */
  --z-dropdown: 100;
  --z-sticky: 50;
  --z-fixed: 40;
  --z-modal-bg: 90;
  --z-modal: 99;
  
  /* Transitions */
  --transition-fast: 0.15s ease-out;
  --transition-base: 0.3s ease;
  --transition-slow: 0.5s ease;
}

/* Dark mode support - DISABLED - Always light theme */
/* @media (prefers-color-scheme: dark) {
  :root {
    --background: #0f172a;
    --surface: #1e293b;
    --surface-secondary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --border: #334155;
    --border-light: #475569;
    --border-dark: #1e293b;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  }
} */

/* ============================================
   GLOBAL STYLES
   ============================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--background);
  transition: background-color var(--transition-base), 
              color var(--transition-base);
}

/* ============================================
   TYPOGRAPHY HIERARCHY
   ============================================ */

h1 {
  font-family: var(--font-heading);
  font-size: 2.5rem;      /* 40px */
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-lg);
  color: var(--text-primary);
}

h2 {
  font-family: var(--font-heading);
  font-size: 2rem;        /* 32px */
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin-top: var(--space-xl);
  margin-bottom: var(--space-lg);
  color: var(--text-primary);
}

h3 {
  font-family: var(--font-heading);
  font-size: 1.5rem;      /* 24px */
  font-weight: 600;
  line-height: 1.3;
  margin-top: var(--space-lg);
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}

h4 {
  font-family: var(--font-heading);
  font-size: 1.25rem;     /* 20px */
  font-weight: 600;
  margin-top: var(--space-md);
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

h5, h6 {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

p {
  margin-bottom: var(--space-md);
  color: var(--text-primary);
  line-height: 1.7;
}

p:last-child {
  margin-bottom: 0;
}

/* ============================================
   SEMANTIC ELEMENTS
   ============================================ */

strong, b {
  font-weight: 600;
  color: var(--text-primary);
}

em, i {
  font-style: italic;
  color: var(--text-secondary);
}

small {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color var(--transition-fast), 
              text-decoration var(--transition-fast);
  position: relative;
}

a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

a:active {
  color: var(--primary-dark);
}

/* Code styles */
code, pre {
  font-family: var(--font-mono);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.25rem 0.5rem;
  color: var(--text-primary);
  font-size: 0.875rem;
}

pre {
  padding: var(--space-md);
  overflow-x: auto;
  margin-bottom: var(--space-md);
  line-height: 1.5;
}

code {
  word-break: break-word;
}

/* ============================================
   LISTS & TABLES
   ============================================ */

ul, ol {
  margin-left: var(--space-lg);
  margin-bottom: var(--space-md);
}

li {
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
  line-height: 1.7;
}

ul ul, ol ol {
  margin-top: var(--space-sm);
  margin-bottom: 0;
  margin-left: var(--space-md);
}

dl {
  margin-bottom: var(--space-lg);
}

dt {
  font-weight: 600;
  margin-top: var(--space-md);
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

dd {
  margin-left: var(--space-lg);
  margin-bottom: var(--space-md);
  color: var(--text-secondary);
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-lg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

th {
  background-color: var(--surface);
  font-weight: 600;
  text-align: left;
  padding: var(--space-md);
  border-bottom: 2px solid var(--border-dark);
  color: var(--text-primary);
}

td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

tr:last-child td {
  border-bottom: none;
}

/* ============================================
   BLOCKQUOTE & HIGHLIGHTS
   ============================================ */

blockquote {
  margin: var(--space-lg) 0;
  padding: var(--space-md) var(--space-lg);
  border-left: 4px solid var(--primary-color);
  background-color: var(--surface);
  font-style: italic;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
}

.highlight {
  background-color: var(--accent-color);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: #000;
  font-weight: 500;
}

/* ============================================
   BUTTONS
   ============================================ */

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  
  padding: 0.75rem 1.5rem;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.5;
  
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  
  background-color: var(--primary-color);
  color: var(--text-inverse);
  
  transition: all var(--transition-base);
  user-select: none;
  
  text-decoration: none;
  display: inline-flex;
  white-space: nowrap;
}

button:hover, .btn:hover {
  background-color: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

button:active, .btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

button:disabled, .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Button variants */
.btn-secondary {
  background-color: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background-color: var(--border);
  border-color: var(--border-dark);
}

.btn-success {
  background-color: var(--success);
}

.btn-success:hover {
  background-color: #059669;
}

.btn-outline {
  background-color: transparent;
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
}

.btn-outline:hover {
  background-color: var(--primary-color);
  color: var(--text-inverse);
}

.btn-small {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-sm {
  padding: 0.5rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
  transition: all var(--transition-base);
}

.btn-sm:hover {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.3);
}

/* ============================================
   INPUTS & FORMS
   ============================================ */

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
textarea,
select {
  width: 100%;
  padding: 0.75rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--text-primary);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-base), 
              box-shadow var(--transition-base);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

label {
  display: block;
  margin-bottom: var(--space-sm);
  font-weight: 500;
  color: var(--text-primary);
}

.form-group {
  margin-bottom: var(--space-lg);
}

/* ============================================
   IMAGES & MEDIA
   ============================================ */

img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-lg);
  transition: transform var(--transition-base), 
              filter var(--transition-base);
}

img:hover {
  transform: scale(1.02);
}

picture {
  display: block;
}

svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* ============================================
   CONTAINER & LAYOUT
   ============================================ */

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.container-sm {
  max-width: 768px;
}

.container-lg {
  max-width: 1400px;
}

/* Sections */
section {
  margin-bottom: var(--space-2xl);
}

article {
  margin-bottom: var(--space-2xl);
}

/* Grid & Flexbox utilities */
.grid {
  display: grid;
  gap: var(--space-lg);
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-col {
  display: flex;
  flex-direction: column;
}

.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* ============================================
   CARDS
   ============================================ */

.card {
  background-color: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition-base);
  box-shadow: var(--shadow-sm);
}

.card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-color);
  transform: translateY(-4px);
}

.card-header {
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.card-body {
  margin-bottom: var(--space-md);
}

.card-footer {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border);
}

/* ============================================
   BADGES & TAGS
   ============================================ */

.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background-color: var(--primary-color);
  color: var(--text-inverse);
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-secondary {
  background-color: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.badge-success {
  background-color: var(--success);
  color: var(--text-inverse);
}

.badge-warning {
  background-color: var(--warning);
  color: #000;
}

.badge-error {
  background-color: var(--error);
  color: var(--text-inverse);
}

/* ============================================
   ALERTS
   ============================================ */

.alert {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  border: 1px solid;
  margin-bottom: var(--space-lg);
  display: flex;
  gap: var(--space-md);
  align-items: flex-start;
}

.alert-info {
  background-color: rgba(59, 130, 246, 0.1);
  border-color: var(--info);
  color: var(--text-primary);
}

.alert-success {
  background-color: rgba(16, 185, 129, 0.1);
  border-color: var(--success);
  color: var(--text-primary);
}

.alert-warning {
  background-color: rgba(245, 158, 11, 0.1);
  border-color: var(--warning);
  color: var(--text-primary);
}

.alert-error {
  background-color: rgba(239, 68, 68, 0.1);
  border-color: var(--error);
  color: var(--text-primary);
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/* Animation utility classes */
.animate-fade-in {
  animation: fadeIn var(--transition-base) ease-out;
}

.animate-fade-in-up {
  animation: fadeInUp var(--transition-base) ease-out;
}

.animate-fade-in-down {
  animation: fadeInDown var(--transition-base) ease-out;
}

.animate-slide-in-left {
  animation: slideInLeft var(--transition-base) ease-out;
}

.animate-slide-in-right {
  animation: slideInRight var(--transition-base) ease-out;
}

/* Intersection Observer animations */
.observe-fade-in {
  opacity: 0;
  animation: fadeIn var(--transition-base) ease-out forwards;
}

.observe-fade-in-up {
  opacity: 0;
  animation: fadeInUp var(--transition-base) ease-out forwards;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-accent { color: var(--primary-color); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error { color: var(--error); }

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.font-normal { font-weight: 400; }
.font-light { font-weight: 300; }

.italic { font-style: italic; }
.underline { text-decoration: underline; }
.no-underline { text-decoration: none; }

.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line-clamp-2 { 
  overflow: hidden; 
  display: -webkit-box; 
  -webkit-line-clamp: 2; 
  -webkit-box-orient: vertical;
  line-clamp: 2;
}
.line-clamp-3 { 
  overflow: hidden; 
  display: -webkit-box; 
  -webkit-line-clamp: 3; 
  -webkit-box-orient: vertical;
  line-clamp: 3;
}

.bg-primary { background-color: var(--primary-color); }
.bg-surface { background-color: var(--surface); }
.bg-surface-secondary { background-color: var(--surface-secondary); }

.m-0 { margin: 0; }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }

.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.px-md { padding-left: var(--space-md); padding-right: var(--space-md); }
.py-md { padding-top: var(--space-md); padding-bottom: var(--space-md); }

.hidden { display: none !important; }
.invisible { visibility: hidden; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }

/* ============================================
   SECTION & PAGE LAYOUT FIXES
   ============================================ */

/* Ensure main content flows properly */
main {
  width: 100%;
}

/* Page-wide container centering */
.container {
  width: 100% !important;
  max-width: 1200px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: var(--space-lg) !important;
  padding-right: var(--space-lg) !important;
}

/* Grid responsive behavior */
.grid-2 {
  grid-template-columns: repeat(2, 1fr) !important;
  width: 100% !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr) !important;
  width: 100% !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* Cards styling - centered content */
.card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  text-align: left;
}

/* Special styling for silo cards on main page */
#silos .card {
  text-align: center;
  align-items: center;
}

#silos .card > div:first-child {
  text-align: center;
  width: 100%;
  display: flex;
  justify-content: center;
}

#silos .card h3 {
  text-align: center;
  width: 100%;
}

#silos .card p {
  text-align: center;
  width: 100%;
}

#silos .card a {
  align-self: center;
  justify-self: center;
}

/* Media queries for responsive grid */
@media (max-width: 1024px) {
  .grid-3 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  
  .grid-2 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 768px) {
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr !important;
  }
  
  #silos .card:nth-child(5) {
    grid-column: auto !important;
  }
}

/* ============================================
   SCROLL & CUSTOM SCROLLBAR
   ============================================ */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--surface);
}

::-webkit-scrollbar-thumb {
  background: var(--border-dark);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ============================================
   SELECTION
   ============================================ */

::selection {
  background-color: var(--primary-color);
  color: var(--text-inverse);
}

::-moz-selection {
  background-color: var(--primary-color);
  color: var(--text-inverse);
}
