/* КРИТИЧЕСКОЕ ПРАВИЛО: Стабилизация шрифта Raleway */
* {
  font-variant-numeric: lining-nums;
  font-family: 'Raleway', sans-serif;
  border: none;
  box-sizing: border-box;
}

/* ========================================
   ГЛОБАЛЬНЫЕ СТИЛИ
   ======================================== */

body {
  margin: 0;
  padding: 0;
  background-color: #f9fafb;
  color: #1f2937;
  overflow-x: hidden;
}

/* ========================================
   HEADER
   ======================================== */

.header {
  background-color: #35574f;
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: relative;
}

.header-link {
  color: white;
  text-decoration: none;
  font-size: 1.5rem;
  font-weight: 600;
  transition: color 0.3s ease, transform 0.2s ease;
}

.header-link:hover {
  color: #d1f7dd;
  transform: scale(1.05);
}

.header-nav {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.header-nav-link {
  color: white;
  text-decoration: none;
  font-size: 1rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  transition: background-color 0.3s ease, transform 0.2s ease;
  background-color: rgba(255, 255, 255, 0.1);
}

.header-nav-link:hover {
  background-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.header-nav-link:active {
  transform: translateY(0);
}

/* ========================================
   HERO SECTIONS
   ======================================== */

.hero {
  background: linear-gradient(to right, #008082, #46AE5B);
  color: white;
  padding: 1.5rem 1rem;
  text-align: center;
  animation: fadeInDown 0.6s ease-out;
}

@keyframes fadeInDown {
  0% {
    opacity: 0;
    transform: translateY(-20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero h1 {
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
  animation: fadeIn 0.8s ease-out 0.2s both;
}

@keyframes fadeIn {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

.hero p {
  font-size: 0.9rem;
  max-width: 600px;
  margin: 0 auto;
  opacity: 0.9;
  padding: 0 0.5rem;
  animation: fadeIn 0.8s ease-out 0.4s both;
}

/* Hero для админ-панели */
.hero-admin {
  background: linear-gradient(to right, #2d3748, #4a5568);
}

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

.btn, .primary-button, a.button, button[type="submit"] {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
  text-decoration: none;
}

/* Primary button (зелёная) */
.btn-primary, .primary-button, a.button {
  background-color: #4aaf2f;
  color: white;
  box-shadow: 0 3px 6px rgba(74, 175, 47, 0.4);
}

.btn-primary:hover, .primary-button:hover, a.button:hover {
  background-color: #3b8a24;
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(59, 138, 36, 0.5);
}

/* Secondary button (серая) */
.btn-secondary, .button-admin {
  background-color: #e5e7eb;
  color: #374151;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.btn-secondary:hover, .button-admin:hover {
  background-color: #d1d5db;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

/* Danger button (красная) */
.btn-danger {
  background-color: #ef4444;
  color: white;
  box-shadow: 0 3px 6px rgba(239, 68, 68, 0.4);
}

.btn-danger:hover {
  background-color: #dc2626;
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(220, 38, 38, 0.5);
}

/* Logout button */
.logout-button {
  background-color: #d1d5db;
  color: #111827;
}

.logout-button:hover {
  background-color: #9ca3af;
}

/* ========================================
   CARDS
   ======================================== */

.card {
  background-color: white;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.04);
  border: 1px solid #e2e8f0;
  margin-bottom: 2rem;
  transition: box-shadow 0.3s ease, transform 0.3s ease;
  animation: fadeInUp 0.6s ease-out;
}

@keyframes fadeInUp {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.card:hover {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.card h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: #35574f;
}

/* Tool cards */
.tool-card {
  background-color: #ffffffee;
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: 0 4px 8px rgba(0,0,0,0.06);
  text-align: center;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease, border-color 0.3s ease;
  border-left: 4px solid #46AE5B;
  width: 100%;
  max-width: 100%;
  opacity: 0;
  animation: slideUp 0.5s ease-out forwards;
}

@keyframes slideUp {
  0% {
    opacity: 0;
    transform: translateY(30px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.tool-card:nth-child(1) { animation-delay: 0.1s; }
.tool-card:nth-child(2) { animation-delay: 0.2s; }
.tool-card:nth-child(3) { animation-delay: 0.3s; }
.tool-card:nth-child(4) { animation-delay: 0.4s; }

.tool-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
  border-left-color: #4aaf2f;
}

.tool-card h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #2d3748;
  transition: color 0.3s ease;
}

.tool-card:hover h3 {
  color: #4aaf2f;
}

.tool-card p {
  font-size: 0.875rem;
  color: #4b5563;
  min-height: auto;
  margin-bottom: 1rem;
}

/* ========================================
   FORMS
   ======================================== */

input[type="text"],
input[type="password"],
input[type="email"],
input[type="file"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 1rem;
  background-color: #ffffff;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.04);
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.2s ease;
  margin-bottom: 1rem;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #4aaf2f;
  outline: none;
  box-shadow: 0 0 0 3px rgba(74, 175, 47, 0.1), inset 0 1px 2px rgba(0,0,0,0.04);
  transform: scale(1.01);
}

.form-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.form-field {
  flex: 1;
  display: flex;
  flex-direction: column;
}

label {
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #35574f;
}

/* ========================================
   TABLES
   ======================================== */

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 1rem;
}

table {
  min-width: 600px;
  border-collapse: collapse;
  width: 100%;
}

th, td {
  padding: 0.75rem;
  border: 1px solid #e2e8f0;
  text-align: left;
  font-size: 0.9rem;
}

th {
  background-color: #f3f4f6;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.3s ease;
}

th.asc {
  background-color: #d1fae5;
}

th.desc {
  background-color: #bbf7d0;
}

tr:nth-child(even) {
  background-color: #f9fafb;
}

tr:hover {
  background-color: #f3f4f6;
  transition: background-color 0.2s ease;
}

/* ========================================
   FLASH MESSAGES
   ======================================== */

.flash-message {
  max-width: 500px;
  margin: 1rem auto;
  padding: 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  text-align: center;
  opacity: 0;
  transform: scale(0.9);
  animation: popIn 0.5s ease-out forwards;
}

@keyframes popIn {
  0% {
    opacity: 0;
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.flash-success {
  background-color: #d1f7dd;
  color: #047857;
}

.flash-error {
  background-color: #fee2e2;
  color: #9f1239;
}

.flash-warning {
  background-color: #fef3c7;
  color: #92400e;
}

.flash-info {
  background-color: #dbeafe;
  color: #1e40af;
}

/* ========================================
   MODAL
   ======================================== */

.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal.active {
  display: flex;
}

.modal-content {
  background-color: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  max-width: 500px;
  width: 90%;
  text-align: center;
}

/* ========================================
   LOADING OVERLAY
   ======================================== */

#loading-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.8);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: #35574f;
  font-weight: 600;
}

/* ========================================
   LAYOUT CONTAINERS
   ======================================== */

main {
  padding: 2rem 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

.tools {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  padding: 1.5rem 1rem;
  max-width: 1200px;
  margin: 0 auto;
}

/* ========================================
   TOP BAR (для index.html)
   ======================================== */

header.top-bar {
  display: flex;
  justify-content: flex-end;
  padding: 1rem 2rem;
  background-color: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.top-buttons {
  display: flex;
  gap: 1rem;
}

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

/* Tablet: >= 640px */
@media (min-width: 640px) {
  .hero {
    padding: 2rem 1.5rem;
  }

  .hero h1 {
    font-size: 1.875rem;
    margin-bottom: 1rem;
  }

  .hero p {
    font-size: 1rem;
  }

  .tools {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 2rem 1.5rem;
  }

  .tool-card {
    flex: 1 1 calc(50% - 0.5rem);
    max-width: calc(50% - 0.5rem);
    padding: 1.8rem;
  }

  .tool-card h3 {
    font-size: 1.25rem;
  }

  .tool-card p {
    font-size: 0.95rem;
    min-height: 40px;
  }

  a.button {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
  }
}

/* Desktop: >= 1024px */
@media (min-width: 1024px) {
  .tools {
    flex-wrap: nowrap;
    gap: 1.5rem;
  }

  .tool-card {
    flex: 1 1 0;
    max-width: none;
  }
}

/* Mobile form adjustments */
@media (max-width: 768px) {
  .form-row {
    flex-direction: column;
    gap: 0;
  }
}
