/* Reset и базовые стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background-color: #2c3e50;
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header__title {
    font-size: 1.5rem;
    font-weight: 600;
}

.nav__list {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav__link {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: background-color 0.3s;
}

.nav__link:hover,
.nav__link.active {
    background-color: #34495e;
}

.auth-section {
    display: flex;
    gap: 1rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn--primary {
    background-color: #3498db;
    color: white;
}

.btn--primary:hover {
    background-color: #2980b9;
}

.btn--secondary {
    background-color: #95a5a6;
    color: white;
}

.btn--secondary:hover {
    background-color: #7f8c8d;
}

.btn--danger {
    background-color: #e74c3c;
    color: white;
}

.btn--danger:hover {
    background-color: #c0392b;
}

.btn--small {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

/* Main Content */
.main {
    min-height: calc(100vh - 140px);
    padding: 2rem 0;
}

.page {
    background-color: white;
    border-radius: 8px;
    padding: 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    overflow-y: auto;
}

.modal__content {
    background-color: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.modal__content--large {
    max-width: 600px;
}

.modal__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
}

.modal__close:hover {
    color: #333;
}

.modal__title {
    margin-bottom: 1.5rem;
    text-align: center;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52,152,219,0.2);
}

.auth-switch {
    text-align: center;
    margin-top: 1rem;
}

.auth-switch a {
    color: #3498db;
    text-decoration: none;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* Table */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

.table th,
.table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.table th {
    background-color: #f8f9fa;
    font-weight: 600;
}

.table tr:hover {
    background-color: #f8f9fa;
}

/* Dashboard */
.dashboard {
    display: grid;
    gap: 2rem;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.stat-card {
    background-color: #f8f9fa;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #eee;
}

.stat-card h3 {
    margin-bottom: 0.5rem;
    color: #666;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: #2c3e50;
}

.recent-runs {
    margin-top: 2rem;
}

.recent-runs h3 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
}

/* Check Form */
.check-form {
    background-color: #f8f9fa;
    padding: 2rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.test-runs {
    margin-top: 2rem;
}

.test-run-item {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border-left: 4px solid #3498db;
}

.test-run-item.success {
    border-left-color: #27ae60;
}

.test-run-item.failed {
    border-left-color: #e74c3c;
}

.test-run-item.running {
    border-left-color: #f39c12;
    animation: pulse 2s ease-in-out infinite;
}

.test-run-item.pending {
    border-left-color: #3498db;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.test-run-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.test-run-status {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
}

.test-run-status.success {
    background-color: #d4edda;
    color: #155724;
}

.test-run-status.failed {
    background-color: #f8d7da;
    color: #721c24;
}

.test-run-status.running {
    background-color: #fff3cd;
    color: #856404;
}

.test-run-status.running::after {
    content: " ●";
    animation: blink 1s ease-in-out infinite;
}

.test-run-status.pending {
    background-color: #d1ecf1;
    color: #0c5460;
}

.test-run-status.pending::after {
    content: " ●";
    animation: blink 1s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.3;
    }
}

.test-run-details {
    font-size: 0.9rem;
    color: #666;
}

/* Footer */
.footer {
    background-color: #2c3e50;
    color: white;
    text-align: center;
    padding: 1rem 0;
    margin-top: auto;
}

/* Responsive */
@media (max-width: 768px) {
    .header .container {
        flex-direction: column;
        gap: 1rem;
    }

    .nav__list {
        flex-wrap: wrap;
        justify-content: center;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .stats {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .modal__content {
        margin: 5% auto;
        width: 95%;
    }
}

/* Utility classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-success {
    color: #27ae60;
}

.text-danger {
    color: #e74c3c;
}

.text-warning {
    color: #f39c12;
}

.text-info {
    color: #3498db;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: 0.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Test Configuration */
.test-config {
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    background-color: #f8f9fa;
}

.test-config h3 {
    margin-bottom: 1rem;
    color: #2c3e50;
    font-size: 1.1rem;
}

.utm-params {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
}

.utm-params input {
    margin-bottom: 0.5rem;
}

/* Tests Selection */
.tests-selection {
    border: 1px solid #ddd;
    border-radius: 8px;
    max-height: 300px;
    overflow-y: auto;
    padding: 1rem;
    background-color: #f8f9fa;
}

.test-item {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background-color: white;
    border-radius: 4px;
    border: 1px solid #eee;
}

.test-item input[type="checkbox"] {
    margin-right: 0.5rem;
    width: auto;
}

.test-item-info {
    flex: 1;
}

.test-item-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.test-item-description {
    font-size: 0.85rem;
    color: #666;
}

.test-item-category {
    font-size: 0.8rem;
    color: #999;
    margin-top: 0.25rem;
}

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

.category-card {
    background-color: white;
    border-radius: 8px;
    padding: 1.5rem;
    border: 1px solid #eee;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s;
}

.category-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.category-card-header {
    display: flex;
    justify-content: between;
    align-items: start;
    margin-bottom: 1rem;
}

.category-card-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.category-card-description {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 1rem;
}

.category-card-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: #999;
}

.category-card-actions {
    display: flex;
    gap: 0.5rem;
}

/* Enhanced forms */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-section {
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
}

.form-section h4 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

/* Responsive modal improvements */
@media (max-width: 768px) {
    .modal__content {
        margin: 2% auto;
        width: 95%;
        padding: 1rem;
    }

    .modal__content--large {
        max-width: none;
    }

    .utm-params {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .category-cards {
        grid-template-columns: 1fr;
    }

    .filters-row {
        flex-direction: column;
    }

    .filter-group {
        width: 100%;
    }
}

/* Filters */
.filters-container {
    margin: 1.5rem 0;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: 8px;
}

.filters-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.filter-group {
    flex: 1;
    min-width: 200px;
}

.filter-input,
.filter-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.875rem;
    background-color: white;
}

.filter-input:focus,
.filter-select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52,152,219,0.2);
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding: 1rem 0;
}

.pagination button {
    padding: 0.5rem 0.75rem;
    min-width: 40px;
    border: 1px solid #ddd;
    background-color: white;
    color: #333;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
    background-color: #3498db;
    color: white;
    border-color: #3498db;
}

.pagination button:disabled {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
}

.pagination button.active {
    background-color: #3498db;
    color: white;
    border-color: #3498db;
}

.pagination-info {
    color: #666;
    font-size: 0.875rem;
    margin: 0 0.5rem;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.badge--primary {
    background-color: #3498db;
    color: white;
}

.badge--secondary {
    background-color: #95a5a6;
    color: white;
}

.badge--success {
    background-color: #27ae60;
    color: white;
}

.badge--danger {
    background-color: #e74c3c;
    color: white;
}

.user-role-select {
    padding: 0.25rem 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-right: 0.5rem;
    font-size: 0.875rem;
}

.text-muted {
    color: #999;
}