/* styles.css - оптимизированная версия */

:root {
    --primary: #3498db;
    --secondary: #2c3e50;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --light: #ecf0f1;
    --dark: #2c3e50;
    --gray: #95a5a6;
}

/* ===== БАЗОВЫЕ СТИЛИ ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #1a2980, #26d0ce);
    color: var(--light);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ===== АНИМАЦИИ ===== */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* ===== ШАПКА И АВТОРИЗАЦИЯ ===== */
header {
    text-align: center;
    padding: 30px 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    backdrop-filter: blur(10px);
    margin-bottom: 30px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(to right, #fff, var(--primary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.subtitle {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 20px;
}

/* Компактная форма авторизации */
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

.header-title {
    flex: 1;
    min-width: 300px;
}

.auth-compact {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 280px;
    max-width: 400px;
    backdrop-filter: blur(5px);
}

.auth-header {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.auth-header i {
    color: var(--primary);
}

.auth-form-compact {
    display: flex;
    gap: 8px;
    align-items: center;
}

.password-input, 
.password-input-compact {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    transition: all 0.3s;
}

.password-input-compact {
    flex: 1;
    padding: 8px 12px;
    font-size: 0.9rem;
    min-width: 120px;
}

.password-input {
    width: 100%;
    padding: 12px 15px;
    font-size: 1rem;
}

.password-input:focus,
.password-input-compact:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.3);
}

/* Кнопки */
.auth-btn,
.auth-btn-compact,
.save-btn,
.personal-site-btn,
.manual-check-btn {
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.auth-btn {
    background: var(--primary);
    padding: 12px;
    font-size: 1rem;
    font-weight: 600;
    margin-top: 10px;
}

.auth-btn-compact {
    background: var(--primary);
    padding: 8px 15px;
    font-size: 0.9rem;
    white-space: nowrap;
}

.logout-btn,
.logout-btn-compact {
    background: rgba(231, 76, 60, 0.2);
    border: 1px solid var(--danger);
    color: #ffcccc;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.logout-btn {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.logout-btn-compact {
    padding: 8px 15px;
    font-size: 0.9rem;
}

.manual-check-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    margin-left: 10px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.save-btn {
    background: var(--primary);
    padding: 8px 16px;
    font-size: 0.9rem;
}

.personal-site-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    padding: 6px 10px;
    font-size: 0.85rem;
}

/* Ховер-эффекты для кнопок */
.auth-btn:hover,
.auth-btn-compact:hover,
.save-btn:hover {
    background: #2980b9;
}

.logout-btn:hover,
.logout-btn-compact:hover {
    background: rgba(231, 76, 60, 0.4);
}

.manual-check-btn:hover {
    background: linear-gradient(135deg, #764ba2, #667eea);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.personal-site-btn:hover {
    background: linear-gradient(135deg, #764ba2, #667eea);
    transform: translateY(-1px);
}

/* ===== СТАТУС-БАР ===== */
.status-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 20px;
    font-size: 0.9rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success);
}

.status-dot.loading {
    background: var(--warning);
    animation: pulse 1s infinite;
}

.status-dot.offline {
    background: var(--danger);
}

/* ===== СТАТИСТИКА СЕРВЕРА ===== */
.server-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-top: 25px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    font-size: 0.9rem;
}

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

.stat-value {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--primary);
}

.stat-label {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    margin-top: 5px;
}

/* ===== КАТЕГОРИИ И СЕРВИСЫ ===== */
.main-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.category {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 15px;
    padding: 25px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.3s, background 0.3s;
}

.category:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.12);
}

.category-title {
    font-size: 1.4rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.category-title i {
    color: var(--primary);
}

/* Сервисы Synology - специальный стиль для отображения всех */
.synology-services .app-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.app-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.app-item {
    display: flex;
    align-items: center;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
    border-left: 4px solid var(--primary);
    position: relative;
}

.app-item:hover {
    background: rgba(0, 0, 0, 0.3);
    transform: translateX(5px);
    border-left: 4px solid var(--success);
}

.app-icon {
    width: 45px;
    height: 45px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    font-size: 1.3rem;
    font-weight: bold;
    flex-shrink: 0;
}

.app-info {
    flex: 1;
    min-width: 0;
}

.app-name {
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-desc {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.app-url {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    margin-top: 5px;
    word-break: break-all;
}

/* Статус сервиса */
.app-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--success);
    margin-left: 10px;
    position: relative;
    flex-shrink: 0;
}

.app-status.loading {
    background: var(--warning);
    animation: pulse 1s infinite;
}

.app-status.offline {
    background: var(--danger);
}

.status-tooltip {
    position: absolute;
    top: -30px;
    right: 0;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 10;
}

.app-status:hover .status-tooltip {
    opacity: 1;
}

/* ===== ЛИЧНЫЙ САЙТ ===== */
.personal-site-compact {
    position: relative;
}

.personal-site-controls {
    display: flex;
    gap: 8px;
    margin-top: 5px;
    align-items: center;
}

.personal-site-input,
.username-input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    color: white;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.personal-site-input:focus,
.username-input:focus {
    outline: none;
    border-color: rgba(52, 152, 219, 0.5);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.compact-desc {
    font-size: 0.8rem;
    margin-top: 5px;
    color: rgba(255, 255, 255, 0.7);
    min-height: 1.2rem;
    transition: color 0.2s;
}

/* ===== УВЕДОМЛЕНИЯ И ОШИБКИ ===== */
.auth-error,
.auth-error-compact {
    background: rgba(231, 76, 60, 0.2);
    border: 1px solid var(--danger);
    border-radius: 6px;
    color: #ffcccc;
    font-size: 0.9rem;
    display: none;
}

.auth-error {
    margin-top: 15px;
    padding: 10px;
}

.auth-error-compact {
    margin-top: 8px;
    padding: 6px 10px;
    font-size: 0.8rem;
}

.auth-status {
    margin-top: 8px;
    padding: 6px 10px;
    background: rgba(39, 174, 96, 0.2);
    border: 1px solid var(--success);
    border-radius: 6px;
    color: #ccffcc;
    font-size: 0.8rem;
    display: none;
}

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

/* ===== ФУТЕР ===== */
footer {
    text-align: center;
    padding: 25px;
    margin-top: 40px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.server-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
    text-align: left;
}

.info-column h4 {
    color: var(--primary);
    margin-bottom: 10px;
    font-size: 0.95rem;
}

.info-column p {
    margin: 5px 0;
    font-size: 0.85rem;
    line-height: 1.4;
}

/* ===== АДАПТИВНОСТЬ ===== */
@media (max-width: 992px) {
    .app-list {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

@media (max-width: 768px) {
    .main-grid,
    .app-list,
    .synology-services .app-list {
        grid-template-columns: 1fr;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .header-top {
        flex-direction: column;
    }
    
    .auth-compact {
        width: 100%;
        max-width: 100%;
    }
    
    .auth-form-compact {
        flex-wrap: wrap;
    }
    
    .password-input-compact {
        min-width: 100%;
        margin-bottom: 8px;
    }
    
    .status-bar,
    .server-stats {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
    
    .server-info {
        grid-template-columns: 1fr;
    }
    
    .personal-site-controls {
        flex-direction: column;
        gap: 5px;
    }
    
    .personal-site-btn {
        width: 100%;
        justify-content: center;
    }
    
    .manual-check-btn {
        margin-left: 0;
        margin-top: 10px;
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .app-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .app-icon {
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    .app-status {
        position: absolute;
        top: 15px;
        right: 15px;
        margin-left: 0;
    }
}