/* ===================================================================
   ATLAS ADMIN PANEL v1.5.0
   Полноэкранная админка с sidebar навигацией
   =================================================================== */

/* --- Layout --- */
.admin-panel {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    background: #F5F5F7;
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
    animation: adminFadeIn 0.25s ease-out;
}

@keyframes adminFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- Sidebar --- */
.admin-sidebar {
    width: 240px;
    background: #1D1D1F;
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    border-right: 1px solid rgba(255,255,255,0.05);
}

.admin-sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.admin-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.admin-logo-icon {
    width: 32px;
    height: 32px;
    background: #0A84FF;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.admin-logo-subtitle {
    font-size: 11px;
    color: rgba(255,255,255,0.5);
    font-weight: 400;
    margin-top: 2px;
}

.admin-nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
}

.admin-nav-section {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.4);
    padding: 12px 10px 6px;
    font-weight: 600;
}

.admin-nav-btn {
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.75);
    text-align: left;
    font-size: 14px;
    cursor: pointer;
    border-radius: 8px;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.15s ease;
    font-family: inherit;
}

.admin-nav-btn:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

.admin-nav-btn.active {
    background: #0A84FF;
    color: #fff;
    font-weight: 600;
}

.admin-nav-btn-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

.admin-sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.admin-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    font-size: 12px;
}

.admin-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #0A84FF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    overflow: hidden;
    flex-shrink: 0;
}

.admin-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.admin-user-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-btn-exit {
    width: 100%;
    padding: 8px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.8);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.15s ease;
    font-family: inherit;
}

.admin-btn-exit:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

/* --- Main content area --- */
.admin-content {
    flex: 1;
    overflow-y: auto;
    padding: 28px 36px;
    min-width: 0;
}

.admin-content-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #E5E5EA;
}

.admin-page-title {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin: 0;
    color: #1D1D1F;
}

.admin-page-subtitle {
    font-size: 14px;
    color: #6E6E73;
    margin-top: 4px;
}

/* --- Cards grid --- */
.admin-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.admin-metric {
    background: #fff;
    border-radius: 14px;
    padding: 18px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    border: 1px solid #F0F0F3;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.admin-metric:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.admin-metric-label {
    font-size: 12px;
    color: #6E6E73;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.admin-metric-value {
    font-size: 28px;
    font-weight: 700;
    margin-top: 4px;
    color: #1D1D1F;
    letter-spacing: -0.5px;
}

