/* ============================================
   MOBILE RESPONSIVE CSS FOR MAIL PANEL
   Добавь этот файл ко всем страницам:
   <link rel="stylesheet" href="/static/css/mobile.css">
   ============================================ */

/* ============================================
   MOBILE MENU TOGGLE BUTTON (добавляется JS'ом)
   ============================================ */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 200;
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: transform 0.3s ease;
}

.mobile-menu-toggle:active {
    transform: scale(0.95);
}

/* Overlay для закрытия меню при клике снаружи */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ============================================
   TABLET STYLES (до 1024px)
   ============================================ */
@media screen and (max-width: 1024px) {
    /* Уменьшаем sidebar */
    .sidebar {
        width: 220px;
    }
    
    .main-content {
        margin-left: 220px;
    }
    
    /* Уменьшаем grid'ы статистики */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    /* Менеджеры карточки */
    .managers-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)) !important;
    }
}

/* ============================================
   MOBILE STYLES (до 768px)
   ============================================ */
@media screen and (max-width: 768px) {
    /* Показываем кнопку меню */
    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Скрываем sidebar по умолчанию */
    .sidebar {
        width: 280px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: none;
    }
    
    /* Показываем sidebar когда активен */
    .sidebar.active {
        transform: translateX(0);
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.3);
    }
    
    /* Main content на всю ширину */
    .main-content {
        margin-left: 0 !important;
        width: 100%;
    }
    
    /* Navbar адаптация */
    .navbar {
        padding: 15px 15px 15px 70px !important; /* Отступ для кнопки меню */
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .navbar-left h1 {
        font-size: 18px !important;
    }
    
    .navbar-left p {
        font-size: 12px !important;
    }
    
    .navbar-right {
        display: none; /* Скрываем на мобильных или можно перенести в меню */
    }
    
    /* Контент страницы */
    .page-content,
    .dashboard-content {
        padding: 15px !important;
    }
    
    /* Панели */
    .panel {
        padding: 15px !important;
        border-radius: 12px !important;
    }
    
    /* Stats grid — одна колонка */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    /* Stat cards */
    .stat-card {
        padding: 15px !important;
        flex-direction: row !important;
        justify-content: flex-start !important;
        gap: 15px !important;
    }
    
    .stat-icon {
        width: 50px !important;
        height: 50px !important;
        font-size: 20px !important;
        flex-shrink: 0;
    }
    
    .stat-info h3 {
        font-size: 24px !important;
    }
    
    /* Quick actions — две колонки */
    .quick-actions {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    
    .action-card {
        padding: 15px !important;
    }
    
    .action-card i {
        font-size: 24px !important;
        margin-bottom: 8px !important;
    }
    
    .action-card h4 {
        font-size: 13px !important;
    }
    
    .action-card p {
        font-size: 11px !important;
    }
    
    /* Period filter — горизонтальный скролл */
    .period-filter {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 5px;
        -webkit-overflow-scrolling: touch;
    }
    
    .period-btn {
        flex-shrink: 0;
        padding: 6px 12px !important;
        font-size: 12px !important;
    }
    
    /* Manager cards */
    .managers-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    .manager-card {
        padding: 15px !important;
    }
    
    .manager-stats {
        flex-wrap: wrap;
    }
    
    .manager-stat {
        flex: 1 1 45%;
        min-width: 80px;
    }
    
    .manager-actions {
        flex-wrap: wrap;
    }
    
    .manager-actions .btn {
        flex: 1;
        justify-content: center;
        min-width: 100px;
    }
    
    /* Buttons */
    .btn {
        padding: 8px 14px !important;
        font-size: 13px !important;
    }
    
    .btn-sm {
        padding: 5px 10px !important;
        font-size: 11px !important;
    }
    
    /* Form controls */
    .form-control {
        padding: 12px !important;
        font-size: 16px !important; /* Предотвращает зум на iOS */
    }
    
    /* Modals */
    .modal {
        width: 95% !important;
        max-width: none !important;
        padding: 20px !important;
        margin: 10px;
        max-height: 85vh !important;
    }
    
    .modal h3 {
        font-size: 18px !important;
    }
    
    .modal-actions {
        flex-direction: column;
    }
    
    .modal-actions .btn {
        width: 100%;
        justify-content: center;
    }
    
    /* Tables — горизонтальный скролл */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
    }
    
    /* Activity list */
    .activity-item {
        flex-wrap: wrap;
        gap: 10px !important;
    }
    
    .activity-text {
        flex: 1;
        min-width: 150px;
    }
    
    .activity-time {
        width: 100%;
        text-align: right;
        font-size: 11px !important;
    }
    
    /* Log panel */
    .log-panel {
        font-size: 11px !important;
        max-height: 150px !important;
    }
    
    /* Section headers */
    .section-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 8px;
    }
    
    .section-header h2 {
        font-size: 16px !important;
    }
}

/* ============================================
   SMALL MOBILE STYLES (до 480px)
   ============================================ */
@media screen and (max-width: 480px) {
    .navbar {
        padding: 12px 12px 12px 65px !important;
    }
    
    .navbar-left h1 {
        font-size: 16px !important;
    }
    
    /* Quick actions — одна колонка */
    .quick-actions {
        grid-template-columns: 1fr !important;
    }
    
    /* Stats в ряд */
    .manager-stats {
        gap: 8px;
    }
    
    .manager-stat {
        padding: 8px !important;
    }
    
    .manager-stat .value {
        font-size: 16px !important;
    }
    
    .manager-stat .label {
        font-size: 10px !important;
    }
    
    /* Sidebar немного уже */
    .sidebar {
        width: 260px;
    }
    
    .sidebar-logo-text h2 {
        font-size: 16px !important;
    }
    
    .sidebar-menu a {
        padding: 10px 12px !important;
        font-size: 13px !important;
    }
    
    /* User menu в sidebar */
    .user-menu {
        padding: 6px 10px !important;
    }
    
    .user-avatar {
        width: 32px !important;
        height: 32px !important;
        font-size: 12px !important;
    }
    
    .user-info .name {
        font-size: 12px !important;
    }
    
    .user-info .role {
        font-size: 10px !important;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Скрыть на мобильных */
@media screen and (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Скрыть на десктопах */
@media screen and (min-width: 769px) {
    .hide-desktop {
        display: none !important;
    }
}

/* Адаптивная таблица-обёртка */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Touch-friendly элементы */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .action-card,
    .manager-card,
    .sidebar-menu a {
        min-height: 44px; /* Apple's minimum touch target */
    }
    
    /* Убираем hover эффекты на touch устройствах */
    .stat-card:hover,
    .action-card:hover,
    .manager-card:hover {
        transform: none;
    }
}

/* ============================================
   SAFE AREA (для iPhone X и новее)
   ============================================ */
@supports (padding: max(0px)) {
    .sidebar {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
    
    .main-content {
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
}

/* ============================================
   DARK MODE SUPPORT (опционально)
   ============================================ */
@media (prefers-color-scheme: dark) {
    /* Если захотите добавить темную тему */
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .sidebar,
    .mobile-menu-toggle,
    .navbar-right {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
    }
}
