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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* Навигация */
.navbar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.75rem 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 60px;
}

.nav-brand {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

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

.nav-link {
    color: white;
    text-decoration: none;
    padding: 0.75rem 1.25rem;
    border-radius: 25px;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 0.95rem;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.nav-link:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.nav-link:hover:before {
    left: 100%;
}

.nav-link:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

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

/* Специальная кнопка выхода */
.nav-link.logout {
    background: rgba(255,77,77,0.8);
    margin-left: 1rem;
    border: 1px solid rgba(255,255,255,0.3);
}

.nav-link.logout:hover {
    background: rgba(255,77,77,1);
    box-shadow: 0 4px 15px rgba(255,77,77,0.3);
}

/* Основной контент */
.main-content {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
}

h1 {
    margin-bottom: 2rem;
    color: #333;
}

h2 {
    margin: 2rem 0 1rem;
    color: #555;
}

/* Страница входа */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 2rem;
}

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

.login-box h1 {
    text-align: center;
    margin-bottom: 0.5rem;
}

.login-box h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: #666;
    font-size: 1.2rem;
}

.login-info {
    margin-top: 1rem;
    padding: 1rem;
    background: #f0f0f0;
    border-radius: 4px;
    text-align: center;
    font-size: 0.9rem;
    color: #666;
}

/* Формы */
.form-group {
    margin-bottom: 1.5rem;
}

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

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

.form-group textarea {
    resize: vertical;
    font-family: 'Courier New', monospace;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* Кнопки */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* Алерты */
.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-error {
    background: #fee;
    color: #c33;
    border: 1px solid #fcc;
}

/* Dashboard */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

/* Обеспечиваем горизонтальное расположение только для основных stat-card компонентов */
.row.mt-4:first-of-type {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.row.mt-4:first-of-type .col-md-3 {
    flex: 1;
    min-width: 200px;
    margin-bottom: 0;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    height: 100%;
}

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

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: #667eea;
}

.quick-links {
    margin-top: 3rem;
}

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

.link-card {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-decoration: none;
    color: inherit;
    transition: transform 0.3s, box-shadow 0.3s;
}

.link-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.link-card h3 {
    margin-bottom: 0.5rem;
    color: #333;
}

.link-card p {
    color: #666;
    font-size: 0.9rem;
}

/* Промпты */
.prompts-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.prompt-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.prompt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.prompt-header h3 {
    margin: 0;
    color: #333;
}

.prompt-description {
    color: #666;
    margin-bottom: 1rem;
    font-style: italic;
}

.prompt-preview {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.prompt-preview pre {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.9rem;
    color: #555;
}

.prompt-meta {
    color: #999;
    font-size: 0.85rem;
}

/* Карты */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.card-item {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
}

.card-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.card-image-container {
    width: 100%;
    height: 300px;
    overflow: hidden;
    background: #f0f0f0;
}

.card-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-info {
    padding: 1rem;
}

.card-info h3 {
    margin-bottom: 0.5rem;
    color: #333;
}

.card-id {
    color: #999;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* Таблицы */
.table-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: #f8f9fa;
}

.data-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #dee2e6;
}

.data-table td {
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
}

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

/* Модальные окна */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    overflow: auto;
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-large {
    max-width: 800px;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.close:hover {
    color: #000;
}

#current-image-container {
    margin-bottom: 2rem;
    text-align: center;
}

#current-image-container img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Утилиты */
.loading {
    text-align: center;
    padding: 2rem;
    color: #999;
}

.empty {
    text-align: center;
    padding: 2rem;
    color: #999;
    font-style: italic;
}

.error {
    text-align: center;
    padding: 2rem;
    color: #c33;
}

.stats-section {
    margin-bottom: 3rem;
}

/* Адаптивность */
@media (max-width: 1024px) {
    .nav-container {
        padding: 0 1.5rem;
    }
    
    .nav-menu {
        gap: 0.25rem;
    }
    
    .nav-link {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 0.5rem 0;
    }
    
    .nav-container {
        flex-wrap: wrap;
        padding: 0 1rem;
        min-height: auto;
    }
    
    .nav-brand {
        font-size: 1.5rem;
        flex-grow: 1;
    }

    .nav-toggle {
        display: block;
    }
    
    .nav-menu {
        display: none;
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
        margin-top: 1rem;
        padding-top: 1rem;
        border-top: 1px solid rgba(255,255,255,0.1);
    }

    .nav-menu.active {
        display: flex;
    }
    
    .nav-link {
        padding: 0.75rem 1rem;
        font-size: 1rem;
        width: 100%;
        text-align: left;
        border-radius: 8px;
    }
    
    .nav-link.logout {
        margin-left: 0;
        margin-top: 0.5rem;
        width: 100%;
        text-align: center;
    }
    
    .main-content {
        padding: 1rem;
        margin-top: 1rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 1rem;
    }
    
    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    
    /* Статистические карточки на мобильных */
    .row.mt-4:first-of-type {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .row.mt-4:first-of-type .col-md-3 {
        min-width: auto;
        flex: none;
    }

    /* Улучшение таблиц на мобильных */
    .table-container {
        margin: 0 -1rem;
        border-radius: 0;
        box-shadow: none;
        border-top: 1px solid #eee;
        border-bottom: 1px solid #eee;
    }

    .data-table th, .data-table td {
        padding: 0.75rem;
        font-size: 0.9rem;
        white-space: nowrap;
    }
}

@media (max-width: 480px) {
    .nav-brand {
        font-size: 1.25rem;
        text-align: left;
    }
    
    .nav-link {
        min-width: 100px;
        font-size: 0.85rem;
    }
    
    .main-content {
        padding: 0.75rem;
    }
    
    h1 {
        font-size: 1.75rem;
    }

    /* Улучшение отступов для мобильных */
    .stat-card, .link-card, .prompt-card, .card-item {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.75rem;
    }

    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }

    /* Одна колонка для сеток на очень узких экранах */
    .cards-grid, .music-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Контейнер для графиков */
.chart-container {
    position: relative;
    margin: auto;
    height: 300px;
    width: 100%;
}

/* Глобальные улучшения адаптивности */
img {
    max-width: 100%;
    height: auto;
}

/* Адаптивные таблицы */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Стилизация скроллбара для таблиц */
.table-responsive::-webkit-scrollbar {
    height: 8px;
}

.table-responsive::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Улучшение форм на мобильных */
@media (max-width: 768px) {
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    select,
    textarea {
        font-size: 16px !important; /* Предотвращает зум на iOS */
    }
    
    .btn {
        width: 100%;
        margin-bottom: 0.5rem;
        justify-content: center;
    }
    
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .modal-content {
        width: 95% !important;
        margin: 10px auto !important;
        max-height: 90vh;
    }
}