.admin-metric-trend {
    font-size: 12px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.admin-metric-trend.up { color: #34C759; }
.admin-metric-trend.down { color: #FF3B30; }
.admin-metric-trend.neutral { color: #6E6E73; }

/* --- Chart --- */
.admin-chart-card {
    background: #fff;
    border-radius: 14px;
    padding: 20px 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    border: 1px solid #F0F0F3;
    margin-bottom: 20px;
}

.admin-chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.admin-chart-title {
    font-size: 16px;
    font-weight: 600;
    color: #1D1D1F;
}

.admin-chart-legend {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #6E6E73;
}

.admin-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.admin-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.admin-chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 200px;
    padding: 10px 0;
}

.admin-chart-bar-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.admin-chart-bars {
    display: flex;
    gap: 2px;
    align-items: flex-end;
    height: 100%;
    width: 100%;
}

.admin-chart-bar {
    flex: 1;
    background: #0A84FF;
    border-radius: 3px 3px 0 0;
    min-height: 2px;
    transition: opacity 0.2s;
    position: relative;
    cursor: pointer;
}

.admin-chart-bar:hover {
    opacity: 0.8;
}

.admin-chart-bar.bots {
    background: #FF9500;
}

.admin-chart-bar.humans {
    background: #34C759;
}

.admin-chart-bar-label {
    font-size: 11px;
    color: #6E6E73;
    text-align: center;
}

/* --- Section cards --- */
.admin-section-card {
    background: #fff;
    border-radius: 14px;
    padding: 20px 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    border: 1px solid #F0F0F3;
    margin-bottom: 20px;
}

.admin-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.admin-section-title {
    font-size: 15px;
    font-weight: 600;
    color: #1D1D1F;
}

/* --- Lists --- */
.admin-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #F9F9FB;
    border-radius: 10px;
    transition: background 0.15s;
}

.admin-list-item:hover {
    background: #F0F0F3;
}

.admin-list-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #0A84FF;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
    overflow: hidden;
}

.admin-list-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.admin-list-body {
    flex: 1;
    min-width: 0;
}

.admin-list-title {
    font-size: 14px;
    font-weight: 500;
    color: #1D1D1F;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-list-meta {
    font-size: 12px;
    color: #6E6E73;
    margin-top: 2px;
}

/* --- Tables (для visits, users, places) --- */
.admin-table-wrapper {
    overflow-x: auto;
    border: 1px solid #E5E5EA;
    border-radius: 10px;
    background: #fff;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.admin-table th,
.admin-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #F0F0F3;
}

.admin-table th {
    background: #F9F9FB;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6E6E73;
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.admin-table tr:hover {
    background: #FAFAFC;
}

/* --- Badges --- */
.admin-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.admin-badge.bot {
    background: #FFF3CD;
    color: #856404;
}

.admin-badge.user {
    background: #D4EDFF;
    color: #004085;
}

.admin-badge.admin {
    background: #FFE5E5;
    color: #C62828;
}

.admin-badge.method {
    background: #EAF3FF;
    color: #0A84FF;
}

.admin-badge.status-ok { background: #D4F5DD; color: #155724; }
.admin-badge.status-redir { background: #FFF3CD; color: #856404; }
.admin-badge.status-err { background: #FFE5E5; color: #C62828; }

/* --- Buttons --- */
.admin-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s ease;
    font-family: inherit;
}

.admin-btn-primary {
    background: #0A84FF;
    color: #fff;
}

.admin-btn-primary:hover {
    background: #0064D2;
}

.admin-btn-secondary {
    background: #fff;
    color: #1D1D1F;
    border-color: #E5E5EA;
}

.admin-btn-secondary:hover {
    background: #F9F9FB;
    border-color: #D0D0D5;
}

.admin-btn-danger {
    background: #FF3B30;
    color: #fff;
}

.admin-btn-danger:hover {
    background: #D42A20;
}

.admin-btn-ghost {
    background: transparent;
    color: #6E6E73;
    border-color: transparent;
}

.admin-btn-ghost:hover {
    background: #F0F0F3;
    color: #1D1D1F;
}

.admin-btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

.admin-btn-group {
    display: flex;
    gap: 6px;
}

/* --- Chips / filters --- */
.admin-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.admin-chip {
    padding: 6px 12px;
    background: #F0F0F3;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    color: #6E6E73;
}

.admin-chip:hover {
    background: #E5E5EA;
}

.admin-chip.active {
    background: #EAF3FF;
    border-color: #0A84FF;
    color: #0A84FF;
    font-weight: 600;
}

/* --- Search --- */
.admin-search {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #E5E5EA;
    border-radius: 10px;
    font-size: 14px;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}

.admin-search:focus {
    outline: none;
    border-color: #0A84FF;
    box-shadow: 0 0 0 3px rgba(10,132,255,0.15);
}

/* --- System info --- */
.admin-system-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

.admin-system-item {
    background: #F9F9FB;
    border-radius: 10px;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-system-item-label {
    font-size: 13px;
    color: #6E6E73;
}

.admin-system-item-value {
    font-size: 14px;
    font-weight: 600;
    color: #1D1D1F;
    font-family: 'SF Mono', Consolas, monospace;
}

/* --- Toggle switch --- */
.admin-toggle {
    position: relative;
    width: 44px;
    height: 24px;
    background: #E5E5EA;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
    border: none;
    padding: 0;
}

.admin-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}

.admin-toggle.active {
    background: #34C759;
}

.admin-toggle.active::after {
    transform: translateX(20px);
}

/* --- Pagination --- */
.admin-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    font-size: 13px;
    color: #6E6E73;
}

/* --- Loading --- */
.admin-loading {
    text-align: center;
    padding: 40px;
    color: #6E6E73;
}

.admin-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #E5E5EA;
    border-top-color: #0A84FF;
    border-radius: 50%;
    animation: adminSpin 0.8s linear infinite;
    margin: 0 auto 12px;
}

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

/* --- Toast notifications --- */
.admin-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 18px;
    background: #1D1D1F;
    color: #fff;
    border-radius: 10px;
    font-size: 14px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    z-index: 1100;
    animation: adminToastIn 0.25s ease-out;
}

.admin-toast.success { background: #34C759; }
.admin-toast.error { background: #FF3B30; }

@keyframes adminToastIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Responsive --- */
@media (max-width: 900px) {
    .admin-sidebar {
        width: 64px;
    }
    
    .admin-logo-subtitle,
    .admin-nav-btn span,
    .admin-nav-section,
    .admin-user-name,
    .admin-sidebar-header > div:not(.admin-logo) {
        display: none;
    }
    
    .admin-logo {
        justify-content: center;
    }
    
    .admin-logo-icon {
        width: 36px;
        height: 36px;
    }
    
    .admin-nav-btn {
        justify-content: center;
    }
    
    .admin-user-info {
        justify-content: center;
    }
    
    .admin-content {
        padding: 20px 16px;
    }
    
    .admin-page-title {
        font-size: 22px;
    }
}

@media (max-width: 600px) {
    .admin-metrics {
        grid-template-columns: 1fr 1fr;
    }
    
    .admin-metric-value {
        font-size: 22px;
    }
}


/* === Модальные окна админки === */
.admin-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1200;
    animation: adminFadeIn 0.2s ease-out;
}

.admin-modal {
    background: #fff;
    border-radius: 16px;
    padding: 28px;
    max-width: 700px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.admin-modal h2 {
    margin: 0 0 20px 0;
    font-size: 22px;
    font-weight: 700;
    color: #1D1D1F;
}

.admin-modal h3 {
    margin: 16px 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: #6E6E73;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.admin-modal-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #E5E5EA;
}

.admin-modal-section:last-child {
    border-bottom: none;
}

.admin-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    font-size: 14px;
}

.admin-info-grid div {
    padding: 8px 12px;
    background: #F9F9FB;
    border-radius: 8px;
}

.admin-info-grid b {
    color: #6E6E73;
    font-weight: 500;
    margin-right: 6px;
}

/* Массовые действия */
.admin-bulk-actions {
    padding: 12px 16px;
    background: #FFF3CD;
    border: 1px solid #FFC107;
    border-radius: 10px;
    margin-bottom: 16px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.admin-bulk-actions::before {
    content: '⚠️';
    font-size: 18px;
}
