/* === ЦВЕТА И ТЕМА === */
:root {
  --bg: #f5f7fa;
  --panel-bg: white;
  --text: #333;
  --border: #ddd;
  --accent: #3498db;
  --urgent: #e74c3c;
  --warn: #f39c12;
  --ok: #27ae60;
  --header-text: #2c3e50;
  --gray: #95a5a6; /* Новый серый цвет для всех указанных элементов */
}

.dark-theme {
  --bg: #1e1e1e;
  --panel-bg: #2d2d2d;
  --text: #eee;
  --border: #555;
  --header-text: #ffffff;
  --gray: #7f8c8d;
}

body {
  font-family: 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 0.3s;
  margin: 0;
  padding: 0;
}

/* === КНОПКА ТЕМЫ === */
.theme-toggle {
  position: fixed;
  top: 10px;
  right: 10px;
  padding: 8px 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  z-index: 1000;
}

/* === ЗАГОЛОВКИ === */
h1, h2 {
  text-align: center;
  color: var(--header-text);
  margin-bottom: 15px;
  font-size: 1.3rem;
}

/* === КНОПКИ-ПЕРЕКЛЮЧАТЕЛИ === */
.option-group {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.btn-option {
  flex: 1;
  text-align: center;
  padding: 10px 8px;
  background: #ecf0f1;
  border: 2px solid #bdc3c7;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
  white-space: nowrap;
}

.dark-theme .btn-option {
  background: #3c3c3c;
  border-color: #555;
  color: white;
}

.btn-option:hover {
  background: #bdc3c7;
}

.dark-theme .btn-option:hover {
  background: #555;
}

input[type="radio"] {
  display: none;
}

/* === ЦВЕТА КНОПОК === */
input[name="urgency"][value="СРОЧНО"]:checked ~ .option-group .btn-option[data-value="СРОЧНО"],
input[name="urgency"][value="СРОЧНО"] ~ .option-group .btn-option[data-value="СРОЧНО"].forced-active {
  background: var(--urgent);
  color: white;
  border-color: #c0392b;
}

input[name="urgency"][value="ТЕРПИТ"]:checked ~ .option-group .btn-option[data-value="ТЕРПИТ"],
input[name="urgency"][value="ТЕРПИТ"] ~ .option-group .btn-option[data-value="ТЕРПИТ"].forced-active {
  background: var(--warn);
  color: white;
  border-color: #d35400;
}

input[name="urgency"][value="ПОТОМ"]:checked ~ .option-group .btn-option[data-value="ПОТОМ"],
input[name="urgency"][value="ПОТОМ"] ~ .option-group .btn-option[data-value="ПОТОМ"].forced-active {
  background: var(--ok);
  color: white;
  border-color: #219653;
}

input[name="complexity"][value="ЛЕГКАЯ"]:checked ~ .option-group .btn-option[data-value="ЛЕГКАЯ"],
input[name="complexity"][value="ЛЕГКАЯ"] ~ .option-group .btn-option[data-value="ЛЕГКАЯ"].forced-active {
  background: var(--ok);
  color: white;
  border-color: #219653;
}

input[name="complexity"][value="СРЕДНЯЯ"]:checked ~ .option-group .btn-option[data-value="СРЕДНЯЯ"],
input[name="complexity"][value="СРЕДНЯЯ"] ~ .option-group .btn-option[data-value="СРЕДНЯЯ"].forced-active {
  background: var(--warn);
  color: white;
  border-color: #d35400;
}

input[name="complexity"][value="ТРУДНАЯ"]:checked ~ .option-group .btn-option[data-value="ТРУДНАЯ"],
input[name="complexity"][value="ТРУДНАЯ"] ~ .option-group .btn-option[data-value="ТРУДНАЯ"].forced-active {
  background: var(--urgent);
  color: white;
  border-color: #c0392b;
}

/* === КНОПКА ДОБАВЛЕНИЯ — СЕРАЯ === */
.submit-btn {
  padding: 12px;
  background: var(--gray); /* Серый */
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  width: 100%;
}

/* === МАТРИЦА — ЗАГОЛОВКИ СЕРЫЕ === */
/* === МАТРИЦА === */
.matrix {
  display: grid;
  grid-template-rows: auto repeat(3, 1fr);
  grid-template-columns: auto repeat(3, 1fr);
  gap: 8px;
}

.matrix-header {
  background: var(--gray);
  color: white;
  font-weight: bold;
  padding: 10px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dark-theme .matrix-header {
  background: var(--gray);
}

.matrix-cell {
  min-height: 70px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  background: var(--panel-bg);
  font-size: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-content: flex-start;
}

.matrix-cell.empty {
  color: #95a5a6;
  font-style: italic;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* === НОМЕРА ЗАДАЧ В МАТРИЦЕ — СЕРЫЕ === */
.task-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  min-width: 26px;
  max-width: 26px;
  height: 22px;
  background: var(--gray); /* Серый */
  color: white;
  font-size: 0.8rem;
  font-weight: bold;
  border-radius: 4px;
  margin: 2px;
  padding: 0;
  text-align: center;
  white-space: nowrap;
  box-sizing: border-box;
  cursor: help;
}

/* === ОБЩИЕ СТИЛИ СПИСКА ЗАДАЧ === */
.task-list-header {
  text-align: center;
  padding: 15px 20px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  font-size: 1.3rem;
  font-weight: bold;
  color: var(--header-text);
}

.filters {
  display: flex;
  justify-content: center;
  gap: 15px;
  padding: 15px 20px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.filters select {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--panel-bg);
  color: var(--text);
}

.task-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  padding-bottom: 20px;
}

.task-list {
  margin: 0;
  padding: 0;
  list-style: none;
  width: 100%;
}

/* === СТРОКИ ЗАДАЧ — НЕВЫПОЛНЕННЫЕ С СЕРЫМ ФОНОМ === */
.task-item {
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
  width: 100%;
  scroll-margin: 20px 0;
}

.task-item:not(.done) {
  background: var(--gray); /* Серый фон */
  color: white;
  border-bottom: 1px solid rgba(0,0,0,0.1);
}

.task-item:not(.done) .task-title,
.task-item:not(.done) .btn-small {
  color: white;
}

/* === ОБЩИЕ СТИЛИ КНОПОК === */
.btn-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
  text-align: center;
  text-decoration: none;
  border-radius: 4px;
  color: white;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0;
  margin: 3px 0;
  height: 30px;
  min-width: 60px;
  border: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.urgency-btn[data-level="СРОЧНО"] { background: var(--urgent); border-color: #c0392b; }
.urgency-btn[data-level="ТЕРПИТ"]  { background: var(--warn);   border-color: #d35400; }
.urgency-btn[data-level="ПОТОМ"]   { background: var(--ok);     border-color: #219653; }

.complexity-btn[data-level="ЛЕГКАЯ"]   { background: var(--ok);     border-color: #219653; }
.complexity-btn[data-level="СРЕДНЯЯ"]  { background: var(--warn);   border-color: #d35400; }
.complexity-btn[data-level="ТРУДНАЯ"]  { background: var(--urgent); border-color: #c0392b; }

.btn-toggle { background: var(--warn);   border-color: #d35400; }
.btn-delete { background: var(--urgent); border-color: #c0392b; }

.btn-small:hover,
.btn-small:active {
  opacity: 0.9;
  transform: scale(1.02);
}

/* === ДЕСКТОПНАЯ ВЕРСИЯ === */
@media (min-width: 768px) {
  body {
    height: 100vh;
    overflow: hidden;
  }

  .layout {
    display: flex !important;
    height: 100vh !important;
    padding: 20px;
    gap: 15px;
  }

  .mobile-tabs {
    display: none !important;
  }

  .mobile-panel {
    display: none !important;
  }

  .left-column {
    width: 35%;
    display: flex;
    flex-direction: column;
    gap: 20px;
  }

  .panel {
    background: var(--panel-bg);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    flex: none;
  }

  .sticky {
    position: sticky;
    top: 20px;
  }

  .task-form input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1.1rem;
    margin-bottom: 15px;
    box-sizing: border-box;
  }

  .right-column {
    width: 65%;
    background: var(--panel-bg);
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .task-item {
    display: flex;
    align-items: center;
    min-height: 36px;
    height: 36px;
    border-bottom: 1px solid var(--border);
    font-size: 0.95rem;
    width: 100%;
    scroll-margin: 20px 0;
  }

  .task-item:not(.done) {
    background: var(--gray); /* Серый */
    color: white;
    border-bottom: 1px solid rgba(0,0,0,0.1);
  }

  .task-item:not(.done) .task-title {
    color: white;
  }

  .task-item:not(.done) .btn-small {
    color: white;
  }

  span:first-child {
    width: 40px;
    text-align: center;
    font-size: 0.95rem;
    padding-left: 8px;
    font-weight: 500;
  }

  .task-title {
    flex: 1;
    justify-content: flex-start;
    padding: 0 8px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .task-actions-container {
    display: flex;
    gap: 2px;
    margin-right: 4px;
  }

  .btn-small {
    width: 80px;
    min-width: 80px;
    max-width: 80px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    text-align: center;
    text-decoration: none;
    border-radius: 4px;
    color: white;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0;
    margin: 3px 0;
  }

  .btn-small:hover {
    opacity: 0.9;
    transform: scale(1.02);
  }
}

/* === МОБИЛЬНАЯ ВЕРСИЯ === */
@media (max-width: 767px) {
  body {
    padding-top: 50px;
    font-size: 14px;
  }

  .layout {
    display: none;
  }

  .mobile-tabs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  }

  .mobile-tab {
    flex: 1;
    text-align: center;
    padding: 12px 0;
    font-weight: bold;
    color: #7f8c8d;
    cursor: pointer;
    font-size: 0.9rem;
  }

  .mobile-tab.active {
    color: var(--accent);
    border-bottom: 3px solid var(--accent);
  }

  .mobile-panel {
    display: none;
    background: var(--panel-bg);
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 20px;
    margin: 20px;
    margin-top: 50px;
  }

  .matrix-header.rotate {
    writing-mode: vertical-lr;
    text-orientation: mixed;
    transform: rotate(180deg);
    white-space: nowrap;
    padding: 10px 4px;
    font-size: 0.85rem;
  }

  .mobile-panel#task-list .filters {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 15px;
  }

  .mobile-panel#task-list .filters select {
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--panel-bg);
    color: var(--text);
    font-size: 0.9rem;
  }

  .mobile-panel .task-item {
    display: block !important;
    min-height: auto !important;
    height: auto !important;
    padding: 6px 0;
  }

  .mobile-panel .task-item > * {
    display: block;
    margin: 0;
    padding: 0;
  }

  .mobile-panel .btn-small {
    width: auto;
    padding: 0 8px;
    box-sizing: border-box;
    border: 2px solid;
    border-color: inherit;
  }
}

/* === СТРАНИЦА ВХОДА === */
.login-page {
  background: #1e1e1e;
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  font-family: 'Segoe UI', sans-serif;
}

.login-box {
  background: #2d2d2d;
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  width: 300px;
  text-align: center;
}

.login-box input[type="password"],
.login-box button {
  width: 100%;
  box-sizing: border-box;
}

.login-box input[type="password"] {
  padding: 12px;
  margin: 10px 0;
  border: 1px solid #555;
  border-radius: 6px;
  background: #1e1e1e;
  color: white;
  font-size: 1rem;
}

.login-box button {
  padding: 12px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: bold;
  margin-top: 10px;
}

.login-box .error {
  color: #e74c3c;
  margin: 10px 0;
  font-size: 0.9rem;
}

/* === СТИЛЬ ДЛЯ ПОЛЯ РЕДАКТИРОВАНИЯ ЗАДАЧИ === */
.task-title-edit {
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: white;
  font-size: 0.95rem;
  padding: 0 8px;
  box-sizing: border-box;
}

.task-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    padding-bottom: 20px;
    max-height: calc(100vh - 200px); /* Ограничиваем высоту */
}

body {
    margin-top: 60px; /* Увеличиваем отступ для кнопок списков */
}

.layout {
    height: calc(100vh - 80px) !important; /* Учитываем высоту кнопок */
}

/* === СТИЛИ ДЛЯ ПЕЧАТИ === */
@media print {
    body * {
        visibility: hidden;
    }
    
    .print-visible, .print-visible * {
        visibility: visible;
    }
    
    .print-visible {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        background: white;
        color: black;
        font-family: Arial, sans-serif;
    }
    
    .no-print {
        display: none !important;
    }
    
    .print-table {
        width: 100%;
        border-collapse: collapse;
        margin: 20px 0;
        font-size: 12px;
    }
    
    .print-table th,
    .print-table td {
        border: 1px solid #ddd;
        padding: 8px;
        text-align: left;
    }
    
    .print-table th {
        background-color: #f2f2f2;
        font-weight: bold;
    }
    
    .print-header {
        text-align: center;
        margin-bottom: 20px;
        border-bottom: 2px solid #000;
        padding-bottom: 10px;
    }
    
    .print-header h1 {
        margin: 0;
        font-size: 18px;
    }
    
    .print-header .date {
        font-size: 14px;
        color: #666;
    }
    
    .urgency-SРОЧНО { background-color: #ffcccc; }
    .urgency-ТЕРПИТ { background-color: #fff0cc; }
    .urgency-ПОТОМ { background-color: #ccffcc; }
    
    .complexity-ЛЕГКАЯ { background-color: #ccffcc; }
    .complexity-СРЕДНЯЯ { background-color: #fff0cc; }
    .complexity-ТРУДНАЯ { background-color: #ffcccc; }
    
    .status-done { text-decoration: line-through; color: #666; }
    .status-overdue { font-weight: bold; color: #ff0000; }
}

/* Скрытый контейнер для печати */
#print-container {
    display: none;
}