/* O2O3.RU - Modern Responsive Design */

:root {
  --bg-dark: #ffffff;
  --bg-card: #f8fafc;
  --bg-elevated: #f1f5f9;
  --primary: #1e40af;
  --primary-glow: rgba(30, 64, 175, 0.15);
  --accent: #0ea5e9;
  --text: #1e293b;
  --text-muted: #475569;
  --text-dim: #64748b;
  --border: #e2e8f0;
  --gradient-1: linear-gradient(135deg, #1e40af 0%, #0ea5e9 100%);
  --gradient-2: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%);
  --shadow-glow: 0 0 20px var(--primary-glow);
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.08);
  --radius: 12px;
  --radius-lg: 20px;
  --header-height: 70px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg-dark);
  overflow-x: hidden;
}

/* Background effects */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(ellipse at 20% 20%, rgba(30, 64, 175, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 80%, rgba(14, 165, 233, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
}

/* Header */
.header {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 0.75rem 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.header-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none;
  letter-spacing: -1px;
  font-family: 'Courier New', monospace;
  white-space: nowrap;
}

.logo span {
  filter: drop-shadow(0 0 10px var(--primary-glow));
}

/* Mobile menu button */
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  z-index: 1001;
}

.menu-toggle span {
  width: 25px;
  height: 3px;
  background: var(--text);
  border-radius: 3px;
  transition: all 0.3s;
}

.menu-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(6px, 6px);
}

.menu-toggle.active span:nth-child(2) {
  opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}

.nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 50px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 0.85rem;
  font-weight: 500;
  position: relative;
  white-space: nowrap;
}

.nav a:hover {
  color: var(--primary);
  background: var(--bg-elevated);
}

.nav a.active {
  color: white;
  background: var(--gradient-2);
  box-shadow: var(--shadow-glow);
}

/* Main content */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.container {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2rem;
  align-items: start;
}

.content {
  background: var(--bg-card);
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--gradient-1);
}

/* Sidebar - Desktop */
.sidebar {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  height: fit-content;
  position: sticky;
  top: calc(var(--header-height) + 1rem);
}

/* Sidebar - Mobile: Slide-out panel from right */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9998;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

.sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 5rem;
  right: 1rem;
  width: 50px;
  height: 50px;
  background: var(--gradient-1);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  z-index: 9999;
  box-shadow: 0 4px 15px rgba(30, 64, 175, 0.4);
  font-size: 1.2rem;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.sidebar-toggle:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(30, 64, 175, 0.5);
}

.sidebar-toggle.active {
  background: var(--text);
}

.sidebar h3 {
  margin-bottom: 1.2rem;
  color: var(--primary);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 600;
}

.sidebar ul {
  list-style: none;
  margin-bottom: 2rem;
}

.sidebar li {
  margin-bottom: 0.4rem;
}

.sidebar a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.7rem 1rem;
  display: block;
  border-radius: 8px;
  transition: all 0.3s;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
}

.sidebar a:hover {
  color: var(--text);
  background: var(--bg-elevated);
  border-left-color: var(--primary);
}

.sidebar a.active {
  color: var(--primary);
  background: rgba(59, 130, 246, 0.1);
  border-left-color: var(--primary);
}

/* Typography */
h1 {
  font-size: 2.8rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
  line-height: 1.2;
  background: linear-gradient(135deg, #1e293b 0%, #475569 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -1px;
}

h2 {
  font-size: 1.8rem;
  font-weight: 700;
  margin: 2.5rem 0 1.5rem;
  color: var(--text);
  position: relative;
  padding-left: 1.5rem;
}

h2::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 1.5rem;
  background: var(--gradient-1);
  border-radius: 2px;
}

h3 {
  font-size: 1.3rem;
  font-weight: 600;
  margin: 2rem 0 1rem;
  color: var(--text);
}

h4 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.8rem;
  color: var(--text);
}

p {
  margin-bottom: 1.2rem;
  color: var(--text-muted);
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.3s;
}

a:hover {
  color: var(--accent);
  text-decoration: underline;
}

ul, ol {
  margin: 1rem 0 1.5rem;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.6rem;
  color: var(--text-muted);
}

li::marker {
  color: var(--primary);
}

/* Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin: 2rem 0;
}

.card {
  background: var(--bg-elevated);
  padding: 2rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-1);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s;
}

.card:hover {
  transform: translateY(-5px);
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}

.card:hover::before {
  transform: scaleX(1);
}

.card h3 {
  margin-top: 0;
  color: var(--text);
  margin-bottom: 0.8rem;
}

.card p {
  font-size: 0.95rem;
  margin: 0;
}

/* Info boxes */
.info-box {
  background: rgba(30, 64, 175, 0.05);
  border-left: 4px solid var(--primary);
  padding: 1.5rem 2rem;
  margin: 2rem 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  backdrop-filter: blur(10px);
}

.info-box.warning {
  background: rgba(245, 158, 11, 0.08);
  border-left-color: #f59e0b;
}

.info-box.success {
  background: rgba(16, 185, 129, 0.08);
  border-left-color: #10b981;
}

.info-box h4 {
  margin-bottom: 0.8rem;
  color: var(--primary);
  font-size: 1rem;
}

.info-box.warning h4 {
  color: #f59e0b;
}

.info-box.success h4 {
  color: #10b981;
}

/* References */
.references {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.references h3 {
  color: var(--primary);
  margin-top: 0;
}

.references ol {
  padding-left: 1.5rem;
}

.references li {
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Table of contents */
.toc {
  background: var(--bg-elevated);
  padding: 1.5rem 2rem;
  border-radius: var(--radius);
  margin: 2rem 0;
  border: 1px solid var(--border);
}

.toc h4 {
  margin-bottom: 1rem;
  color: var(--primary);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc li {
  margin-bottom: 0.5rem;
}

.toc a {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 0.4rem 0;
  display: block;
}

.toc a:hover {
  color: var(--primary);
  text-decoration: none;
}

/* Footer */
.footer {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: 3rem 0;
  margin-top: 4rem;
}

.footer-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
  text-align: center;
}

.footer p {
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}

.footer a {
  color: var(--primary);
}

/* Search */
.search-box {
  position: relative;
  margin-top: 1rem;
}

.search-box input {
  width: 100%;
  padding: 0.8rem 1.2rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 50px;
  color: var(--text);
  font-size: 0.9rem;
  transition: all 0.3s;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-box input::placeholder {
  color: var(--text-dim);
}

/* Breadcrumb */
.breadcrumb {
  margin-bottom: 2rem;
  font-size: 0.9rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.breadcrumb a {
  color: var(--primary);
}

/* Tags */
.tags {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin: 1.5rem 0;
}

.tag {
  background: var(--bg-elevated);
  color: var(--text-muted);
  padding: 0.4rem 1rem;
  border-radius: 50px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
}

/* Back to top */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--gradient-1);
  color: white;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: var(--shadow-glow);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
  z-index: 1000;
  font-size: 1.2rem;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  transform: translateY(-3px);
  box-shadow: 0 0 40px var(--primary-glow);
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  overflow: hidden;
}

th, td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: rgba(59, 130, 246, 0.1);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

td {
  color: var(--text-muted);
}

tr:last-child td {
  border-bottom: none;
}

/* Code blocks */
code {
  background: var(--bg-elevated);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9em;
  color: var(--accent);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-card);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* Selection */
::selection {
  background: var(--primary);
  color: white;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Tablet: 768px - 1024px */
@media (max-width: 1024px) {
  .container {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .sidebar {
    position: static;
    order: -1;
  }
  
  .content {
    padding: 2rem;
  }
  
  h1 {
    font-size: 2.2rem;
  }
  
  h2 {
    font-size: 1.6rem;
  }
  
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }
}

/* Mobile: up to 768px */
@media (max-width: 768px) {
  :root {
    --header-height: 60px;
  }
  
  .header {
    padding: 0.5rem 0;
  }
  
  .header-content {
    padding: 0 1rem;
    gap: 1rem;
  }
  
  .logo {
    font-size: 1.2rem;
  }
  
  /* Show mobile menu button */
  .menu-toggle {
    display: flex;
  }
  
  /* Hide nav on mobile, show when active */
  .nav {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: white;
    flex-direction: column;
    padding: 1rem;
    gap: 0.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    transform: translateY(-100%);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }
  
  .nav.active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
  }
  
  .nav a {
    width: 100%;
    text-align: center;
    padding: 0.8rem 1rem;
    font-size: 1rem;
  }
  
  .main {
    padding: 1.5rem 1rem;
  }
  
  .content {
    padding: 1.5rem;
    border-radius: var(--radius);
  }
  
  /* Sidebar: hidden by default, slides in from right */
  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 300px;
    max-width: 85vw;
    height: 100vh;
    padding: 1.5rem;
    border-radius: 0;
    border: none;
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 9999;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .sidebar.active {
    transform: translateX(0);
  }
  
  .sidebar-close {
    display: block;
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 35px;
    height: 35px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text);
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
  }
  
  .sidebar-close:hover {
    background: var(--primary);
    color: white;
  }
  
  h1 {
    font-size: 1.8rem;
    line-height: 1.3;
  }
  
  h2 {
    font-size: 1.4rem;
    margin: 2rem 0 1rem;
  }
  
  h3 {
    font-size: 1.1rem;
  }
  
  p {
    font-size: 0.95rem;
  }
  
  ul, ol {
    padding-left: 1.25rem;
  }
  
  li {
    font-size: 0.95rem;
  }
  
  .card-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .card {
    padding: 1.5rem;
  }
  
  .info-box {
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
  }
  
  .info-box h4 {
    font-size: 0.95rem;
  }
  
  table {
    font-size: 0.85rem;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
  
  th, td {
    padding: 0.75rem;
  }
  
  .references li {
    font-size: 0.85rem;
  }
  
  .breadcrumb {
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
  }
  
  .search-box input {
    font-size: 16px; /* Prevent zoom on iOS */
    padding: 0.75rem 1rem;
  }
  
  .back-to-top {
    width: 40px;
    height: 40px;
    bottom: 1rem;
    right: 1rem;
    font-size: 1rem;
  }
  
  /* Show sidebar toggle button on mobile */
  .sidebar-toggle {
    display: flex;
  }
}

/* Small Mobile: up to 480px */
@media (max-width: 480px) {
  .logo {
    font-size: 1.1rem;
  }
  
  .main {
    padding: 1rem 0.75rem;
  }
  
  .content {
    padding: 1.25rem;
  }
  
  h1 {
    font-size: 1.6rem;
  }
  
  h2 {
    font-size: 1.3rem;
  }
  
  .card {
    padding: 1.25rem;
  }
  
  .card h3 {
    font-size: 1.1rem;
  }
  
  .card p {
    font-size: 0.9rem;
  }
  
  .info-box {
    padding: 0.875rem 1rem;
  }
  
  .sidebar h3 {
    font-size: 0.8rem;
  }
  
  .sidebar a {
    font-size: 0.85rem;
    padding: 0.6rem 0.75rem;
  }
}

/* Landscape Mobile: 480px - 768px */
@media (min-width: 480px) and (max-width: 768px) and (orientation: landscape) {
  .container {
    grid-template-columns: 1fr;
  }
  
  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    max-width: 80vw;
    height: 100vh;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 9999;
    overflow-y: auto;
    border-radius: 0;
    border: none;
    box-shadow: -5px 0 30px rgba(0, 0, 0, 0.15);
  }
  
  .sidebar.active {
    transform: translateX(0);
  }
  
  .sidebar-close {
    display: block;
  }
}

/* Touch devices optimization */
@media (hover: none) and (pointer: coarse) {
  .nav a {
    padding: 0.75rem 1.25rem;
  }
  
  .sidebar a {
    padding: 0.875rem 1rem;
  }
  
  .card {
    padding: 1.75rem;
  }
  
  button, .menu-toggle {
    min-width: 44px;
    min-height: 44px;
  }
}

/* Print styles */
@media print {
  .header,
  .sidebar,
  .back-to-top,
  .menu-toggle,
  .sidebar-toggle,
  .sidebar-overlay,
  .sidebar-close,
  .search-box {
    display: none !important;
  }
  
  .main {
    padding: 0;
    max-width: 100%;
  }
  
  .content {
    box-shadow: none;
    border: none;
    padding: 0;
  }
  
  .container {
    grid-template-columns: 1fr;
  }
  
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #666;
  }
}
